Mercurial > illumos > illumos-gate
annotate usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c @ 8851:cf2ef2a74136 onnv_109
6801824 Panic in vhci_scsi_reset_target
author | Chris Liu <Chris.Liu@Sun.COM> |
---|---|
date | Wed, 18 Feb 2009 13:55:44 +0800 |
parents | 2b50eb467f7f |
children | ee8f18cdafb2 |
rev | line source |
---|---|
4851 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
4 * The contents of this file are subject to the terms of the | |
5 * Common Development and Distribution License (the "License"). | |
6 * You may not use this file except in compliance with the License. | |
7 * | |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 * or http://www.opensolaris.org/os/licensing. | |
10 * See the License for the specific language governing permissions | |
11 * and limitations under the License. | |
12 * | |
13 * When distributing Covered Code, include this CDDL HEADER in each | |
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 * If applicable, add the following below this CDDL HEADER, with the | |
16 * fields enclosed by brackets "[]" replaced with your own identifying | |
17 * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 * | |
19 * CDDL HEADER END | |
20 */ | |
21 /* | |
8851
cf2ef2a74136
6801824 Panic in vhci_scsi_reset_target
Chris Liu <Chris.Liu@Sun.COM>
parents:
8335
diff
changeset
|
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
4851 | 23 * Use is subject to license terms. |
24 */ | |
25 | |
26 /* | |
27 * Multiplexed I/O SCSI vHCI implementation | |
28 */ | |
29 | |
30 #include <sys/conf.h> | |
31 #include <sys/file.h> | |
32 #include <sys/ddi.h> | |
33 #include <sys/sunddi.h> | |
34 #include <sys/scsi/scsi.h> | |
35 #include <sys/scsi/impl/scsi_reset_notify.h> | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
36 #include <sys/scsi/impl/services.h> |
4851 | 37 #include <sys/sunmdi.h> |
38 #include <sys/mdi_impldefs.h> | |
39 #include <sys/scsi/adapters/scsi_vhci.h> | |
40 #include <sys/disp.h> | |
41 #include <sys/byteorder.h> | |
42 | |
43 extern uintptr_t scsi_callback_id; | |
44 extern ddi_dma_attr_t scsi_alloc_attr; | |
45 | |
46 #ifdef DEBUG | |
47 int vhci_debug = VHCI_DEBUG_DEFAULT_VAL; | |
48 #endif | |
49 | |
50 /* retry for the vhci_do_prout command when a not ready is returned */ | |
51 int vhci_prout_not_ready_retry = 180; | |
52 | |
53 /* | |
54 * These values are defined to support the internal retry of | |
55 * SCSI packets for better sense code handling. | |
56 */ | |
57 #define VHCI_CMD_CMPLT 0 | |
58 #define VHCI_CMD_RETRY 1 | |
59 #define VHCI_CMD_ERROR -1 | |
60 | |
61 #define PROPFLAGS (DDI_PROP_DONTPASS | DDI_PROP_NOTPROM) | |
62 #define VHCI_SCSI_PERR 0x47 | |
63 #define VHCI_PGR_ILLEGALOP -2 | |
64 #define VHCI_NUM_UPDATE_TASKQ 8 | |
6023
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
65 /* changed to 132 to accomodate HDS */ |
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
66 #define VHCI_STD_INQ_SIZE 132 |
4851 | 67 |
68 /* | |
69 * Version Macros | |
70 */ | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7654
diff
changeset
|
71 #define VHCI_NAME_VERSION "SCSI VHCI Driver" |
4851 | 72 char vhci_version_name[] = VHCI_NAME_VERSION; |
73 | |
74 int vhci_first_time = 0; | |
75 clock_t vhci_to_ticks = 0; | |
76 int vhci_init_wait_timeout = VHCI_INIT_WAIT_TIMEOUT; | |
77 kcondvar_t vhci_cv; | |
78 kmutex_t vhci_global_mutex; | |
79 void *vhci_softstate = NULL; /* for soft state */ | |
80 | |
81 /* | |
82 * Flag to delay the retry of the reserve command | |
83 */ | |
84 int vhci_reserve_delay = 100000; | |
85 static int vhci_path_quiesce_timeout = 60; | |
86 static uchar_t zero_key[MHIOC_RESV_KEY_SIZE]; | |
87 | |
88 /* uscsi delay for a TRAN_BUSY */ | |
89 static int vhci_uscsi_delay = 100000; | |
90 static int vhci_uscsi_retry_count = 180; | |
91 /* uscsi_restart_sense timeout id in case it needs to get canceled */ | |
92 static timeout_id_t vhci_restart_timeid = 0; | |
93 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
94 static int vhci_bus_config_debug = 0; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
95 |
4851 | 96 /* |
97 * Bidirectional map of 'target-port' to port id <pid> for support of | |
98 * iostat(1M) '-Xx' and '-Yx' output. | |
99 */ | |
100 static kmutex_t vhci_targetmap_mutex; | |
101 static uint_t vhci_targetmap_pid = 1; | |
102 static mod_hash_t *vhci_targetmap_bypid; /* <pid> -> 'target-port' */ | |
103 static mod_hash_t *vhci_targetmap_byport; /* 'target-port' -> <pid> */ | |
104 | |
105 /* | |
106 * functions exported by scsi_vhci struct cb_ops | |
107 */ | |
108 static int vhci_open(dev_t *, int, int, cred_t *); | |
109 static int vhci_close(dev_t, int, int, cred_t *); | |
110 static int vhci_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
111 | |
112 /* | |
113 * functions exported by scsi_vhci struct dev_ops | |
114 */ | |
115 static int vhci_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); | |
116 static int vhci_attach(dev_info_t *, ddi_attach_cmd_t); | |
117 static int vhci_detach(dev_info_t *, ddi_detach_cmd_t); | |
118 | |
119 /* | |
120 * functions exported by scsi_vhci scsi_hba_tran_t transport table | |
121 */ | |
122 static int vhci_scsi_tgt_init(dev_info_t *, dev_info_t *, | |
123 scsi_hba_tran_t *, struct scsi_device *); | |
124 static void vhci_scsi_tgt_free(dev_info_t *, dev_info_t *, scsi_hba_tran_t *, | |
125 struct scsi_device *); | |
126 static int vhci_pgr_register_start(scsi_vhci_lun_t *, struct scsi_pkt *); | |
127 static int vhci_scsi_start(struct scsi_address *, struct scsi_pkt *); | |
128 static int vhci_scsi_abort(struct scsi_address *, struct scsi_pkt *); | |
129 static int vhci_scsi_reset(struct scsi_address *, int); | |
130 static int vhci_scsi_reset_target(struct scsi_address *, int level, | |
131 uint8_t select_path); | |
132 static int vhci_scsi_reset_bus(struct scsi_address *); | |
133 static int vhci_scsi_getcap(struct scsi_address *, char *, int); | |
134 static int vhci_scsi_setcap(struct scsi_address *, char *, int, int); | |
135 static int vhci_commoncap(struct scsi_address *, char *, int, int, int); | |
136 static int vhci_pHCI_cap(struct scsi_address *ap, char *cap, int val, int whom, | |
137 mdi_pathinfo_t *pip); | |
138 static struct scsi_pkt *vhci_scsi_init_pkt(struct scsi_address *, | |
139 struct scsi_pkt *, struct buf *, int, int, int, int, int (*)(), caddr_t); | |
140 static void vhci_scsi_destroy_pkt(struct scsi_address *, struct scsi_pkt *); | |
141 static void vhci_scsi_dmafree(struct scsi_address *, struct scsi_pkt *); | |
142 static void vhci_scsi_sync_pkt(struct scsi_address *, struct scsi_pkt *); | |
143 static int vhci_scsi_reset_notify(struct scsi_address *, int, void (*)(caddr_t), | |
144 caddr_t); | |
145 static int vhci_scsi_get_bus_addr(struct scsi_device *, char *, int); | |
146 static int vhci_scsi_get_name(struct scsi_device *, char *, int); | |
147 static int vhci_scsi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, | |
148 void *, void *); | |
149 static int vhci_scsi_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, | |
150 void *, dev_info_t **); | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
151 static int vhci_scsi_bus_unconfig(dev_info_t *, uint_t, ddi_bus_config_op_t, |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
152 void *); |
4851 | 153 |
154 /* | |
155 * functions registered with the mpxio framework via mdi_vhci_ops_t | |
156 */ | |
157 static int vhci_pathinfo_init(dev_info_t *, mdi_pathinfo_t *, int); | |
158 static int vhci_pathinfo_uninit(dev_info_t *, mdi_pathinfo_t *, int); | |
159 static int vhci_pathinfo_state_change(dev_info_t *, mdi_pathinfo_t *, | |
160 mdi_pathinfo_state_t, uint32_t, int); | |
161 static int vhci_pathinfo_online(dev_info_t *, mdi_pathinfo_t *, int); | |
162 static int vhci_pathinfo_offline(dev_info_t *, mdi_pathinfo_t *, int); | |
163 static int vhci_failover(dev_info_t *, dev_info_t *, int); | |
164 static void vhci_client_attached(dev_info_t *); | |
165 | |
166 static int vhci_ctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
167 static int vhci_devctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
168 static int vhci_ioc_get_phci_path(sv_iocdata_t *, caddr_t, int, caddr_t); | |
169 static int vhci_ioc_get_client_path(sv_iocdata_t *, caddr_t, int, caddr_t); | |
170 static int vhci_ioc_get_paddr(sv_iocdata_t *, caddr_t, int, caddr_t); | |
171 static int vhci_ioc_send_client_path(caddr_t, sv_iocdata_t *, int, caddr_t); | |
172 static void vhci_ioc_devi_to_path(dev_info_t *, caddr_t); | |
173 static int vhci_get_phci_path_list(dev_info_t *, sv_path_info_t *, uint_t); | |
174 static int vhci_get_client_path_list(dev_info_t *, sv_path_info_t *, uint_t); | |
175 static int vhci_get_iocdata(const void *, sv_iocdata_t *, int, caddr_t); | |
176 static int vhci_get_iocswitchdata(const void *, sv_switch_to_cntlr_iocdata_t *, | |
177 int, caddr_t); | |
178 static int vhci_ioc_alloc_pathinfo(sv_path_info_t **, sv_path_info_t **, | |
179 uint_t, sv_iocdata_t *, int, caddr_t); | |
180 static void vhci_ioc_free_pathinfo(sv_path_info_t *, sv_path_info_t *, uint_t); | |
181 static int vhci_ioc_send_pathinfo(sv_path_info_t *, sv_path_info_t *, uint_t, | |
182 sv_iocdata_t *, int, caddr_t); | |
183 static int vhci_handle_ext_fo(struct scsi_pkt *, int); | |
184 static int vhci_efo_watch_cb(caddr_t, struct scsi_watch_result *); | |
185 static int vhci_quiesce_lun(struct scsi_vhci_lun *); | |
186 static int vhci_pgr_validate_and_register(scsi_vhci_priv_t *); | |
187 static void vhci_dispatch_scsi_start(void *); | |
188 static void vhci_efo_done(void *); | |
189 static void vhci_initiate_auto_failback(void *); | |
190 static void vhci_update_pHCI_pkt(struct vhci_pkt *, struct scsi_pkt *); | |
191 static int vhci_update_pathinfo(struct scsi_device *, mdi_pathinfo_t *, | |
192 struct scsi_failover_ops *, scsi_vhci_lun_t *, struct scsi_vhci *); | |
193 static void vhci_kstat_create_pathinfo(mdi_pathinfo_t *); | |
194 static int vhci_quiesce_paths(dev_info_t *, dev_info_t *, | |
195 scsi_vhci_lun_t *, char *, char *); | |
196 | |
197 static char *vhci_devnm_to_guid(char *); | |
198 static int vhci_bind_transport(struct scsi_address *, struct vhci_pkt *, | |
199 int, int (*func)(caddr_t)); | |
200 static void vhci_intr(struct scsi_pkt *); | |
201 static int vhci_do_prout(scsi_vhci_priv_t *); | |
202 static void vhci_run_cmd(void *); | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
203 static int vhci_do_prin(struct vhci_pkt **); |
4851 | 204 static struct scsi_pkt *vhci_create_retry_pkt(struct vhci_pkt *); |
205 static struct vhci_pkt *vhci_sync_retry_pkt(struct vhci_pkt *); | |
206 static struct scsi_vhci_lun *vhci_lun_lookup(dev_info_t *); | |
207 static struct scsi_vhci_lun *vhci_lun_lookup_alloc(dev_info_t *, char *, int *); | |
208 static void vhci_lun_free(dev_info_t *); | |
209 static int vhci_recovery_reset(scsi_vhci_lun_t *, struct scsi_address *, | |
210 uint8_t, uint8_t); | |
211 void vhci_update_pathstates(void *); | |
212 | |
213 #ifdef DEBUG | |
214 static void vhci_print_prin_keys(vhci_prin_readkeys_t *, int); | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
215 static void vhci_print_cdb(dev_info_t *dip, uint_t level, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
216 char *title, uchar_t *cdb); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
217 static void vhci_clean_print(dev_info_t *dev, uint_t level, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
218 char *title, uchar_t *data, int len); |
6962
225346ebbb42
6719151 scsi_vhci debug kernels spews a *lot* on the console during boot
rralphs
parents:
6941
diff
changeset
|
219 #endif |
4851 | 220 static void vhci_print_prout_keys(scsi_vhci_lun_t *, char *); |
221 static void vhci_uscsi_iodone(struct scsi_pkt *pkt); | |
222 | |
223 /* | |
224 * MP-API related functions | |
225 */ | |
226 extern int vhci_mpapi_init(struct scsi_vhci *); | |
227 extern void vhci_mpapi_add_dev_prod(struct scsi_vhci *, char *); | |
228 extern int vhci_mpapi_ctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
229 extern void vhci_update_mpapi_data(struct scsi_vhci *, | |
230 scsi_vhci_lun_t *, mdi_pathinfo_t *); | |
231 extern void* vhci_get_mpapi_item(struct scsi_vhci *, mpapi_list_header_t *, | |
232 uint8_t, void*); | |
233 extern void vhci_mpapi_set_path_state(dev_info_t *, mdi_pathinfo_t *, int); | |
234 extern int vhci_mpapi_update_tpg_acc_state_for_lu(struct scsi_vhci *, | |
235 scsi_vhci_lun_t *); | |
236 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
237 #define VHCI_DMA_MAX_XFER_CAP INT_MAX |
4851 | 238 |
239 #define VHCI_MAX_PGR_RETRIES 3 | |
240 | |
241 /* | |
242 * Macros for the device-type mpxio options | |
243 */ | |
244 #define LOAD_BALANCE_OPTIONS "load-balance-options" | |
245 #define LOGICAL_BLOCK_REGION_SIZE "region-size" | |
246 #define MPXIO_OPTIONS_LIST "device-type-mpxio-options-list" | |
247 #define DEVICE_TYPE_STR "device-type" | |
248 #define isdigit(ch) ((ch) >= '0' && (ch) <= '9') | |
249 | |
250 static struct cb_ops vhci_cb_ops = { | |
251 vhci_open, /* open */ | |
252 vhci_close, /* close */ | |
253 nodev, /* strategy */ | |
254 nodev, /* print */ | |
255 nodev, /* dump */ | |
256 nodev, /* read */ | |
257 nodev, /* write */ | |
258 vhci_ioctl, /* ioctl */ | |
259 nodev, /* devmap */ | |
260 nodev, /* mmap */ | |
261 nodev, /* segmap */ | |
262 nochpoll, /* chpoll */ | |
263 ddi_prop_op, /* cb_prop_op */ | |
264 0, /* streamtab */ | |
265 D_NEW | D_MP, /* cb_flag */ | |
266 CB_REV, /* rev */ | |
267 nodev, /* aread */ | |
268 nodev /* awrite */ | |
269 }; | |
270 | |
271 static struct dev_ops vhci_ops = { | |
272 DEVO_REV, | |
273 0, | |
274 vhci_getinfo, | |
275 nulldev, /* identify */ | |
276 nulldev, /* probe */ | |
277 vhci_attach, /* attach and detach are mandatory */ | |
278 vhci_detach, | |
279 nodev, /* reset */ | |
280 &vhci_cb_ops, /* cb_ops */ | |
281 NULL, /* bus_ops */ | |
282 NULL, /* power */ | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7654
diff
changeset
|
283 ddi_quiesce_not_needed, /* quiesce */ |
4851 | 284 }; |
285 | |
286 extern struct mod_ops mod_driverops; | |
287 | |
288 static struct modldrv modldrv = { | |
289 &mod_driverops, | |
290 vhci_version_name, /* module name */ | |
291 &vhci_ops | |
292 }; | |
293 | |
294 static struct modlinkage modlinkage = { | |
295 MODREV_1, | |
296 &modldrv, | |
297 NULL | |
298 }; | |
299 | |
300 static mdi_vhci_ops_t vhci_opinfo = { | |
301 MDI_VHCI_OPS_REV, | |
302 vhci_pathinfo_init, /* Pathinfo node init callback */ | |
303 vhci_pathinfo_uninit, /* Pathinfo uninit callback */ | |
304 vhci_pathinfo_state_change, /* Pathinfo node state change */ | |
305 vhci_failover, /* failover callback */ | |
306 vhci_client_attached /* client attached callback */ | |
307 }; | |
308 | |
309 /* | |
310 * The scsi_failover table defines an ordered set of 'fops' modules supported | |
311 * by scsi_vhci. Currently, initialize this table from the 'ddi-forceload' | |
312 * property specified in scsi_vhci.conf. | |
313 */ | |
314 struct scsi_failover { | |
315 ddi_modhandle_t sf_mod; | |
316 struct scsi_failover_ops *sf_sfo; | |
317 } *scsi_failover_table; | |
318 uint_t scsi_nfailover; | |
319 | |
320 int | |
321 _init(void) | |
322 { | |
323 int rval; | |
324 | |
325 /* | |
326 * Allocate soft state and prepare to do ddi_soft_state_zalloc() | |
327 * before registering with the transport first. | |
328 */ | |
329 if ((rval = ddi_soft_state_init(&vhci_softstate, | |
330 sizeof (struct scsi_vhci), 1)) != 0) { | |
331 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
332 "!_init:soft state init failed\n")); | |
333 return (rval); | |
334 } | |
335 | |
336 if ((rval = scsi_hba_init(&modlinkage)) != 0) { | |
337 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
338 "!_init: scsi hba init failed\n")); | |
339 ddi_soft_state_fini(&vhci_softstate); | |
340 return (rval); | |
341 } | |
342 | |
343 mutex_init(&vhci_global_mutex, NULL, MUTEX_DRIVER, NULL); | |
344 cv_init(&vhci_cv, NULL, CV_DRIVER, NULL); | |
345 | |
346 mutex_init(&vhci_targetmap_mutex, NULL, MUTEX_DRIVER, NULL); | |
347 vhci_targetmap_byport = mod_hash_create_strhash( | |
348 "vhci_targetmap_byport", 256, mod_hash_null_valdtor); | |
349 vhci_targetmap_bypid = mod_hash_create_idhash( | |
350 "vhci_targetmap_bypid", 256, mod_hash_null_valdtor); | |
351 | |
352 if ((rval = mod_install(&modlinkage)) != 0) { | |
353 VHCI_DEBUG(1, (CE_NOTE, NULL, "!_init: mod_install failed\n")); | |
354 if (vhci_targetmap_bypid) | |
355 mod_hash_destroy_idhash(vhci_targetmap_bypid); | |
356 if (vhci_targetmap_byport) | |
357 mod_hash_destroy_strhash(vhci_targetmap_byport); | |
358 mutex_destroy(&vhci_targetmap_mutex); | |
359 cv_destroy(&vhci_cv); | |
360 mutex_destroy(&vhci_global_mutex); | |
361 scsi_hba_fini(&modlinkage); | |
362 ddi_soft_state_fini(&vhci_softstate); | |
363 } | |
364 return (rval); | |
365 } | |
366 | |
367 | |
368 /* | |
369 * the system is done with us as a driver, so clean up | |
370 */ | |
371 int | |
372 _fini(void) | |
373 { | |
374 int rval; | |
375 | |
376 /* | |
377 * don't start cleaning up until we know that the module remove | |
378 * has worked -- if this works, then we know that each instance | |
379 * has successfully been DDI_DETACHed | |
380 */ | |
381 if ((rval = mod_remove(&modlinkage)) != 0) { | |
382 VHCI_DEBUG(4, (CE_NOTE, NULL, "!_fini: mod_remove failed\n")); | |
383 return (rval); | |
384 } | |
385 | |
386 if (vhci_targetmap_bypid) | |
387 mod_hash_destroy_idhash(vhci_targetmap_bypid); | |
388 if (vhci_targetmap_byport) | |
389 mod_hash_destroy_strhash(vhci_targetmap_byport); | |
390 mutex_destroy(&vhci_targetmap_mutex); | |
391 cv_destroy(&vhci_cv); | |
392 mutex_destroy(&vhci_global_mutex); | |
393 scsi_hba_fini(&modlinkage); | |
394 ddi_soft_state_fini(&vhci_softstate); | |
395 | |
396 return (rval); | |
397 } | |
398 | |
399 int | |
400 _info(struct modinfo *modinfop) | |
401 { | |
402 return (mod_info(&modlinkage, modinfop)); | |
403 } | |
404 | |
405 /* | |
406 * Lookup scsi_failover by "short name" of failover module. | |
407 */ | |
408 struct scsi_failover_ops * | |
409 vhci_failover_ops_by_name(char *name) | |
410 { | |
411 struct scsi_failover *sf; | |
412 | |
413 for (sf = scsi_failover_table; sf->sf_mod; sf++) { | |
414 if (sf->sf_sfo == NULL) | |
415 continue; | |
416 if (strcmp(sf->sf_sfo->sfo_name, name) == 0) | |
417 return (sf->sf_sfo); | |
418 } | |
419 return (NULL); | |
420 } | |
421 | |
422 /* | |
423 * Load all scsi_failover_ops 'fops' modules. | |
424 */ | |
425 static void | |
426 vhci_failover_modopen(struct scsi_vhci *vhci) | |
427 { | |
428 char **module; | |
429 int i; | |
430 struct scsi_failover *sf; | |
431 char **dt; | |
432 int e; | |
433 | |
434 if (scsi_failover_table) | |
435 return; | |
436 | |
437 /* Get the list of modules from scsi_vhci.conf */ | |
438 if (ddi_prop_lookup_string_array(DDI_DEV_T_ANY, | |
439 vhci->vhci_dip, DDI_PROP_DONTPASS, "ddi-forceload", | |
440 &module, &scsi_nfailover) != DDI_PROP_SUCCESS) { | |
441 cmn_err(CE_WARN, "scsi_vhci: " | |
442 "scsi_vhci.conf is missing 'ddi-forceload'"); | |
443 return; | |
444 } | |
445 if (scsi_nfailover == 0) { | |
446 cmn_err(CE_WARN, "scsi_vhci: " | |
447 "scsi_vhci.conf has empty 'ddi-forceload'"); | |
4949
f3b9c8c61dbe
6594740 vhci_failover_modopen leaks "ddi-forceload" property
cth
parents:
4896
diff
changeset
|
448 ddi_prop_free(module); |
4851 | 449 return; |
450 } | |
451 | |
452 /* allocate failover table based on number of modules */ | |
453 scsi_failover_table = (struct scsi_failover *) | |
454 kmem_zalloc(sizeof (struct scsi_failover) * (scsi_nfailover + 1), | |
455 KM_SLEEP); | |
456 | |
457 /* loop over modules specified in scsi_vhci.conf and open each module */ | |
458 for (i = 0, sf = scsi_failover_table; i < scsi_nfailover; i++) { | |
459 if (module[i] == NULL) | |
460 continue; | |
461 | |
462 sf->sf_mod = ddi_modopen(module[i], KRTLD_MODE_FIRST, &e); | |
463 if (sf->sf_mod == NULL) { | |
464 /* | |
465 * A module returns EEXIST if other software is | |
466 * supporting the intended function: for example | |
467 * the scsi_vhci_f_sum_emc module returns EEXIST | |
468 * from _init if EMC powerpath software is installed. | |
469 */ | |
470 if (e != EEXIST) | |
471 cmn_err(CE_WARN, "scsi_vhci: unable to open " | |
472 "module '%s', error %d", module[i], e); | |
473 continue; | |
474 } | |
475 sf->sf_sfo = ddi_modsym(sf->sf_mod, | |
476 "scsi_vhci_failover_ops", &e); | |
477 if (sf->sf_sfo == NULL) { | |
478 cmn_err(CE_WARN, "scsi_vhci: " | |
479 "unable to import 'scsi_failover_ops' from '%s', " | |
480 "error %d", module[i], e); | |
481 (void) ddi_modclose(sf->sf_mod); | |
482 sf->sf_mod = NULL; | |
483 continue; | |
484 } | |
485 | |
486 /* register vid/pid of devices supported with mpapi */ | |
487 for (dt = sf->sf_sfo->sfo_devices; *dt; dt++) | |
488 vhci_mpapi_add_dev_prod(vhci, *dt); | |
489 sf++; | |
490 } | |
491 | |
492 /* verify that at least the "well-known" modules were there */ | |
493 if (vhci_failover_ops_by_name(SFO_NAME_SYM) == NULL) | |
494 cmn_err(CE_WARN, "scsi_vhci: well-known module \"" | |
495 SFO_NAME_SYM "\" not defined in scsi_vhci.conf's " | |
496 "'ddi-forceload'"); | |
497 if (vhci_failover_ops_by_name(SFO_NAME_TPGS) == NULL) | |
498 cmn_err(CE_WARN, "scsi_vhci: well-known module \"" | |
499 SFO_NAME_TPGS "\" not defined in scsi_vhci.conf's " | |
500 "'ddi-forceload'"); | |
501 | |
502 /* call sfo_init for modules that need it */ | |
503 for (sf = scsi_failover_table; sf->sf_mod; sf++) { | |
504 if (sf->sf_sfo && sf->sf_sfo->sfo_init) | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
505 sf->sf_sfo->sfo_init(); |
4851 | 506 } |
4949
f3b9c8c61dbe
6594740 vhci_failover_modopen leaks "ddi-forceload" property
cth
parents:
4896
diff
changeset
|
507 |
f3b9c8c61dbe
6594740 vhci_failover_modopen leaks "ddi-forceload" property
cth
parents:
4896
diff
changeset
|
508 ddi_prop_free(module); |
4851 | 509 } |
510 | |
511 /* | |
512 * unload all loaded scsi_failover_ops modules | |
513 */ | |
514 static void | |
515 vhci_failover_modclose() | |
516 { | |
517 struct scsi_failover *sf; | |
518 | |
519 for (sf = scsi_failover_table; sf->sf_mod; sf++) { | |
520 if ((sf->sf_mod == NULL) || (sf->sf_sfo == NULL)) | |
521 continue; | |
522 (void) ddi_modclose(sf->sf_mod); | |
523 sf->sf_mod = NULL; | |
524 sf->sf_sfo = NULL; | |
525 } | |
526 | |
527 if (scsi_failover_table && scsi_nfailover) | |
528 kmem_free(scsi_failover_table, | |
529 sizeof (struct scsi_failover) * (scsi_nfailover + 1)); | |
530 scsi_failover_table = NULL; | |
531 scsi_nfailover = 0; | |
532 } | |
533 | |
534 /* ARGSUSED */ | |
535 static int | |
536 vhci_open(dev_t *devp, int flag, int otype, cred_t *credp) | |
537 { | |
538 struct scsi_vhci *vhci; | |
539 | |
540 if (otype != OTYP_CHR) { | |
541 return (EINVAL); | |
542 } | |
543 | |
544 vhci = ddi_get_soft_state(vhci_softstate, MINOR2INST(getminor(*devp))); | |
545 if (vhci == NULL) { | |
546 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_open: failed ENXIO\n")); | |
547 return (ENXIO); | |
548 } | |
549 | |
550 mutex_enter(&vhci->vhci_mutex); | |
551 if ((flag & FEXCL) && (vhci->vhci_state & VHCI_STATE_OPEN)) { | |
552 mutex_exit(&vhci->vhci_mutex); | |
553 vhci_log(CE_NOTE, vhci->vhci_dip, | |
554 "!vhci%d: Already open\n", getminor(*devp)); | |
555 return (EBUSY); | |
556 } | |
557 | |
558 vhci->vhci_state |= VHCI_STATE_OPEN; | |
559 mutex_exit(&vhci->vhci_mutex); | |
560 return (0); | |
561 } | |
562 | |
563 | |
564 /* ARGSUSED */ | |
565 static int | |
566 vhci_close(dev_t dev, int flag, int otype, cred_t *credp) | |
567 { | |
568 struct scsi_vhci *vhci; | |
569 | |
570 if (otype != OTYP_CHR) { | |
571 return (EINVAL); | |
572 } | |
573 | |
574 vhci = ddi_get_soft_state(vhci_softstate, MINOR2INST(getminor(dev))); | |
575 if (vhci == NULL) { | |
576 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_close: failed ENXIO\n")); | |
577 return (ENXIO); | |
578 } | |
579 | |
580 mutex_enter(&vhci->vhci_mutex); | |
581 vhci->vhci_state &= ~VHCI_STATE_OPEN; | |
582 mutex_exit(&vhci->vhci_mutex); | |
583 | |
584 return (0); | |
585 } | |
586 | |
587 /* ARGSUSED */ | |
588 static int | |
589 vhci_ioctl(dev_t dev, int cmd, intptr_t data, int mode, | |
590 cred_t *credp, int *rval) | |
591 { | |
592 if (IS_DEVCTL(cmd)) { | |
593 return (vhci_devctl(dev, cmd, data, mode, credp, rval)); | |
594 } else if (cmd == MP_CMD) { | |
595 return (vhci_mpapi_ctl(dev, cmd, data, mode, credp, rval)); | |
596 } else { | |
597 return (vhci_ctl(dev, cmd, data, mode, credp, rval)); | |
598 } | |
599 } | |
600 | |
601 /* | |
602 * attach the module | |
603 */ | |
604 static int | |
605 vhci_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) | |
606 { | |
607 int rval = DDI_FAILURE; | |
608 int scsi_hba_attached = 0; | |
609 int vhci_attached = 0; | |
610 int mutex_initted = 0; | |
611 int instance; | |
612 struct scsi_vhci *vhci; | |
613 scsi_hba_tran_t *tran; | |
614 char cache_name_buf[64]; | |
615 char *data; | |
616 | |
617 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_attach: cmd=0x%x\n", cmd)); | |
618 | |
619 instance = ddi_get_instance(dip); | |
620 | |
621 switch (cmd) { | |
622 case DDI_ATTACH: | |
623 break; | |
624 | |
625 case DDI_RESUME: | |
626 case DDI_PM_RESUME: | |
627 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_attach: resume not yet" | |
628 "implemented\n")); | |
629 return (rval); | |
630 | |
631 default: | |
632 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
633 "!vhci_attach: unknown ddi command\n")); | |
634 return (rval); | |
635 } | |
636 | |
637 /* | |
638 * Allocate vhci data structure. | |
639 */ | |
640 if (ddi_soft_state_zalloc(vhci_softstate, instance) != DDI_SUCCESS) { | |
641 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
642 "soft state alloc failed\n")); | |
643 return (DDI_FAILURE); | |
644 } | |
645 | |
646 if ((vhci = ddi_get_soft_state(vhci_softstate, instance)) == NULL) { | |
647 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
648 "bad soft state\n")); | |
649 ddi_soft_state_free(vhci_softstate, instance); | |
650 return (DDI_FAILURE); | |
651 } | |
652 | |
653 /* Allocate packet cache */ | |
654 (void) snprintf(cache_name_buf, sizeof (cache_name_buf), | |
655 "vhci%d_cache", instance); | |
656 | |
657 mutex_init(&vhci->vhci_mutex, NULL, MUTEX_DRIVER, NULL); | |
658 mutex_initted++; | |
659 | |
660 /* | |
661 * Allocate a transport structure | |
662 */ | |
663 tran = scsi_hba_tran_alloc(dip, SCSI_HBA_CANSLEEP); | |
664 ASSERT(tran != NULL); | |
665 | |
666 vhci->vhci_tran = tran; | |
667 vhci->vhci_dip = dip; | |
668 vhci->vhci_instance = instance; | |
669 | |
670 tran->tran_hba_private = vhci; | |
671 tran->tran_tgt_init = vhci_scsi_tgt_init; | |
672 tran->tran_tgt_probe = NULL; | |
673 tran->tran_tgt_free = vhci_scsi_tgt_free; | |
674 | |
675 tran->tran_start = vhci_scsi_start; | |
676 tran->tran_abort = vhci_scsi_abort; | |
677 tran->tran_reset = vhci_scsi_reset; | |
678 tran->tran_getcap = vhci_scsi_getcap; | |
679 tran->tran_setcap = vhci_scsi_setcap; | |
680 tran->tran_init_pkt = vhci_scsi_init_pkt; | |
681 tran->tran_destroy_pkt = vhci_scsi_destroy_pkt; | |
682 tran->tran_dmafree = vhci_scsi_dmafree; | |
683 tran->tran_sync_pkt = vhci_scsi_sync_pkt; | |
684 tran->tran_reset_notify = vhci_scsi_reset_notify; | |
685 | |
686 tran->tran_get_bus_addr = vhci_scsi_get_bus_addr; | |
687 tran->tran_get_name = vhci_scsi_get_name; | |
688 tran->tran_bus_reset = NULL; | |
689 tran->tran_quiesce = NULL; | |
690 tran->tran_unquiesce = NULL; | |
691 | |
692 /* | |
693 * register event notification routines with scsa | |
694 */ | |
695 tran->tran_get_eventcookie = NULL; | |
696 tran->tran_add_eventcall = NULL; | |
697 tran->tran_remove_eventcall = NULL; | |
698 tran->tran_post_event = NULL; | |
699 | |
700 tran->tran_bus_power = vhci_scsi_bus_power; | |
701 | |
702 tran->tran_bus_config = vhci_scsi_bus_config; | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
703 tran->tran_bus_unconfig = vhci_scsi_bus_unconfig; |
4851 | 704 |
705 /* | |
706 * Attach this instance with the mpxio framework | |
707 */ | |
708 if (mdi_vhci_register(MDI_HCI_CLASS_SCSI, dip, &vhci_opinfo, 0) | |
709 != MDI_SUCCESS) { | |
710 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
711 "mdi_vhci_register failed\n")); | |
712 goto attach_fail; | |
713 } | |
714 vhci_attached++; | |
715 | |
716 /* | |
717 * Attach this instance of the hba. | |
718 * | |
719 * Regarding dma attributes: Since scsi_vhci is a virtual scsi HBA | |
720 * driver, it has nothing to do with DMA. However, when calling | |
721 * scsi_hba_attach_setup() we need to pass something valid in the | |
722 * dma attributes parameter. So we just use scsi_alloc_attr. | |
723 * SCSA itself seems to care only for dma_attr_minxfer and | |
724 * dma_attr_burstsizes fields of dma attributes structure. | |
725 * It expects those fileds to be non-zero. | |
726 */ | |
727 if (scsi_hba_attach_setup(dip, &scsi_alloc_attr, tran, | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
728 SCSI_HBA_ADDR_COMPLEX) != DDI_SUCCESS) { |
4851 | 729 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" |
730 "hba attach failed\n")); | |
731 goto attach_fail; | |
732 } | |
733 scsi_hba_attached++; | |
734 | |
735 if (ddi_create_minor_node(dip, "devctl", S_IFCHR, | |
736 INST2DEVCTL(instance), DDI_NT_SCSI_NEXUS, 0) != DDI_SUCCESS) { | |
737 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
738 " ddi_create_minor_node failed\n")); | |
739 goto attach_fail; | |
740 } | |
741 | |
742 /* | |
743 * Set pm-want-child-notification property for | |
744 * power management of the phci and client | |
745 */ | |
746 if (ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP, | |
747 "pm-want-child-notification?", NULL, NULL) != DDI_PROP_SUCCESS) { | |
748 cmn_err(CE_WARN, | |
749 "%s%d fail to create pm-want-child-notification? prop", | |
750 ddi_driver_name(dip), ddi_get_instance(dip)); | |
751 goto attach_fail; | |
752 } | |
753 | |
754 vhci->vhci_taskq = taskq_create("vhci_taskq", 1, MINCLSYSPRI, 1, 4, 0); | |
755 vhci->vhci_update_pathstates_taskq = | |
756 taskq_create("vhci_update_pathstates", VHCI_NUM_UPDATE_TASKQ, | |
757 MINCLSYSPRI, 1, 4, 0); | |
758 ASSERT(vhci->vhci_taskq); | |
759 ASSERT(vhci->vhci_update_pathstates_taskq); | |
760 | |
761 /* | |
762 * Set appropriate configuration flags based on options set in | |
763 * conf file. | |
764 */ | |
765 vhci->vhci_conf_flags = 0; | |
766 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, PROPFLAGS, | |
767 "auto-failback", &data) == DDI_SUCCESS) { | |
768 if (strcmp(data, "enable") == 0) | |
769 vhci->vhci_conf_flags |= VHCI_CONF_FLAGS_AUTO_FAILBACK; | |
770 ddi_prop_free(data); | |
771 } | |
772 | |
773 if (!(vhci->vhci_conf_flags & VHCI_CONF_FLAGS_AUTO_FAILBACK)) | |
774 vhci_log(CE_NOTE, dip, "!Auto-failback capability " | |
775 "disabled through scsi_vhci.conf file."); | |
776 | |
777 /* | |
778 * Allocate an mpapi private structure | |
779 */ | |
780 vhci->mp_priv = kmem_zalloc(sizeof (mpapi_priv_t), KM_SLEEP); | |
781 if (vhci_mpapi_init(vhci) != 0) { | |
782 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_attach: " | |
783 "vhci_mpapi_init() failed")); | |
784 } | |
785 | |
786 vhci_failover_modopen(vhci); /* load failover modules */ | |
787 | |
788 ddi_report_dev(dip); | |
789 return (DDI_SUCCESS); | |
790 | |
791 attach_fail: | |
792 if (vhci_attached) | |
793 (void) mdi_vhci_unregister(dip, 0); | |
794 | |
795 if (scsi_hba_attached) | |
796 (void) scsi_hba_detach(dip); | |
797 | |
798 if (vhci->vhci_tran) | |
799 scsi_hba_tran_free(vhci->vhci_tran); | |
800 | |
801 if (mutex_initted) { | |
802 mutex_destroy(&vhci->vhci_mutex); | |
803 } | |
804 | |
805 ddi_soft_state_free(vhci_softstate, instance); | |
806 return (DDI_FAILURE); | |
807 } | |
808 | |
809 | |
810 /*ARGSUSED*/ | |
811 static int | |
812 vhci_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) | |
813 { | |
814 int instance = ddi_get_instance(dip); | |
815 scsi_hba_tran_t *tran; | |
816 struct scsi_vhci *vhci; | |
817 | |
818 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_detach: cmd=0x%x\n", cmd)); | |
819 | |
820 if ((tran = ddi_get_driver_private(dip)) == NULL) | |
821 return (DDI_FAILURE); | |
822 | |
823 vhci = TRAN2HBAPRIVATE(tran); | |
824 if (!vhci) { | |
825 return (DDI_FAILURE); | |
826 } | |
827 | |
828 switch (cmd) { | |
829 case DDI_DETACH: | |
830 break; | |
831 | |
832 case DDI_SUSPEND: | |
833 case DDI_PM_SUSPEND: | |
834 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_detach: suspend/pm not yet" | |
835 "implemented\n")); | |
836 return (DDI_FAILURE); | |
837 | |
838 default: | |
839 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
840 "!vhci_detach: unknown ddi command\n")); | |
841 return (DDI_FAILURE); | |
842 } | |
843 | |
844 (void) mdi_vhci_unregister(dip, 0); | |
845 (void) scsi_hba_detach(dip); | |
846 scsi_hba_tran_free(tran); | |
847 | |
848 if (ddi_prop_remove(DDI_DEV_T_NONE, dip, | |
849 "pm-want-child-notification?") != DDI_PROP_SUCCESS) { | |
850 cmn_err(CE_WARN, | |
851 "%s%d unable to remove prop pm-want_child_notification?", | |
852 ddi_driver_name(dip), ddi_get_instance(dip)); | |
853 } | |
854 if (vhci_restart_timeid != 0) { | |
855 (void) untimeout(vhci_restart_timeid); | |
856 } | |
857 vhci_restart_timeid = 0; | |
858 | |
859 mutex_destroy(&vhci->vhci_mutex); | |
860 vhci->vhci_dip = NULL; | |
861 vhci->vhci_tran = NULL; | |
862 taskq_destroy(vhci->vhci_taskq); | |
863 taskq_destroy(vhci->vhci_update_pathstates_taskq); | |
864 ddi_remove_minor_node(dip, NULL); | |
865 ddi_soft_state_free(vhci_softstate, instance); | |
866 | |
867 vhci_failover_modclose(); /* unload failover modules */ | |
868 return (DDI_SUCCESS); | |
869 } | |
870 | |
871 /* | |
872 * vhci_getinfo() | |
873 * Given the device number, return the devinfo pointer or the | |
874 * instance number. | |
875 * Note: always succeed DDI_INFO_DEVT2INSTANCE, even before attach. | |
876 */ | |
877 | |
878 /*ARGSUSED*/ | |
879 static int | |
880 vhci_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result) | |
881 { | |
882 struct scsi_vhci *vhcip; | |
883 int instance = MINOR2INST(getminor((dev_t)arg)); | |
884 | |
885 switch (cmd) { | |
886 case DDI_INFO_DEVT2DEVINFO: | |
887 vhcip = ddi_get_soft_state(vhci_softstate, instance); | |
888 if (vhcip != NULL) | |
889 *result = vhcip->vhci_dip; | |
890 else { | |
891 *result = NULL; | |
892 return (DDI_FAILURE); | |
893 } | |
894 break; | |
895 | |
896 case DDI_INFO_DEVT2INSTANCE: | |
897 *result = (void *)(uintptr_t)instance; | |
898 break; | |
899 | |
900 default: | |
901 return (DDI_FAILURE); | |
902 } | |
903 | |
904 return (DDI_SUCCESS); | |
905 } | |
906 | |
907 /*ARGSUSED*/ | |
908 static int | |
909 vhci_scsi_tgt_init(dev_info_t *hba_dip, dev_info_t *tgt_dip, | |
910 scsi_hba_tran_t *hba_tran, struct scsi_device *sd) | |
911 { | |
912 char *guid; | |
913 scsi_vhci_lun_t *vlun; | |
914 struct scsi_vhci *vhci; | |
915 clock_t from_ticks; | |
916 mdi_pathinfo_t *pip; | |
917 int rval; | |
918 | |
919 ASSERT(hba_dip != NULL); | |
920 ASSERT(tgt_dip != NULL); | |
921 | |
6777 | 922 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, tgt_dip, PROPFLAGS, |
923 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) { | |
924 /* | |
925 * This must be the .conf node without GUID property. | |
926 * The node under fp already inserts a delay, so we | |
927 * just return from here. We rely on this delay to have | |
928 * all dips be posted to the ndi hotplug thread's newdev | |
929 * list. This is necessary for the deferred attach | |
930 * mechanism to work and opens() done soon after boot to | |
931 * succeed. | |
932 */ | |
933 VHCI_DEBUG(4, (CE_WARN, hba_dip, "tgt_init: lun guid " | |
934 "property failed")); | |
935 return (DDI_NOT_WELL_FORMED); | |
936 } | |
937 | |
938 if (ndi_dev_is_persistent_node(tgt_dip) == 0) { | |
939 /* | |
940 * This must be .conf node with the GUID property. We don't | |
941 * merge property by ndi_merge_node() here because the | |
942 * devi_addr_buf of .conf node is "" always according the | |
943 * implementation of vhci_scsi_get_name_bus_addr(). | |
944 */ | |
945 ddi_set_name_addr(tgt_dip, NULL); | |
946 return (DDI_FAILURE); | |
947 } | |
948 | |
4851 | 949 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(hba_dip)); |
950 ASSERT(vhci != NULL); | |
951 | |
952 VHCI_DEBUG(4, (CE_NOTE, hba_dip, | |
953 "!tgt_init: called for %s (instance %d)\n", | |
954 ddi_driver_name(tgt_dip), ddi_get_instance(tgt_dip))); | |
955 | |
956 vlun = vhci_lun_lookup(tgt_dip); | |
957 | |
958 mutex_enter(&vhci_global_mutex); | |
959 | |
960 from_ticks = ddi_get_lbolt(); | |
961 if (vhci_to_ticks == 0) { | |
962 vhci_to_ticks = from_ticks + | |
963 drv_usectohz(vhci_init_wait_timeout); | |
964 } | |
965 | |
966 #if DEBUG | |
967 if (vlun) { | |
968 VHCI_DEBUG(1, (CE_WARN, hba_dip, "tgt_init: " | |
969 "vhci_scsi_tgt_init: guid %s : found vlun 0x%p " | |
970 "from_ticks %lx to_ticks %lx", | |
971 guid, (void *)vlun, from_ticks, vhci_to_ticks)); | |
972 } else { | |
973 VHCI_DEBUG(1, (CE_WARN, hba_dip, "tgt_init: " | |
974 "vhci_scsi_tgt_init: guid %s : vlun not found " | |
975 "from_ticks %lx to_ticks %lx", guid, from_ticks, | |
976 vhci_to_ticks)); | |
977 } | |
978 #endif | |
979 | |
980 rval = mdi_select_path(tgt_dip, NULL, | |
981 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), NULL, &pip); | |
982 if (rval == MDI_SUCCESS) { | |
983 mdi_rele_path(pip); | |
984 } | |
985 | |
986 /* | |
987 * Wait for the following conditions : | |
988 * 1. no vlun available yet | |
989 * 2. no path established | |
990 * 3. timer did not expire | |
991 */ | |
992 while ((vlun == NULL) || (mdi_client_get_path_count(tgt_dip) == 0) || | |
993 (rval != MDI_SUCCESS)) { | |
994 if (vlun && vlun->svl_not_supported) { | |
995 VHCI_DEBUG(1, (CE_WARN, hba_dip, "tgt_init: " | |
996 "vlun 0x%p lun guid %s not supported!", | |
997 (void *)vlun, guid)); | |
998 mutex_exit(&vhci_global_mutex); | |
999 ddi_prop_free(guid); | |
1000 return (DDI_NOT_WELL_FORMED); | |
1001 } | |
1002 if ((vhci_first_time == 0) && (from_ticks >= vhci_to_ticks)) { | |
1003 vhci_first_time = 1; | |
1004 } | |
1005 if (vhci_first_time == 1) { | |
1006 VHCI_DEBUG(1, (CE_WARN, hba_dip, "vhci_scsi_tgt_init: " | |
1007 "no wait for %s. from_tick %lx, to_tick %lx", | |
1008 guid, from_ticks, vhci_to_ticks)); | |
1009 mutex_exit(&vhci_global_mutex); | |
1010 ddi_prop_free(guid); | |
1011 return (DDI_NOT_WELL_FORMED); | |
1012 } | |
1013 | |
1014 if (cv_timedwait(&vhci_cv, | |
1015 &vhci_global_mutex, vhci_to_ticks) == -1) { | |
1016 /* Timed out */ | |
1017 #ifdef DEBUG | |
1018 if (vlun == NULL) { | |
1019 VHCI_DEBUG(1, (CE_WARN, hba_dip, | |
1020 "tgt_init: no vlun for %s!", guid)); | |
1021 } else if (mdi_client_get_path_count(tgt_dip) == 0) { | |
1022 VHCI_DEBUG(1, (CE_WARN, hba_dip, | |
1023 "tgt_init: client path count is " | |
1024 "zero for %s!", guid)); | |
1025 } else { | |
1026 VHCI_DEBUG(1, (CE_WARN, hba_dip, | |
1027 "tgt_init: client path not " | |
1028 "available yet for %s!", guid)); | |
1029 } | |
1030 #endif /* DEBUG */ | |
1031 mutex_exit(&vhci_global_mutex); | |
1032 ddi_prop_free(guid); | |
1033 return (DDI_NOT_WELL_FORMED); | |
1034 } | |
1035 vlun = vhci_lun_lookup(tgt_dip); | |
1036 rval = mdi_select_path(tgt_dip, NULL, | |
1037 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), | |
1038 NULL, &pip); | |
1039 if (rval == MDI_SUCCESS) { | |
1040 mdi_rele_path(pip); | |
1041 } | |
1042 from_ticks = ddi_get_lbolt(); | |
1043 } | |
1044 mutex_exit(&vhci_global_mutex); | |
1045 | |
1046 ASSERT(vlun != NULL); | |
1047 ddi_prop_free(guid); | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
1048 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
1049 scsi_device_hba_private_set(sd, vlun); |
4851 | 1050 |
1051 return (DDI_SUCCESS); | |
1052 } | |
1053 | |
1054 /*ARGSUSED*/ | |
1055 static void | |
1056 vhci_scsi_tgt_free(dev_info_t *hba_dip, dev_info_t *tgt_dip, | |
1057 scsi_hba_tran_t *hba_tran, struct scsi_device *sd) | |
1058 { | |
1059 } | |
1060 | |
1061 /* | |
1062 * a PGR register command has started; copy the info we need | |
1063 */ | |
1064 int | |
1065 vhci_pgr_register_start(scsi_vhci_lun_t *vlun, struct scsi_pkt *pkt) | |
1066 { | |
1067 struct vhci_pkt *vpkt = TGTPKT2VHCIPKT(pkt); | |
1068 void *addr; | |
1069 | |
1070 if (!vpkt->vpkt_tgt_init_bp) | |
1071 return (TRAN_BADPKT); | |
1072 | |
1073 addr = bp_mapin_common(vpkt->vpkt_tgt_init_bp, | |
1074 (vpkt->vpkt_flags & CFLAG_NOWAIT) ? VM_NOSLEEP : VM_SLEEP); | |
1075 if (addr == NULL) | |
1076 return (TRAN_BUSY); | |
1077 | |
1078 mutex_enter(&vlun->svl_mutex); | |
1079 | |
1080 vhci_print_prout_keys(vlun, "v_pgr_reg_start: before bcopy:"); | |
1081 | |
1082 bcopy(addr, &vlun->svl_prout, sizeof (vhci_prout_t) - | |
1083 (2 * MHIOC_RESV_KEY_SIZE*sizeof (char))); | |
1084 bcopy(pkt->pkt_cdbp, vlun->svl_cdb, sizeof (vlun->svl_cdb)); | |
1085 | |
1086 vhci_print_prout_keys(vlun, "v_pgr_reg_start: after bcopy:"); | |
1087 | |
1088 vlun->svl_time = pkt->pkt_time; | |
1089 vlun->svl_bcount = vpkt->vpkt_tgt_init_bp->b_bcount; | |
1090 vlun->svl_first_path = vpkt->vpkt_path; | |
1091 mutex_exit(&vlun->svl_mutex); | |
1092 return (0); | |
1093 } | |
1094 | |
1095 /* | |
1096 * Function name : vhci_scsi_start() | |
1097 * | |
1098 * Return Values : TRAN_FATAL_ERROR - vhci has been shutdown | |
1099 * or other fatal failure | |
1100 * preventing packet transportation | |
1101 * TRAN_BUSY - request queue is full | |
1102 * TRAN_ACCEPT - pkt has been submitted to phci | |
1103 * (or is held in the waitQ) | |
1104 * Description : Implements SCSA's tran_start() entry point for | |
1105 * packet transport | |
1106 * | |
1107 */ | |
1108 static int | |
1109 vhci_scsi_start(struct scsi_address *ap, struct scsi_pkt *pkt) | |
1110 { | |
1111 int rval = TRAN_ACCEPT; | |
1112 int instance, held; | |
1113 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
1114 struct scsi_vhci_lun *vlun = ADDR2VLUN(ap); | |
1115 struct vhci_pkt *vpkt = TGTPKT2VHCIPKT(pkt); | |
1116 int flags = 0; | |
1117 scsi_vhci_priv_t *svp; | |
1118 dev_info_t *cdip; | |
1119 client_lb_t lbp; | |
1120 int restore_lbp = 0; | |
1121 /* set if pkt is SCSI-II RESERVE cmd */ | |
1122 int pkt_reserve_cmd = 0; | |
1123 int reserve_failed = 0; | |
1124 | |
1125 ASSERT(vhci != NULL); | |
1126 ASSERT(vpkt != NULL); | |
1127 ASSERT(vpkt->vpkt_state != VHCI_PKT_ISSUED); | |
1128 cdip = ADDR2DIP(ap); | |
1129 | |
1130 /* | |
1131 * Block IOs if LUN is held or QUIESCED for IOs. | |
1132 */ | |
1133 if ((VHCI_LUN_IS_HELD(vlun)) || | |
1134 ((vlun->svl_flags & VLUN_QUIESCED_FLG) == VLUN_QUIESCED_FLG)) { | |
1135 return (TRAN_BUSY); | |
1136 } | |
1137 | |
1138 /* | |
1139 * vhci_lun needs to be quiesced before SCSI-II RESERVE command | |
1140 * can be issued. This may require a cv_timedwait, which is | |
1141 * dangerous to perform in an interrupt context. So if this | |
1142 * is a RESERVE command a taskq is dispatched to service it. | |
1143 * This taskq shall again call vhci_scsi_start, but we shall be | |
1144 * sure its not in an interrupt context. | |
1145 */ | |
1146 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
1147 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
1148 if (!(vpkt->vpkt_state & VHCI_PKT_THRU_TASKQ)) { | |
1149 if (taskq_dispatch(vhci->vhci_taskq, | |
1150 vhci_dispatch_scsi_start, (void *) vpkt, | |
1151 KM_NOSLEEP)) { | |
1152 return (TRAN_ACCEPT); | |
1153 } else { | |
1154 return (TRAN_BUSY); | |
1155 } | |
1156 } | |
1157 | |
1158 /* | |
1159 * Here we ensure that simultaneous SCSI-II RESERVE cmds don't | |
1160 * get serviced for a lun. | |
1161 */ | |
1162 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
1163 if (!held) { | |
1164 return (TRAN_BUSY); | |
1165 } else if ((vlun->svl_flags & VLUN_QUIESCED_FLG) == | |
1166 VLUN_QUIESCED_FLG) { | |
1167 VHCI_RELEASE_LUN(vlun); | |
1168 return (TRAN_BUSY); | |
1169 } | |
1170 | |
1171 /* | |
1172 * To ensure that no IOs occur for this LUN for the duration | |
1173 * of this pkt set the VLUN_QUIESCED_FLG. | |
1174 * In case this routine needs to exit on error make sure that | |
1175 * this flag is cleared. | |
1176 */ | |
1177 vlun->svl_flags |= VLUN_QUIESCED_FLG; | |
1178 pkt_reserve_cmd = 1; | |
1179 | |
1180 /* | |
1181 * if this is a SCSI-II RESERVE command, set load balancing | |
1182 * policy to be ALTERNATE PATH to ensure that all subsequent | |
1183 * IOs are routed on the same path. This is because if commands | |
1184 * are routed across multiple paths then IOs on paths other than | |
1185 * the one on which the RESERVE was executed will get a | |
1186 * RESERVATION CONFLICT | |
1187 */ | |
1188 lbp = mdi_get_lb_policy(cdip); | |
1189 if (lbp != LOAD_BALANCE_NONE) { | |
1190 if (vhci_quiesce_lun(vlun) != 1) { | |
1191 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1192 VHCI_RELEASE_LUN(vlun); | |
1193 return (TRAN_FATAL_ERROR); | |
1194 } | |
1195 vlun->svl_lb_policy_save = lbp; | |
1196 if (mdi_set_lb_policy(cdip, LOAD_BALANCE_NONE) != | |
1197 MDI_SUCCESS) { | |
1198 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1199 VHCI_RELEASE_LUN(vlun); | |
1200 return (TRAN_FATAL_ERROR); | |
1201 } | |
1202 restore_lbp = 1; | |
1203 } | |
1204 /* | |
1205 * See comments for VLUN_RESERVE_ACTIVE_FLG in scsi_vhci.h | |
1206 * To narrow this window where a reserve command may be sent | |
1207 * down an inactive path the path states first need to be | |
1208 * updated. Before calling vhci_update_pathstates reset | |
1209 * VLUN_RESERVE_ACTIVE_FLG, just in case it was already set | |
1210 * for this lun. This shall prevent an unnecessary reset | |
1211 * from being sent out. | |
1212 */ | |
1213 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
1214 vhci_update_pathstates((void *)vlun); | |
1215 } | |
1216 | |
1217 instance = ddi_get_instance(vhci->vhci_dip); | |
1218 | |
1219 /* | |
1220 * If the command is PRIN with action of zero, then the cmd | |
1221 * is reading PR keys which requires filtering on completion. | |
1222 * Data cache sync must be guaranteed. | |
1223 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1224 if ((pkt->pkt_cdbp[0] == SCMD_PRIN) && (pkt->pkt_cdbp[1] == 0) && |
4851 | 1225 (vpkt->vpkt_org_vpkt == NULL)) { |
1226 vpkt->vpkt_tgt_init_pkt_flags |= PKT_CONSISTENT; | |
1227 } | |
1228 | |
1229 /* | |
1230 * Do not defer bind for PKT_DMA_PARTIAL | |
1231 */ | |
1232 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1233 | |
1234 /* This is a non pkt_dma_partial case */ | |
1235 if ((rval = vhci_bind_transport( | |
1236 ap, vpkt, vpkt->vpkt_tgt_init_pkt_flags, NULL_FUNC)) | |
1237 != TRAN_ACCEPT) { | |
1238 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1239 "!vhci%d %x: failed to bind transport: " | |
1240 "vlun 0x%p pkt_reserved %x restore_lbp %x," | |
1241 "lbp %x", instance, rval, (void *)vlun, | |
1242 pkt_reserve_cmd, restore_lbp, lbp)); | |
1243 if (restore_lbp) | |
1244 (void) mdi_set_lb_policy(cdip, lbp); | |
1245 if (pkt_reserve_cmd) | |
1246 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1247 return (rval); | |
1248 } | |
1249 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
1250 "vhci_scsi_start: v_b_t called 0x%p\n", (void *)vpkt)); | |
1251 } | |
1252 ASSERT(vpkt->vpkt_hba_pkt != NULL); | |
1253 ASSERT(vpkt->vpkt_path != NULL); | |
1254 | |
1255 /* | |
1256 * This is the chance to adjust the pHCI's pkt and other information | |
1257 * from target driver's pkt. | |
1258 */ | |
1259 VHCI_DEBUG(8, (CE_NOTE, vhci->vhci_dip, "vhci_scsi_start vpkt %p\n", | |
1260 (void *)vpkt)); | |
1261 vhci_update_pHCI_pkt(vpkt, pkt); | |
1262 | |
1263 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
1264 if (vpkt->vpkt_path != vlun->svl_resrv_pip) { | |
1265 VHCI_DEBUG(1, (CE_WARN, vhci->vhci_dip, | |
1266 "!vhci_bind: reserve flag set for vlun 0x%p, but, " | |
1267 "pktpath 0x%p resrv path 0x%p differ. lb_policy %x", | |
1268 (void *)vlun, (void *)vpkt->vpkt_path, | |
1269 (void *)vlun->svl_resrv_pip, | |
1270 mdi_get_lb_policy(cdip))); | |
1271 reserve_failed = 1; | |
1272 } | |
1273 } | |
1274 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1275 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(vpkt->vpkt_path); |
4851 | 1276 if (svp == NULL || reserve_failed) { |
1277 if (pkt_reserve_cmd) { | |
1278 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1279 "!vhci_bind returned null svp vlun 0x%p", | |
1280 (void *)vlun)); | |
1281 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1282 if (restore_lbp) | |
1283 (void) mdi_set_lb_policy(cdip, lbp); | |
1284 } | |
1285 pkt_cleanup: | |
1286 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1287 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
1288 vpkt->vpkt_hba_pkt = NULL; | |
1289 if (vpkt->vpkt_path) { | |
1290 mdi_rele_path(vpkt->vpkt_path); | |
1291 vpkt->vpkt_path = NULL; | |
1292 } | |
1293 } | |
1294 if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
1295 (((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) || | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1296 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { |
4851 | 1297 sema_v(&vlun->svl_pgr_sema); |
1298 } | |
1299 return (TRAN_BUSY); | |
1300 } | |
1301 | |
1302 VHCI_INCR_PATH_CMDCOUNT(svp); | |
1303 | |
1304 /* | |
1305 * Ensure that no other IOs raced ahead, while a RESERVE cmd was | |
1306 * QUIESCING the same lun. | |
1307 */ | |
1308 if ((!pkt_reserve_cmd) && | |
1309 ((vlun->svl_flags & VLUN_QUIESCED_FLG) == VLUN_QUIESCED_FLG)) { | |
1310 VHCI_DECR_PATH_CMDCOUNT(svp); | |
1311 goto pkt_cleanup; | |
1312 } | |
1313 | |
1314 if ((pkt->pkt_cdbp[0] == SCMD_PRIN) || | |
1315 (pkt->pkt_cdbp[0] == SCMD_PROUT)) { | |
1316 /* | |
1317 * currently this thread only handles running PGR | |
1318 * commands, so don't bother creating it unless | |
1319 * something interesting is going to happen (like | |
1320 * either a PGR out, or a PGR in with enough space | |
1321 * to hold the keys that are getting returned) | |
1322 */ | |
1323 mutex_enter(&vlun->svl_mutex); | |
1324 if (((vlun->svl_flags & VLUN_TASK_D_ALIVE_FLG) == 0) && | |
1325 (pkt->pkt_cdbp[0] == SCMD_PROUT)) { | |
1326 vlun->svl_taskq = taskq_create("vlun_pgr_task_daemon", | |
1327 1, MINCLSYSPRI, 1, 4, 0); | |
1328 vlun->svl_flags |= VLUN_TASK_D_ALIVE_FLG; | |
1329 } | |
1330 mutex_exit(&vlun->svl_mutex); | |
1331 if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
1332 (((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) || | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1333 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { |
4851 | 1334 if (rval = vhci_pgr_register_start(vlun, pkt)) { |
1335 /* an error */ | |
1336 sema_v(&vlun->svl_pgr_sema); | |
1337 return (rval); | |
1338 } | |
1339 } | |
1340 } | |
1341 | |
1342 /* | |
1343 * SCSI-II RESERVE cmd is not expected in polled mode. | |
1344 * If this changes it needs to be handled for the polled scenario. | |
1345 */ | |
1346 flags = vpkt->vpkt_hba_pkt->pkt_flags; | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1347 |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1348 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1349 * Set the path_instance *before* sending the scsi_pkt down the path |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1350 * to mpxio's pHCI so that additional path abstractions at a pHCI |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1351 * level (like maybe iSCSI at some point in the future) can update |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1352 * the path_instance. |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1353 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1354 if (scsi_pkt_allocated_correctly(vpkt->vpkt_hba_pkt)) |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1355 vpkt->vpkt_hba_pkt->pkt_path_instance = |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1356 mdi_pi_get_path_instance(vpkt->vpkt_path); |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1357 |
4851 | 1358 rval = scsi_transport(vpkt->vpkt_hba_pkt); |
1359 if (rval == TRAN_ACCEPT) { | |
1360 if (flags & FLAG_NOINTR) { | |
1361 struct scsi_pkt *tpkt = vpkt->vpkt_tgt_pkt; | |
1362 struct scsi_pkt *pkt = vpkt->vpkt_hba_pkt; | |
1363 | |
1364 ASSERT(tpkt != NULL); | |
1365 *(tpkt->pkt_scbp) = *(pkt->pkt_scbp); | |
1366 tpkt->pkt_resid = pkt->pkt_resid; | |
1367 tpkt->pkt_state = pkt->pkt_state; | |
1368 tpkt->pkt_statistics = pkt->pkt_statistics; | |
1369 tpkt->pkt_reason = pkt->pkt_reason; | |
1370 | |
1371 if ((*(pkt->pkt_scbp) == STATUS_CHECK) && | |
1372 (pkt->pkt_state & STATE_ARQ_DONE)) { | |
1373 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
1374 vpkt->vpkt_tgt_init_scblen); | |
1375 } | |
1376 | |
1377 VHCI_DECR_PATH_CMDCOUNT(svp); | |
1378 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1379 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
1380 vpkt->vpkt_hba_pkt = NULL; | |
1381 if (vpkt->vpkt_path) { | |
1382 mdi_rele_path(vpkt->vpkt_path); | |
1383 vpkt->vpkt_path = NULL; | |
1384 } | |
1385 } | |
1386 /* | |
1387 * This path will not automatically retry pkts | |
1388 * internally, therefore, vpkt_org_vpkt should | |
1389 * never be set. | |
1390 */ | |
1391 ASSERT(vpkt->vpkt_org_vpkt == NULL); | |
1392 if (tpkt->pkt_comp) { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1393 tpkt->pkt_comp(tpkt); |
4851 | 1394 } |
1395 } | |
1396 return (rval); | |
1397 } else if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
1398 (((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) || | |
1399 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { | |
1400 /* the command exited with bad status */ | |
1401 sema_v(&vlun->svl_pgr_sema); | |
1402 } else if (vpkt->vpkt_tgt_pkt->pkt_cdbp[0] == SCMD_PRIN) { | |
1403 /* the command exited with bad status */ | |
1404 sema_v(&vlun->svl_pgr_sema); | |
1405 } else if (pkt_reserve_cmd) { | |
1406 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1407 "!vhci_scsi_start: reserve failed vlun 0x%p", | |
1408 (void *)vlun)); | |
1409 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1410 if (restore_lbp) | |
1411 (void) mdi_set_lb_policy(cdip, lbp); | |
1412 } | |
1413 | |
1414 ASSERT(vpkt->vpkt_hba_pkt != NULL); | |
1415 VHCI_DECR_PATH_CMDCOUNT(svp); | |
1416 | |
1417 /* Do not destroy phci packet information for PKT_DMA_PARTIAL */ | |
1418 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1419 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
1420 vpkt->vpkt_hba_pkt = NULL; | |
1421 if (vpkt->vpkt_path) { | |
1422 MDI_PI_ERRSTAT(vpkt->vpkt_path, MDI_PI_TRANSERR); | |
1423 mdi_rele_path(vpkt->vpkt_path); | |
1424 vpkt->vpkt_path = NULL; | |
1425 } | |
1426 } | |
1427 return (TRAN_BUSY); | |
1428 } | |
1429 | |
1430 /* | |
1431 * Function name : vhci_scsi_reset() | |
1432 * | |
1433 * Return Values : 0 - reset failed | |
1434 * 1 - reset succeeded | |
1435 */ | |
1436 | |
1437 /* ARGSUSED */ | |
1438 static int | |
1439 vhci_scsi_reset(struct scsi_address *ap, int level) | |
1440 { | |
1441 int rval = 0; | |
1442 | |
1443 cmn_err(CE_WARN, "!vhci_scsi_reset 0x%x", level); | |
1444 if ((level == RESET_TARGET) || (level == RESET_LUN)) { | |
1445 return (vhci_scsi_reset_target(ap, level, TRUE)); | |
1446 } else if (level == RESET_ALL) { | |
1447 return (vhci_scsi_reset_bus(ap)); | |
1448 } | |
1449 | |
1450 return (rval); | |
1451 } | |
1452 | |
1453 /* | |
1454 * vhci_recovery_reset: | |
1455 * Issues reset to the device | |
1456 * Input: | |
1457 * vlun - vhci lun pointer of the device | |
1458 * ap - address of the device | |
1459 * select_path: | |
1460 * If select_path is FALSE, then the address specified in ap is | |
1461 * the path on which reset will be issued. | |
1462 * If select_path is TRUE, then path is obtained by calling | |
1463 * mdi_select_path. | |
1464 * | |
1465 * recovery_depth: | |
1466 * Caller can specify the level of reset. | |
1467 * VHCI_DEPTH_LUN - | |
1468 * Issues LUN RESET if device supports lun reset. | |
1469 * VHCI_DEPTH_TARGET - | |
1470 * If Lun Reset fails or the device does not support | |
1471 * Lun Reset, issues TARGET RESET | |
1472 * VHCI_DEPTH_ALL - | |
1473 * If Lun Reset fails or the device does not support | |
1474 * Lun Reset, issues TARGET RESET. | |
1475 * If TARGET RESET does not succeed, issues Bus Reset. | |
1476 */ | |
1477 | |
1478 static int | |
1479 vhci_recovery_reset(scsi_vhci_lun_t *vlun, struct scsi_address *ap, | |
1480 uint8_t select_path, uint8_t recovery_depth) | |
1481 { | |
1482 int ret = 0; | |
1483 | |
1484 ASSERT(ap != NULL); | |
1485 | |
1486 if (vlun && vlun->svl_support_lun_reset == 1) { | |
1487 ret = vhci_scsi_reset_target(ap, RESET_LUN, | |
1488 select_path); | |
1489 } | |
1490 | |
1491 recovery_depth--; | |
1492 | |
1493 if ((ret == 0) && recovery_depth) { | |
1494 ret = vhci_scsi_reset_target(ap, RESET_TARGET, | |
1495 select_path); | |
1496 recovery_depth--; | |
1497 } | |
1498 | |
1499 if ((ret == 0) && recovery_depth) { | |
1500 (void) scsi_reset(ap, RESET_ALL); | |
1501 } | |
1502 | |
1503 return (ret); | |
1504 } | |
1505 | |
1506 /* | |
1507 * Note: The scsi_address passed to this routine could be the scsi_address | |
1508 * for the virtual device or the physical device. No assumptions should be | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
1509 * made in this routine about the contents of the ap structure. |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
1510 * Further, note that the child dip would be the dip of the ssd node regardless |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
1511 * of the scsi_address passed in. |
4851 | 1512 */ |
1513 static int | |
1514 vhci_scsi_reset_target(struct scsi_address *ap, int level, uint8_t select_path) | |
1515 { | |
8851
cf2ef2a74136
6801824 Panic in vhci_scsi_reset_target
Chris Liu <Chris.Liu@Sun.COM>
parents:
8335
diff
changeset
|
1516 dev_info_t *vdip, *pdip, *cdip; |
4851 | 1517 mdi_pathinfo_t *pip = NULL; |
1518 mdi_pathinfo_t *npip = NULL; | |
1519 int rval = -1; | |
1520 scsi_vhci_priv_t *svp = NULL; | |
1521 struct scsi_address *pap = NULL; | |
1522 scsi_hba_tran_t *hba = NULL; | |
1523 int sps; | |
1524 struct scsi_vhci *vhci = NULL; | |
1525 | |
1526 if (select_path != TRUE) { | |
1527 ASSERT(ap != NULL); | |
1528 if (level == RESET_LUN) { | |
1529 hba = ap->a_hba_tran; | |
1530 ASSERT(hba != NULL); | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1531 return (hba->tran_reset(ap, RESET_LUN)); |
4851 | 1532 } |
1533 return (scsi_reset(ap, level)); | |
1534 } | |
1535 | |
8851
cf2ef2a74136
6801824 Panic in vhci_scsi_reset_target
Chris Liu <Chris.Liu@Sun.COM>
parents:
8335
diff
changeset
|
1536 cdip = ADDR2DIP(ap); |
4851 | 1537 ASSERT(cdip != NULL); |
1538 vdip = ddi_get_parent(cdip); | |
1539 ASSERT(vdip != NULL); | |
1540 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
1541 ASSERT(vhci != NULL); | |
1542 | |
1543 rval = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH, NULL, &pip); | |
1544 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
1545 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_scsi_reset_target: " | |
1546 "Unable to get a path, dip 0x%p", (void *)cdip)); | |
1547 return (0); | |
1548 } | |
1549 again: | |
1550 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
1551 if (svp == NULL) { | |
1552 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_scsi_reset_target: " | |
1553 "priv is NULL, pip 0x%p", (void *)pip)); | |
1554 mdi_rele_path(pip); | |
1555 return (0); | |
1556 } | |
1557 | |
1558 if (svp->svp_psd == NULL) { | |
1559 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_scsi_reset_target: " | |
1560 "psd is NULL, pip 0x%p, svp 0x%p", | |
1561 (void *)pip, (void *)svp)); | |
1562 mdi_rele_path(pip); | |
1563 return (0); | |
1564 } | |
1565 | |
1566 pap = &svp->svp_psd->sd_address; | |
1567 hba = pap->a_hba_tran; | |
1568 | |
1569 ASSERT(pap != NULL); | |
1570 ASSERT(hba != NULL); | |
1571 | |
1572 if (hba->tran_reset != NULL) { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1573 if (hba->tran_reset(pap, level) == 0) { |
4851 | 1574 pdip = mdi_pi_get_phci(pip); |
1575 vhci_log(CE_WARN, vdip, "!(%s%d):" | |
1576 " path (%s%d), reset %d failed", | |
1577 ddi_driver_name(cdip), ddi_get_instance(cdip), | |
1578 ddi_driver_name(pdip), ddi_get_instance(pdip), | |
1579 level); | |
1580 | |
1581 /* | |
1582 * Select next path and issue the reset, repeat | |
1583 * until all paths are exhausted | |
1584 */ | |
1585 sps = mdi_select_path(cdip, NULL, | |
1586 MDI_SELECT_ONLINE_PATH, pip, &npip); | |
1587 if ((sps != MDI_SUCCESS) || (npip == NULL)) { | |
1588 mdi_rele_path(pip); | |
1589 return (0); | |
1590 } | |
1591 mdi_rele_path(pip); | |
1592 pip = npip; | |
1593 goto again; | |
1594 } | |
1595 mdi_rele_path(pip); | |
1596 mutex_enter(&vhci->vhci_mutex); | |
1597 scsi_hba_reset_notify_callback(&vhci->vhci_mutex, | |
1598 &vhci->vhci_reset_notify_listf); | |
1599 mutex_exit(&vhci->vhci_mutex); | |
1600 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_scsi_reset_target: " | |
1601 "reset %d sent down pip:%p for cdip:%p\n", level, | |
1602 (void *)pip, (void *)cdip)); | |
1603 return (1); | |
1604 } | |
1605 mdi_rele_path(pip); | |
1606 return (0); | |
1607 } | |
1608 | |
1609 | |
1610 /* ARGSUSED */ | |
1611 static int | |
1612 vhci_scsi_reset_bus(struct scsi_address *ap) | |
1613 { | |
1614 return (1); | |
1615 } | |
1616 | |
1617 | |
1618 /* | |
1619 * called by vhci_getcap and vhci_setcap to get and set (respectively) | |
1620 * SCSI capabilities | |
1621 */ | |
1622 /* ARGSUSED */ | |
1623 static int | |
1624 vhci_commoncap(struct scsi_address *ap, char *cap, | |
1625 int val, int tgtonly, int doset) | |
1626 { | |
1627 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
1628 struct scsi_vhci_lun *vlun = ADDR2VLUN(ap); | |
1629 int cidx; | |
1630 int rval = 0; | |
1631 | |
1632 if (cap == (char *)0) { | |
1633 VHCI_DEBUG(3, (CE_WARN, vhci->vhci_dip, | |
1634 "!vhci_commoncap: invalid arg")); | |
1635 return (rval); | |
1636 } | |
1637 | |
4882
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1638 if (vlun == NULL) { |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1639 VHCI_DEBUG(3, (CE_WARN, vhci->vhci_dip, |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1640 "!vhci_commoncap: vlun is null")); |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1641 return (rval); |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1642 } |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1643 |
4851 | 1644 if ((cidx = scsi_hba_lookup_capstr(cap)) == -1) { |
1645 return (UNDEFINED); | |
1646 } | |
1647 | |
1648 /* | |
1649 * Process setcap request. | |
1650 */ | |
1651 if (doset) { | |
1652 /* | |
1653 * At present, we can only set binary (0/1) values | |
1654 */ | |
1655 switch (cidx) { | |
1656 case SCSI_CAP_ARQ: | |
1657 if (val == 0) { | |
1658 rval = 0; | |
1659 } else { | |
1660 rval = 1; | |
1661 } | |
1662 break; | |
1663 | |
1664 case SCSI_CAP_LUN_RESET: | |
1665 if (tgtonly == 0) { | |
1666 VHCI_DEBUG(1, (CE_WARN, vhci->vhci_dip, | |
1667 "scsi_vhci_setcap: " | |
1668 "Returning error since whom = 0")); | |
1669 rval = -1; | |
1670 break; | |
1671 } | |
1672 /* | |
1673 * Set the capability accordingly. | |
1674 */ | |
1675 mutex_enter(&vlun->svl_mutex); | |
1676 vlun->svl_support_lun_reset = val; | |
1677 rval = val; | |
1678 mutex_exit(&vlun->svl_mutex); | |
1679 break; | |
1680 | |
1681 case SCSI_CAP_SECTOR_SIZE: | |
1682 mutex_enter(&vlun->svl_mutex); | |
1683 vlun->svl_sector_size = val; | |
1684 vlun->svl_setcap_done = 1; | |
1685 mutex_exit(&vlun->svl_mutex); | |
1686 (void) vhci_pHCI_cap(ap, cap, val, tgtonly, NULL); | |
1687 | |
1688 /* Always return success */ | |
1689 rval = 1; | |
1690 break; | |
1691 | |
1692 default: | |
1693 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1694 "!vhci_setcap: unsupported %d", cidx)); | |
1695 rval = UNDEFINED; | |
1696 break; | |
1697 } | |
1698 | |
1699 VHCI_DEBUG(6, (CE_NOTE, vhci->vhci_dip, | |
1700 "!set cap: cap=%s, val/tgtonly/doset/rval = " | |
1701 "0x%x/0x%x/0x%x/%d\n", | |
1702 cap, val, tgtonly, doset, rval)); | |
1703 | |
1704 } else { | |
1705 /* | |
1706 * Process getcap request. | |
1707 */ | |
1708 switch (cidx) { | |
1709 case SCSI_CAP_DMA_MAX: | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1710 /* |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1711 * For X86 this capability is caught in scsi_ifgetcap(). |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1712 * XXX Should this be getting the value from the pHCI? |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1713 */ |
4851 | 1714 rval = (int)VHCI_DMA_MAX_XFER_CAP; |
1715 break; | |
1716 | |
1717 case SCSI_CAP_INITIATOR_ID: | |
1718 rval = 0x00; | |
1719 break; | |
1720 | |
1721 case SCSI_CAP_ARQ: | |
1722 case SCSI_CAP_RESET_NOTIFICATION: | |
1723 case SCSI_CAP_TAGGED_QING: | |
1724 rval = 1; | |
1725 break; | |
1726 | |
1727 case SCSI_CAP_SCSI_VERSION: | |
1728 rval = 3; | |
1729 break; | |
1730 | |
1731 case SCSI_CAP_INTERCONNECT_TYPE: | |
1732 rval = INTERCONNECT_FABRIC; | |
1733 break; | |
1734 | |
1735 case SCSI_CAP_LUN_RESET: | |
1736 /* | |
1737 * scsi_vhci will always return success for LUN reset. | |
1738 * When request for doing LUN reset comes | |
1739 * through scsi_reset entry point, at that time attempt | |
1740 * will be made to do reset through all the possible | |
1741 * paths. | |
1742 */ | |
1743 mutex_enter(&vlun->svl_mutex); | |
1744 rval = vlun->svl_support_lun_reset; | |
1745 mutex_exit(&vlun->svl_mutex); | |
1746 VHCI_DEBUG(4, (CE_WARN, vhci->vhci_dip, | |
1747 "scsi_vhci_getcap:" | |
1748 "Getting the Lun reset capability %d", rval)); | |
1749 break; | |
1750 | |
1751 case SCSI_CAP_SECTOR_SIZE: | |
1752 mutex_enter(&vlun->svl_mutex); | |
1753 rval = vlun->svl_sector_size; | |
1754 mutex_exit(&vlun->svl_mutex); | |
1755 break; | |
1756 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1757 case SCSI_CAP_CDB_LEN: |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1758 rval = VHCI_SCSI_CDB_SIZE; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1759 break; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1760 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1761 case SCSI_CAP_DMA_MAX_ARCH: |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1762 /* |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1763 * For X86 this capability is caught in scsi_ifgetcap(). |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1764 * XXX Should this be getting the value from the pHCI? |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1765 */ |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1766 rval = 0; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1767 break; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1768 |
4851 | 1769 default: |
1770 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1771 "!vhci_getcap: unsupported %d", cidx)); | |
1772 rval = UNDEFINED; | |
1773 break; | |
1774 } | |
1775 | |
1776 VHCI_DEBUG(6, (CE_NOTE, vhci->vhci_dip, | |
1777 "!get cap: cap=%s, val/tgtonly/doset/rval = " | |
1778 "0x%x/0x%x/0x%x/%d\n", | |
1779 cap, val, tgtonly, doset, rval)); | |
1780 } | |
1781 return (rval); | |
1782 } | |
1783 | |
1784 | |
1785 /* | |
1786 * Function name : vhci_scsi_getcap() | |
1787 * | |
1788 */ | |
1789 static int | |
1790 vhci_scsi_getcap(struct scsi_address *ap, char *cap, int whom) | |
1791 { | |
1792 return (vhci_commoncap(ap, cap, 0, whom, 0)); | |
1793 } | |
1794 | |
1795 static int | |
1796 vhci_scsi_setcap(struct scsi_address *ap, char *cap, int value, int whom) | |
1797 { | |
1798 return (vhci_commoncap(ap, cap, value, whom, 1)); | |
1799 } | |
1800 | |
1801 /* | |
1802 * Function name : vhci_scsi_abort() | |
1803 */ | |
1804 /* ARGSUSED */ | |
1805 static int | |
1806 vhci_scsi_abort(struct scsi_address *ap, struct scsi_pkt *pkt) | |
1807 { | |
1808 return (0); | |
1809 } | |
1810 | |
1811 /* | |
1812 * Function name : vhci_scsi_init_pkt | |
1813 * | |
1814 * Return Values : pointer to scsi_pkt, or NULL | |
1815 */ | |
1816 /* ARGSUSED */ | |
1817 static struct scsi_pkt * | |
1818 vhci_scsi_init_pkt(struct scsi_address *ap, struct scsi_pkt *pkt, | |
1819 struct buf *bp, int cmdlen, int statuslen, int tgtlen, | |
1820 int flags, int (*callback)(caddr_t), caddr_t arg) | |
1821 { | |
1822 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
1823 struct vhci_pkt *vpkt; | |
1824 int rval; | |
1825 int newpkt = 0; | |
1826 struct scsi_pkt *pktp; | |
1827 | |
1828 | |
1829 if (pkt == NULL) { | |
1830 if (cmdlen > VHCI_SCSI_CDB_SIZE) { | |
7654
82798d9a3db9
6747477 scsi_vhci should not check for cdb length while initializing scsi_pkt
Ramana.Srikanth <Ramana.Srikanth@Sun.COM>
parents:
7461
diff
changeset
|
1831 if ((cmdlen != VHCI_SCSI_OSD_CDB_SIZE) || |
82798d9a3db9
6747477 scsi_vhci should not check for cdb length while initializing scsi_pkt
Ramana.Srikanth <Ramana.Srikanth@Sun.COM>
parents:
7461
diff
changeset
|
1832 ((flags & VHCI_SCSI_OSD_PKT_FLAGS) != |
82798d9a3db9
6747477 scsi_vhci should not check for cdb length while initializing scsi_pkt
Ramana.Srikanth <Ramana.Srikanth@Sun.COM>
parents:
7461
diff
changeset
|
1833 VHCI_SCSI_OSD_PKT_FLAGS)) { |
82798d9a3db9
6747477 scsi_vhci should not check for cdb length while initializing scsi_pkt
Ramana.Srikanth <Ramana.Srikanth@Sun.COM>
parents:
7461
diff
changeset
|
1834 VHCI_DEBUG(1, (CE_NOTE, NULL, |
82798d9a3db9
6747477 scsi_vhci should not check for cdb length while initializing scsi_pkt
Ramana.Srikanth <Ramana.Srikanth@Sun.COM>
parents:
7461
diff
changeset
|
1835 "!init pkt: cdb size not supported\n")); |
82798d9a3db9
6747477 scsi_vhci should not check for cdb length while initializing scsi_pkt
Ramana.Srikanth <Ramana.Srikanth@Sun.COM>
parents:
7461
diff
changeset
|
1836 return (NULL); |
82798d9a3db9
6747477 scsi_vhci should not check for cdb length while initializing scsi_pkt
Ramana.Srikanth <Ramana.Srikanth@Sun.COM>
parents:
7461
diff
changeset
|
1837 } |
4851 | 1838 } |
1839 | |
1840 pktp = scsi_hba_pkt_alloc(vhci->vhci_dip, | |
1841 ap, cmdlen, statuslen, tgtlen, sizeof (*vpkt), callback, | |
1842 arg); | |
1843 | |
1844 if (pktp == NULL) { | |
1845 return (NULL); | |
1846 } | |
1847 | |
1848 /* Get the vhci's private structure */ | |
1849 vpkt = (struct vhci_pkt *)(pktp->pkt_ha_private); | |
1850 ASSERT(vpkt); | |
1851 | |
1852 /* Save the target driver's packet */ | |
1853 vpkt->vpkt_tgt_pkt = pktp; | |
1854 | |
1855 /* | |
1856 * Save pkt_tgt_init_pkt fields if deferred binding | |
1857 * is needed or for other purposes. | |
1858 */ | |
1859 vpkt->vpkt_tgt_init_pkt_flags = flags; | |
1860 vpkt->vpkt_flags = (callback == NULL_FUNC) ? CFLAG_NOWAIT : 0; | |
1861 vpkt->vpkt_state = VHCI_PKT_IDLE; | |
1862 vpkt->vpkt_tgt_init_cdblen = cmdlen; | |
1863 vpkt->vpkt_tgt_init_scblen = statuslen; | |
1864 newpkt = 1; | |
1865 } else { /* pkt not NULL */ | |
1866 vpkt = pkt->pkt_ha_private; | |
1867 } | |
1868 | |
1869 VHCI_DEBUG(8, (CE_NOTE, NULL, "vhci_scsi_init_pkt " | |
1870 "vpkt %p flags %x\n", (void *)vpkt, flags)); | |
1871 | |
1872 /* Clear any stale error flags */ | |
1873 if (bp) { | |
1874 bioerror(bp, 0); | |
1875 } | |
1876 | |
1877 vpkt->vpkt_tgt_init_bp = bp; | |
1878 | |
1879 if (flags & PKT_DMA_PARTIAL) { | |
1880 | |
1881 /* | |
1882 * Immediate binding is needed. | |
1883 * Target driver may not set this flag in next invocation. | |
1884 * vhci has to remember this flag was set during first | |
1885 * invocation of vhci_scsi_init_pkt. | |
1886 */ | |
1887 vpkt->vpkt_flags |= CFLAG_DMA_PARTIAL; | |
1888 } | |
1889 | |
1890 if (vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) { | |
1891 | |
1892 /* | |
1893 * Re-initialize some of the target driver packet state | |
1894 * information. | |
1895 */ | |
1896 vpkt->vpkt_tgt_pkt->pkt_state = 0; | |
1897 vpkt->vpkt_tgt_pkt->pkt_statistics = 0; | |
1898 vpkt->vpkt_tgt_pkt->pkt_reason = 0; | |
1899 | |
1900 /* | |
1901 * Binding a vpkt->vpkt_path for this IO at init_time. | |
1902 * If an IO error happens later, target driver will clear | |
1903 * this vpkt->vpkt_path binding before re-init IO again. | |
1904 */ | |
1905 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
1906 "vhci_scsi_init_pkt: calling v_b_t %p, newpkt %d\n", | |
1907 (void *)vpkt, newpkt)); | |
1908 if (pkt && vpkt->vpkt_hba_pkt) { | |
1909 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
1910 "v_s_i_p calling update_pHCI_pkt resid %ld\n", | |
1911 pkt->pkt_resid)); | |
1912 vhci_update_pHCI_pkt(vpkt, pkt); | |
1913 } | |
1914 if (callback == SLEEP_FUNC) { | |
1915 rval = vhci_bind_transport( | |
1916 ap, vpkt, flags, callback); | |
1917 } else { | |
1918 rval = vhci_bind_transport( | |
1919 ap, vpkt, flags, NULL_FUNC); | |
1920 } | |
1921 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
1922 "vhci_scsi_init_pkt: v_b_t called 0x%p rval 0x%x\n", | |
1923 (void *)vpkt, rval)); | |
1924 if (bp) { | |
1925 if (rval == TRAN_FATAL_ERROR) { | |
1926 /* | |
1927 * No paths available. Could not bind | |
1928 * any pHCI. Setting EFAULT as a way | |
1929 * to indicate no DMA is mapped. | |
1930 */ | |
1931 bioerror(bp, EFAULT); | |
1932 } else { | |
1933 /* | |
1934 * Do not indicate any pHCI errors to | |
1935 * target driver otherwise. | |
1936 */ | |
1937 bioerror(bp, 0); | |
1938 } | |
1939 } | |
1940 if (rval != TRAN_ACCEPT) { | |
1941 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
1942 "vhci_scsi_init_pkt: " | |
1943 "v_b_t failed 0x%p newpkt %x\n", | |
1944 (void *)vpkt, newpkt)); | |
1945 if (newpkt) { | |
1946 scsi_hba_pkt_free(ap, | |
1947 vpkt->vpkt_tgt_pkt); | |
1948 } | |
1949 return (NULL); | |
1950 } | |
1951 ASSERT(vpkt->vpkt_hba_pkt != NULL); | |
1952 ASSERT(vpkt->vpkt_path != NULL); | |
1953 | |
1954 /* Update the resid for the target driver */ | |
1955 vpkt->vpkt_tgt_pkt->pkt_resid = | |
1956 vpkt->vpkt_hba_pkt->pkt_resid; | |
1957 } | |
1958 | |
1959 return (vpkt->vpkt_tgt_pkt); | |
1960 } | |
1961 | |
1962 /* | |
1963 * Function name : vhci_scsi_destroy_pkt | |
1964 * | |
1965 * Return Values : none | |
1966 */ | |
1967 static void | |
1968 vhci_scsi_destroy_pkt(struct scsi_address *ap, struct scsi_pkt *pkt) | |
1969 { | |
1970 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_ha_private; | |
1971 | |
1972 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
1973 "vhci_scsi_destroy_pkt: vpkt 0x%p\n", (void *)vpkt)); | |
1974 | |
1975 vpkt->vpkt_tgt_init_pkt_flags = 0; | |
1976 if (vpkt->vpkt_hba_pkt) { | |
1977 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
1978 vpkt->vpkt_hba_pkt = NULL; | |
1979 } | |
1980 if (vpkt->vpkt_path) { | |
1981 mdi_rele_path(vpkt->vpkt_path); | |
1982 vpkt->vpkt_path = NULL; | |
1983 } | |
1984 | |
1985 ASSERT(vpkt->vpkt_state != VHCI_PKT_ISSUED); | |
1986 scsi_hba_pkt_free(ap, vpkt->vpkt_tgt_pkt); | |
1987 } | |
1988 | |
1989 /* | |
1990 * Function name : vhci_scsi_dmafree() | |
1991 * | |
1992 * Return Values : none | |
1993 */ | |
1994 /*ARGSUSED*/ | |
1995 static void | |
1996 vhci_scsi_dmafree(struct scsi_address *ap, struct scsi_pkt *pkt) | |
1997 { | |
1998 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_ha_private; | |
1999 | |
2000 VHCI_DEBUG(6, (CE_NOTE, NULL, | |
2001 "vhci_scsi_dmafree: vpkt 0x%p\n", (void *)vpkt)); | |
2002 | |
2003 ASSERT(vpkt != NULL); | |
2004 if (vpkt->vpkt_hba_pkt) { | |
2005 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
2006 vpkt->vpkt_hba_pkt = NULL; | |
2007 } | |
2008 if (vpkt->vpkt_path) { | |
2009 mdi_rele_path(vpkt->vpkt_path); | |
2010 vpkt->vpkt_path = NULL; | |
2011 } | |
2012 } | |
2013 | |
2014 /* | |
2015 * Function name : vhci_scsi_sync_pkt() | |
2016 * | |
2017 * Return Values : none | |
2018 */ | |
2019 /*ARGSUSED*/ | |
2020 static void | |
2021 vhci_scsi_sync_pkt(struct scsi_address *ap, struct scsi_pkt *pkt) | |
2022 { | |
2023 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_ha_private; | |
2024 | |
2025 ASSERT(vpkt != NULL); | |
2026 if (vpkt->vpkt_hba_pkt) { | |
2027 scsi_sync_pkt(vpkt->vpkt_hba_pkt); | |
2028 } | |
2029 } | |
2030 | |
2031 /* | |
2032 * routine for reset notification setup, to register or cancel. | |
2033 */ | |
2034 static int | |
2035 vhci_scsi_reset_notify(struct scsi_address *ap, int flag, | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2036 void (*callback)(caddr_t), caddr_t arg) |
4851 | 2037 { |
2038 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
2039 return (scsi_hba_reset_notify_setup(ap, flag, callback, arg, | |
2040 &vhci->vhci_mutex, &vhci->vhci_reset_notify_listf)); | |
2041 } | |
2042 | |
2043 static int | |
2044 vhci_scsi_get_name_bus_addr(struct scsi_device *sd, | |
2045 char *name, int len, int bus_addr) | |
2046 { | |
2047 dev_info_t *cdip; | |
2048 char *guid; | |
2049 scsi_vhci_lun_t *vlun; | |
2050 | |
2051 ASSERT(sd != NULL); | |
2052 ASSERT(name != NULL); | |
2053 | |
2054 cdip = sd->sd_dev; | |
2055 | |
2056 ASSERT(cdip != NULL); | |
2057 | |
2058 if (mdi_component_is_client(cdip, NULL) != MDI_SUCCESS) { | |
2059 name[0] = '\0'; | |
2060 return (1); | |
2061 } | |
2062 | |
2063 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, cdip, PROPFLAGS, | |
2064 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) { | |
2065 name[0] = '\0'; | |
2066 return (1); | |
2067 } | |
2068 | |
2069 vlun = ADDR2VLUN(&sd->sd_address); | |
2070 if (bus_addr && vlun && vlun->svl_fops_name) { | |
2071 /* report the guid and the name of the failover module */ | |
2072 (void) snprintf(name, len, "g%s %s", guid, vlun->svl_fops_name); | |
2073 } else { | |
2074 /* report the guid */ | |
2075 (void) snprintf(name, len, "g%s", guid); | |
2076 } | |
2077 | |
2078 ddi_prop_free(guid); | |
2079 return (1); | |
2080 } | |
2081 | |
2082 static int | |
2083 vhci_scsi_get_bus_addr(struct scsi_device *sd, char *name, int len) | |
2084 { | |
2085 return (vhci_scsi_get_name_bus_addr(sd, name, len, 1)); | |
2086 } | |
2087 | |
2088 static int | |
2089 vhci_scsi_get_name(struct scsi_device *sd, char *name, int len) | |
2090 { | |
2091 return (vhci_scsi_get_name_bus_addr(sd, name, len, 0)); | |
2092 } | |
2093 | |
2094 /* | |
2095 * Return a pointer to the guid part of the devnm. | |
2096 * devnm format is "nodename@busaddr", busaddr format is "gGUID". | |
2097 */ | |
2098 static char * | |
2099 vhci_devnm_to_guid(char *devnm) | |
2100 { | |
2101 char *cp = devnm; | |
2102 | |
2103 if (devnm == NULL) | |
2104 return (NULL); | |
2105 | |
2106 while (*cp != '\0' && *cp != '@') | |
2107 cp++; | |
2108 if (*cp == '@' && *(cp + 1) == 'g') | |
2109 return (cp + 2); | |
2110 return (NULL); | |
2111 } | |
2112 | |
2113 static int | |
2114 vhci_bind_transport(struct scsi_address *ap, struct vhci_pkt *vpkt, int flags, | |
2115 int (*func)(caddr_t)) | |
2116 { | |
2117 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
2118 dev_info_t *cdip = ADDR2DIP(ap); | |
2119 mdi_pathinfo_t *pip = NULL; | |
2120 mdi_pathinfo_t *npip = NULL; | |
2121 scsi_vhci_priv_t *svp = NULL; | |
2122 struct scsi_device *psd = NULL; | |
2123 struct scsi_address *address = NULL; | |
2124 struct scsi_pkt *pkt = NULL; | |
2125 int rval = -1; | |
2126 int pgr_sema_held = 0; | |
2127 int held; | |
2128 int mps_flag = MDI_SELECT_ONLINE_PATH; | |
2129 struct scsi_vhci_lun *vlun; | |
2130 time_t tnow; | |
7121
4b91990abccd
6723122 assertion failed: (path_instance == 0) || (path_instance == mdi_pi_get_path_instance(vpkt->vpkt_path
rralphs
parents:
7047
diff
changeset
|
2131 int path_instance = 0; |
4851 | 2132 |
2133 vlun = ADDR2VLUN(ap); | |
2134 ASSERT(vlun != 0); | |
2135 | |
2136 if ((vpkt->vpkt_tgt_pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
2137 (((vpkt->vpkt_tgt_pkt->pkt_cdbp[1] & 0x1f) == | |
2138 VHCI_PROUT_REGISTER) || | |
2139 ((vpkt->vpkt_tgt_pkt->pkt_cdbp[1] & 0x1f) == | |
2140 VHCI_PROUT_R_AND_IGNORE))) { | |
2141 if (!sema_tryp(&vlun->svl_pgr_sema)) | |
2142 return (TRAN_BUSY); | |
2143 pgr_sema_held = 1; | |
2144 if (vlun->svl_first_path != NULL) { | |
2145 rval = mdi_select_path(cdip, NULL, | |
2146 MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH, | |
2147 NULL, &pip); | |
2148 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
2149 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2150 "vhci_bind_transport: path select fail\n")); | |
2151 } else { | |
2152 npip = pip; | |
2153 do { | |
2154 if (npip == vlun->svl_first_path) { | |
2155 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2156 "vhci_bind_transport: " | |
2157 "valid first path 0x%p\n", | |
2158 (void *) | |
2159 vlun->svl_first_path)); | |
2160 pip = vlun->svl_first_path; | |
2161 goto bind_path; | |
2162 } | |
2163 pip = npip; | |
2164 rval = mdi_select_path(cdip, NULL, | |
2165 MDI_SELECT_ONLINE_PATH | | |
2166 MDI_SELECT_STANDBY_PATH, | |
2167 pip, &npip); | |
2168 mdi_rele_path(pip); | |
2169 } while ((rval == MDI_SUCCESS) && | |
2170 (npip != NULL)); | |
2171 } | |
2172 } | |
2173 | |
2174 if (vlun->svl_first_path) { | |
2175 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2176 "vhci_bind_transport: invalid first path 0x%p\n", | |
2177 (void *)vlun->svl_first_path)); | |
2178 vlun->svl_first_path = NULL; | |
2179 } | |
2180 } else if (vpkt->vpkt_tgt_pkt->pkt_cdbp[0] == SCMD_PRIN) { | |
2181 if ((vpkt->vpkt_state & VHCI_PKT_THRU_TASKQ) == 0) { | |
2182 if (!sema_tryp(&vlun->svl_pgr_sema)) | |
2183 return (TRAN_BUSY); | |
2184 } | |
2185 pgr_sema_held = 1; | |
2186 } | |
2187 | |
2188 /* | |
2189 * If the path is already bound for PKT_PARTIAL_DMA case, | |
2190 * try to use the same path. | |
2191 */ | |
2192 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) && vpkt->vpkt_path) { | |
2193 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2194 "vhci_bind_transport: PKT_PARTIAL_DMA " | |
2195 "vpkt 0x%p, path 0x%p\n", | |
2196 (void *)vpkt, (void *)vpkt->vpkt_path)); | |
2197 pip = vpkt->vpkt_path; | |
2198 goto bind_path; | |
2199 } | |
2200 | |
2201 /* | |
7047
8e4f1d0e9dd8
6722672 sd does not clear pkt_path_instance when retrying commands
gap
parents:
6962
diff
changeset
|
2202 * Get path_instance. Non-zero with FLAG_PKT_PATH_INSTANCE set |
8e4f1d0e9dd8
6722672 sd does not clear pkt_path_instance when retrying commands
gap
parents:
6962
diff
changeset
|
2203 * indicates that mdi_select_path should be called to select a |
8e4f1d0e9dd8
6722672 sd does not clear pkt_path_instance when retrying commands
gap
parents:
6962
diff
changeset
|
2204 * specific instance. |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2205 * |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2206 * NB: Condition pkt_path_instance reference on proper allocation. |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2207 */ |
7121
4b91990abccd
6723122 assertion failed: (path_instance == 0) || (path_instance == mdi_pi_get_path_instance(vpkt->vpkt_path
rralphs
parents:
7047
diff
changeset
|
2208 if ((vpkt->vpkt_tgt_pkt->pkt_flags & FLAG_PKT_PATH_INSTANCE) && |
4b91990abccd
6723122 assertion failed: (path_instance == 0) || (path_instance == mdi_pi_get_path_instance(vpkt->vpkt_path
rralphs
parents:
7047
diff
changeset
|
2209 scsi_pkt_allocated_correctly(vpkt->vpkt_tgt_pkt)) { |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2210 path_instance = vpkt->vpkt_tgt_pkt->pkt_path_instance; |
7121
4b91990abccd
6723122 assertion failed: (path_instance == 0) || (path_instance == mdi_pi_get_path_instance(vpkt->vpkt_path
rralphs
parents:
7047
diff
changeset
|
2211 } |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2212 |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2213 /* |
4851 | 2214 * If reservation is active bind the transport directly to the pip |
2215 * with the reservation. | |
2216 */ | |
2217 if (vpkt->vpkt_hba_pkt == NULL) { | |
2218 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
2219 if (MDI_PI_IS_ONLINE(vlun->svl_resrv_pip)) { | |
2220 pip = vlun->svl_resrv_pip; | |
2221 mdi_hold_path(pip); | |
2222 vlun->svl_waiting_for_activepath = 0; | |
2223 rval = MDI_SUCCESS; | |
2224 goto bind_path; | |
2225 } else { | |
2226 if (pgr_sema_held) { | |
2227 sema_v(&vlun->svl_pgr_sema); | |
2228 } | |
2229 return (TRAN_BUSY); | |
2230 } | |
2231 } | |
2232 try_again: | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2233 rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp, |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2234 path_instance ? MDI_SELECT_PATH_INSTANCE : 0, |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2235 (void *)(intptr_t)path_instance, &pip); |
4851 | 2236 if (rval == MDI_BUSY) { |
2237 if (pgr_sema_held) { | |
2238 sema_v(&vlun->svl_pgr_sema); | |
2239 } | |
2240 return (TRAN_BUSY); | |
2241 } else if (rval == MDI_DEVI_ONLINING) { | |
2242 /* | |
2243 * if we are here then we are in the midst of | |
2244 * an attach/probe of the client device. | |
2245 * We attempt to bind to ONLINE path if available, | |
2246 * else it is OK to bind to a STANDBY path (instead | |
2247 * of triggering a failover) because IO associated | |
2248 * with attach/probe (eg. INQUIRY, block 0 read) | |
2249 * are completed by targets even on passive paths | |
2250 * If no ONLINE paths available, it is important | |
2251 * to set svl_waiting_for_activepath for two | |
2252 * reasons: (1) avoid sense analysis in the | |
2253 * "external failure detection" codepath in | |
2254 * vhci_intr(). Failure to do so will result in | |
2255 * infinite loop (unless an ONLINE path becomes | |
2256 * available at some point) (2) avoid | |
2257 * unnecessary failover (see "---Waiting For Active | |
2258 * Path---" comment below). | |
2259 */ | |
2260 VHCI_DEBUG(1, (CE_NOTE, NULL, "!%p in onlining " | |
2261 "state\n", (void *)cdip)); | |
2262 pip = NULL; | |
2263 rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp, | |
2264 mps_flag, NULL, &pip); | |
2265 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
2266 if (vlun->svl_waiting_for_activepath == 0) { | |
2267 vlun->svl_waiting_for_activepath = 1; | |
2268 vlun->svl_wfa_time = ddi_get_time(); | |
2269 } | |
2270 mps_flag |= MDI_SELECT_STANDBY_PATH; | |
2271 rval = mdi_select_path(cdip, | |
2272 vpkt->vpkt_tgt_init_bp, | |
2273 mps_flag, NULL, &pip); | |
2274 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
2275 if (pgr_sema_held) { | |
2276 sema_v(&vlun->svl_pgr_sema); | |
2277 } | |
2278 return (TRAN_FATAL_ERROR); | |
2279 } | |
2280 goto bind_path; | |
2281 } | |
2282 } else if (rval == MDI_FAILURE) { | |
2283 if (pgr_sema_held) { | |
2284 sema_v(&vlun->svl_pgr_sema); | |
2285 } | |
2286 return (TRAN_FATAL_ERROR); | |
2287 } | |
2288 | |
2289 if ((pip == NULL) || (rval == MDI_NOPATH)) { | |
2290 while (vlun->svl_waiting_for_activepath) { | |
2291 /* | |
2292 * ---Waiting For Active Path--- | |
2293 * This device was discovered across a | |
2294 * passive path; lets wait for a little | |
2295 * bit, hopefully an active path will | |
2296 * show up obviating the need for a | |
2297 * failover | |
2298 */ | |
2299 tnow = ddi_get_time(); | |
2300 if (tnow - vlun->svl_wfa_time >= 60) { | |
2301 vlun->svl_waiting_for_activepath = 0; | |
2302 } else { | |
2303 drv_usecwait(1000); | |
2304 if (vlun->svl_waiting_for_activepath | |
2305 == 0) { | |
2306 /* | |
2307 * an active path has come | |
2308 * online! | |
2309 */ | |
2310 goto try_again; | |
2311 } | |
2312 } | |
2313 } | |
2314 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
2315 if (!held) { | |
2316 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2317 "!Lun not held\n")); | |
2318 if (pgr_sema_held) { | |
2319 sema_v(&vlun->svl_pgr_sema); | |
2320 } | |
2321 return (TRAN_BUSY); | |
2322 } | |
2323 /* | |
2324 * now that the LUN is stable, one last check | |
2325 * to make sure no other changes sneaked in | |
2326 * (like a path coming online or a | |
2327 * failover initiated by another thread) | |
2328 */ | |
2329 pip = NULL; | |
2330 rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp, | |
2331 0, NULL, &pip); | |
2332 if (pip != NULL) { | |
2333 VHCI_RELEASE_LUN(vlun); | |
2334 vlun->svl_waiting_for_activepath = 0; | |
2335 goto bind_path; | |
2336 } | |
2337 | |
2338 /* | |
2339 * Check if there is an ONLINE path OR a STANDBY path | |
2340 * available. If none is available, do not attempt | |
2341 * to do a failover, just return a fatal error at this | |
2342 * point. | |
2343 */ | |
2344 npip = NULL; | |
2345 rval = mdi_select_path(cdip, NULL, | |
2346 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), | |
2347 NULL, &npip); | |
2348 if ((npip == NULL) || (rval != MDI_SUCCESS)) { | |
2349 /* | |
2350 * No paths available, jus return FATAL error. | |
2351 */ | |
2352 VHCI_RELEASE_LUN(vlun); | |
2353 if (pgr_sema_held) { | |
2354 sema_v(&vlun->svl_pgr_sema); | |
2355 } | |
2356 return (TRAN_FATAL_ERROR); | |
2357 } | |
2358 mdi_rele_path(npip); | |
2359 VHCI_DEBUG(1, (CE_NOTE, NULL, "!invoking " | |
2360 "mdi_failover\n")); | |
2361 rval = mdi_failover(vhci->vhci_dip, cdip, | |
2362 MDI_FAILOVER_ASYNC); | |
2363 if (rval == MDI_FAILURE) { | |
2364 VHCI_RELEASE_LUN(vlun); | |
2365 if (pgr_sema_held) { | |
2366 sema_v(&vlun->svl_pgr_sema); | |
2367 } | |
2368 return (TRAN_FATAL_ERROR); | |
2369 } else if (rval == MDI_BUSY) { | |
2370 VHCI_RELEASE_LUN(vlun); | |
2371 if (pgr_sema_held) { | |
2372 sema_v(&vlun->svl_pgr_sema); | |
2373 } | |
2374 return (TRAN_BUSY); | |
2375 } else { | |
2376 if (pgr_sema_held) { | |
2377 sema_v(&vlun->svl_pgr_sema); | |
2378 } | |
2379 return (TRAN_BUSY); | |
2380 } | |
2381 } | |
2382 vlun->svl_waiting_for_activepath = 0; | |
2383 bind_path: | |
2384 vpkt->vpkt_path = pip; | |
2385 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
2386 ASSERT(svp != NULL); | |
2387 | |
2388 psd = svp->svp_psd; | |
2389 ASSERT(psd != NULL); | |
2390 address = &psd->sd_address; | |
2391 } else { | |
2392 pkt = vpkt->vpkt_hba_pkt; | |
2393 address = &pkt->pkt_address; | |
2394 } | |
2395 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2396 /* Verify match of specified path_instance and selected path_instance */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2397 ASSERT((path_instance == 0) || |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2398 (path_instance == mdi_pi_get_path_instance(vpkt->vpkt_path))); |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2399 |
4851 | 2400 /* |
2401 * For PKT_PARTIAL_DMA case, call pHCI's scsi_init_pkt whenever | |
2402 * target driver calls vhci_scsi_init_pkt. | |
2403 */ | |
2404 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) && | |
2405 vpkt->vpkt_path && vpkt->vpkt_hba_pkt) { | |
2406 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2407 "vhci_bind_transport: PKT_PARTIAL_DMA " | |
2408 "vpkt 0x%p, path 0x%p hba_pkt 0x%p\n", | |
2409 (void *)vpkt, (void *)vpkt->vpkt_path, (void *)pkt)); | |
2410 pkt = vpkt->vpkt_hba_pkt; | |
2411 address = &pkt->pkt_address; | |
2412 } | |
2413 | |
2414 if (pkt == NULL || (vpkt->vpkt_flags & CFLAG_DMA_PARTIAL)) { | |
2415 pkt = scsi_init_pkt(address, pkt, | |
2416 vpkt->vpkt_tgt_init_bp, vpkt->vpkt_tgt_init_cdblen, | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2417 vpkt->vpkt_tgt_init_scblen, 0, flags, func, NULL); |
4851 | 2418 |
2419 if (pkt == NULL) { | |
2420 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2421 "!bind transport: 0x%p 0x%p 0x%p\n", | |
2422 (void *)vhci, (void *)psd, (void *)vpkt)); | |
2423 if ((vpkt->vpkt_hba_pkt == NULL) && vpkt->vpkt_path) { | |
2424 MDI_PI_ERRSTAT(vpkt->vpkt_path, | |
2425 MDI_PI_TRANSERR); | |
2426 mdi_rele_path(vpkt->vpkt_path); | |
2427 vpkt->vpkt_path = NULL; | |
2428 } | |
2429 if (pgr_sema_held) { | |
2430 sema_v(&vlun->svl_pgr_sema); | |
2431 } | |
2432 /* | |
2433 * Looks like a fatal error. | |
2434 * May be device disappeared underneath. | |
2435 * Give another chance to target driver for a retry to | |
2436 * get another path. | |
2437 */ | |
2438 return (TRAN_BUSY); | |
2439 } | |
2440 } | |
2441 | |
2442 pkt->pkt_private = vpkt; | |
2443 vpkt->vpkt_hba_pkt = pkt; | |
2444 return (TRAN_ACCEPT); | |
2445 } | |
2446 | |
2447 | |
2448 /*PRINTFLIKE3*/ | |
2449 void | |
2450 vhci_log(int level, dev_info_t *dip, const char *fmt, ...) | |
2451 { | |
2452 char buf[256]; | |
2453 va_list ap; | |
2454 | |
2455 va_start(ap, fmt); | |
2456 (void) vsprintf(buf, fmt, ap); | |
2457 va_end(ap); | |
2458 | |
2459 scsi_log(dip, "scsi_vhci", level, buf); | |
2460 } | |
2461 | |
2462 /* do a PGR out with the information we've saved away */ | |
2463 static int | |
2464 vhci_do_prout(scsi_vhci_priv_t *svp) | |
2465 { | |
2466 | |
2467 struct scsi_pkt *new_pkt; | |
2468 struct buf *bp; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2469 scsi_vhci_lun_t *vlun = svp->svp_svl; |
4851 | 2470 int rval, retry, nr_retry, ua_retry; |
2471 struct scsi_extended_sense *sns; | |
2472 | |
2473 bp = getrbuf(KM_SLEEP); | |
2474 bp->b_flags = B_WRITE; | |
2475 bp->b_resid = 0; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2476 bp->b_un.b_addr = (caddr_t)&vlun->svl_prout; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2477 bp->b_bcount = vlun->svl_bcount; |
4851 | 2478 |
2479 VHCI_INCR_PATH_CMDCOUNT(svp); | |
2480 | |
2481 new_pkt = scsi_init_pkt(&svp->svp_psd->sd_address, NULL, bp, | |
2482 CDB_GROUP1, sizeof (struct scsi_arq_status), 0, 0, | |
2483 SLEEP_FUNC, NULL); | |
2484 if (new_pkt == NULL) { | |
2485 VHCI_DECR_PATH_CMDCOUNT(svp); | |
2486 freerbuf(bp); | |
2487 cmn_err(CE_WARN, "!vhci_do_prout: scsi_init_pkt failed"); | |
2488 return (0); | |
2489 } | |
2490 mutex_enter(&vlun->svl_mutex); | |
2491 bp->b_un.b_addr = (caddr_t)&vlun->svl_prout; | |
2492 bp->b_bcount = vlun->svl_bcount; | |
2493 bcopy(vlun->svl_cdb, new_pkt->pkt_cdbp, | |
2494 sizeof (vlun->svl_cdb)); | |
2495 new_pkt->pkt_time = vlun->svl_time; | |
2496 mutex_exit(&vlun->svl_mutex); | |
2497 new_pkt->pkt_flags = FLAG_NOINTR; | |
2498 | |
2499 ua_retry = nr_retry = retry = 0; | |
2500 again: | |
2501 rval = vhci_do_scsi_cmd(new_pkt); | |
2502 if (rval != 1) { | |
2503 if ((new_pkt->pkt_reason == CMD_CMPLT) && | |
2504 (SCBP_C(new_pkt) == STATUS_CHECK) && | |
2505 (new_pkt->pkt_state & STATE_ARQ_DONE)) { | |
2506 sns = &(((struct scsi_arq_status *)(uintptr_t) | |
2507 (new_pkt->pkt_scbp))->sts_sensedata); | |
2508 if ((sns->es_key == KEY_UNIT_ATTENTION) || | |
2509 (sns->es_key == KEY_NOT_READY)) { | |
2510 int max_retry; | |
2511 struct scsi_failover_ops *fops; | |
2512 fops = vlun->svl_fops; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2513 rval = fops->sfo_analyze_sense(svp->svp_psd, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2514 sns, vlun->svl_fops_ctpriv); |
4851 | 2515 if (rval == SCSI_SENSE_NOT_READY) { |
2516 max_retry = vhci_prout_not_ready_retry; | |
2517 retry = nr_retry++; | |
2518 delay(1*drv_usectohz(1000000)); | |
2519 } else { | |
2520 /* chk for state change and update */ | |
2521 if (rval == SCSI_SENSE_STATE_CHANGED) { | |
2522 int held; | |
2523 VHCI_HOLD_LUN(vlun, | |
2524 VH_NOSLEEP, held); | |
2525 if (!held) { | |
2526 rval = TRAN_BUSY; | |
2527 } else { | |
2528 /* chk for alua first */ | |
2529 vhci_update_pathstates( | |
2530 (void *)vlun); | |
2531 } | |
2532 } | |
2533 retry = ua_retry++; | |
2534 max_retry = VHCI_MAX_PGR_RETRIES; | |
2535 } | |
2536 if (retry < max_retry) { | |
2537 VHCI_DEBUG(4, (CE_WARN, NULL, | |
2538 "!vhci_do_prout retry 0x%x " | |
2539 "(0x%x 0x%x 0x%x)", | |
2540 SCBP_C(new_pkt), | |
2541 new_pkt->pkt_cdbp[0], | |
2542 new_pkt->pkt_cdbp[1], | |
2543 new_pkt->pkt_cdbp[2])); | |
2544 goto again; | |
2545 } | |
2546 rval = 0; | |
2547 VHCI_DEBUG(4, (CE_WARN, NULL, | |
2548 "!vhci_do_prout 0x%x " | |
2549 "(0x%x 0x%x 0x%x)", | |
2550 SCBP_C(new_pkt), | |
2551 new_pkt->pkt_cdbp[0], | |
2552 new_pkt->pkt_cdbp[1], | |
2553 new_pkt->pkt_cdbp[2])); | |
2554 } else if (sns->es_key == KEY_ILLEGAL_REQUEST) | |
2555 rval = VHCI_PGR_ILLEGALOP; | |
2556 } | |
2557 } else { | |
2558 rval = 1; | |
2559 } | |
2560 scsi_destroy_pkt(new_pkt); | |
2561 VHCI_DECR_PATH_CMDCOUNT(svp); | |
2562 freerbuf(bp); | |
2563 return (rval); | |
2564 } | |
2565 | |
2566 static void | |
2567 vhci_run_cmd(void *arg) | |
2568 { | |
2569 struct scsi_pkt *pkt = (struct scsi_pkt *)arg; | |
2570 struct scsi_pkt *tpkt; | |
2571 scsi_vhci_priv_t *svp; | |
2572 mdi_pathinfo_t *pip, *npip; | |
2573 scsi_vhci_lun_t *vlun; | |
2574 dev_info_t *cdip; | |
2575 scsi_vhci_priv_t *nsvp; | |
2576 int fail = 0; | |
2577 int rval; | |
2578 struct vhci_pkt *vpkt; | |
2579 uchar_t cdb_1; | |
2580 vhci_prout_t *prout; | |
2581 | |
2582 vpkt = (struct vhci_pkt *)pkt->pkt_private; | |
2583 tpkt = vpkt->vpkt_tgt_pkt; | |
2584 pip = vpkt->vpkt_path; | |
2585 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
2586 if (svp == NULL) { | |
2587 tpkt->pkt_reason = CMD_TRAN_ERR; | |
2588 tpkt->pkt_statistics = STAT_ABORTED; | |
2589 goto done; | |
2590 } | |
2591 vlun = svp->svp_svl; | |
2592 prout = &vlun->svl_prout; | |
2593 if (SCBP_C(pkt) != STATUS_GOOD) | |
2594 fail++; | |
2595 cdip = vlun->svl_dip; | |
2596 pip = npip = NULL; | |
2597 rval = mdi_select_path(cdip, NULL, | |
2598 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, NULL, &npip); | |
2599 if ((rval != MDI_SUCCESS) || (npip == NULL)) { | |
2600 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2601 "vhci_run_cmd: no path! 0x%p\n", (void *)svp)); | |
2602 tpkt->pkt_reason = CMD_TRAN_ERR; | |
2603 tpkt->pkt_statistics = STAT_ABORTED; | |
2604 goto done; | |
2605 } | |
2606 | |
2607 cdb_1 = vlun->svl_cdb[1]; | |
2608 vlun->svl_cdb[1] &= 0xe0; | |
2609 vlun->svl_cdb[1] |= VHCI_PROUT_R_AND_IGNORE; | |
2610 | |
2611 do { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2612 nsvp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(npip); |
4851 | 2613 if (nsvp == NULL) { |
2614 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2615 "vhci_run_cmd: no " | |
2616 "client priv! 0x%p offlined?\n", | |
2617 (void *)npip)); | |
2618 goto next_path; | |
2619 } | |
2620 if (vlun->svl_first_path == npip) { | |
2621 goto next_path; | |
2622 } else { | |
2623 if (vhci_do_prout(nsvp) != 1) | |
2624 fail++; | |
2625 } | |
2626 next_path: | |
2627 pip = npip; | |
2628 rval = mdi_select_path(cdip, NULL, | |
2629 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, | |
2630 pip, &npip); | |
2631 mdi_rele_path(pip); | |
2632 } while ((rval == MDI_SUCCESS) && (npip != NULL)); | |
2633 | |
2634 vlun->svl_cdb[1] = cdb_1; | |
2635 | |
2636 if (fail) { | |
2637 VHCI_DEBUG(4, (CE_WARN, NULL, "%s%d: key registration failed, " | |
2638 "couldn't be replicated on all paths", | |
2639 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
2640 vhci_print_prout_keys(vlun, "vhci_run_cmd: "); | |
2641 | |
2642 if (SCBP_C(pkt) != STATUS_GOOD) { | |
2643 tpkt->pkt_reason = CMD_TRAN_ERR; | |
2644 tpkt->pkt_statistics = STAT_ABORTED; | |
2645 } | |
2646 } else { | |
2647 vlun->svl_pgr_active = 1; | |
2648 vhci_print_prout_keys(vlun, "vhci_run_cmd: before bcopy:"); | |
2649 | |
2650 bcopy((const void *)prout->service_key, | |
2651 (void *)prout->active_service_key, MHIOC_RESV_KEY_SIZE); | |
2652 bcopy((const void *)prout->res_key, | |
2653 (void *)prout->active_res_key, MHIOC_RESV_KEY_SIZE); | |
2654 | |
2655 vhci_print_prout_keys(vlun, "vhci_run_cmd: after bcopy:"); | |
2656 } | |
2657 done: | |
2658 if (SCBP_C(pkt) == STATUS_GOOD) | |
2659 vlun->svl_first_path = NULL; | |
2660 | |
2661 if (svp) | |
2662 VHCI_DECR_PATH_CMDCOUNT(svp); | |
2663 | |
2664 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
2665 scsi_destroy_pkt(pkt); | |
2666 vpkt->vpkt_hba_pkt = NULL; | |
2667 if (vpkt->vpkt_path) { | |
2668 mdi_rele_path(vpkt->vpkt_path); | |
2669 vpkt->vpkt_path = NULL; | |
2670 } | |
2671 } | |
2672 | |
2673 sema_v(&vlun->svl_pgr_sema); | |
2674 /* | |
2675 * The PROUT commands are not included in the automatic retry | |
2676 * mechanism, therefore, vpkt_org_vpkt should never be set here. | |
2677 */ | |
2678 ASSERT(vpkt->vpkt_org_vpkt == NULL); | |
2679 if (tpkt->pkt_comp) | |
2680 (*tpkt->pkt_comp)(tpkt); | |
2681 | |
2682 } | |
2683 | |
2684 /* | |
2685 * Get the keys registered with this target. Since we will have | |
2686 * registered the same key with multiple initiators, strip out | |
2687 * any duplicate keys. | |
2688 * | |
2689 * The pointers which will be used to filter the registered keys from | |
2690 * the device will be stored in filter_prin and filter_pkt. If the | |
2691 * allocation length of the buffer was sufficient for the number of | |
2692 * parameter data bytes available to be returned by the device then the | |
2693 * key filtering will use the keylist returned from the original | |
2694 * request. If the allocation length of the buffer was not sufficient, | |
2695 * then the filtering will use the keylist returned from the request | |
2696 * that is resent below. | |
2697 * | |
2698 * If the device returns an additional length field that is greater than | |
2699 * the allocation length of the buffer, then allocate a new buffer which | |
2700 * can accommodate the number of parameter data bytes available to be | |
2701 * returned. Resend the scsi PRIN command, filter out the duplicate | |
2702 * keys and return as many of the unique keys found that was originally | |
2703 * requested and set the additional length field equal to the data bytes | |
2704 * of unique reservation keys available to be returned. | |
2705 * | |
2706 * If the device returns an additional length field that is less than or | |
2707 * equal to the allocation length of the buffer, then all the available | |
2708 * keys registered were returned by the device. Filter out the | |
2709 * duplicate keys and return all of the unique keys found and set the | |
2710 * additional length field equal to the data bytes of the reservation | |
2711 * keys to be returned. | |
2712 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2713 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2714 #define VHCI_PRIN_HEADER_SZ (sizeof (prin->length) + sizeof (prin->generation)) |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2715 |
4851 | 2716 static int |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2717 vhci_do_prin(struct vhci_pkt **intr_vpkt) |
4851 | 2718 { |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2719 scsi_vhci_priv_t *svp; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2720 struct vhci_pkt *vpkt = *intr_vpkt; |
4851 | 2721 vhci_prin_readkeys_t *prin; |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2722 scsi_vhci_lun_t *vlun; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2723 struct scsi_vhci *vhci = ADDR2VHCI(&vpkt->vpkt_tgt_pkt->pkt_address); |
4851 | 2724 |
2725 struct buf *new_bp = NULL; | |
2726 struct scsi_pkt *new_pkt = NULL; | |
2727 struct vhci_pkt *new_vpkt = NULL; | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2728 uint32_t needed_length; |
4851 | 2729 int rval = VHCI_CMD_CMPLT; |
2730 uint32_t prin_length = 0; | |
2731 uint32_t svl_prin_length = 0; | |
2732 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2733 ASSERT(vpkt->vpkt_path); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2734 svp = mdi_pi_get_vhci_private(vpkt->vpkt_path); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2735 ASSERT(svp); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2736 vlun = svp->svp_svl; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2737 ASSERT(vlun); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2738 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2739 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2740 * If the caller only asked for an amount of data that would not |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2741 * be enough to include any key data it is likely that they will |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2742 * send the next command with a buffer size based on the information |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2743 * from this header. Doing recovery on this would be a duplication |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2744 * of efforts. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2745 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2746 if (vpkt->vpkt_tgt_init_bp->b_bcount <= VHCI_PRIN_HEADER_SZ) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2747 rval = VHCI_CMD_CMPLT; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2748 goto exit; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2749 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2750 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2751 if (vpkt->vpkt_org_vpkt == NULL) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2752 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2753 * Can fail as sleep is not allowed. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2754 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2755 prin = (vhci_prin_readkeys_t *) |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2756 bp_mapin_common(vpkt->vpkt_tgt_init_bp, VM_NOSLEEP); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2757 } else { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2758 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2759 * The retry buf doesn't need to be mapped in. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2760 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2761 prin = (vhci_prin_readkeys_t *) |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2762 vpkt->vpkt_tgt_init_bp->b_un.b_daddr; |
4851 | 2763 } |
2764 | |
2765 if (prin == NULL) { | |
2766 VHCI_DEBUG(5, (CE_WARN, NULL, | |
2767 "vhci_do_prin: bp_mapin_common failed.")); | |
2768 rval = VHCI_CMD_ERROR; | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2769 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2770 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2771 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2772 prin_length = BE_32(prin->length); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2773 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2774 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2775 * According to SPC-3r22, sec 4.3.4.6: "If the amount of |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2776 * information to be transferred exceeds the maximum value |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2777 * that the ALLOCATION LENGTH field is capable of specifying, |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2778 * the device server shall...terminate the command with CHECK |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2779 * CONDITION status". The ALLOCATION LENGTH field of the |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2780 * PERSISTENT RESERVE IN command is 2 bytes. We should never |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2781 * get here with an ADDITIONAL LENGTH greater than 0xFFFF |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2782 * so if we do, then it is an error! |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2783 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2784 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2785 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2786 if ((prin_length + VHCI_PRIN_HEADER_SZ) > 0xFFFF) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2787 VHCI_DEBUG(5, (CE_NOTE, NULL, |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2788 "vhci_do_prin: Device returned invalid " |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2789 "length 0x%x\n", prin_length)); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2790 rval = VHCI_CMD_ERROR; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2791 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2792 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2793 needed_length = prin_length + VHCI_PRIN_HEADER_SZ; |
4851 | 2794 |
2795 /* | |
2796 * If prin->length is greater than the byte count allocated in the | |
2797 * original buffer, then resend the request with enough buffer | |
2798 * allocated to get all of the available registered keys. | |
2799 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2800 if ((vpkt->vpkt_tgt_init_bp->b_bcount < needed_length) && |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2801 (vpkt->vpkt_org_vpkt == NULL)) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2802 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2803 new_pkt = vhci_create_retry_pkt(vpkt); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2804 if (new_pkt == NULL) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2805 rval = VHCI_CMD_ERROR; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2806 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2807 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2808 new_vpkt = TGTPKT2VHCIPKT(new_pkt); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2809 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2810 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2811 * This is the buf with buffer pointer |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2812 * where the prin readkeys will be |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2813 * returned from the device |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2814 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2815 new_bp = scsi_alloc_consistent_buf(&svp->svp_psd->sd_address, |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2816 NULL, needed_length, B_READ, NULL_FUNC, NULL); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2817 if ((new_bp == NULL) || (new_bp->b_un.b_addr == NULL)) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2818 if (new_bp) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2819 scsi_free_consistent_buf(new_bp); |
4851 | 2820 } |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2821 vhci_scsi_destroy_pkt(&new_pkt->pkt_address, new_pkt); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2822 rval = VHCI_CMD_ERROR; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2823 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2824 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2825 new_bp->b_bcount = needed_length; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2826 new_pkt->pkt_cdbp[7] = (uchar_t)(needed_length >> 8); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2827 new_pkt->pkt_cdbp[8] = (uchar_t)needed_length; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2828 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2829 rval = VHCI_CMD_RETRY; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2830 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2831 new_vpkt->vpkt_tgt_init_bp = new_bp; |
4851 | 2832 } |
2833 | |
2834 if (rval == VHCI_CMD_RETRY) { | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2835 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2836 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2837 * There were more keys then the original request asked for. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2838 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2839 mdi_pathinfo_t *path_holder = vpkt->vpkt_path; |
4851 | 2840 |
2841 /* | |
2842 * Release the old path because it does not matter which path | |
2843 * this command is sent down. This allows the normal bind | |
2844 * transport mechanism to be used. | |
2845 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2846 if (vpkt->vpkt_path != NULL) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2847 mdi_rele_path(vpkt->vpkt_path); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2848 vpkt->vpkt_path = NULL; |
4851 | 2849 } |
2850 | |
2851 /* | |
2852 * Dispatch the retry command | |
2853 */ | |
2854 if (taskq_dispatch(vhci->vhci_taskq, vhci_dispatch_scsi_start, | |
2855 (void *) new_vpkt, KM_NOSLEEP) == NULL) { | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2856 if (path_holder) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2857 vpkt->vpkt_path = path_holder; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2858 mdi_hold_path(path_holder); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2859 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2860 scsi_free_consistent_buf(new_bp); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2861 vhci_scsi_destroy_pkt(&new_pkt->pkt_address, new_pkt); |
4851 | 2862 rval = VHCI_CMD_ERROR; |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2863 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2864 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2865 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2866 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2867 * If we return VHCI_CMD_RETRY, that means the caller |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2868 * is going to bail and wait for the reissued command |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2869 * to complete. In that case, we need to decrement |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2870 * the path command count right now. In any other |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2871 * case, it'll be decremented by the caller. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2872 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2873 VHCI_DECR_PATH_CMDCOUNT(svp); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2874 goto exit; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2875 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2876 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2877 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2878 if (rval == VHCI_CMD_CMPLT) { |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2879 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2880 * The original request got all of the keys or the recovery |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2881 * packet returns. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2882 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2883 int new; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2884 int old; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2885 int num_keys = prin_length / MHIOC_RESV_KEY_SIZE; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2886 |
4851 | 2887 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_do_prin: %d keys read\n", |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2888 num_keys)); |
4851 | 2889 |
2890 #ifdef DEBUG | |
2891 VHCI_DEBUG(5, (CE_NOTE, NULL, "vhci_do_prin: from storage\n")); | |
2892 if (vhci_debug == 5) | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2893 vhci_print_prin_keys(prin, num_keys); |
4851 | 2894 VHCI_DEBUG(5, (CE_NOTE, NULL, |
2895 "vhci_do_prin: MPxIO old keys:\n")); | |
2896 if (vhci_debug == 5) | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2897 vhci_print_prin_keys(&vlun->svl_prin, num_keys); |
4851 | 2898 #endif |
2899 | |
2900 /* | |
2901 * Filter out all duplicate keys returned from the device | |
2902 * We know that we use a different key for every host, so we | |
2903 * can simply strip out duplicates. Otherwise we would need to | |
2904 * do more bookkeeping to figure out which keys to strip out. | |
2905 */ | |
2906 | |
2907 new = 0; | |
2908 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2909 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2910 * If we got at least 1 key copy it. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2911 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2912 if (num_keys > 0) { |
4851 | 2913 vlun->svl_prin.keylist[0] = prin->keylist[0]; |
2914 new++; | |
2915 } | |
2916 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2917 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2918 * find next unique key. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2919 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2920 for (old = 1; old < num_keys; old++) { |
4851 | 2921 int j; |
2922 int match = 0; | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2923 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2924 if (new >= VHCI_NUM_RESV_KEYS) |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2925 break; |
4851 | 2926 for (j = 0; j < new; j++) { |
2927 if (bcmp(&prin->keylist[old], | |
2928 &vlun->svl_prin.keylist[j], | |
2929 sizeof (mhioc_resv_key_t)) == 0) { | |
2930 match = 1; | |
2931 break; | |
2932 } | |
2933 } | |
2934 if (!match) { | |
2935 vlun->svl_prin.keylist[new] = | |
2936 prin->keylist[old]; | |
2937 new++; | |
2938 } | |
2939 } | |
2940 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2941 /* Stored Big Endian */ |
4851 | 2942 vlun->svl_prin.generation = prin->generation; |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2943 svl_prin_length = new * sizeof (mhioc_resv_key_t); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2944 /* Stored Big Endian */ |
4851 | 2945 vlun->svl_prin.length = BE_32(svl_prin_length); |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2946 svl_prin_length += VHCI_PRIN_HEADER_SZ; |
4851 | 2947 |
2948 /* | |
2949 * If we arrived at this point after issuing a retry, make sure | |
2950 * that we put everything back the way it originally was so | |
2951 * that the target driver can complete the command correctly. | |
2952 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2953 if (vpkt->vpkt_org_vpkt != NULL) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2954 new_bp = vpkt->vpkt_tgt_init_bp; |
4851 | 2955 |
2956 scsi_free_consistent_buf(new_bp); | |
2957 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2958 vpkt = vhci_sync_retry_pkt(vpkt); |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2959 *intr_vpkt = vpkt; |
4851 | 2960 |
2961 /* | |
2962 * Make sure the original buffer is mapped into kernel | |
2963 * space before we try to copy the filtered keys into | |
2964 * it. | |
2965 */ | |
2966 prin = (vhci_prin_readkeys_t *)bp_mapin_common( | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2967 vpkt->vpkt_tgt_init_bp, VM_NOSLEEP); |
4851 | 2968 } |
2969 | |
2970 /* | |
2971 * Now copy the desired number of prin keys into the original | |
2972 * target buffer. | |
2973 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2974 if (svl_prin_length <= vpkt->vpkt_tgt_init_bp->b_bcount) { |
4851 | 2975 /* |
2976 * It is safe to return all of the available unique | |
2977 * keys | |
2978 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2979 bcopy(&vlun->svl_prin, prin, svl_prin_length); |
4851 | 2980 } else { |
2981 /* | |
2982 * Not all of the available keys were requested by the | |
2983 * original command. | |
2984 */ | |
2985 bcopy(&vlun->svl_prin, prin, | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2986 vpkt->vpkt_tgt_init_bp->b_bcount); |
4851 | 2987 } |
2988 #ifdef DEBUG | |
2989 VHCI_DEBUG(5, (CE_NOTE, NULL, | |
2990 "vhci_do_prin: To Application:\n")); | |
2991 if (vhci_debug == 5) | |
2992 vhci_print_prin_keys(prin, new); | |
2993 VHCI_DEBUG(5, (CE_NOTE, NULL, | |
2994 "vhci_do_prin: MPxIO new keys:\n")); | |
2995 if (vhci_debug == 5) | |
2996 vhci_print_prin_keys(&vlun->svl_prin, new); | |
2997 #endif | |
2998 } | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2999 fail: |
4851 | 3000 if (rval == VHCI_CMD_ERROR) { |
3001 /* | |
3002 * If we arrived at this point after issuing a | |
3003 * retry, make sure that we put everything back | |
3004 * the way it originally was so that ssd can | |
3005 * complete the command correctly. | |
3006 */ | |
3007 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3008 if (vpkt->vpkt_org_vpkt != NULL) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3009 new_bp = vpkt->vpkt_tgt_init_bp; |
4851 | 3010 if (new_bp != NULL) { |
3011 scsi_free_consistent_buf(new_bp); | |
3012 } | |
3013 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3014 new_vpkt = vpkt; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3015 vpkt = vpkt->vpkt_org_vpkt; |
4851 | 3016 |
3017 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
3018 new_vpkt->vpkt_tgt_pkt); | |
3019 } | |
3020 | |
3021 /* | |
3022 * Mark this command completion as having an error so that | |
3023 * ssd will retry the command. | |
3024 */ | |
3025 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3026 vpkt->vpkt_tgt_pkt->pkt_reason = CMD_ABORTED; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3027 vpkt->vpkt_tgt_pkt->pkt_statistics |= STAT_ABORTED; |
4851 | 3028 |
3029 rval = VHCI_CMD_CMPLT; | |
3030 } | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3031 exit: |
4851 | 3032 /* |
3033 * Make sure that the semaphore is only released once. | |
3034 */ | |
3035 if (rval == VHCI_CMD_CMPLT) { | |
3036 sema_v(&vlun->svl_pgr_sema); | |
3037 } | |
3038 | |
3039 return (rval); | |
3040 } | |
3041 | |
3042 static void | |
3043 vhci_intr(struct scsi_pkt *pkt) | |
3044 { | |
3045 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_private; | |
3046 struct scsi_pkt *tpkt; | |
3047 scsi_vhci_priv_t *svp; | |
3048 scsi_vhci_lun_t *vlun; | |
3049 int rval, held; | |
3050 struct scsi_failover_ops *fops; | |
3051 struct scsi_extended_sense *sns; | |
3052 mdi_pathinfo_t *lpath; | |
3053 static char *timeout_err = "Command Timeout"; | |
3054 static char *parity_err = "Parity Error"; | |
3055 char *err_str = NULL; | |
3056 dev_info_t *vdip, *cdip, *pdip; | |
3057 char *cpath, *dpath; | |
3058 | |
3059 ASSERT(vpkt != NULL); | |
3060 tpkt = vpkt->vpkt_tgt_pkt; | |
3061 ASSERT(tpkt != NULL); | |
3062 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
3063 ASSERT(svp != NULL); | |
3064 vlun = svp->svp_svl; | |
3065 ASSERT(vlun != NULL); | |
3066 lpath = vpkt->vpkt_path; | |
3067 | |
3068 /* | |
3069 * sync up the target driver's pkt with the pkt that | |
3070 * we actually used | |
3071 */ | |
3072 *(tpkt->pkt_scbp) = *(pkt->pkt_scbp); | |
3073 tpkt->pkt_resid = pkt->pkt_resid; | |
3074 tpkt->pkt_state = pkt->pkt_state; | |
3075 tpkt->pkt_statistics = pkt->pkt_statistics; | |
3076 tpkt->pkt_reason = pkt->pkt_reason; | |
3077 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3078 /* Return path_instance information back to the target driver. */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3079 if (scsi_pkt_allocated_correctly(tpkt)) { |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3080 if (scsi_pkt_allocated_correctly(pkt)) { |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3081 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3082 * If both packets were correctly allocated, |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3083 * return path returned by pHCI. |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3084 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3085 tpkt->pkt_path_instance = pkt->pkt_path_instance; |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3086 } else { |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3087 /* Otherwise return path of pHCI we used */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3088 tpkt->pkt_path_instance = |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3089 mdi_pi_get_path_instance(lpath); |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3090 } |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3091 } |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3092 |
4851 | 3093 if (pkt->pkt_cdbp[0] == SCMD_PROUT && |
3094 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) || | |
3095 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE)) { | |
3096 if ((SCBP_C(pkt) != STATUS_GOOD) || | |
3097 (pkt->pkt_reason != CMD_CMPLT)) { | |
3098 sema_v(&vlun->svl_pgr_sema); | |
3099 } | |
3100 } else if (pkt->pkt_cdbp[0] == SCMD_PRIN) { | |
3101 if (pkt->pkt_reason != CMD_CMPLT || | |
3102 (SCBP_C(pkt) != STATUS_GOOD)) { | |
3103 sema_v(&vlun->svl_pgr_sema); | |
3104 } | |
3105 } | |
3106 | |
3107 switch (pkt->pkt_reason) { | |
3108 case CMD_CMPLT: | |
3109 /* | |
3110 * cmd completed successfully, check for scsi errors | |
3111 */ | |
3112 switch (*(pkt->pkt_scbp)) { | |
3113 case STATUS_CHECK: | |
3114 if (pkt->pkt_state & STATE_ARQ_DONE) { | |
3115 sns = &(((struct scsi_arq_status *)(uintptr_t) | |
3116 (pkt->pkt_scbp))->sts_sensedata); | |
3117 fops = vlun->svl_fops; | |
3118 ASSERT(fops != NULL); | |
3119 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_intr: " | |
3120 "Received sns key %x esc %x escq %x\n", | |
3121 sns->es_key, sns->es_add_code, | |
3122 sns->es_qual_code)); | |
3123 | |
3124 if (vlun->svl_waiting_for_activepath == 1) { | |
3125 /* | |
3126 * if we are here it means we are | |
3127 * in the midst of a probe/attach | |
3128 * through a passive path; this | |
3129 * case is exempt from sense analysis | |
3130 * for detection of ext. failover | |
3131 * because that would unnecessarily | |
3132 * increase attach time. | |
3133 */ | |
3134 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
3135 vpkt->vpkt_tgt_init_scblen); | |
3136 break; | |
3137 } | |
3138 if (sns->es_add_code == VHCI_SCSI_PERR) { | |
3139 /* | |
3140 * parity error | |
3141 */ | |
3142 err_str = parity_err; | |
3143 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
3144 vpkt->vpkt_tgt_init_scblen); | |
3145 break; | |
3146 } | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3147 rval = fops->sfo_analyze_sense(svp->svp_psd, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3148 sns, vlun->svl_fops_ctpriv); |
4851 | 3149 if ((rval == SCSI_SENSE_NOFAILOVER) || |
3150 (rval == SCSI_SENSE_UNKNOWN) || | |
3151 (rval == SCSI_SENSE_NOT_READY)) { | |
3152 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
3153 vpkt->vpkt_tgt_init_scblen); | |
3154 break; | |
3155 } else if (rval == SCSI_SENSE_STATE_CHANGED) { | |
3156 struct scsi_vhci *vhci; | |
3157 vhci = ADDR2VHCI(&tpkt->pkt_address); | |
3158 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
3159 if (!held) { | |
3160 /* | |
3161 * looks like some other thread | |
3162 * has already detected this | |
3163 * condition | |
3164 */ | |
3165 tpkt->pkt_state &= | |
3166 ~STATE_ARQ_DONE; | |
3167 *(tpkt->pkt_scbp) = | |
3168 STATUS_BUSY; | |
3169 break; | |
3170 } | |
3171 (void) taskq_dispatch( | |
3172 vhci->vhci_update_pathstates_taskq, | |
3173 vhci_update_pathstates, | |
3174 (void *)vlun, KM_SLEEP); | |
3175 } else { | |
3176 /* | |
3177 * externally initiated failover | |
3178 * has occurred or is in progress | |
3179 */ | |
3180 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
3181 if (!held) { | |
3182 /* | |
3183 * looks like some other thread | |
3184 * has already detected this | |
3185 * condition | |
3186 */ | |
3187 tpkt->pkt_state &= | |
3188 ~STATE_ARQ_DONE; | |
3189 *(tpkt->pkt_scbp) = | |
3190 STATUS_BUSY; | |
3191 break; | |
3192 } else { | |
3193 rval = vhci_handle_ext_fo | |
3194 (pkt, rval); | |
3195 if (rval == BUSY_RETURN) { | |
3196 tpkt->pkt_state &= | |
3197 ~STATE_ARQ_DONE; | |
3198 *(tpkt->pkt_scbp) = | |
3199 STATUS_BUSY; | |
3200 break; | |
3201 } | |
3202 bcopy(pkt->pkt_scbp, | |
3203 tpkt->pkt_scbp, | |
3204 vpkt->vpkt_tgt_init_scblen); | |
3205 break; | |
3206 } | |
3207 } | |
3208 } | |
3209 break; | |
3210 | |
3211 /* | |
3212 * If this is a good SCSI-II RELEASE cmd completion then restore | |
3213 * the load balancing policy and reset VLUN_RESERVE_ACTIVE_FLG. | |
3214 * If this is a good SCSI-II RESERVE cmd completion then set | |
3215 * VLUN_RESERVE_ACTIVE_FLG. | |
3216 */ | |
3217 case STATUS_GOOD: | |
3218 if ((pkt->pkt_cdbp[0] == SCMD_RELEASE) || | |
3219 (pkt->pkt_cdbp[0] == SCMD_RELEASE_G1)) { | |
3220 (void) mdi_set_lb_policy(vlun->svl_dip, | |
3221 vlun->svl_lb_policy_save); | |
3222 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
3223 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3224 "!vhci_intr: vlun 0x%p release path 0x%p", | |
3225 (void *)vlun, (void *)vpkt->vpkt_path)); | |
3226 } | |
3227 | |
3228 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
3229 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
3230 vlun->svl_flags |= VLUN_RESERVE_ACTIVE_FLG; | |
3231 vlun->svl_resrv_pip = vpkt->vpkt_path; | |
3232 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3233 "!vhci_intr: vlun 0x%p reserved path 0x%p", | |
3234 (void *)vlun, (void *)vpkt->vpkt_path)); | |
3235 } | |
3236 break; | |
3237 | |
3238 case STATUS_RESERVATION_CONFLICT: | |
3239 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3240 "!vhci_intr: vlun 0x%p " | |
3241 "reserve conflict on path 0x%p", | |
3242 (void *)vlun, (void *)vpkt->vpkt_path)); | |
3243 /* FALLTHROUGH */ | |
3244 default: | |
3245 break; | |
3246 } | |
3247 | |
3248 /* | |
3249 * Update I/O completion statistics for the path | |
3250 */ | |
3251 mdi_pi_kstat_iosupdate(vpkt->vpkt_path, vpkt->vpkt_tgt_init_bp); | |
3252 | |
3253 /* | |
3254 * Command completed successfully, release the dma binding and | |
3255 * destroy the transport side of the packet. | |
3256 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3257 if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && |
4851 | 3258 (((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) || |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3259 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { |
4851 | 3260 if (SCBP_C(pkt) == STATUS_GOOD) { |
3261 ASSERT(vlun->svl_taskq); | |
3262 svp->svp_last_pkt_reason = pkt->pkt_reason; | |
3263 (void) taskq_dispatch(vlun->svl_taskq, | |
3264 vhci_run_cmd, pkt, KM_SLEEP); | |
3265 return; | |
3266 } | |
3267 } | |
3268 if ((SCBP_C(pkt) == STATUS_GOOD) && | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3269 (pkt->pkt_cdbp[0] == SCMD_PRIN) && vpkt->vpkt_tgt_init_bp) { |
4851 | 3270 /* |
3271 * If the action (value in byte 1 of the cdb) is zero, | |
3272 * we're reading keys, and that's the only condition | |
3273 * where we need to be concerned with filtering keys | |
3274 * and potential retries. Otherwise, we simply signal | |
3275 * the semaphore and move on. | |
3276 */ | |
3277 if (pkt->pkt_cdbp[1] == 0) { | |
3278 /* | |
3279 * If this is the completion of an internal | |
3280 * retry then we need to make sure that the | |
3281 * pkt and tpkt pointers are readjusted so | |
3282 * the calls to scsi_destroy_pkt and pkt_comp | |
3283 * below work * correctly. | |
3284 */ | |
3285 if (vpkt->vpkt_org_vpkt != NULL) { | |
3286 pkt = vpkt->vpkt_org_vpkt->vpkt_hba_pkt; | |
3287 tpkt = vpkt->vpkt_org_vpkt-> | |
3288 vpkt_tgt_pkt; | |
3289 | |
3290 /* | |
3291 * If this command was issued through | |
3292 * the taskq then we need to clear | |
3293 * this flag for proper processing in | |
3294 * the case of a retry from the target | |
3295 * driver. | |
3296 */ | |
3297 vpkt->vpkt_state &= | |
3298 ~VHCI_PKT_THRU_TASKQ; | |
3299 } | |
3300 | |
3301 /* | |
3302 * if vhci_do_prin returns VHCI_CMD_CMPLT then | |
3303 * vpkt will contain the address of the | |
3304 * original vpkt | |
3305 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3306 if (vhci_do_prin(&vpkt) == VHCI_CMD_RETRY) { |
4851 | 3307 /* |
3308 * The command has been resent to get | |
3309 * all the keys from the device. Don't | |
3310 * complete the command with ssd until | |
3311 * the retry completes. | |
3312 */ | |
3313 return; | |
3314 } | |
3315 } else { | |
3316 sema_v(&vlun->svl_pgr_sema); | |
3317 } | |
3318 } | |
3319 | |
3320 break; | |
3321 | |
3322 case CMD_TIMEOUT: | |
3323 if ((pkt->pkt_statistics & | |
3324 (STAT_BUS_RESET|STAT_DEV_RESET|STAT_ABORTED)) == 0) { | |
3325 | |
3326 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3327 "!scsi vhci timeout invoked\n")); | |
3328 | |
3329 (void) vhci_recovery_reset(vlun, &pkt->pkt_address, | |
3330 FALSE, VHCI_DEPTH_ALL); | |
3331 } | |
3332 MDI_PI_ERRSTAT(lpath, MDI_PI_TRANSERR); | |
3333 tpkt->pkt_statistics |= STAT_ABORTED; | |
3334 err_str = timeout_err; | |
3335 break; | |
3336 | |
3337 case CMD_TRAN_ERR: | |
3338 /* | |
3339 * This status is returned if the transport has sent the cmd | |
3340 * down the link to the target and then some error occurs. | |
3341 * In case of SCSI-II RESERVE cmd, we don't know if the | |
3342 * reservation been accepted by the target or not, so we need | |
3343 * to clear the reservation. | |
3344 */ | |
3345 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
3346 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
3347 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_intr received" | |
3348 " cmd_tran_err for scsi-2 reserve cmd\n")); | |
3349 if (!vhci_recovery_reset(vlun, &pkt->pkt_address, | |
3350 TRUE, VHCI_DEPTH_TARGET)) { | |
3351 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3352 "!vhci_intr cmd_tran_err reset failed!")); | |
3353 } | |
3354 } | |
3355 break; | |
3356 | |
3357 case CMD_DEV_GONE: | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3358 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_intr received " |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3359 "cmd_dev_gone\n")); |
4851 | 3360 tpkt->pkt_reason = CMD_CMPLT; |
3361 tpkt->pkt_state = STATE_GOT_BUS | | |
3362 STATE_GOT_TARGET | STATE_SENT_CMD | | |
3363 STATE_GOT_STATUS; | |
3364 *(tpkt->pkt_scbp) = STATUS_BUSY; | |
3365 break; | |
3366 | |
3367 default: | |
3368 break; | |
3369 } | |
3370 | |
3371 /* | |
3372 * SCSI-II RESERVE cmd has been serviced by the lower layers clear | |
3373 * the flag so the lun is not QUIESCED any longer. | |
3374 * Also clear the VHCI_PKT_THRU_TASKQ flag, to ensure that if this pkt | |
3375 * is retried, a taskq shall again be dispatched to service it. Else | |
3376 * it may lead to a system hang if the retry is within interrupt | |
3377 * context. | |
3378 */ | |
3379 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
3380 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
3381 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
3382 vpkt->vpkt_state &= ~VHCI_PKT_THRU_TASKQ; | |
3383 } | |
3384 | |
3385 /* | |
3386 * vpkt_org_vpkt should always be NULL here if the retry command | |
3387 * has been successfully processed. If vpkt_org_vpkt != NULL at | |
3388 * this point, it is an error so restore the original vpkt and | |
3389 * return an error to the target driver so it can retry the | |
3390 * command as appropriate. | |
3391 */ | |
3392 if (vpkt->vpkt_org_vpkt != NULL) { | |
3393 struct vhci_pkt *new_vpkt = vpkt; | |
3394 vpkt = vpkt->vpkt_org_vpkt; | |
3395 | |
3396 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
3397 new_vpkt->vpkt_tgt_pkt); | |
3398 | |
3399 /* | |
3400 * Mark this command completion as having an error so that | |
3401 * ssd will retry the command. | |
3402 */ | |
3403 vpkt->vpkt_tgt_pkt->pkt_reason = CMD_ABORTED; | |
3404 vpkt->vpkt_tgt_pkt->pkt_statistics |= STAT_ABORTED; | |
3405 | |
3406 pkt = vpkt->vpkt_hba_pkt; | |
3407 tpkt = vpkt->vpkt_tgt_pkt; | |
3408 } | |
3409 | |
3410 if ((err_str != NULL) && (pkt->pkt_reason != | |
3411 svp->svp_last_pkt_reason)) { | |
3412 cdip = vlun->svl_dip; | |
3413 pdip = mdi_pi_get_phci(vpkt->vpkt_path); | |
3414 vdip = ddi_get_parent(cdip); | |
3415 cpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3416 dpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3417 vhci_log(CE_WARN, vdip, "!%s (%s%d): %s on path %s (%s%d)", | |
3418 ddi_pathname(cdip, cpath), ddi_driver_name(cdip), | |
3419 ddi_get_instance(cdip), err_str, | |
3420 ddi_pathname(pdip, dpath), ddi_driver_name(pdip), | |
3421 ddi_get_instance(pdip)); | |
3422 kmem_free(cpath, MAXPATHLEN); | |
3423 kmem_free(dpath, MAXPATHLEN); | |
3424 } | |
3425 svp->svp_last_pkt_reason = pkt->pkt_reason; | |
3426 VHCI_DECR_PATH_CMDCOUNT(svp); | |
3427 | |
3428 /* | |
3429 * For PARTIAL_DMA, vhci should not free the path. | |
3430 * Target driver will call into vhci_scsi_dmafree or | |
3431 * destroy pkt to release this path. | |
3432 */ | |
3433 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
3434 scsi_destroy_pkt(pkt); | |
3435 vpkt->vpkt_hba_pkt = NULL; | |
3436 if (vpkt->vpkt_path) { | |
3437 mdi_rele_path(vpkt->vpkt_path); | |
3438 vpkt->vpkt_path = NULL; | |
3439 } | |
3440 } | |
3441 | |
3442 if (tpkt->pkt_comp) { | |
3443 (*tpkt->pkt_comp)(tpkt); | |
3444 } | |
3445 } | |
3446 | |
3447 /* | |
3448 * two possibilities: (1) failover has completed | |
3449 * or (2) is in progress; update our path states for | |
3450 * the former case; for the latter case, | |
3451 * initiate a scsi_watch request to | |
3452 * determine when failover completes - vlun is HELD | |
3453 * until failover completes; BUSY is returned to upper | |
3454 * layer in both the cases | |
3455 */ | |
3456 static int | |
3457 vhci_handle_ext_fo(struct scsi_pkt *pkt, int fostat) | |
3458 { | |
3459 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_private; | |
3460 struct scsi_pkt *tpkt; | |
3461 scsi_vhci_priv_t *svp; | |
3462 scsi_vhci_lun_t *vlun; | |
3463 struct scsi_vhci *vhci; | |
3464 scsi_vhci_swarg_t *swarg; | |
3465 char *path; | |
3466 | |
3467 ASSERT(vpkt != NULL); | |
3468 tpkt = vpkt->vpkt_tgt_pkt; | |
3469 ASSERT(tpkt != NULL); | |
3470 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
3471 ASSERT(svp != NULL); | |
3472 vlun = svp->svp_svl; | |
3473 ASSERT(vlun != NULL); | |
3474 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
3475 | |
3476 vhci = ADDR2VHCI(&tpkt->pkt_address); | |
3477 | |
3478 if (fostat == SCSI_SENSE_INACTIVE) { | |
3479 VHCI_DEBUG(1, (CE_NOTE, NULL, "!Failover " | |
3480 "detected for %s; updating path states...\n", | |
3481 vlun->svl_lun_wwn)); | |
3482 /* | |
3483 * set the vlun flag to indicate to the task that the target | |
3484 * port group needs updating | |
3485 */ | |
3486 vlun->svl_flags |= VLUN_UPDATE_TPG; | |
3487 (void) taskq_dispatch(vhci->vhci_update_pathstates_taskq, | |
3488 vhci_update_pathstates, (void *)vlun, KM_SLEEP); | |
3489 } else { | |
3490 path = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3491 vhci_log(CE_NOTE, ddi_get_parent(vlun->svl_dip), | |
3492 "!%s (%s%d): Waiting for externally initiated failover " | |
3493 "to complete", ddi_pathname(vlun->svl_dip, path), | |
3494 ddi_driver_name(vlun->svl_dip), | |
3495 ddi_get_instance(vlun->svl_dip)); | |
3496 kmem_free(path, MAXPATHLEN); | |
3497 swarg = kmem_alloc(sizeof (*swarg), KM_NOSLEEP); | |
3498 if (swarg == NULL) { | |
3499 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_handle_ext_fo: " | |
3500 "request packet allocation for %s failed....\n", | |
3501 vlun->svl_lun_wwn)); | |
3502 VHCI_RELEASE_LUN(vlun); | |
3503 return (PKT_RETURN); | |
3504 } | |
3505 swarg->svs_svp = svp; | |
3506 swarg->svs_tos = ddi_get_time(); | |
3507 swarg->svs_pi = vpkt->vpkt_path; | |
3508 swarg->svs_release_lun = 0; | |
3509 swarg->svs_done = 0; | |
3510 /* | |
3511 * place a hold on the path...we don't want it to | |
3512 * vanish while scsi_watch is in progress | |
3513 */ | |
3514 mdi_hold_path(vpkt->vpkt_path); | |
3515 svp->svp_sw_token = scsi_watch_request_submit(svp->svp_psd, | |
3516 VHCI_FOWATCH_INTERVAL, SENSE_LENGTH, vhci_efo_watch_cb, | |
3517 (caddr_t)swarg); | |
3518 } | |
3519 return (BUSY_RETURN); | |
3520 } | |
3521 | |
3522 /* | |
3523 * vhci_efo_watch_cb: | |
3524 * Callback from scsi_watch request to check the failover status. | |
3525 * Completion is either due to successful failover or timeout. | |
3526 * Upon successful completion, vhci_update_path_states is called. | |
3527 * For timeout condition, vhci_efo_done is called. | |
3528 * Always returns 0 to scsi_watch to keep retrying till vhci_efo_done | |
3529 * terminates this request properly in a separate thread. | |
3530 */ | |
3531 | |
3532 static int | |
3533 vhci_efo_watch_cb(caddr_t arg, struct scsi_watch_result *resultp) | |
3534 { | |
3535 struct scsi_status *statusp = resultp->statusp; | |
3536 struct scsi_extended_sense *sensep = resultp->sensep; | |
3537 struct scsi_pkt *pkt = resultp->pkt; | |
3538 scsi_vhci_swarg_t *swarg; | |
3539 scsi_vhci_priv_t *svp; | |
3540 scsi_vhci_lun_t *vlun; | |
3541 struct scsi_vhci *vhci; | |
3542 dev_info_t *vdip; | |
3543 int rval, updt_paths; | |
3544 | |
3545 swarg = (scsi_vhci_swarg_t *)(uintptr_t)arg; | |
3546 svp = swarg->svs_svp; | |
3547 if (swarg->svs_done) { | |
3548 /* | |
3549 * Already completed failover or timedout. | |
3550 * Waiting for vhci_efo_done to terminate this scsi_watch. | |
3551 */ | |
3552 return (0); | |
3553 } | |
3554 | |
3555 ASSERT(svp != NULL); | |
3556 vlun = svp->svp_svl; | |
3557 ASSERT(vlun != NULL); | |
3558 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
3559 vlun->svl_efo_update_path = 0; | |
3560 vdip = ddi_get_parent(vlun->svl_dip); | |
3561 vhci = ddi_get_soft_state(vhci_softstate, | |
3562 ddi_get_instance(vdip)); | |
3563 | |
3564 updt_paths = 0; | |
3565 | |
3566 if (pkt->pkt_reason != CMD_CMPLT) { | |
3567 if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) { | |
3568 swarg->svs_release_lun = 1; | |
3569 goto done; | |
3570 } | |
3571 return (0); | |
3572 } | |
3573 if (*((unsigned char *)statusp) == STATUS_CHECK) { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3574 rval = vlun->svl_fops->sfo_analyze_sense(svp->svp_psd, sensep, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3575 vlun->svl_fops_ctpriv); |
4851 | 3576 switch (rval) { |
3577 /* | |
3578 * Only update path states in case path is definitely | |
3579 * inactive, or no failover occurred. For all other | |
3580 * check conditions continue pinging. A unexpected | |
3581 * check condition shouldn't cause pinging to complete | |
3582 * prematurely. | |
3583 */ | |
3584 case SCSI_SENSE_INACTIVE: | |
3585 case SCSI_SENSE_NOFAILOVER: | |
3586 updt_paths = 1; | |
3587 break; | |
3588 default: | |
3589 if ((ddi_get_time() - swarg->svs_tos) | |
3590 >= VHCI_EXTFO_TIMEOUT) { | |
3591 swarg->svs_release_lun = 1; | |
3592 goto done; | |
3593 } | |
3594 return (0); | |
3595 } | |
3596 } else if (*((unsigned char *)statusp) == | |
3597 STATUS_RESERVATION_CONFLICT) { | |
3598 updt_paths = 1; | |
3599 } else if ((*((unsigned char *)statusp)) & | |
3600 (STATUS_BUSY | STATUS_QFULL)) { | |
3601 return (0); | |
3602 } | |
3603 if ((*((unsigned char *)statusp) == STATUS_GOOD) || | |
3604 (updt_paths == 1)) { | |
3605 /* | |
3606 * we got here because we had detected an | |
3607 * externally initiated failover; things | |
3608 * have settled down now, so let's | |
3609 * start up a task to update the | |
3610 * path states and target port group | |
3611 */ | |
3612 vlun->svl_efo_update_path = 1; | |
3613 swarg->svs_done = 1; | |
3614 vlun->svl_swarg = swarg; | |
3615 vlun->svl_flags |= VLUN_UPDATE_TPG; | |
3616 (void) taskq_dispatch(vhci->vhci_update_pathstates_taskq, | |
3617 vhci_update_pathstates, (void *)vlun, | |
3618 KM_SLEEP); | |
3619 return (0); | |
3620 } | |
3621 if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) { | |
3622 swarg->svs_release_lun = 1; | |
3623 goto done; | |
3624 } | |
3625 return (0); | |
3626 done: | |
3627 swarg->svs_done = 1; | |
3628 (void) taskq_dispatch(vhci->vhci_taskq, | |
3629 vhci_efo_done, (void *)swarg, KM_SLEEP); | |
3630 return (0); | |
3631 } | |
3632 | |
3633 /* | |
3634 * vhci_efo_done: | |
3635 * cleanly terminates scsi_watch and free up resources. | |
3636 * Called as taskq function in vhci_efo_watch_cb for EFO timeout condition | |
3637 * or by vhci_update_path_states invoked during external initiated | |
3638 * failover completion. | |
3639 */ | |
3640 static void | |
3641 vhci_efo_done(void *arg) | |
3642 { | |
3643 scsi_vhci_lun_t *vlun; | |
3644 scsi_vhci_swarg_t *swarg = (scsi_vhci_swarg_t *)arg; | |
3645 scsi_vhci_priv_t *svp = swarg->svs_svp; | |
3646 ASSERT(svp); | |
3647 | |
3648 vlun = svp->svp_svl; | |
3649 ASSERT(vlun); | |
3650 | |
3651 /* Wait for clean termination of scsi_watch */ | |
3652 (void) scsi_watch_request_terminate(svp->svp_sw_token, | |
7191
174d749b3f22
6520112 simultaneous DKIOCSTATE calls causes panic
tl223370
parents:
7121
diff
changeset
|
3653 SCSI_WATCH_TERMINATE_ALL_WAIT); |
4851 | 3654 svp->svp_sw_token = NULL; |
3655 | |
3656 /* release path and freeup resources to indicate failover completion */ | |
3657 mdi_rele_path(swarg->svs_pi); | |
3658 if (swarg->svs_release_lun) { | |
3659 VHCI_RELEASE_LUN(vlun); | |
3660 } | |
3661 kmem_free((void *)swarg, sizeof (*swarg)); | |
3662 } | |
3663 | |
3664 /* | |
3665 * Update the path states | |
3666 * vlun should be HELD when this is invoked. | |
3667 * Calls vhci_efo_done to cleanup resources allocated for EFO. | |
3668 */ | |
3669 void | |
3670 vhci_update_pathstates(void *arg) | |
3671 { | |
3672 mdi_pathinfo_t *pip, *npip; | |
3673 dev_info_t *dip, *pdip; | |
3674 struct scsi_failover_ops *fo; | |
3675 struct scsi_vhci_priv *svp; | |
3676 struct scsi_device *psd; | |
3677 struct scsi_path_opinfo opinfo; | |
3678 char *pclass, *tptr; | |
3679 struct scsi_vhci_lun *vlun = (struct scsi_vhci_lun *)arg; | |
3680 int sps; /* mdi_select_path() status */ | |
3681 char *cpath, *dpath; | |
3682 struct scsi_vhci *vhci; | |
3683 struct scsi_pkt *pkt; | |
3684 struct buf *bp; | |
3685 int reserve_conflict = 0; | |
3686 | |
3687 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
3688 dip = vlun->svl_dip; | |
3689 pip = npip = NULL; | |
3690 | |
3691 vhci = ddi_get_soft_state(vhci_softstate, | |
3692 ddi_get_instance(ddi_get_parent(dip))); | |
3693 | |
3694 sps = mdi_select_path(dip, NULL, (MDI_SELECT_ONLINE_PATH | | |
7461
1c206c17e7a2
6649625 MPxIO not trying on all available paths on device and path failures to storage
Sheshadri Vasudevan <Sheshadri.Vasudevan@Sun.COM>
parents:
7399
diff
changeset
|
3695 MDI_SELECT_STANDBY_PATH | MDI_SELECT_NO_PREFERRED), NULL, &npip); |
4851 | 3696 if ((npip == NULL) || (sps != MDI_SUCCESS)) { |
3697 goto done; | |
3698 } | |
3699 | |
3700 fo = vlun->svl_fops; | |
3701 do { | |
3702 pip = npip; | |
3703 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
3704 psd = svp->svp_psd; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3705 if (fo->sfo_path_get_opinfo(psd, &opinfo, |
4851 | 3706 vlun->svl_fops_ctpriv) != 0) { |
3707 sps = mdi_select_path(dip, NULL, | |
7461
1c206c17e7a2
6649625 MPxIO not trying on all available paths on device and path failures to storage
Sheshadri Vasudevan <Sheshadri.Vasudevan@Sun.COM>
parents:
7399
diff
changeset
|
3708 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH | |
1c206c17e7a2
6649625 MPxIO not trying on all available paths on device and path failures to storage
Sheshadri Vasudevan <Sheshadri.Vasudevan@Sun.COM>
parents:
7399
diff
changeset
|
3709 MDI_SELECT_NO_PREFERRED), pip, &npip); |
4851 | 3710 mdi_rele_path(pip); |
3711 continue; | |
3712 } | |
3713 | |
3714 if (mdi_prop_lookup_string(pip, "path-class", &pclass) != | |
3715 MDI_SUCCESS) { | |
3716 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3717 "!vhci_update_pathstates: prop lookup failed for " | |
3718 "path 0x%p\n", (void *)pip)); | |
3719 sps = mdi_select_path(dip, NULL, | |
7461
1c206c17e7a2
6649625 MPxIO not trying on all available paths on device and path failures to storage
Sheshadri Vasudevan <Sheshadri.Vasudevan@Sun.COM>
parents:
7399
diff
changeset
|
3720 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH | |
1c206c17e7a2
6649625 MPxIO not trying on all available paths on device and path failures to storage
Sheshadri Vasudevan <Sheshadri.Vasudevan@Sun.COM>
parents:
7399
diff
changeset
|
3721 MDI_SELECT_NO_PREFERRED), pip, &npip); |
4851 | 3722 mdi_rele_path(pip); |
3723 continue; | |
3724 } | |
3725 | |
3726 /* | |
3727 * Need to update the "path-class" property | |
3728 * value in the device tree if different | |
3729 * from the existing value. | |
3730 */ | |
3731 if (strcmp(pclass, opinfo.opinfo_path_attr) != 0) { | |
3732 (void) mdi_prop_update_string(pip, "path-class", | |
3733 opinfo.opinfo_path_attr); | |
3734 } | |
3735 | |
3736 /* | |
3737 * Only change the state if needed. i.e. Don't call | |
3738 * mdi_pi_set_state to ONLINE a path if its already | |
3739 * ONLINE. Same for STANDBY paths. | |
3740 */ | |
3741 | |
3742 if ((opinfo.opinfo_path_state == SCSI_PATH_ACTIVE || | |
3743 opinfo.opinfo_path_state == SCSI_PATH_ACTIVE_NONOPT)) { | |
3744 if (!(MDI_PI_IS_ONLINE(pip))) { | |
3745 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3746 "!vhci_update_pathstates: marking path" | |
3747 " 0x%p as ONLINE\n", (void *)pip)); | |
3748 pdip = mdi_pi_get_phci(pip); | |
3749 cpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3750 dpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3751 vhci_log(CE_NOTE, ddi_get_parent(dip), "!%s" | |
3752 " (%s%d): path %s (%s%d) target address %s" | |
3753 " is now ONLINE because of" | |
3754 " an externally initiated failover", | |
3755 ddi_pathname(dip, cpath), | |
3756 ddi_driver_name(dip), | |
3757 ddi_get_instance(dip), | |
3758 ddi_pathname(pdip, dpath), | |
3759 ddi_driver_name(pdip), | |
3760 ddi_get_instance(pdip), | |
3761 mdi_pi_get_addr(pip)); | |
3762 kmem_free(cpath, MAXPATHLEN); | |
3763 kmem_free(dpath, MAXPATHLEN); | |
3764 mdi_pi_set_state(pip, | |
3765 MDI_PATHINFO_STATE_ONLINE); | |
3766 mdi_pi_set_preferred(pip, | |
3767 opinfo.opinfo_preferred); | |
3768 tptr = kmem_alloc(strlen | |
3769 (opinfo.opinfo_path_attr)+1, KM_SLEEP); | |
3770 (void) strlcpy(tptr, opinfo.opinfo_path_attr, | |
3771 (strlen(opinfo.opinfo_path_attr)+1)); | |
3772 mutex_enter(&vlun->svl_mutex); | |
3773 if (vlun->svl_active_pclass != NULL) { | |
3774 kmem_free(vlun->svl_active_pclass, | |
3775 strlen(vlun->svl_active_pclass)+1); | |
3776 } | |
3777 vlun->svl_active_pclass = tptr; | |
3778 if (vlun->svl_waiting_for_activepath) { | |
3779 vlun->svl_waiting_for_activepath = 0; | |
3780 } | |
3781 mutex_exit(&vlun->svl_mutex); | |
3782 /* Check for Reservation Conflict */ | |
3783 bp = scsi_alloc_consistent_buf( | |
3784 &svp->svp_psd->sd_address, | |
3785 (struct buf *)NULL, DEV_BSIZE, B_READ, | |
3786 NULL, NULL); | |
3787 if (!bp) { | |
3788 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3789 "vhci_update_pathstates: " | |
3790 "!No resources (buf)\n")); | |
3791 mdi_rele_path(pip); | |
3792 goto done; | |
3793 } | |
3794 pkt = scsi_init_pkt(&svp->svp_psd->sd_address, | |
3795 NULL, bp, CDB_GROUP1, | |
3796 sizeof (struct scsi_arq_status), 0, | |
3797 PKT_CONSISTENT, NULL, NULL); | |
3798 if (pkt) { | |
3799 (void) scsi_setup_cdb((union scsi_cdb *) | |
3800 (uintptr_t)pkt->pkt_cdbp, | |
3801 SCMD_READ, 1, 1, 0); | |
3802 pkt->pkt_time = 3*30; | |
3803 pkt->pkt_flags = FLAG_NOINTR; | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3804 pkt->pkt_path_instance = |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3805 mdi_pi_get_path_instance(pip); |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3806 |
4851 | 3807 if ((scsi_transport(pkt) == |
3808 TRAN_ACCEPT) && (pkt->pkt_reason | |
3809 == CMD_CMPLT) && (SCBP_C(pkt) == | |
3810 STATUS_RESERVATION_CONFLICT)) { | |
3811 reserve_conflict = 1; | |
3812 } | |
3813 scsi_destroy_pkt(pkt); | |
3814 } | |
3815 scsi_free_consistent_buf(bp); | |
3816 } else if (MDI_PI_IS_ONLINE(pip)) { | |
3817 if (strcmp(pclass, opinfo.opinfo_path_attr) | |
3818 != 0) { | |
3819 mdi_pi_set_preferred(pip, | |
3820 opinfo.opinfo_preferred); | |
3821 mutex_enter(&vlun->svl_mutex); | |
3822 if (vlun->svl_active_pclass == NULL || | |
3823 strcmp(opinfo.opinfo_path_attr, | |
3824 vlun->svl_active_pclass) != 0) { | |
3825 mutex_exit(&vlun->svl_mutex); | |
3826 tptr = kmem_alloc(strlen | |
3827 (opinfo.opinfo_path_attr)+1, | |
3828 KM_SLEEP); | |
3829 (void) strlcpy(tptr, | |
3830 opinfo.opinfo_path_attr, | |
3831 (strlen | |
3832 (opinfo.opinfo_path_attr) | |
3833 +1)); | |
3834 mutex_enter(&vlun->svl_mutex); | |
3835 } else { | |
3836 /* | |
3837 * No need to update | |
3838 * svl_active_pclass | |
3839 */ | |
3840 tptr = NULL; | |
3841 mutex_exit(&vlun->svl_mutex); | |
3842 } | |
3843 if (tptr) { | |
3844 if (vlun->svl_active_pclass | |
3845 != NULL) { | |
3846 kmem_free(vlun-> | |
3847 svl_active_pclass, | |
3848 strlen(vlun-> | |
3849 svl_active_pclass) | |
3850 +1); | |
3851 } | |
3852 vlun->svl_active_pclass = tptr; | |
3853 mutex_exit(&vlun->svl_mutex); | |
3854 } | |
3855 } | |
3856 } | |
3857 } else if ((opinfo.opinfo_path_state == SCSI_PATH_INACTIVE) && | |
3858 !(MDI_PI_IS_STANDBY(pip))) { | |
3859 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3860 "!vhci_update_pathstates: marking path" | |
3861 " 0x%p as STANDBY\n", (void *)pip)); | |
3862 pdip = mdi_pi_get_phci(pip); | |
3863 cpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3864 dpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3865 vhci_log(CE_NOTE, ddi_get_parent(dip), "!%s" | |
3866 " (%s%d): path %s (%s%d) target address %s" | |
3867 " is now STANDBY because of" | |
3868 " an externally initiated failover", | |
3869 ddi_pathname(dip, cpath), | |
3870 ddi_driver_name(dip), | |
3871 ddi_get_instance(dip), | |
3872 ddi_pathname(pdip, dpath), | |
3873 ddi_driver_name(pdip), | |
3874 ddi_get_instance(pdip), | |
3875 mdi_pi_get_addr(pip)); | |
3876 kmem_free(cpath, MAXPATHLEN); | |
3877 kmem_free(dpath, MAXPATHLEN); | |
3878 mdi_pi_set_state(pip, | |
3879 MDI_PATHINFO_STATE_STANDBY); | |
3880 mdi_pi_set_preferred(pip, | |
3881 opinfo.opinfo_preferred); | |
3882 mutex_enter(&vlun->svl_mutex); | |
3883 if (vlun->svl_active_pclass != NULL) { | |
3884 if (strcmp(vlun->svl_active_pclass, | |
3885 opinfo.opinfo_path_attr) == 0) { | |
3886 kmem_free(vlun-> | |
3887 svl_active_pclass, | |
3888 strlen(vlun-> | |
3889 svl_active_pclass)+1); | |
3890 vlun->svl_active_pclass = NULL; | |
3891 } | |
3892 } | |
3893 mutex_exit(&vlun->svl_mutex); | |
3894 } | |
3895 (void) mdi_prop_free(pclass); | |
3896 sps = mdi_select_path(dip, NULL, | |
7461
1c206c17e7a2
6649625 MPxIO not trying on all available paths on device and path failures to storage
Sheshadri Vasudevan <Sheshadri.Vasudevan@Sun.COM>
parents:
7399
diff
changeset
|
3897 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH | |
1c206c17e7a2
6649625 MPxIO not trying on all available paths on device and path failures to storage
Sheshadri Vasudevan <Sheshadri.Vasudevan@Sun.COM>
parents:
7399
diff
changeset
|
3898 MDI_SELECT_NO_PREFERRED), pip, &npip); |
4851 | 3899 mdi_rele_path(pip); |
3900 | |
3901 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
3902 | |
3903 /* | |
3904 * Check to see if this vlun has an active SCSI-II RESERVE. If so | |
3905 * clear the reservation by sending a reset, so the host doesn't | |
3906 * receive a reservation conflict. | |
3907 * Reset VLUN_RESERVE_ACTIVE_FLG for this vlun. Also notify ssd | |
3908 * of the reset, explicitly. | |
3909 */ | |
3910 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
3911 if (reserve_conflict && (vlun->svl_xlf_capable == 0)) { | |
3912 (void) vhci_recovery_reset(vlun, | |
3913 &svp->svp_psd->sd_address, FALSE, | |
3914 VHCI_DEPTH_TARGET); | |
3915 } | |
3916 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
3917 mutex_enter(&vhci->vhci_mutex); | |
3918 scsi_hba_reset_notify_callback(&vhci->vhci_mutex, | |
3919 &vhci->vhci_reset_notify_listf); | |
3920 mutex_exit(&vhci->vhci_mutex); | |
3921 } | |
3922 if (vlun->svl_flags & VLUN_UPDATE_TPG) { | |
3923 /* | |
3924 * Update the AccessState of related MP-API TPGs | |
3925 */ | |
3926 (void) vhci_mpapi_update_tpg_acc_state_for_lu(vhci, vlun); | |
3927 vlun->svl_flags &= ~VLUN_UPDATE_TPG; | |
3928 } | |
3929 done: | |
3930 if (vlun->svl_efo_update_path) { | |
3931 vlun->svl_efo_update_path = 0; | |
3932 vhci_efo_done(vlun->svl_swarg); | |
3933 vlun->svl_swarg = 0; | |
3934 } | |
3935 VHCI_RELEASE_LUN(vlun); | |
3936 } | |
3937 | |
3938 /* ARGSUSED */ | |
3939 static int | |
3940 vhci_pathinfo_init(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
3941 { | |
3942 scsi_hba_tran_t *hba = NULL; | |
3943 struct scsi_device *psd = NULL; | |
3944 scsi_vhci_lun_t *vlun = NULL; | |
3945 dev_info_t *pdip = NULL; | |
3946 dev_info_t *tgt_dip; | |
3947 struct scsi_vhci *vhci; | |
3948 char *guid; | |
3949 scsi_vhci_priv_t *svp = NULL; | |
3950 int rval = MDI_FAILURE; | |
3951 int vlun_alloced = 0; | |
3952 | |
3953 ASSERT(vdip != NULL); | |
3954 ASSERT(pip != NULL); | |
3955 | |
3956 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
3957 ASSERT(vhci != NULL); | |
3958 | |
3959 pdip = mdi_pi_get_phci(pip); | |
3960 ASSERT(pdip != NULL); | |
3961 | |
3962 hba = ddi_get_driver_private(pdip); | |
3963 ASSERT(hba != NULL); | |
3964 | |
3965 tgt_dip = mdi_pi_get_client(pip); | |
3966 ASSERT(tgt_dip != NULL); | |
3967 | |
3968 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, tgt_dip, PROPFLAGS, | |
3969 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) { | |
3970 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3971 "vhci_pathinfo_init: lun guid property failed")); | |
3972 goto failure; | |
3973 } | |
3974 | |
3975 vlun = vhci_lun_lookup_alloc(tgt_dip, guid, &vlun_alloced); | |
3976 ddi_prop_free(guid); | |
3977 | |
3978 vlun->svl_dip = tgt_dip; | |
3979 | |
3980 svp = kmem_zalloc(sizeof (*svp), KM_SLEEP); | |
3981 svp->svp_svl = vlun; | |
3982 | |
3983 vlun->svl_lb_policy_save = mdi_get_lb_policy(tgt_dip); | |
3984 mutex_init(&svp->svp_mutex, NULL, MUTEX_DRIVER, NULL); | |
3985 cv_init(&svp->svp_cv, NULL, CV_DRIVER, NULL); | |
3986 | |
3987 psd = kmem_zalloc(sizeof (*psd), KM_SLEEP); | |
3988 mutex_init(&psd->sd_mutex, NULL, MUTEX_DRIVER, NULL); | |
3989 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3990 if (hba->tran_hba_flags & SCSI_HBA_ADDR_COMPLEX) { |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3991 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3992 * For a SCSI_HBA_ADDR_COMPLEX transport we store a pointer to |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3993 * scsi_device in the scsi_address structure. This allows an |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3994 * an HBA driver to find its scsi_device(9S) and |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3995 * per-scsi_device(9S) HBA private data given a |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3996 * scsi_address(9S) by using scsi_address_device(9F) and |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3997 * scsi_device_hba_private_get(9F)). |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3998 */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
3999 psd->sd_address.a.a_sd = psd; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4000 } else if (hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE) { |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4001 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4002 * Clone transport structure if requested, so |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4003 * Self enumerating HBAs always need to use cloning |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4004 */ |
4851 | 4005 scsi_hba_tran_t *clone = |
4006 kmem_alloc(sizeof (scsi_hba_tran_t), KM_SLEEP); | |
4007 bcopy(hba, clone, sizeof (scsi_hba_tran_t)); | |
4008 hba = clone; | |
4009 hba->tran_sd = psd; | |
4010 } else { | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4011 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4012 * SPI pHCI unit-address. If we ever need to support this |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4013 * we could set a.spi.a_target/a.spi.a_lun based on pathinfo |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4014 * node unit-address properties. For now we fail... |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4015 */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4016 goto failure; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4017 } |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4018 |
4851 | 4019 psd->sd_dev = tgt_dip; |
4020 psd->sd_address.a_hba_tran = hba; | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4021 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4022 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4023 * Mark scsi_device as being associated with a pathinfo node. For |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4024 * a scsi_device structure associated with a devinfo node, |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4025 * scsi_ctlops_initchild sets this field to NULL. |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4026 */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4027 psd->sd_pathinfo = pip; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4028 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4029 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4030 * LEGACY: sd_private: set for older mpxio-capable pHCI drivers with |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4031 * too much scsi_vhci/mdi/ndi knowledge. Remove this code when all |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4032 * mpxio-capable pHCI drivers use SCSA enumeration services (or at |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4033 * least have been changed to use sd_pathinfo instead). |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4034 */ |
4851 | 4035 psd->sd_private = (caddr_t)pip; |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4036 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4037 /* See scsi_hba.c for info on sd_tran_safe kludge */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4038 psd->sd_tran_safe = hba; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4039 |
4851 | 4040 svp->svp_psd = psd; |
4041 mdi_pi_set_vhci_private(pip, (caddr_t)svp); | |
4042 | |
4043 /* | |
4044 * call hba's target init entry point if it exists | |
4045 */ | |
4046 if (hba->tran_tgt_init != NULL) { | |
4047 if ((rval = (*hba->tran_tgt_init)(pdip, tgt_dip, | |
4048 hba, psd)) != DDI_SUCCESS) { | |
4049 VHCI_DEBUG(1, (CE_WARN, pdip, | |
4050 "!vhci_pathinfo_init: tran_tgt_init failed for " | |
4051 "path=0x%p rval=%x", (void *)pip, rval)); | |
4052 goto failure; | |
4053 } | |
4054 } | |
4055 | |
4056 svp->svp_new_path = 1; | |
4057 | |
4058 psd->sd_inq = NULL; | |
4059 | |
4060 VHCI_DEBUG(4, (CE_NOTE, NULL, "!vhci_pathinfo_init: path:%p\n", | |
4061 (void *)pip)); | |
4062 return (MDI_SUCCESS); | |
4063 | |
4064 failure: | |
4065 if (psd) { | |
4066 mutex_destroy(&psd->sd_mutex); | |
4067 kmem_free(psd, sizeof (*psd)); | |
4068 } | |
4069 if (svp) { | |
4070 mdi_pi_set_vhci_private(pip, NULL); | |
4071 mutex_destroy(&svp->svp_mutex); | |
4072 cv_destroy(&svp->svp_cv); | |
4073 kmem_free(svp, sizeof (*svp)); | |
4074 } | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4075 if (hba && (hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE)) |
4851 | 4076 kmem_free(hba, sizeof (scsi_hba_tran_t)); |
4077 | |
4078 if (vlun_alloced) | |
4079 vhci_lun_free(tgt_dip); | |
4080 | |
4081 return (rval); | |
4082 } | |
4083 | |
4084 /* ARGSUSED */ | |
4085 static int | |
4086 vhci_pathinfo_uninit(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
4087 { | |
4088 scsi_hba_tran_t *hba = NULL; | |
4089 struct scsi_device *psd = NULL; | |
4090 dev_info_t *pdip = NULL; | |
4091 dev_info_t *cdip = NULL; | |
4092 scsi_vhci_priv_t *svp = NULL; | |
4093 | |
4094 ASSERT(vdip != NULL); | |
4095 ASSERT(pip != NULL); | |
4096 | |
4097 pdip = mdi_pi_get_phci(pip); | |
4098 ASSERT(pdip != NULL); | |
4099 | |
4100 cdip = mdi_pi_get_client(pip); | |
4101 ASSERT(cdip != NULL); | |
4102 | |
4103 hba = ddi_get_driver_private(pdip); | |
4104 ASSERT(hba != NULL); | |
4105 | |
4106 vhci_mpapi_set_path_state(vdip, pip, MP_DRVR_PATH_STATE_REMOVED); | |
4107 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
4108 if (svp == NULL) { | |
4109 /* path already freed. Nothing to do. */ | |
4110 return (MDI_SUCCESS); | |
4111 } | |
4112 | |
4113 psd = svp->svp_psd; | |
4114 ASSERT(psd != NULL); | |
4115 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4116 if (hba->tran_hba_flags & SCSI_HBA_ADDR_COMPLEX) { |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4117 /* Verify plumbing */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4118 ASSERT(psd->sd_address.a_hba_tran == hba); |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4119 ASSERT(psd->sd_address.a.a_sd == psd); |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4120 } else if (hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE) { |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4121 /* Switch to cloned scsi_hba_tran(9S) structure */ |
4851 | 4122 hba = psd->sd_address.a_hba_tran; |
4123 ASSERT(hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE); | |
4124 ASSERT(hba->tran_sd == psd); | |
4125 } | |
4126 | |
4127 if (hba->tran_tgt_free != NULL) { | |
4128 (*hba->tran_tgt_free) (pdip, cdip, hba, psd); | |
4129 } | |
4130 mutex_destroy(&psd->sd_mutex); | |
4131 if (hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE) { | |
4132 kmem_free(hba, sizeof (*hba)); | |
4133 } | |
4134 | |
4135 mdi_pi_set_vhci_private(pip, NULL); | |
4136 kmem_free((caddr_t)psd, sizeof (*psd)); | |
4137 | |
4138 mutex_destroy(&svp->svp_mutex); | |
4139 cv_destroy(&svp->svp_cv); | |
4140 kmem_free((caddr_t)svp, sizeof (*svp)); | |
4141 | |
4142 /* | |
4143 * If this is the last path to the client, | |
4144 * then free up the vlun as well. | |
4145 */ | |
4146 if (mdi_client_get_path_count(cdip) == 1) { | |
4147 vhci_lun_free(cdip); | |
4148 } | |
4149 | |
4150 VHCI_DEBUG(4, (CE_NOTE, NULL, "!vhci_pathinfo_uninit: path=0x%p\n", | |
4151 (void *)pip)); | |
4152 return (MDI_SUCCESS); | |
4153 } | |
4154 | |
4155 /* ARGSUSED */ | |
4156 static int | |
4157 vhci_pathinfo_state_change(dev_info_t *vdip, mdi_pathinfo_t *pip, | |
4158 mdi_pathinfo_state_t state, uint32_t ext_state, int flags) | |
4159 { | |
4160 int rval = MDI_SUCCESS; | |
4161 scsi_vhci_priv_t *svp; | |
4162 scsi_vhci_lun_t *vlun; | |
4163 int held; | |
4164 int op = (flags & 0xf00) >> 8; | |
4165 struct scsi_vhci *vhci; | |
4166 | |
4167 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
4168 | |
4169 if (flags & MDI_EXT_STATE_CHANGE) { | |
4170 /* | |
4171 * We do not want to issue any commands down the path in case | |
4172 * sync flag is set. Lower layers might not be ready to accept | |
4173 * any I/O commands. | |
4174 */ | |
4175 if (op == DRIVER_DISABLE) | |
4176 return (MDI_SUCCESS); | |
4177 | |
4178 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
4179 if (svp == NULL) { | |
4180 return (MDI_FAILURE); | |
4181 } | |
4182 vlun = svp->svp_svl; | |
4183 | |
4184 if (flags & MDI_BEFORE_STATE_CHANGE) { | |
4185 /* | |
4186 * Hold the LUN. | |
4187 */ | |
4188 VHCI_HOLD_LUN(vlun, VH_SLEEP, held); | |
4189 if (flags & MDI_DISABLE_OP) { | |
4190 /* | |
4191 * Issue scsi reset if it happens to be | |
4192 * reserved path. | |
4193 */ | |
4194 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
4195 /* | |
4196 * if reservation pending on | |
4197 * this path, dont' mark the | |
4198 * path busy | |
4199 */ | |
4200 if (op == DRIVER_DISABLE_TRANSIENT) { | |
4201 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
4202 "!vhci_pathinfo" | |
4203 "_state_change (pip:%p): " | |
4204 " reservation: fail busy\n", | |
4205 (void *)pip)); | |
4206 return (MDI_FAILURE); | |
4207 } | |
4208 if (pip == vlun->svl_resrv_pip) { | |
4209 if (vhci_recovery_reset( | |
4210 svp->svp_svl, | |
4211 &svp->svp_psd->sd_address, | |
4212 TRUE, | |
4213 VHCI_DEPTH_TARGET) == 0) { | |
4214 VHCI_DEBUG(1, | |
4215 (CE_NOTE, NULL, | |
4216 "!vhci_pathinfo" | |
4217 "_state_change " | |
4218 " (pip:%p): " | |
4219 "reset failed, " | |
4220 "give up!\n", | |
4221 (void *)pip)); | |
4222 } | |
4223 vlun->svl_flags &= | |
4224 ~VLUN_RESERVE_ACTIVE_FLG; | |
4225 } | |
4226 } | |
4227 } else if (flags & MDI_ENABLE_OP) { | |
4228 if (((vhci->vhci_conf_flags & | |
4229 VHCI_CONF_FLAGS_AUTO_FAILBACK) == | |
4230 VHCI_CONF_FLAGS_AUTO_FAILBACK) && | |
4231 MDI_PI_IS_USER_DISABLE(pip) && | |
4232 MDI_PI_IS_STANDBY(pip)) { | |
4233 struct scsi_failover_ops *fo; | |
4234 char *best_pclass, *pclass = NULL; | |
4235 int best_class, rv; | |
4236 /* | |
4237 * Failback if enabling a standby path | |
4238 * and it is the primary class or | |
4239 * preferred class | |
4240 */ | |
4241 best_class = mdi_pi_get_preferred(pip); | |
4242 if (best_class == 0) { | |
4243 /* | |
4244 * if not preferred - compare | |
4245 * path-class with class | |
4246 */ | |
4247 fo = vlun->svl_fops; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4248 (void) fo->sfo_pathclass_next( |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4249 NULL, &best_pclass, |
4851 | 4250 vlun->svl_fops_ctpriv); |
4251 pclass = NULL; | |
4252 rv = mdi_prop_lookup_string(pip, | |
4253 "path-class", &pclass); | |
4254 if (rv != MDI_SUCCESS || | |
4255 pclass == NULL) { | |
4256 vhci_log(CE_NOTE, vdip, | |
4257 "!path-class " | |
4258 " lookup " | |
4259 "failed. rv: %d" | |
4260 "class: %p", rv, | |
4261 (void *)pclass); | |
4262 } else if (strncmp(pclass, | |
4263 best_pclass, | |
4264 strlen(best_pclass)) == 0) { | |
4265 best_class = 1; | |
4266 } | |
4267 if (rv == MDI_SUCCESS && | |
4268 pclass != NULL) { | |
4269 rv = mdi_prop_free( | |
4270 pclass); | |
4271 if (rv != | |
4272 DDI_PROP_SUCCESS) { | |
4273 vhci_log( | |
4274 CE_NOTE, | |
4275 vdip, | |
4276 "!path-" | |
4277 "class" | |
4278 " free" | |
4279 " failed" | |
4280 " rv: %d" | |
4281 " class: " | |
4282 "%p", | |
4283 rv, | |
4284 (void *) | |
4285 pclass); | |
4286 } | |
4287 } | |
4288 } | |
4289 if (best_class == 1) { | |
4290 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
4291 "preferred path: %p " | |
4292 "USER_DISABLE->USER_ENABLE " | |
4293 "transition for lun %s\n", | |
4294 (void *)pip, | |
4295 vlun->svl_lun_wwn)); | |
4296 (void) taskq_dispatch( | |
4297 vhci->vhci_taskq, | |
4298 vhci_initiate_auto_failback, | |
4299 (void *) vlun, KM_SLEEP); | |
4300 } | |
4301 } | |
4302 /* | |
4303 * if PGR is active, revalidate key and | |
4304 * register on this path also, if key is | |
4305 * still valid | |
4306 */ | |
4307 sema_p(&vlun->svl_pgr_sema); | |
4308 if (vlun->svl_pgr_active) | |
4309 (void) | |
4310 vhci_pgr_validate_and_register(svp); | |
4311 sema_v(&vlun->svl_pgr_sema); | |
4312 /* | |
4313 * Inform target driver about any | |
4314 * reservations to be reinstated if target | |
4315 * has dropped reservation during the busy | |
4316 * period. | |
4317 */ | |
4318 mutex_enter(&vhci->vhci_mutex); | |
4319 scsi_hba_reset_notify_callback( | |
4320 &vhci->vhci_mutex, | |
4321 &vhci->vhci_reset_notify_listf); | |
4322 mutex_exit(&vhci->vhci_mutex); | |
4323 } | |
4324 } | |
4325 if (flags & MDI_AFTER_STATE_CHANGE) { | |
4326 if (flags & MDI_ENABLE_OP) { | |
4327 mutex_enter(&vhci_global_mutex); | |
4328 cv_broadcast(&vhci_cv); | |
4329 mutex_exit(&vhci_global_mutex); | |
4330 } | |
4331 if (vlun->svl_setcap_done) { | |
4332 (void) vhci_pHCI_cap(&svp->svp_psd->sd_address, | |
4333 "sector-size", vlun->svl_sector_size, | |
4334 1, pip); | |
4335 } | |
4336 | |
4337 /* | |
4338 * Release the LUN | |
4339 */ | |
4340 VHCI_RELEASE_LUN(vlun); | |
4341 | |
4342 /* | |
4343 * Path transition is complete. | |
4344 * Run callback to indicate target driver to | |
4345 * retry to prevent IO starvation. | |
4346 */ | |
4347 if (scsi_callback_id != 0) { | |
4348 ddi_run_callback(&scsi_callback_id); | |
4349 } | |
4350 } | |
4351 } else { | |
4352 switch (state) { | |
4353 case MDI_PATHINFO_STATE_ONLINE: | |
4354 rval = vhci_pathinfo_online(vdip, pip, flags); | |
4355 break; | |
4356 | |
4357 case MDI_PATHINFO_STATE_OFFLINE: | |
4358 rval = vhci_pathinfo_offline(vdip, pip, flags); | |
4359 break; | |
4360 | |
4361 default: | |
4362 break; | |
4363 } | |
4364 /* | |
4365 * Path transition is complete. | |
4366 * Run callback to indicate target driver to | |
4367 * retry to prevent IO starvation. | |
4368 */ | |
4369 if ((rval == MDI_SUCCESS) && (scsi_callback_id != 0)) { | |
4370 ddi_run_callback(&scsi_callback_id); | |
4371 } | |
4372 return (rval); | |
4373 } | |
4374 | |
4375 return (MDI_SUCCESS); | |
4376 } | |
4377 | |
4378 /* | |
4379 * Parse the mpxio load balancing options. The datanameptr | |
4380 * will point to a string containing the load-balance-options value. | |
4381 * The load-balance-options value will be a property that | |
4382 * defines the load-balance algorithm and any arguments to that | |
4383 * algorithm. | |
4384 * For example: | |
4385 * device-type-mpxio-options-list= | |
4386 * "device-type=SUN SENA", "load-balance-options=logical-block-options" | |
4387 * "device-type=SUN SE6920", "round-robin-options"; | |
4388 * logical-block-options="load-balance=logical-block", "region-size=15"; | |
4389 * round-robin-options="load-balance=round-robin"; | |
4390 * | |
4391 * If the load-balance is not defined the load balance algorithm will | |
4392 * default to the global setting. There will be default values assigned | |
4393 * to the arguments (region-size=18) and if an argument is one | |
4394 * that is not known, it will be ignored. | |
4395 */ | |
4396 static void | |
4397 vhci_parse_mpxio_lb_options(dev_info_t *dip, dev_info_t *cdip, | |
4398 caddr_t datanameptr) | |
4399 { | |
4400 char *dataptr, *next_entry; | |
4401 caddr_t config_list = NULL; | |
4402 int config_list_len = 0, list_len = 0; | |
4403 int region_size = -1; | |
4404 client_lb_t load_balance; | |
4405 | |
4406 if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, datanameptr, | |
4407 (caddr_t)&config_list, &config_list_len) != DDI_PROP_SUCCESS) { | |
4408 return; | |
4409 } | |
4410 | |
4411 list_len = config_list_len; | |
4412 next_entry = config_list; | |
4413 while (config_list_len > 0) { | |
4414 dataptr = next_entry; | |
4415 | |
4416 if (strncmp(mdi_load_balance, dataptr, | |
4417 strlen(mdi_load_balance)) == 0) { | |
4418 /* get the load-balance scheme */ | |
4419 dataptr += strlen(mdi_load_balance) + 1; | |
4420 if (strcmp(dataptr, LOAD_BALANCE_PROP_RR) == 0) { | |
4421 (void) mdi_set_lb_policy(cdip, LOAD_BALANCE_RR); | |
4422 load_balance = LOAD_BALANCE_RR; | |
4423 } else if (strcmp(dataptr, | |
4424 LOAD_BALANCE_PROP_LBA) == 0) { | |
4425 (void) mdi_set_lb_policy(cdip, | |
4426 LOAD_BALANCE_LBA); | |
4427 load_balance = LOAD_BALANCE_LBA; | |
4428 } else if (strcmp(dataptr, | |
4429 LOAD_BALANCE_PROP_NONE) == 0) { | |
4430 (void) mdi_set_lb_policy(cdip, | |
4431 LOAD_BALANCE_NONE); | |
4432 load_balance = LOAD_BALANCE_NONE; | |
4433 } | |
4434 } else if (strncmp(dataptr, LOGICAL_BLOCK_REGION_SIZE, | |
4435 strlen(LOGICAL_BLOCK_REGION_SIZE)) == 0) { | |
4436 int i = 0; | |
4437 char *ptr; | |
4438 char *tmp; | |
4439 | |
4440 tmp = dataptr + (strlen(LOGICAL_BLOCK_REGION_SIZE) + 1); | |
4441 /* check for numeric value */ | |
4442 for (ptr = tmp; i < strlen(tmp); i++, ptr++) { | |
4443 if (!isdigit(*ptr)) { | |
4444 cmn_err(CE_WARN, | |
4445 "Illegal region size: %s." | |
4446 " Setting to default value: %d", | |
4447 tmp, | |
4448 LOAD_BALANCE_DEFAULT_REGION_SIZE); | |
4449 region_size = | |
4450 LOAD_BALANCE_DEFAULT_REGION_SIZE; | |
4451 break; | |
4452 } | |
4453 } | |
4454 if (i >= strlen(tmp)) { | |
4455 region_size = stoi(&tmp); | |
4456 } | |
4457 (void) mdi_set_lb_region_size(cdip, region_size); | |
4458 } | |
4459 config_list_len -= (strlen(next_entry) + 1); | |
4460 next_entry += strlen(next_entry) + 1; | |
4461 } | |
4462 #ifdef DEBUG | |
4463 if ((region_size >= 0) && (load_balance != LOAD_BALANCE_LBA)) { | |
4464 VHCI_DEBUG(1, (CE_NOTE, dip, | |
4465 "!vhci_parse_mpxio_lb_options: region-size: %d" | |
4466 "only valid for load-balance=logical-block\n", | |
4467 region_size)); | |
4468 } | |
4469 #endif | |
4470 if ((region_size == -1) && (load_balance == LOAD_BALANCE_LBA)) { | |
4471 VHCI_DEBUG(1, (CE_NOTE, dip, | |
4472 "!vhci_parse_mpxio_lb_options: No region-size" | |
4473 " defined load-balance=logical-block." | |
4474 " Default to: %d\n", LOAD_BALANCE_DEFAULT_REGION_SIZE)); | |
4475 (void) mdi_set_lb_region_size(cdip, | |
4476 LOAD_BALANCE_DEFAULT_REGION_SIZE); | |
4477 } | |
4478 if (list_len > 0) { | |
4479 kmem_free(config_list, list_len); | |
4480 } | |
4481 } | |
4482 | |
4483 /* | |
4484 * Parse the device-type-mpxio-options-list looking for the key of | |
4485 * "load-balance-options". If found, parse the load balancing options. | |
4486 * Check the comment of the vhci_get_device_type_mpxio_options() | |
4487 * for the device-type-mpxio-options-list. | |
4488 */ | |
4489 static void | |
4490 vhci_parse_mpxio_options(dev_info_t *dip, dev_info_t *cdip, | |
4491 caddr_t datanameptr, int list_len) | |
4492 { | |
4493 char *dataptr; | |
4494 int len; | |
4495 | |
4496 /* | |
4497 * get the data list | |
4498 */ | |
4499 dataptr = datanameptr; | |
4500 len = 0; | |
4501 while (len < list_len && | |
4502 strncmp(dataptr, DEVICE_TYPE_STR, strlen(DEVICE_TYPE_STR)) | |
4503 != 0) { | |
4504 if (strncmp(dataptr, LOAD_BALANCE_OPTIONS, | |
4505 strlen(LOAD_BALANCE_OPTIONS)) == 0) { | |
4506 len += strlen(LOAD_BALANCE_OPTIONS) + 1; | |
4507 dataptr += strlen(LOAD_BALANCE_OPTIONS) + 1; | |
4508 vhci_parse_mpxio_lb_options(dip, cdip, dataptr); | |
4509 } | |
4510 len += strlen(dataptr) + 1; | |
4511 dataptr += strlen(dataptr) + 1; | |
4512 } | |
4513 } | |
4514 | |
4515 /* | |
4516 * Check the inquriy string returned from the device wiith the device-type | |
4517 * Check for the existence of the device-type-mpxio-options-list and | |
4518 * if found parse the list checking for a match with the device-type | |
4519 * value and the inquiry string returned from the device. If a match | |
4520 * is found, parse the mpxio options list. The format of the | |
4521 * device-type-mpxio-options-list is: | |
4522 * device-type-mpxio-options-list= | |
4523 * "device-type=SUN SENA", "load-balance-options=logical-block-options" | |
4524 * "device-type=SUN SE6920", "round-robin-options"; | |
4525 * logical-block-options="load-balance=logical-block", "region-size=15"; | |
4526 * round-robin-options="load-balance=round-robin"; | |
4527 */ | |
4528 void | |
4529 vhci_get_device_type_mpxio_options(dev_info_t *dip, dev_info_t *cdip, | |
4530 struct scsi_device *devp) | |
4531 { | |
4532 | |
4533 caddr_t config_list = NULL; | |
4534 caddr_t vidptr, datanameptr; | |
4535 int vidlen, dupletlen = 0; | |
4536 int config_list_len = 0, len; | |
4537 struct scsi_inquiry *inq = devp->sd_inq; | |
4538 | |
4539 /* | |
4540 * look up the device-type-mpxio-options-list and walk thru | |
4541 * the list compare the vendor ids of the earlier inquiry command and | |
4542 * with those vids in the list if there is a match, lookup | |
4543 * the mpxio-options value | |
4544 */ | |
4545 if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, | |
4546 MPXIO_OPTIONS_LIST, | |
4547 (caddr_t)&config_list, &config_list_len) == DDI_PROP_SUCCESS) { | |
4548 | |
4549 /* | |
4550 * Compare vids in each duplet - if it matches, | |
4551 * parse the mpxio options list. | |
4552 */ | |
4553 for (len = config_list_len, vidptr = config_list; len > 0; | |
4554 len -= dupletlen) { | |
4555 | |
4556 dupletlen = 0; | |
4557 | |
4558 if (strlen(vidptr) != 0 && | |
4559 strncmp(vidptr, DEVICE_TYPE_STR, | |
4560 strlen(DEVICE_TYPE_STR)) == 0) { | |
4561 /* point to next duplet */ | |
4562 datanameptr = vidptr + strlen(vidptr) + 1; | |
4563 /* add len of this duplet */ | |
4564 dupletlen += strlen(vidptr) + 1; | |
4565 /* get to device type */ | |
4566 vidptr += strlen(DEVICE_TYPE_STR) + 1; | |
4567 vidlen = strlen(vidptr); | |
4568 if ((vidlen != 0) && | |
4569 bcmp(inq->inq_vid, vidptr, vidlen) == 0) { | |
4570 vhci_parse_mpxio_options(dip, cdip, | |
4571 datanameptr, len - dupletlen); | |
4572 break; | |
4573 } | |
4574 /* get to next duplet */ | |
4575 vidptr += strlen(vidptr) + 1; | |
4576 } | |
4577 /* get to the next device-type */ | |
4578 while (len - dupletlen > 0 && | |
4579 strlen(vidptr) != 0 && | |
4580 strncmp(vidptr, DEVICE_TYPE_STR, | |
4581 strlen(DEVICE_TYPE_STR)) != 0) { | |
4582 dupletlen += strlen(vidptr) + 1; | |
4583 vidptr += strlen(vidptr) + 1; | |
4584 } | |
4585 } | |
4586 if (config_list_len > 0) { | |
4587 kmem_free(config_list, config_list_len); | |
4588 } | |
4589 } | |
4590 } | |
4591 | |
4592 static int | |
4593 vhci_update_pathinfo(struct scsi_device *psd, mdi_pathinfo_t *pip, | |
4594 struct scsi_failover_ops *fo, | |
4595 scsi_vhci_lun_t *vlun, | |
4596 struct scsi_vhci *vhci) | |
4597 { | |
4598 struct scsi_path_opinfo opinfo; | |
4599 char *pclass, *best_pclass; | |
4600 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4601 if (fo->sfo_path_get_opinfo(psd, &opinfo, vlun->svl_fops_ctpriv) != 0) { |
4851 | 4602 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_update_pathinfo: " |
4603 "Failed to get operation info for path:%p\n", (void *)pip)); | |
4604 return (MDI_FAILURE); | |
4605 } | |
4606 /* set the xlf capable flag in the vlun for future use */ | |
4607 vlun->svl_xlf_capable = opinfo.opinfo_xlf_capable; | |
4608 (void) mdi_prop_update_string(pip, "path-class", | |
4609 opinfo.opinfo_path_attr); | |
4610 | |
4611 pclass = opinfo.opinfo_path_attr; | |
4612 if (opinfo.opinfo_path_state == SCSI_PATH_ACTIVE) { | |
4613 mutex_enter(&vlun->svl_mutex); | |
4614 if (vlun->svl_active_pclass != NULL) { | |
4615 if (strcmp(vlun->svl_active_pclass, pclass) != 0) { | |
4616 mutex_exit(&vlun->svl_mutex); | |
4617 /* | |
4618 * Externally initiated failover has happened; | |
4619 * force the path state to be STANDBY/ONLINE, | |
4620 * next IO will trigger failover and thus | |
4621 * sync-up the pathstates. Reason we don't | |
4622 * sync-up immediately by invoking | |
4623 * vhci_update_pathstates() is because it | |
4624 * needs a VHCI_HOLD_LUN() and we don't | |
4625 * want to block here. | |
4626 * | |
4627 * Further, if the device is an ALUA device, | |
4628 * then failure to exactly match 'pclass' and | |
4629 * 'svl_active_pclass'(as is the case here) | |
4630 * indicates that the currently active path | |
4631 * is a 'non-optimized' path - which means | |
4632 * that 'svl_active_pclass' needs to be | |
4633 * replaced with opinfo.opinfo_path_state | |
4634 * value. | |
4635 */ | |
4636 | |
4637 if (SCSI_FAILOVER_IS_TPGS(vlun->svl_fops)) { | |
4638 char *tptr; | |
4639 | |
4640 /* | |
4641 * The device is ALUA compliant. The | |
4642 * state need to be changed to online | |
4643 * rather than standby state which is | |
4644 * done typically for a asymmetric | |
4645 * device that is non ALUA compliant. | |
4646 */ | |
4647 mdi_pi_set_state(pip, | |
4648 MDI_PATHINFO_STATE_ONLINE); | |
4649 tptr = kmem_alloc(strlen | |
4650 (opinfo.opinfo_path_attr)+1, | |
4651 KM_SLEEP); | |
4652 (void) strlcpy(tptr, | |
4653 opinfo.opinfo_path_attr, | |
4654 (strlen(opinfo.opinfo_path_attr) | |
4655 +1)); | |
4656 mutex_enter(&vlun->svl_mutex); | |
4657 kmem_free(vlun->svl_active_pclass, | |
4658 strlen(vlun->svl_active_pclass)+1); | |
4659 vlun->svl_active_pclass = tptr; | |
4660 mutex_exit(&vlun->svl_mutex); | |
4661 } else { | |
4662 /* | |
4663 * Non ALUA device case. | |
4664 */ | |
4665 mdi_pi_set_state(pip, | |
4666 MDI_PATHINFO_STATE_STANDBY); | |
4667 } | |
4668 vlun->svl_fo_support = opinfo.opinfo_mode; | |
4669 mdi_pi_set_preferred(pip, | |
4670 opinfo.opinfo_preferred); | |
4671 return (MDI_SUCCESS); | |
4672 } | |
4673 } else { | |
4674 char *tptr; | |
4675 | |
4676 /* | |
4677 * lets release the mutex before we try to | |
4678 * allocate since the potential to sleep is | |
4679 * possible. | |
4680 */ | |
4681 mutex_exit(&vlun->svl_mutex); | |
4682 tptr = kmem_alloc(strlen(pclass)+1, KM_SLEEP); | |
4683 (void) strlcpy(tptr, pclass, (strlen(pclass)+1)); | |
4684 mutex_enter(&vlun->svl_mutex); | |
4685 vlun->svl_active_pclass = tptr; | |
4686 } | |
4687 mutex_exit(&vlun->svl_mutex); | |
4688 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_ONLINE); | |
4689 vlun->svl_waiting_for_activepath = 0; | |
4690 } else if (opinfo.opinfo_path_state == SCSI_PATH_ACTIVE_NONOPT) { | |
4691 mutex_enter(&vlun->svl_mutex); | |
4692 if (vlun->svl_active_pclass == NULL) { | |
4693 char *tptr; | |
4694 | |
4695 mutex_exit(&vlun->svl_mutex); | |
4696 tptr = kmem_alloc(strlen(pclass)+1, KM_SLEEP); | |
4697 (void) strlcpy(tptr, pclass, (strlen(pclass)+1)); | |
4698 mutex_enter(&vlun->svl_mutex); | |
4699 vlun->svl_active_pclass = tptr; | |
4700 } | |
4701 mutex_exit(&vlun->svl_mutex); | |
4702 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_ONLINE); | |
4703 vlun->svl_waiting_for_activepath = 0; | |
4704 } else if (opinfo.opinfo_path_state == SCSI_PATH_INACTIVE) { | |
4705 mutex_enter(&vlun->svl_mutex); | |
4706 if (vlun->svl_active_pclass != NULL) { | |
4707 if (strcmp(vlun->svl_active_pclass, pclass) == 0) { | |
4708 mutex_exit(&vlun->svl_mutex); | |
4709 /* | |
4710 * externally initiated failover has happened; | |
4711 * force state to ONLINE (see comment above) | |
4712 */ | |
4713 mdi_pi_set_state(pip, | |
4714 MDI_PATHINFO_STATE_ONLINE); | |
4715 vlun->svl_fo_support = opinfo.opinfo_mode; | |
4716 mdi_pi_set_preferred(pip, | |
4717 opinfo.opinfo_preferred); | |
4718 return (MDI_SUCCESS); | |
4719 } | |
4720 } | |
4721 mutex_exit(&vlun->svl_mutex); | |
4722 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_STANDBY); | |
4723 | |
4724 /* | |
4725 * Initiate auto-failback, if enabled, for path if path-state | |
4726 * is transitioning from OFFLINE->STANDBY and pathclass is the | |
4727 * prefered pathclass for this storage. | |
4728 * NOTE: In case where opinfo_path_state is SCSI_PATH_ACTIVE | |
4729 * (above), where the pi state is set to STANDBY, we don't | |
4730 * initiate auto-failback as the next IO shall take care of. | |
4731 * this. See comment above. | |
4732 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4733 (void) fo->sfo_pathclass_next(NULL, &best_pclass, |
4851 | 4734 vlun->svl_fops_ctpriv); |
4735 if (((vhci->vhci_conf_flags & VHCI_CONF_FLAGS_AUTO_FAILBACK) == | |
4736 VHCI_CONF_FLAGS_AUTO_FAILBACK) && | |
4737 ((strcmp(pclass, best_pclass) == 0) || | |
4738 mdi_pi_get_preferred(pip) == 1) && | |
4739 ((MDI_PI_OLD_STATE(pip) == MDI_PATHINFO_STATE_OFFLINE)|| | |
4740 (MDI_PI_OLD_STATE(pip) == MDI_PATHINFO_STATE_INIT))) { | |
4741 VHCI_DEBUG(1, (CE_NOTE, NULL, "%s pathclass path: %p" | |
4742 " OFFLINE->STANDBY transition for lun %s\n", | |
4743 best_pclass, (void *)pip, vlun->svl_lun_wwn)); | |
4744 (void) taskq_dispatch(vhci->vhci_taskq, | |
4745 vhci_initiate_auto_failback, (void *) vlun, | |
4746 KM_SLEEP); | |
4747 } | |
4748 } | |
4749 vlun->svl_fo_support = opinfo.opinfo_mode; | |
4750 mdi_pi_set_preferred(pip, opinfo.opinfo_preferred); | |
4751 | |
4752 VHCI_DEBUG(8, (CE_NOTE, NULL, "vhci_update_pathinfo: opinfo_rev = %x," | |
4753 " opinfo_path_state = %x opinfo_preferred = %x, opinfo_mode = %x\n", | |
4754 opinfo.opinfo_rev, opinfo.opinfo_path_state, | |
4755 opinfo.opinfo_preferred, opinfo.opinfo_mode)); | |
4756 | |
4757 return (MDI_SUCCESS); | |
4758 } | |
4759 | |
4760 /* | |
4761 * Form the kstat name and and call mdi_pi_kstat_create() | |
4762 */ | |
4763 void | |
4764 vhci_kstat_create_pathinfo(mdi_pathinfo_t *pip) | |
4765 { | |
4766 dev_info_t *tgt_dip; | |
4767 dev_info_t *pdip; | |
4768 char *guid; | |
4769 char *target_port, *target_port_dup; | |
4770 char ks_name[KSTAT_STRLEN]; | |
4771 uint_t pid; | |
4772 int by_id; | |
4773 mod_hash_val_t hv; | |
4774 | |
4775 | |
4776 /* return if we have already allocated kstats */ | |
4777 if (mdi_pi_kstat_exists(pip)) | |
4778 return; | |
4779 | |
4780 /* | |
4781 * We need instance numbers to create a kstat name, return if we don't | |
4782 * have instance numbers assigned yet. | |
4783 */ | |
4784 tgt_dip = mdi_pi_get_client(pip); | |
4785 pdip = mdi_pi_get_phci(pip); | |
4786 if ((ddi_get_instance(tgt_dip) == -1) || (ddi_get_instance(pdip) == -1)) | |
4787 return; | |
4788 | |
4789 /* | |
4790 * A path oriented kstat has a ks_name of the form: | |
4791 * | |
4792 * <client-driver><instance>.t<pid>.<pHCI-driver><instance> | |
4793 * | |
4794 * We maintain a bidirectional 'target-port' to <pid> map, | |
4795 * called targetmap. All pathinfo nodes with the same | |
4796 * 'target-port' map to the same <pid>. The iostat(1M) code, | |
4797 * when parsing a path oriented kstat name, uses the <pid> as | |
4798 * a SCSI_VHCI_GET_TARGET_LONGNAME ioctl argument in order | |
4799 * to get the 'target-port'. For KSTAT_FLAG_PERSISTENT kstats, | |
4800 * this ioctl needs to translate a <pid> to a 'target-port' | |
4801 * even after all pathinfo nodes associated with the | |
4802 * 'target-port' have been destroyed. This is needed to support | |
4803 * consistent first-iteration activity-since-boot iostat(1M) | |
4804 * output. Because of this requirement, the mapping can't be | |
4805 * based on pathinfo information in a devinfo snapshot. | |
4806 */ | |
4807 | |
4808 /* determine 'target-port' */ | |
4809 if (mdi_prop_lookup_string(pip, | |
4810 "target-port", &target_port) == MDI_SUCCESS) { | |
4811 target_port_dup = i_ddi_strdup(target_port, KM_SLEEP); | |
4812 (void) mdi_prop_free(target_port); | |
4813 by_id = 1; | |
4814 } else { | |
4815 /* | |
4816 * If the pHCI did not set up 'target-port' on this | |
4817 * pathinfo node, assume that our client is the only | |
4818 * one with paths to the device by using the guid | |
4819 * value as the 'target-port'. Since no other client | |
4820 * will have the same guid, no other client will use | |
4821 * the same <pid>. NOTE: a client with an instance | |
4822 * number always has a guid. | |
4823 */ | |
4824 (void) ddi_prop_lookup_string(DDI_DEV_T_ANY, tgt_dip, | |
4825 PROPFLAGS, MDI_CLIENT_GUID_PROP, &guid); | |
4826 target_port_dup = i_ddi_strdup(guid, KM_SLEEP); | |
4827 ddi_prop_free(guid); | |
4828 | |
4829 /* | |
4830 * For this type of mapping we don't want the | |
4831 * <id> -> 'target-port' mapping to be made. This | |
4832 * will cause the SCSI_VHCI_GET_TARGET_LONGNAME ioctl | |
4833 * to fail, and the iostat(1M) long '-n' output will | |
4834 * still use the <pid>. We do this because we just | |
4835 * made up the 'target-port' using the guid, and we | |
4836 * don't want to expose that fact in iostat output. | |
4837 */ | |
4838 by_id = 0; | |
4839 } | |
4840 | |
4841 /* find/establish <pid> given 'target-port' */ | |
4842 mutex_enter(&vhci_targetmap_mutex); | |
4843 if (mod_hash_find(vhci_targetmap_byport, | |
4844 (mod_hash_key_t)target_port_dup, &hv) == 0) { | |
4845 pid = (int)(intptr_t)hv; /* mapping exists */ | |
4846 } else { | |
4847 pid = vhci_targetmap_pid++; /* new mapping */ | |
4848 | |
4849 (void) mod_hash_insert(vhci_targetmap_byport, | |
4850 (mod_hash_key_t)target_port_dup, | |
4851 (mod_hash_val_t)(intptr_t)pid); | |
4852 if (by_id) { | |
4853 (void) mod_hash_insert(vhci_targetmap_bypid, | |
4854 (mod_hash_key_t)(uintptr_t)pid, | |
4855 (mod_hash_val_t)(uintptr_t)target_port_dup); | |
4856 } | |
4857 target_port_dup = NULL; /* owned by hash */ | |
4858 } | |
4859 mutex_exit(&vhci_targetmap_mutex); | |
4860 | |
4861 /* form kstat name */ | |
4862 (void) snprintf(ks_name, KSTAT_STRLEN, "%s%d.t%d.%s%d", | |
4863 ddi_driver_name(tgt_dip), ddi_get_instance(tgt_dip), | |
4864 pid, ddi_driver_name(pdip), ddi_get_instance(pdip)); | |
4865 | |
4866 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_path_online: path:%p " | |
4867 "kstat %s: pid %x <-> port %s\n", (void *)pip, | |
4868 ks_name, pid, target_port_dup)); | |
4869 if (target_port_dup) | |
4870 kmem_free(target_port_dup, strlen(target_port_dup) + 1); | |
4871 | |
4872 /* call mdi to create kstats with the name we built */ | |
4873 (void) mdi_pi_kstat_create(pip, ks_name); | |
4874 } | |
4875 | |
4876 /* ARGSUSED */ | |
4877 static int | |
4878 vhci_pathinfo_online(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
4879 { | |
4880 scsi_hba_tran_t *hba = NULL; | |
4881 struct scsi_device *psd = NULL; | |
4882 scsi_vhci_lun_t *vlun = NULL; | |
4883 dev_info_t *pdip = NULL; | |
4884 dev_info_t *tgt_dip; | |
4885 struct scsi_vhci *vhci; | |
4886 char *guid; | |
4887 struct scsi_failover *sf; | |
4888 struct scsi_failover_ops *sfo; | |
7399
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
4889 char *sfo_name; |
4851 | 4890 char *override; |
4891 scsi_vhci_priv_t *svp = NULL; | |
4892 struct buf *bp; | |
4893 struct scsi_address *ap; | |
4894 struct scsi_pkt *pkt; | |
4895 int rval = MDI_FAILURE; | |
4896 uint_t inq_size = VHCI_STD_INQ_SIZE; | |
4897 mpapi_item_list_t *list_ptr; | |
4898 mpapi_lu_data_t *ld; | |
4899 | |
4900 ASSERT(vdip != NULL); | |
4901 ASSERT(pip != NULL); | |
4902 | |
4903 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
4904 ASSERT(vhci != NULL); | |
4905 | |
4906 pdip = mdi_pi_get_phci(pip); | |
4907 hba = ddi_get_driver_private(pdip); | |
4908 ASSERT(hba != NULL); | |
4909 | |
4910 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
4911 ASSERT(svp != NULL); | |
4912 | |
4913 tgt_dip = mdi_pi_get_client(pip); | |
4914 ASSERT(tgt_dip != NULL); | |
4915 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, tgt_dip, PROPFLAGS, | |
4916 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) { | |
4917 VHCI_DEBUG(1, (CE_WARN, NULL, "vhci_path_online: lun guid " | |
4918 "property failed")); | |
4919 goto failure; | |
4920 } | |
4921 | |
4922 vlun = vhci_lun_lookup(tgt_dip); | |
4923 ASSERT(vlun != NULL); | |
4924 | |
4925 ddi_prop_free(guid); | |
4926 | |
4927 vlun->svl_dip = mdi_pi_get_client(pip); | |
4928 ASSERT(vlun->svl_dip != NULL); | |
4929 | |
4930 psd = svp->svp_psd; | |
4931 ASSERT(psd != NULL); | |
4932 | |
4933 /* | |
6023
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
4934 * For INQUIRY response buffer size, we use VHCI_STD_INQ_SIZE(132bytes) |
4851 | 4935 * instead of SUN_INQSIZE(48bytes) which is used in sd layer. This is |
4936 * because we could get the Vendor specific parameters(present 97th | |
4937 * byte onwards) which are required to process Vendor specific data | |
4938 * based on array type. | |
4939 * This INQUIRY buffer is freed in vhci_pathinfo_offline but NEVER | |
4940 * in a different layer like sd/phci transport. In other words, vhci | |
4941 * maintains its own copy of scsi_device and scsi_inquiry data on a | |
4942 * per-path basis. | |
4943 */ | |
4944 if (psd->sd_inq == NULL) { | |
4945 psd->sd_inq = (struct scsi_inquiry *) | |
4946 kmem_zalloc(inq_size, KM_SLEEP); | |
4947 } | |
4948 | |
4949 tgt_dip = psd->sd_dev; | |
4950 ASSERT(tgt_dip != NULL); | |
4951 | |
4952 /* | |
4953 * do inquiry to pass into probe routine; this | |
4954 * will avoid each probe routine doing scsi inquiry | |
4955 */ | |
4956 bp = getrbuf(KM_SLEEP); | |
4957 bp->b_un.b_addr = (caddr_t)psd->sd_inq; | |
4958 bp->b_flags = B_READ; | |
4959 bp->b_bcount = inq_size; | |
4960 bp->b_resid = 0; | |
4961 | |
4962 ap = &psd->sd_address; | |
4963 pkt = scsi_init_pkt(ap, NULL, bp, CDB_GROUP0, | |
4964 sizeof (struct scsi_arq_status), 0, 0, SLEEP_FUNC, NULL); | |
4965 if (pkt == NULL) { | |
4966 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_pathinfo_online: " | |
4967 "Inquiry init_pkt failed :%p\n", (void *)pip)); | |
4968 rval = MDI_FAILURE; | |
4969 goto failure; | |
4970 } | |
4971 pkt->pkt_cdbp[0] = SCMD_INQUIRY; | |
4972 pkt->pkt_cdbp[4] = (uchar_t)inq_size; | |
4973 pkt->pkt_time = 60; | |
4974 | |
4975 rval = vhci_do_scsi_cmd(pkt); | |
4976 scsi_destroy_pkt(pkt); | |
4977 freerbuf(bp); | |
4978 if (rval == 0) { | |
4979 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_pathinfo_online: " | |
4980 "Failover Inquiry failed path:%p rval:%x\n", | |
4981 (void *)pip, rval)); | |
4982 rval = MDI_FAILURE; | |
4983 goto failure; | |
4984 } | |
4985 | |
4986 /* | |
4987 * Determine if device is supported under scsi_vhci, and select | |
4988 * failover module. | |
4989 * | |
4990 * See if there is a scsi_vhci.conf file override for this devices's | |
4991 * VID/PID. The following values can be returned: | |
4992 * | |
4993 * NULL If the NULL is returned then there is no scsi_vhci.conf | |
4994 * override. For NULL, we determine the failover_ops for | |
4995 * this device by checking the sfo_device_probe entry | |
4996 * point for each 'fops' module, in order. | |
4997 * | |
4998 * NOTE: Correct operation may depend on module ordering | |
4999 * of 'specific' (failover modules that are completely | |
5000 * VID/PID table based) to 'generic' (failover modules | |
5001 * that based on T10 standards like TPGS). Currently, | |
5002 * the value of 'ddi-forceload' in scsi_vhci.conf is used | |
5003 * to establish the module list and probe order. | |
5004 * | |
5005 * "NONE" If value "NONE" is returned then there is a | |
5006 * scsi_vhci.conf VID/PID override to indicate the device | |
5007 * should not be supported under scsi_vhci (even if there | |
5008 * is an 'fops' module supporting the device). | |
5009 * | |
5010 * "<other>" If another value is returned then that value is the | |
5011 * name of the 'fops' module that should be used. | |
5012 */ | |
5013 sfo = NULL; /* "NONE" */ | |
7399
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5014 sfo_name = NULL; |
4851 | 5015 override = scsi_get_device_type_string( |
5016 "scsi-vhci-failover-override", vdip, psd); | |
5017 | |
5018 if (override == NULL) { | |
5019 /* NULL: default: select based on sfo_device_probe results */ | |
5020 for (sf = scsi_failover_table; sf->sf_mod; sf++) { | |
5021 if ((sf->sf_sfo == NULL) || | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5022 sf->sf_sfo->sfo_device_probe(psd, psd->sd_inq, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5023 &vlun->svl_fops_ctpriv) == SFO_DEVICE_PROBE_PHCI) |
4851 | 5024 continue; |
5025 | |
5026 /* found failover module, supported under scsi_vhci */ | |
5027 sfo = sf->sf_sfo; | |
7399
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5028 sfo_name = i_ddi_strdup(sfo->sfo_name, KM_SLEEP); |
4851 | 5029 break; |
5030 } | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5031 } else if (strcasecmp(override, "NONE")) { |
4851 | 5032 /* !"NONE": select based on driver.conf specified name */ |
5033 for (sf = scsi_failover_table, sfo = NULL; sf->sf_mod; sf++) { | |
5034 if ((sf->sf_sfo == NULL) || | |
5035 (sf->sf_sfo->sfo_name == NULL) || | |
5036 strcmp(override, sf->sf_sfo->sfo_name)) | |
5037 continue; | |
5038 | |
5039 /* found failover module, supported under scsi_vhci */ | |
5040 sfo = sf->sf_sfo; | |
7399
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5041 sfo_name = kmem_alloc(strlen("conf ") + |
4851 | 5042 strlen(sfo->sfo_name) + 1, KM_SLEEP); |
7399
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5043 (void) sprintf(sfo_name, "conf %s", sfo->sfo_name); |
4851 | 5044 break; |
5045 } | |
5046 } | |
5047 if (override) | |
5048 kmem_free(override, strlen(override) + 1); | |
5049 | |
5050 if (sfo == NULL) { | |
5051 /* no failover module - device not supported */ | |
5052 VHCI_DEBUG(1, (CE_NOTE, vhci->vhci_dip, | |
5053 "!vhci_pathinfo_online: dev (path 0x%p) not " | |
5054 "supported\n", (void *)pip)); | |
5055 vlun->svl_not_supported = 1; | |
5056 rval = MDI_NOT_SUPPORTED; | |
5057 goto done; | |
5058 } | |
5059 | |
5060 /* failover supported for device - save failover_ops in vlun */ | |
5061 vlun->svl_fops = sfo; | |
7399
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5062 ASSERT(sfo_name != NULL); |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5063 /* to avoid memory leak, free the fops_name if it has already */ |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5064 /* been set one, a vlun has more than one path, the function */ |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5065 /* vhci_pathinfo_online() will be invoked when each path comes */ |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5066 /* online, so the fops name might be set more than one times. */ |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5067 if (vlun->svl_fops_name) { |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5068 kmem_free(vlun->svl_fops_name, |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5069 strlen(vlun->svl_fops_name) + 1); |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5070 } |
9d7357dfac4a
6636264 Memory leak in vhci_pathinfo_online in Nevada build 78
wl202157@chogori
parents:
7201
diff
changeset
|
5071 vlun->svl_fops_name = sfo_name; |
4851 | 5072 |
5073 /* | |
5074 * Obtain the device-type based mpxio options as specified in | |
5075 * scsi_vhci.conf file. | |
5076 * | |
5077 * NOTE: currently, the end result is a call to | |
5078 * mdi_set_lb_region_size(). | |
5079 */ | |
5080 vhci_get_device_type_mpxio_options(vdip, tgt_dip, psd); | |
5081 | |
5082 /* | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5083 * The device probe or options in conf file may have set/changed the |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5084 * lb policy, save the current value. |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5085 */ |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5086 vlun->svl_lb_policy_save = mdi_get_lb_policy(tgt_dip); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5087 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5088 /* |
4851 | 5089 * if PGR is active, revalidate key and register on this path also, |
5090 * if key is still valid | |
5091 */ | |
5092 sema_p(&vlun->svl_pgr_sema); | |
5093 if (vlun->svl_pgr_active) { | |
5094 rval = vhci_pgr_validate_and_register(svp); | |
5095 if (rval != 1) { | |
5096 rval = MDI_FAILURE; | |
5097 sema_v(&vlun->svl_pgr_sema); | |
5098 goto failure; | |
5099 } | |
5100 } | |
5101 sema_v(&vlun->svl_pgr_sema); | |
5102 | |
5103 if (svp->svp_new_path) { | |
5104 /* | |
5105 * Last chance to perform any cleanup operations on this | |
5106 * new path before making this path completely online. | |
5107 */ | |
5108 svp->svp_new_path = 0; | |
5109 | |
5110 /* | |
5111 * If scsi_vhci knows the lun is alread RESERVE'd, | |
5112 * then skip the issue of RELEASE on new path. | |
5113 */ | |
5114 if ((vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) == 0) { | |
5115 /* | |
5116 * Issue SCSI-2 RELEASE only for the first time on | |
5117 * a new path just in case the host rebooted and | |
5118 * a reservation is still pending on this path. | |
5119 * IBM Shark storage does not clear RESERVE upon | |
5120 * host reboot. | |
5121 */ | |
5122 ap = &psd->sd_address; | |
5123 pkt = scsi_init_pkt(ap, NULL, NULL, CDB_GROUP0, | |
5124 sizeof (struct scsi_arq_status), 0, 0, | |
5125 SLEEP_FUNC, NULL); | |
5126 if (pkt == NULL) { | |
5127 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5128 "!vhci_pathinfo_online: " | |
5129 "Release init_pkt failed :%p\n", | |
5130 (void *)pip)); | |
5131 rval = MDI_FAILURE; | |
5132 goto failure; | |
5133 } | |
5134 pkt->pkt_cdbp[0] = SCMD_RELEASE; | |
5135 pkt->pkt_time = 60; | |
5136 | |
5137 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5138 "!vhci_path_online: path:%p " | |
5139 "Issued SCSI-2 RELEASE\n", (void *)pip)); | |
5140 | |
5141 /* Ignore the return value */ | |
5142 (void) vhci_do_scsi_cmd(pkt); | |
5143 scsi_destroy_pkt(pkt); | |
5144 } | |
5145 } | |
5146 | |
5147 rval = vhci_update_pathinfo(psd, pip, sfo, vlun, vhci); | |
5148 if (rval == MDI_FAILURE) { | |
5149 goto failure; | |
5150 } | |
5151 | |
5152 /* Initialize MP-API data */ | |
5153 vhci_update_mpapi_data(vhci, vlun, pip); | |
5154 | |
5155 /* | |
5156 * MP-API also needs the Inquiry data to be maintained in the | |
5157 * mp_vendor_prop_t structure, so find the lun and update its | |
5158 * structure with this data. | |
5159 */ | |
5160 list_ptr = (mpapi_item_list_t *)vhci_get_mpapi_item(vhci, NULL, | |
5161 MP_OBJECT_TYPE_MULTIPATH_LU, (void *)vlun); | |
5162 ld = (mpapi_lu_data_t *)list_ptr->item->idata; | |
5163 if (ld != NULL) { | |
5164 bcopy(psd->sd_inq->inq_vid, ld->prop.prodInfo.vendor, 8); | |
5165 bcopy(psd->sd_inq->inq_pid, ld->prop.prodInfo.product, 16); | |
5166 bcopy(psd->sd_inq->inq_revision, ld->prop.prodInfo.revision, 4); | |
5167 } else { | |
5168 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_pathinfo_online: " | |
5169 "mpapi_lu_data_t is NULL")); | |
5170 } | |
5171 | |
5172 /* create kstats for path */ | |
5173 vhci_kstat_create_pathinfo(pip); | |
5174 | |
5175 done: | |
5176 mutex_enter(&vhci_global_mutex); | |
5177 cv_broadcast(&vhci_cv); | |
5178 mutex_exit(&vhci_global_mutex); | |
5179 | |
5180 if (vlun->svl_setcap_done) { | |
5181 (void) vhci_pHCI_cap(ap, "sector-size", | |
5182 vlun->svl_sector_size, 1, pip); | |
5183 } | |
5184 | |
5185 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_path_online: path:%p\n", | |
5186 (void *)pip)); | |
5187 | |
5188 failure: | |
5189 if ((rval != MDI_SUCCESS) && psd->sd_inq) { | |
5190 kmem_free((caddr_t)psd->sd_inq, inq_size); | |
5191 psd->sd_inq = (struct scsi_inquiry *)NULL; | |
5192 } | |
5193 return (rval); | |
5194 } | |
5195 | |
5196 /* | |
5197 * path offline handler. Release all bindings that will not be | |
5198 * released by the normal packet transport/completion code path. | |
5199 * Since we don't (presently) keep any bindings alive outside of | |
5200 * the in-transport packets (which will be released on completion) | |
5201 * there is not much to do here. | |
5202 */ | |
5203 /* ARGSUSED */ | |
5204 static int | |
5205 vhci_pathinfo_offline(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
5206 { | |
5207 scsi_hba_tran_t *hba = NULL; | |
5208 struct scsi_device *psd = NULL; | |
5209 dev_info_t *pdip = NULL; | |
5210 dev_info_t *cdip = NULL; | |
5211 scsi_vhci_priv_t *svp = NULL; | |
5212 uint_t inq_size = VHCI_STD_INQ_SIZE; | |
5213 | |
5214 ASSERT(vdip != NULL); | |
5215 ASSERT(pip != NULL); | |
5216 | |
5217 pdip = mdi_pi_get_phci(pip); | |
5218 ASSERT(pdip != NULL); | |
5219 if (pdip == NULL) { | |
5220 VHCI_DEBUG(1, (CE_WARN, vdip, "Invalid path 0x%p: NULL " | |
5221 "phci dip", (void *)pip)); | |
5222 return (MDI_FAILURE); | |
5223 } | |
5224 | |
5225 cdip = mdi_pi_get_client(pip); | |
5226 ASSERT(cdip != NULL); | |
5227 if (cdip == NULL) { | |
5228 VHCI_DEBUG(1, (CE_WARN, vdip, "Invalid path 0x%p: NULL " | |
5229 "client dip", (void *)pip)); | |
5230 return (MDI_FAILURE); | |
5231 } | |
5232 | |
5233 hba = ddi_get_driver_private(pdip); | |
5234 ASSERT(hba != NULL); | |
5235 | |
5236 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
5237 if (svp == NULL) { | |
5238 /* | |
5239 * mdi_pathinfo node in INIT state can have vHCI private | |
5240 * information set to null | |
5241 */ | |
5242 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5243 "svp is NULL for pip 0x%p\n", (void *)pip)); | |
5244 return (MDI_SUCCESS); | |
5245 } | |
5246 | |
5247 psd = svp->svp_psd; | |
5248 ASSERT(psd != NULL); | |
5249 | |
5250 mutex_enter(&svp->svp_mutex); | |
5251 | |
5252 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5253 "%d cmds pending on path: 0x%p\n", svp->svp_cmds, (void *)pip)); | |
5254 while (svp->svp_cmds != 0) { | |
5255 if (cv_timedwait(&svp->svp_cv, &svp->svp_mutex, | |
5256 ddi_get_lbolt() + | |
5257 drv_usectohz(vhci_path_quiesce_timeout * 1000000)) == -1) { | |
5258 /* | |
5259 * The timeout time reached without the condition | |
5260 * being signaled. | |
5261 */ | |
5262 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5263 "Timeout reached on path 0x%p without the cond\n", | |
5264 (void *)pip)); | |
5265 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5266 "%d cmds still pending on path: 0x%p\n", | |
5267 svp->svp_cmds, (void *)pip)); | |
5268 break; | |
5269 } | |
5270 } | |
5271 mutex_exit(&svp->svp_mutex); | |
5272 | |
5273 /* | |
5274 * Check to see if this vlun has an active SCSI-II RESERVE. And this | |
5275 * is the pip for the path that has been reserved. | |
5276 * If so clear the reservation by sending a reset, so the host will not | |
5277 * get a reservation conflict. Reset the flag VLUN_RESERVE_ACTIVE_FLG | |
5278 * for this lun. Also a reset notify is sent to the target driver | |
5279 * just in case the POR check condition is cleared by some other layer | |
5280 * in the stack. | |
5281 */ | |
5282 if (svp->svp_svl->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
5283 if (pip == svp->svp_svl->svl_resrv_pip) { | |
5284 if (vhci_recovery_reset(svp->svp_svl, | |
5285 &svp->svp_psd->sd_address, TRUE, | |
5286 VHCI_DEPTH_TARGET) == 0) { | |
5287 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5288 "!vhci_pathinfo_offline (pip:%p):" | |
5289 "reset failed, retrying\n", (void *)pip)); | |
5290 delay(1*drv_usectohz(1000000)); | |
5291 if (vhci_recovery_reset(svp->svp_svl, | |
5292 &svp->svp_psd->sd_address, TRUE, | |
5293 VHCI_DEPTH_TARGET) == 0) { | |
5294 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5295 "!vhci_pathinfo_offline " | |
5296 "(pip:%p): reset failed, " | |
5297 "giving up!\n", (void *)pip)); | |
5298 } | |
5299 } | |
5300 svp->svp_svl->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
5301 } | |
5302 } | |
5303 | |
5304 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_OFFLINE); | |
5305 if (psd->sd_inq) { | |
5306 kmem_free((caddr_t)psd->sd_inq, inq_size); | |
5307 psd->sd_inq = (struct scsi_inquiry *)NULL; | |
5308 } | |
5309 vhci_mpapi_set_path_state(vdip, pip, MP_DRVR_PATH_STATE_REMOVED); | |
5310 | |
5311 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5312 "!vhci_pathinfo_offline: offlined path 0x%p\n", (void *)pip)); | |
5313 return (MDI_SUCCESS); | |
5314 } | |
5315 | |
5316 | |
5317 /* | |
5318 * routine for SCSI VHCI IOCTL implementation. | |
5319 */ | |
5320 /* ARGSUSED */ | |
5321 static int | |
5322 vhci_ctl(dev_t dev, int cmd, intptr_t data, int mode, cred_t *credp, int *rval) | |
5323 { | |
5324 struct scsi_vhci *vhci; | |
5325 dev_info_t *vdip; | |
5326 mdi_pathinfo_t *pip; | |
5327 int instance, held; | |
5328 int retval = 0; | |
5329 caddr_t phci_path = NULL, client_path = NULL; | |
5330 caddr_t paddr = NULL; | |
5331 sv_iocdata_t ioc; | |
5332 sv_iocdata_t *pioc = &ioc; | |
5333 sv_switch_to_cntlr_iocdata_t iocsc; | |
5334 sv_switch_to_cntlr_iocdata_t *piocsc = &iocsc; | |
5335 caddr_t s; | |
5336 scsi_vhci_lun_t *vlun; | |
5337 struct scsi_failover_ops *fo; | |
5338 char *pclass; | |
5339 | |
5340 /* Check for validity of vhci structure */ | |
5341 vhci = ddi_get_soft_state(vhci_softstate, MINOR2INST(getminor(dev))); | |
5342 if (vhci == NULL) { | |
5343 return (ENXIO); | |
5344 } | |
5345 | |
5346 mutex_enter(&vhci->vhci_mutex); | |
5347 if ((vhci->vhci_state & VHCI_STATE_OPEN) == 0) { | |
5348 mutex_exit(&vhci->vhci_mutex); | |
5349 return (ENXIO); | |
5350 } | |
5351 mutex_exit(&vhci->vhci_mutex); | |
5352 | |
5353 /* Get the vhci dip */ | |
5354 vdip = vhci->vhci_dip; | |
5355 ASSERT(vdip != NULL); | |
5356 instance = ddi_get_instance(vdip); | |
5357 | |
5358 /* Allocate memory for getting parameters from userland */ | |
5359 phci_path = kmem_zalloc(MAXPATHLEN, KM_SLEEP); | |
5360 client_path = kmem_zalloc(MAXPATHLEN, KM_SLEEP); | |
5361 paddr = kmem_zalloc(MAXNAMELEN, KM_SLEEP); | |
5362 | |
5363 /* | |
5364 * Set a local variable indicating the ioctl name. Used for | |
5365 * printing debug strings. | |
5366 */ | |
5367 switch (cmd) { | |
5368 case SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO: | |
5369 s = "GET_CLIENT_MULTIPATH_INFO"; | |
5370 break; | |
5371 | |
5372 case SCSI_VHCI_GET_PHCI_MULTIPATH_INFO: | |
5373 s = "GET_PHCI_MULTIPATH_INFO"; | |
5374 break; | |
5375 | |
5376 case SCSI_VHCI_GET_CLIENT_NAME: | |
5377 s = "GET_CLIENT_NAME"; | |
5378 break; | |
5379 | |
5380 case SCSI_VHCI_PATH_ONLINE: | |
5381 s = "PATH_ONLINE"; | |
5382 break; | |
5383 | |
5384 case SCSI_VHCI_PATH_OFFLINE: | |
5385 s = "PATH_OFFLINE"; | |
5386 break; | |
5387 | |
5388 case SCSI_VHCI_PATH_STANDBY: | |
5389 s = "PATH_STANDBY"; | |
5390 break; | |
5391 | |
5392 case SCSI_VHCI_PATH_TEST: | |
5393 s = "PATH_TEST"; | |
5394 break; | |
5395 | |
5396 case SCSI_VHCI_SWITCH_TO_CNTLR: | |
5397 s = "SWITCH_TO_CNTLR"; | |
5398 break; | |
5399 case SCSI_VHCI_PATH_DISABLE: | |
5400 s = "PATH_DISABLE"; | |
5401 break; | |
5402 case SCSI_VHCI_PATH_ENABLE: | |
5403 s = "PATH_ENABLE"; | |
5404 break; | |
5405 | |
5406 case SCSI_VHCI_GET_TARGET_LONGNAME: | |
5407 s = "GET_TARGET_LONGNAME"; | |
5408 break; | |
5409 | |
5410 #ifdef DEBUG | |
5411 case SCSI_VHCI_CONFIGURE_PHCI: | |
5412 s = "CONFIGURE_PHCI"; | |
5413 break; | |
5414 | |
5415 case SCSI_VHCI_UNCONFIGURE_PHCI: | |
5416 s = "UNCONFIGURE_PHCI"; | |
5417 break; | |
5418 #endif | |
5419 | |
5420 default: | |
5421 s = "Unknown"; | |
5422 vhci_log(CE_NOTE, vdip, | |
5423 "!vhci%d: ioctl %x (unsupported ioctl)", instance, cmd); | |
5424 retval = ENOTSUP; | |
5425 break; | |
5426 } | |
5427 if (retval != 0) { | |
5428 goto end; | |
5429 } | |
5430 | |
5431 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci%d: ioctl <%s>", instance, s)); | |
5432 | |
5433 /* | |
5434 * Get IOCTL parameters from userland | |
5435 */ | |
5436 switch (cmd) { | |
5437 case SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO: | |
5438 case SCSI_VHCI_GET_PHCI_MULTIPATH_INFO: | |
5439 case SCSI_VHCI_GET_CLIENT_NAME: | |
5440 case SCSI_VHCI_PATH_ONLINE: | |
5441 case SCSI_VHCI_PATH_OFFLINE: | |
5442 case SCSI_VHCI_PATH_STANDBY: | |
5443 case SCSI_VHCI_PATH_TEST: | |
5444 case SCSI_VHCI_PATH_DISABLE: | |
5445 case SCSI_VHCI_PATH_ENABLE: | |
5446 case SCSI_VHCI_GET_TARGET_LONGNAME: | |
5447 #ifdef DEBUG | |
5448 case SCSI_VHCI_CONFIGURE_PHCI: | |
5449 case SCSI_VHCI_UNCONFIGURE_PHCI: | |
5450 #endif | |
5451 retval = vhci_get_iocdata((const void *)data, pioc, mode, s); | |
5452 break; | |
5453 | |
5454 case SCSI_VHCI_SWITCH_TO_CNTLR: | |
5455 retval = vhci_get_iocswitchdata((const void *)data, piocsc, | |
5456 mode, s); | |
5457 break; | |
5458 } | |
5459 if (retval != 0) { | |
5460 goto end; | |
5461 } | |
5462 | |
5463 | |
5464 /* | |
5465 * Process the IOCTL | |
5466 */ | |
5467 switch (cmd) { | |
5468 case SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO: | |
5469 { | |
5470 uint_t num_paths; /* Num paths to client dev */ | |
5471 sv_path_info_t *upibuf = NULL; /* To keep userland values */ | |
5472 sv_path_info_t *kpibuf = NULL; /* Kernel data for ioctls */ | |
5473 dev_info_t *cdip; /* Client device dip */ | |
5474 | |
5475 if (pioc->ret_elem == NULL) { | |
5476 retval = EINVAL; | |
5477 break; | |
5478 } | |
5479 | |
5480 /* Get client device path from user land */ | |
5481 if (vhci_ioc_get_client_path(pioc, client_path, mode, s)) { | |
5482 retval = EFAULT; | |
5483 break; | |
5484 } | |
5485 | |
5486 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5487 "client <%s>", s, client_path)); | |
5488 | |
5489 /* Get number of paths to this client device */ | |
5490 if ((cdip = mdi_client_path2devinfo(vdip, client_path)) | |
5491 == NULL) { | |
5492 retval = ENXIO; | |
5493 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5494 "client dip doesn't exist. invalid path <%s>", | |
5495 s, client_path)); | |
5496 break; | |
5497 } | |
5498 num_paths = mdi_client_get_path_count(cdip); | |
5499 | |
5500 if (ddi_copyout(&num_paths, pioc->ret_elem, | |
5501 sizeof (num_paths), mode)) { | |
5502 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5503 "num_paths copyout failed", s)); | |
5504 retval = EFAULT; | |
5505 break; | |
5506 } | |
5507 | |
5508 /* If user just wanted num_paths, then return */ | |
5509 if (pioc->buf_elem == 0 || pioc->ret_buf == NULL || | |
5510 num_paths == 0) { | |
5511 break; | |
5512 } | |
5513 | |
5514 /* Set num_paths to value as much as can be sent to userland */ | |
5515 if (num_paths > pioc->buf_elem) { | |
5516 num_paths = pioc->buf_elem; | |
5517 } | |
5518 | |
5519 /* Allocate memory and get userland pointers */ | |
5520 if (vhci_ioc_alloc_pathinfo(&upibuf, &kpibuf, num_paths, | |
5521 pioc, mode, s) != 0) { | |
5522 retval = EFAULT; | |
5523 break; | |
5524 } | |
5525 ASSERT(upibuf != NULL); | |
5526 ASSERT(kpibuf != NULL); | |
5527 | |
5528 /* | |
5529 * Get the path information and send it to userland. | |
5530 */ | |
5531 if (vhci_get_client_path_list(cdip, kpibuf, num_paths) | |
5532 != MDI_SUCCESS) { | |
5533 retval = ENXIO; | |
5534 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5535 break; | |
5536 } | |
5537 | |
5538 if (vhci_ioc_send_pathinfo(upibuf, kpibuf, num_paths, | |
5539 pioc, mode, s)) { | |
5540 retval = EFAULT; | |
5541 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5542 break; | |
5543 } | |
5544 | |
5545 /* Free the memory allocated for path information */ | |
5546 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5547 break; | |
5548 } | |
5549 | |
5550 case SCSI_VHCI_GET_PHCI_MULTIPATH_INFO: | |
5551 { | |
5552 uint_t num_paths; /* Num paths to client dev */ | |
5553 sv_path_info_t *upibuf = NULL; /* To keep userland values */ | |
5554 sv_path_info_t *kpibuf = NULL; /* Kernel data for ioctls */ | |
5555 dev_info_t *pdip; /* PHCI device dip */ | |
5556 | |
5557 if (pioc->ret_elem == NULL) { | |
5558 retval = EINVAL; | |
5559 break; | |
5560 } | |
5561 | |
5562 /* Get PHCI device path from user land */ | |
5563 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
5564 retval = EFAULT; | |
5565 break; | |
5566 } | |
5567 | |
5568 VHCI_DEBUG(6, (CE_WARN, vdip, | |
5569 "!vhci_ioctl: ioctl <%s> phci <%s>", s, phci_path)); | |
5570 | |
5571 /* Get number of devices associated with this PHCI device */ | |
5572 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5573 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5574 "phci dip doesn't exist. invalid path <%s>", | |
5575 s, phci_path)); | |
5576 retval = ENXIO; | |
5577 break; | |
5578 } | |
5579 | |
5580 num_paths = mdi_phci_get_path_count(pdip); | |
5581 | |
5582 if (ddi_copyout(&num_paths, pioc->ret_elem, | |
5583 sizeof (num_paths), mode)) { | |
5584 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5585 "num_paths copyout failed", s)); | |
5586 retval = EFAULT; | |
5587 break; | |
5588 } | |
5589 | |
5590 /* If user just wanted num_paths, then return */ | |
5591 if (pioc->buf_elem == 0 || pioc->ret_buf == NULL || | |
5592 num_paths == 0) { | |
5593 break; | |
5594 } | |
5595 | |
5596 /* Set num_paths to value as much as can be sent to userland */ | |
5597 if (num_paths > pioc->buf_elem) { | |
5598 num_paths = pioc->buf_elem; | |
5599 } | |
5600 | |
5601 /* Allocate memory and get userland pointers */ | |
5602 if (vhci_ioc_alloc_pathinfo(&upibuf, &kpibuf, num_paths, | |
5603 pioc, mode, s) != 0) { | |
5604 retval = EFAULT; | |
5605 break; | |
5606 } | |
5607 ASSERT(upibuf != NULL); | |
5608 ASSERT(kpibuf != NULL); | |
5609 | |
5610 /* | |
5611 * Get the path information and send it to userland. | |
5612 */ | |
5613 if (vhci_get_phci_path_list(pdip, kpibuf, num_paths) | |
5614 != MDI_SUCCESS) { | |
5615 retval = ENXIO; | |
5616 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5617 break; | |
5618 } | |
5619 | |
5620 if (vhci_ioc_send_pathinfo(upibuf, kpibuf, num_paths, | |
5621 pioc, mode, s)) { | |
5622 retval = EFAULT; | |
5623 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5624 break; | |
5625 } | |
5626 | |
5627 /* Free the memory allocated for path information */ | |
5628 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5629 break; | |
5630 } | |
5631 | |
5632 case SCSI_VHCI_GET_CLIENT_NAME: | |
5633 { | |
5634 dev_info_t *cdip, *pdip; | |
5635 | |
5636 /* Get PHCI path and device address from user land */ | |
5637 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s) || | |
5638 vhci_ioc_get_paddr(pioc, paddr, mode, s)) { | |
5639 retval = EFAULT; | |
5640 break; | |
5641 } | |
5642 | |
5643 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5644 "phci <%s>, paddr <%s>", s, phci_path, paddr)); | |
5645 | |
5646 /* Get the PHCI dip */ | |
5647 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5648 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5649 "phci dip doesn't exist. invalid path <%s>", | |
5650 s, phci_path)); | |
5651 retval = ENXIO; | |
5652 break; | |
5653 } | |
5654 | |
5655 if ((pip = mdi_pi_find(pdip, NULL, paddr)) == NULL) { | |
5656 VHCI_DEBUG(1, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5657 "pathinfo doesn't exist. invalid device addr", s)); | |
5658 retval = ENXIO; | |
5659 break; | |
5660 } | |
5661 | |
5662 /* Get the client device pathname and send to userland */ | |
5663 cdip = mdi_pi_get_client(pip); | |
5664 vhci_ioc_devi_to_path(cdip, client_path); | |
5665 | |
5666 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5667 "client <%s>", s, client_path)); | |
5668 | |
5669 if (vhci_ioc_send_client_path(client_path, pioc, mode, s)) { | |
5670 retval = EFAULT; | |
5671 break; | |
5672 } | |
5673 break; | |
5674 } | |
5675 | |
5676 case SCSI_VHCI_PATH_ONLINE: | |
5677 case SCSI_VHCI_PATH_OFFLINE: | |
5678 case SCSI_VHCI_PATH_STANDBY: | |
5679 case SCSI_VHCI_PATH_TEST: | |
5680 { | |
5681 dev_info_t *pdip; /* PHCI dip */ | |
5682 | |
5683 /* Get PHCI path and device address from user land */ | |
5684 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s) || | |
5685 vhci_ioc_get_paddr(pioc, paddr, mode, s)) { | |
5686 retval = EFAULT; | |
5687 break; | |
5688 } | |
5689 | |
5690 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5691 "phci <%s>, paddr <%s>", s, phci_path, paddr)); | |
5692 | |
5693 /* Get the PHCI dip */ | |
5694 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5695 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5696 "phci dip doesn't exist. invalid path <%s>", | |
5697 s, phci_path)); | |
5698 retval = ENXIO; | |
5699 break; | |
5700 } | |
5701 | |
5702 if ((pip = mdi_pi_find(pdip, NULL, paddr)) == NULL) { | |
5703 VHCI_DEBUG(1, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5704 "pathinfo doesn't exist. invalid device addr", s)); | |
5705 retval = ENXIO; | |
5706 break; | |
5707 } | |
5708 | |
5709 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5710 "Calling MDI function to change device state", s)); | |
5711 | |
5712 switch (cmd) { | |
5713 case SCSI_VHCI_PATH_ONLINE: | |
5714 retval = mdi_pi_online(pip, 0); | |
5715 break; | |
5716 | |
5717 case SCSI_VHCI_PATH_OFFLINE: | |
5718 retval = mdi_pi_offline(pip, 0); | |
5719 break; | |
5720 | |
5721 case SCSI_VHCI_PATH_STANDBY: | |
5722 retval = mdi_pi_standby(pip, 0); | |
5723 break; | |
5724 | |
5725 case SCSI_VHCI_PATH_TEST: | |
5726 break; | |
5727 } | |
5728 break; | |
5729 } | |
5730 | |
5731 case SCSI_VHCI_SWITCH_TO_CNTLR: | |
5732 { | |
5733 dev_info_t *cdip; | |
5734 struct scsi_device *devp; | |
5735 | |
5736 /* Get the client device pathname */ | |
5737 if (ddi_copyin(piocsc->client, client_path, | |
5738 MAXPATHLEN, mode)) { | |
5739 VHCI_DEBUG(2, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5740 "client_path copyin failed", s)); | |
5741 retval = EFAULT; | |
5742 break; | |
5743 } | |
5744 | |
5745 /* Get the path class to which user wants to switch */ | |
5746 if (ddi_copyin(piocsc->class, paddr, MAXNAMELEN, mode)) { | |
5747 VHCI_DEBUG(2, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5748 "controller_class copyin failed", s)); | |
5749 retval = EFAULT; | |
5750 break; | |
5751 } | |
5752 | |
5753 /* Perform validity checks */ | |
5754 if ((cdip = mdi_client_path2devinfo(vdip, | |
5755 client_path)) == NULL) { | |
5756 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5757 "client dip doesn't exist. invalid path <%s>", | |
5758 s, client_path)); | |
5759 retval = ENXIO; | |
5760 break; | |
5761 } | |
5762 | |
5763 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: Calling MDI func " | |
5764 "to switch controller")); | |
5765 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: client <%s> " | |
5766 "class <%s>", client_path, paddr)); | |
5767 | |
5768 if (strcmp(paddr, PCLASS_PRIMARY) && | |
5769 strcmp(paddr, PCLASS_SECONDARY)) { | |
5770 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5771 "invalid path class <%s>", s, paddr)); | |
5772 retval = ENXIO; | |
5773 break; | |
5774 } | |
5775 | |
5776 devp = ddi_get_driver_private(cdip); | |
5777 if (devp == NULL) { | |
5778 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5779 "invalid scsi device <%s>", s, client_path)); | |
5780 retval = ENXIO; | |
5781 break; | |
5782 } | |
5783 vlun = ADDR2VLUN(&devp->sd_address); | |
5784 ASSERT(vlun); | |
5785 | |
5786 /* | |
5787 * Checking to see if device has only one pclass, PRIMARY. | |
5788 * If so this device doesn't support failovers. Assumed | |
5789 * that the devices with one pclass is PRIMARY, as thats the | |
5790 * case today. If this is not true and in future other | |
5791 * symmetric devices are supported with other pclass, this | |
5792 * IOCTL shall have to be overhauled anyways as now the only | |
5793 * arguments it accepts are PRIMARY and SECONDARY. | |
5794 */ | |
5795 fo = vlun->svl_fops; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5796 if (fo->sfo_pathclass_next(PCLASS_PRIMARY, &pclass, |
4851 | 5797 vlun->svl_fops_ctpriv)) { |
5798 retval = ENOTSUP; | |
5799 break; | |
5800 } | |
5801 | |
5802 VHCI_HOLD_LUN(vlun, VH_SLEEP, held); | |
5803 mutex_enter(&vlun->svl_mutex); | |
5804 if (vlun->svl_active_pclass != NULL) { | |
5805 if (strcmp(vlun->svl_active_pclass, paddr) == 0) { | |
5806 mutex_exit(&vlun->svl_mutex); | |
5807 retval = EALREADY; | |
5808 VHCI_RELEASE_LUN(vlun); | |
5809 break; | |
5810 } | |
5811 } | |
5812 mutex_exit(&vlun->svl_mutex); | |
5813 /* Call mdi function to cause a switch over */ | |
5814 retval = mdi_failover(vdip, cdip, MDI_FAILOVER_SYNC); | |
5815 if (retval == MDI_SUCCESS) { | |
5816 retval = 0; | |
5817 } else if (retval == MDI_BUSY) { | |
5818 retval = EBUSY; | |
5819 } else { | |
5820 retval = EIO; | |
5821 } | |
5822 VHCI_RELEASE_LUN(vlun); | |
5823 break; | |
5824 } | |
5825 | |
5826 case SCSI_VHCI_PATH_ENABLE: | |
5827 case SCSI_VHCI_PATH_DISABLE: | |
5828 { | |
5829 dev_info_t *cdip, *pdip; | |
5830 | |
5831 /* | |
5832 * Get client device path from user land | |
5833 */ | |
5834 if (vhci_ioc_get_client_path(pioc, client_path, mode, s)) { | |
5835 retval = EFAULT; | |
5836 break; | |
5837 } | |
5838 | |
5839 /* | |
5840 * Get Phci device path from user land | |
5841 */ | |
5842 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
5843 retval = EFAULT; | |
5844 break; | |
5845 } | |
5846 | |
5847 /* | |
5848 * Get the devinfo for the Phci. | |
5849 */ | |
5850 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5851 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5852 "phci dip doesn't exist. invalid path <%s>", | |
5853 s, phci_path)); | |
5854 retval = ENXIO; | |
5855 break; | |
5856 } | |
5857 | |
5858 /* | |
5859 * If the client path is set to /scsi_vhci then we need | |
5860 * to do the operation on all the clients so set cdip to NULL. | |
5861 * Else, try to get the client dip. | |
5862 */ | |
5863 if (strcmp(client_path, "/scsi_vhci") == 0) { | |
5864 cdip = NULL; | |
5865 } else { | |
5866 if ((cdip = mdi_client_path2devinfo(vdip, | |
5867 client_path)) == NULL) { | |
5868 retval = ENXIO; | |
5869 VHCI_DEBUG(1, (CE_WARN, NULL, | |
5870 "!vhci_ioctl: ioctl <%s> client dip " | |
5871 "doesn't exist. invalid path <%s>", | |
5872 s, client_path)); | |
5873 break; | |
5874 } | |
5875 } | |
5876 | |
5877 if (cmd == SCSI_VHCI_PATH_ENABLE) | |
5878 retval = mdi_pi_enable(cdip, pdip, USER_DISABLE); | |
5879 else | |
5880 retval = mdi_pi_disable(cdip, pdip, USER_DISABLE); | |
5881 | |
5882 break; | |
5883 } | |
5884 | |
5885 case SCSI_VHCI_GET_TARGET_LONGNAME: | |
5886 { | |
5887 uint_t pid = pioc->buf_elem; | |
5888 char *target_port; | |
5889 mod_hash_val_t hv; | |
5890 | |
5891 /* targetmap lookup of 'target-port' by <pid> */ | |
5892 if (mod_hash_find(vhci_targetmap_bypid, | |
5893 (mod_hash_key_t)(uintptr_t)pid, &hv) != 0) { | |
5894 /* | |
5895 * NOTE: failure to find the mapping is OK for guid | |
5896 * based 'target-port' values. | |
5897 */ | |
5898 VHCI_DEBUG(3, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5899 "targetport mapping doesn't exist: pid %d", | |
5900 s, pid)); | |
5901 retval = ENXIO; | |
5902 break; | |
5903 } | |
5904 | |
5905 /* copyout 'target-port' result */ | |
5906 target_port = (char *)hv; | |
5907 if (copyoutstr(target_port, pioc->addr, MAXNAMELEN, NULL)) { | |
5908 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5909 "targetport copyout failed: len: %d", | |
5910 s, (int)strlen(target_port))); | |
5911 retval = EFAULT; | |
5912 } | |
5913 break; | |
5914 } | |
5915 | |
5916 #ifdef DEBUG | |
5917 case SCSI_VHCI_CONFIGURE_PHCI: | |
5918 { | |
5919 dev_info_t *pdip; | |
5920 | |
5921 /* Get PHCI path and device address from user land */ | |
5922 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
5923 retval = EFAULT; | |
5924 break; | |
5925 } | |
5926 | |
5927 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5928 "phci <%s>", s, phci_path)); | |
5929 | |
5930 /* Get the PHCI dip */ | |
5931 if ((pdip = e_ddi_hold_devi_by_path(phci_path, 0)) == NULL) { | |
5932 VHCI_DEBUG(3, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5933 "phci dip doesn't exist. invalid path <%s>", | |
5934 s, phci_path)); | |
5935 retval = ENXIO; | |
5936 break; | |
5937 } | |
5938 | |
5939 if (ndi_devi_config(pdip, | |
5940 NDI_DEVFS_CLEAN|NDI_DEVI_PERSIST) != NDI_SUCCESS) { | |
5941 retval = EIO; | |
5942 } | |
5943 | |
5944 ddi_release_devi(pdip); | |
5945 break; | |
5946 } | |
5947 | |
5948 case SCSI_VHCI_UNCONFIGURE_PHCI: | |
5949 { | |
5950 dev_info_t *pdip; | |
5951 | |
5952 /* Get PHCI path and device address from user land */ | |
5953 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
5954 retval = EFAULT; | |
5955 break; | |
5956 } | |
5957 | |
5958 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5959 "phci <%s>", s, phci_path)); | |
5960 | |
5961 /* Get the PHCI dip */ | |
5962 if ((pdip = e_ddi_hold_devi_by_path(phci_path, 0)) == NULL) { | |
5963 VHCI_DEBUG(3, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5964 "phci dip doesn't exist. invalid path <%s>", | |
5965 s, phci_path)); | |
5966 retval = ENXIO; | |
5967 break; | |
5968 } | |
5969 | |
5970 if (ndi_devi_unconfig(pdip, | |
5971 NDI_DEVI_REMOVE|NDI_DEVFS_CLEAN) != NDI_SUCCESS) { | |
5972 retval = EBUSY; | |
5973 } | |
5974 | |
5975 ddi_release_devi(pdip); | |
5976 break; | |
5977 } | |
5978 #endif | |
5979 } | |
5980 | |
5981 end: | |
5982 /* Free the memory allocated above */ | |
5983 if (phci_path != NULL) { | |
5984 kmem_free(phci_path, MAXPATHLEN); | |
5985 } | |
5986 if (client_path != NULL) { | |
5987 kmem_free(client_path, MAXPATHLEN); | |
5988 } | |
5989 if (paddr != NULL) { | |
5990 kmem_free(paddr, MAXNAMELEN); | |
5991 } | |
5992 return (retval); | |
5993 } | |
5994 | |
5995 /* | |
5996 * devctl IOCTL support for client device DR | |
5997 */ | |
5998 /* ARGSUSED */ | |
5999 int | |
6000 vhci_devctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, | |
6001 int *rvalp) | |
6002 { | |
6003 dev_info_t *self; | |
6004 dev_info_t *child; | |
6005 scsi_hba_tran_t *hba; | |
6006 struct devctl_iocdata *dcp; | |
6007 struct scsi_vhci *vhci; | |
6008 int rv = 0; | |
6009 int retval = 0; | |
6010 scsi_vhci_priv_t *svp; | |
6011 mdi_pathinfo_t *pip; | |
6012 | |
6013 if ((vhci = ddi_get_soft_state(vhci_softstate, | |
6014 MINOR2INST(getminor(dev)))) == NULL) | |
6015 return (ENXIO); | |
6016 | |
6017 /* | |
6018 * check if :devctl minor device has been opened | |
6019 */ | |
6020 mutex_enter(&vhci->vhci_mutex); | |
6021 if ((vhci->vhci_state & VHCI_STATE_OPEN) == 0) { | |
6022 mutex_exit(&vhci->vhci_mutex); | |
6023 return (ENXIO); | |
6024 } | |
6025 mutex_exit(&vhci->vhci_mutex); | |
6026 | |
6027 self = vhci->vhci_dip; | |
6028 hba = ddi_get_driver_private(self); | |
6029 if (hba == NULL) | |
6030 return (ENXIO); | |
6031 | |
6032 /* | |
6033 * We can use the generic implementation for these ioctls | |
6034 */ | |
6035 switch (cmd) { | |
6036 case DEVCTL_DEVICE_GETSTATE: | |
6037 case DEVCTL_DEVICE_ONLINE: | |
6038 case DEVCTL_DEVICE_OFFLINE: | |
6039 case DEVCTL_DEVICE_REMOVE: | |
6040 case DEVCTL_BUS_GETSTATE: | |
6041 return (ndi_devctl_ioctl(self, cmd, arg, mode, 0)); | |
6042 } | |
6043 | |
6044 /* | |
6045 * read devctl ioctl data | |
6046 */ | |
6047 if (ndi_dc_allochdl((void *)arg, &dcp) != NDI_SUCCESS) | |
6048 return (EFAULT); | |
6049 | |
6050 switch (cmd) { | |
6051 | |
6052 case DEVCTL_DEVICE_RESET: | |
6053 /* | |
6054 * lookup and hold child device | |
6055 */ | |
6056 if ((child = ndi_devi_find(self, ndi_dc_getname(dcp), | |
6057 ndi_dc_getaddr(dcp))) == NULL) { | |
6058 rv = ENXIO; | |
6059 break; | |
6060 } | |
6061 retval = mdi_select_path(child, NULL, | |
6062 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), | |
6063 NULL, &pip); | |
6064 if ((retval != MDI_SUCCESS) || (pip == NULL)) { | |
6065 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl:" | |
6066 "Unable to get a path, dip 0x%p", (void *)child)); | |
6067 rv = ENXIO; | |
6068 break; | |
6069 } | |
6070 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
6071 if (vhci_recovery_reset(svp->svp_svl, | |
6072 &svp->svp_psd->sd_address, TRUE, | |
6073 VHCI_DEPTH_TARGET) == 0) { | |
6074 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6075 "!vhci_ioctl(pip:%p): " | |
6076 "reset failed\n", (void *)pip)); | |
6077 rv = ENXIO; | |
6078 } | |
6079 mdi_rele_path(pip); | |
6080 break; | |
6081 | |
6082 case DEVCTL_BUS_QUIESCE: | |
6083 case DEVCTL_BUS_UNQUIESCE: | |
6084 case DEVCTL_BUS_RESET: | |
6085 case DEVCTL_BUS_RESETALL: | |
6086 #ifdef DEBUG | |
6087 case DEVCTL_BUS_CONFIGURE: | |
6088 case DEVCTL_BUS_UNCONFIGURE: | |
6089 #endif | |
6090 rv = ENOTSUP; | |
6091 break; | |
6092 | |
6093 default: | |
6094 rv = ENOTTY; | |
6095 } /* end of outer switch */ | |
6096 | |
6097 ndi_dc_freehdl(dcp); | |
6098 return (rv); | |
6099 } | |
6100 | |
6101 /* | |
6102 * Routine to get the PHCI pathname from ioctl structures in userland | |
6103 */ | |
6104 /* ARGSUSED */ | |
6105 static int | |
6106 vhci_ioc_get_phci_path(sv_iocdata_t *pioc, caddr_t phci_path, | |
6107 int mode, caddr_t s) | |
6108 { | |
6109 int retval = 0; | |
6110 | |
6111 if (ddi_copyin(pioc->phci, phci_path, MAXPATHLEN, mode)) { | |
6112 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_get_phci: ioctl <%s> " | |
6113 "phci_path copyin failed", s)); | |
6114 retval = EFAULT; | |
6115 } | |
6116 return (retval); | |
6117 | |
6118 } | |
6119 | |
6120 | |
6121 /* | |
6122 * Routine to get the Client device pathname from ioctl structures in userland | |
6123 */ | |
6124 /* ARGSUSED */ | |
6125 static int | |
6126 vhci_ioc_get_client_path(sv_iocdata_t *pioc, caddr_t client_path, | |
6127 int mode, caddr_t s) | |
6128 { | |
6129 int retval = 0; | |
6130 | |
6131 if (ddi_copyin(pioc->client, client_path, MAXPATHLEN, mode)) { | |
6132 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_get_client: " | |
6133 "ioctl <%s> client_path copyin failed", s)); | |
6134 retval = EFAULT; | |
6135 } | |
6136 return (retval); | |
6137 } | |
6138 | |
6139 | |
6140 /* | |
6141 * Routine to get physical device address from ioctl structure in userland | |
6142 */ | |
6143 /* ARGSUSED */ | |
6144 static int | |
6145 vhci_ioc_get_paddr(sv_iocdata_t *pioc, caddr_t paddr, int mode, caddr_t s) | |
6146 { | |
6147 int retval = 0; | |
6148 | |
6149 if (ddi_copyin(pioc->addr, paddr, MAXNAMELEN, mode)) { | |
6150 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_get_paddr: " | |
6151 "ioctl <%s> device addr copyin failed", s)); | |
6152 retval = EFAULT; | |
6153 } | |
6154 return (retval); | |
6155 } | |
6156 | |
6157 | |
6158 /* | |
6159 * Routine to send client device pathname to userland. | |
6160 */ | |
6161 /* ARGSUSED */ | |
6162 static int | |
6163 vhci_ioc_send_client_path(caddr_t client_path, sv_iocdata_t *pioc, | |
6164 int mode, caddr_t s) | |
6165 { | |
6166 int retval = 0; | |
6167 | |
6168 if (ddi_copyout(client_path, pioc->client, MAXPATHLEN, mode)) { | |
6169 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_send_client: " | |
6170 "ioctl <%s> client_path copyout failed", s)); | |
6171 retval = EFAULT; | |
6172 } | |
6173 return (retval); | |
6174 } | |
6175 | |
6176 | |
6177 /* | |
6178 * Routine to translated dev_info pointer (dip) to device pathname. | |
6179 */ | |
6180 static void | |
6181 vhci_ioc_devi_to_path(dev_info_t *dip, caddr_t path) | |
6182 { | |
6183 (void) ddi_pathname(dip, path); | |
6184 } | |
6185 | |
6186 | |
6187 /* | |
6188 * vhci_get_phci_path_list: | |
6189 * get information about devices associated with a | |
6190 * given PHCI device. | |
6191 * | |
6192 * Return Values: | |
6193 * path information elements | |
6194 */ | |
6195 int | |
6196 vhci_get_phci_path_list(dev_info_t *pdip, sv_path_info_t *pibuf, | |
6197 uint_t num_elems) | |
6198 { | |
6199 uint_t count, done; | |
6200 mdi_pathinfo_t *pip; | |
6201 sv_path_info_t *ret_pip; | |
6202 int status; | |
6203 size_t prop_size; | |
6204 int circular; | |
6205 | |
6206 /* | |
6207 * Get the PHCI structure and retrieve the path information | |
6208 * from the GUID hash table. | |
6209 */ | |
6210 | |
6211 ret_pip = pibuf; | |
6212 count = 0; | |
6213 | |
6214 ndi_devi_enter(pdip, &circular); | |
6215 | |
6216 done = (count >= num_elems); | |
6217 pip = mdi_get_next_client_path(pdip, NULL); | |
6218 while (pip && !done) { | |
6219 mdi_pi_lock(pip); | |
6220 (void) ddi_pathname(mdi_pi_get_phci(pip), | |
6221 ret_pip->device.ret_phci); | |
6222 (void) strcpy(ret_pip->ret_addr, mdi_pi_get_addr(pip)); | |
6223 (void) mdi_pi_get_state2(pip, &ret_pip->ret_state, | |
6224 &ret_pip->ret_ext_state); | |
6225 | |
6226 status = mdi_prop_size(pip, &prop_size); | |
6227 if (status == MDI_SUCCESS && ret_pip->ret_prop.ret_buf_size) { | |
6228 *ret_pip->ret_prop.ret_buf_size = (uint_t)prop_size; | |
6229 } | |
6230 | |
6231 #ifdef DEBUG | |
6232 if (status != MDI_SUCCESS) { | |
6233 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6234 "!vhci_get_phci_path_list: " | |
6235 "phci <%s>, prop size failure 0x%x", | |
6236 ret_pip->device.ret_phci, status)); | |
6237 } | |
6238 #endif /* DEBUG */ | |
6239 | |
6240 | |
6241 if (status == MDI_SUCCESS && ret_pip->ret_prop.buf && | |
6242 prop_size && ret_pip->ret_prop.buf_size >= prop_size) { | |
6243 status = mdi_prop_pack(pip, | |
6244 &ret_pip->ret_prop.buf, | |
6245 ret_pip->ret_prop.buf_size); | |
6246 | |
6247 #ifdef DEBUG | |
6248 if (status != MDI_SUCCESS) { | |
6249 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6250 "!vhci_get_phci_path_list: " | |
6251 "phci <%s>, prop pack failure 0x%x", | |
6252 ret_pip->device.ret_phci, status)); | |
6253 } | |
6254 #endif /* DEBUG */ | |
6255 } | |
6256 | |
6257 mdi_pi_unlock(pip); | |
6258 pip = mdi_get_next_client_path(pdip, pip); | |
6259 ret_pip++; | |
6260 count++; | |
6261 done = (count >= num_elems); | |
6262 } | |
6263 | |
6264 ndi_devi_exit(pdip, circular); | |
6265 | |
6266 return (MDI_SUCCESS); | |
6267 } | |
6268 | |
6269 | |
6270 /* | |
6271 * vhci_get_client_path_list: | |
6272 * get information about various paths associated with a | |
6273 * given client device. | |
6274 * | |
6275 * Return Values: | |
6276 * path information elements | |
6277 */ | |
6278 int | |
6279 vhci_get_client_path_list(dev_info_t *cdip, sv_path_info_t *pibuf, | |
6280 uint_t num_elems) | |
6281 { | |
6282 uint_t count, done; | |
6283 mdi_pathinfo_t *pip; | |
6284 sv_path_info_t *ret_pip; | |
6285 int status; | |
6286 size_t prop_size; | |
6287 int circular; | |
6288 | |
6289 ret_pip = pibuf; | |
6290 count = 0; | |
6291 | |
6292 ndi_devi_enter(cdip, &circular); | |
6293 | |
6294 done = (count >= num_elems); | |
6295 pip = mdi_get_next_phci_path(cdip, NULL); | |
6296 while (pip && !done) { | |
6297 mdi_pi_lock(pip); | |
6298 (void) ddi_pathname(mdi_pi_get_phci(pip), | |
6299 ret_pip->device.ret_phci); | |
6300 (void) strcpy(ret_pip->ret_addr, mdi_pi_get_addr(pip)); | |
6301 (void) mdi_pi_get_state2(pip, &ret_pip->ret_state, | |
6302 &ret_pip->ret_ext_state); | |
6303 | |
6304 status = mdi_prop_size(pip, &prop_size); | |
6305 if (status == MDI_SUCCESS && ret_pip->ret_prop.ret_buf_size) { | |
6306 *ret_pip->ret_prop.ret_buf_size = (uint_t)prop_size; | |
6307 } | |
6308 | |
6309 #ifdef DEBUG | |
6310 if (status != MDI_SUCCESS) { | |
6311 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6312 "!vhci_get_client_path_list: " | |
6313 "phci <%s>, prop size failure 0x%x", | |
6314 ret_pip->device.ret_phci, status)); | |
6315 } | |
6316 #endif /* DEBUG */ | |
6317 | |
6318 | |
6319 if (status == MDI_SUCCESS && ret_pip->ret_prop.buf && | |
6320 prop_size && ret_pip->ret_prop.buf_size >= prop_size) { | |
6321 status = mdi_prop_pack(pip, | |
6322 &ret_pip->ret_prop.buf, | |
6323 ret_pip->ret_prop.buf_size); | |
6324 | |
6325 #ifdef DEBUG | |
6326 if (status != MDI_SUCCESS) { | |
6327 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6328 "!vhci_get_client_path_list: " | |
6329 "phci <%s>, prop pack failure 0x%x", | |
6330 ret_pip->device.ret_phci, status)); | |
6331 } | |
6332 #endif /* DEBUG */ | |
6333 } | |
6334 | |
6335 mdi_pi_unlock(pip); | |
6336 pip = mdi_get_next_phci_path(cdip, pip); | |
6337 ret_pip++; | |
6338 count++; | |
6339 done = (count >= num_elems); | |
6340 } | |
6341 | |
6342 ndi_devi_exit(cdip, circular); | |
6343 | |
6344 return (MDI_SUCCESS); | |
6345 } | |
6346 | |
6347 | |
6348 /* | |
6349 * Routine to get ioctl argument structure from userland. | |
6350 */ | |
6351 /* ARGSUSED */ | |
6352 static int | |
6353 vhci_get_iocdata(const void *data, sv_iocdata_t *pioc, int mode, caddr_t s) | |
6354 { | |
6355 int retval = 0; | |
6356 | |
6357 #ifdef _MULTI_DATAMODEL | |
6358 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6359 case DDI_MODEL_ILP32: | |
6360 { | |
6361 sv_iocdata32_t ioc32; | |
6362 | |
6363 if (ddi_copyin(data, &ioc32, sizeof (ioc32), mode)) { | |
6364 retval = EFAULT; | |
6365 break; | |
6366 } | |
6367 pioc->client = (caddr_t)(uintptr_t)ioc32.client; | |
6368 pioc->phci = (caddr_t)(uintptr_t)ioc32.phci; | |
6369 pioc->addr = (caddr_t)(uintptr_t)ioc32.addr; | |
6370 pioc->buf_elem = (uint_t)ioc32.buf_elem; | |
6371 pioc->ret_buf = (sv_path_info_t *)(uintptr_t)ioc32.ret_buf; | |
6372 pioc->ret_elem = (uint_t *)(uintptr_t)ioc32.ret_elem; | |
6373 break; | |
6374 } | |
6375 | |
6376 case DDI_MODEL_NONE: | |
6377 if (ddi_copyin(data, pioc, sizeof (*pioc), mode)) { | |
6378 retval = EFAULT; | |
6379 break; | |
6380 } | |
6381 break; | |
6382 } | |
6383 #else /* _MULTI_DATAMODEL */ | |
6384 if (ddi_copyin(data, pioc, sizeof (*pioc), mode)) { | |
6385 retval = EFAULT; | |
6386 } | |
6387 #endif /* _MULTI_DATAMODEL */ | |
6388 | |
6389 #ifdef DEBUG | |
6390 if (retval) { | |
6391 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: cmd <%s> " | |
6392 "iocdata copyin failed", s)); | |
6393 } | |
6394 #endif | |
6395 | |
6396 return (retval); | |
6397 } | |
6398 | |
6399 | |
6400 /* | |
6401 * Routine to get the ioctl argument for ioctl causing controller switchover. | |
6402 */ | |
6403 /* ARGSUSED */ | |
6404 static int | |
6405 vhci_get_iocswitchdata(const void *data, sv_switch_to_cntlr_iocdata_t *piocsc, | |
6406 int mode, caddr_t s) | |
6407 { | |
6408 int retval = 0; | |
6409 | |
6410 #ifdef _MULTI_DATAMODEL | |
6411 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6412 case DDI_MODEL_ILP32: | |
6413 { | |
6414 sv_switch_to_cntlr_iocdata32_t ioc32; | |
6415 | |
6416 if (ddi_copyin(data, &ioc32, sizeof (ioc32), mode)) { | |
6417 retval = EFAULT; | |
6418 break; | |
6419 } | |
6420 piocsc->client = (caddr_t)(uintptr_t)ioc32.client; | |
6421 piocsc->class = (caddr_t)(uintptr_t)ioc32.class; | |
6422 break; | |
6423 } | |
6424 | |
6425 case DDI_MODEL_NONE: | |
6426 if (ddi_copyin(data, piocsc, sizeof (*piocsc), mode)) { | |
6427 retval = EFAULT; | |
6428 } | |
6429 break; | |
6430 } | |
6431 #else /* _MULTI_DATAMODEL */ | |
6432 if (ddi_copyin(data, piocsc, sizeof (*piocsc), mode)) { | |
6433 retval = EFAULT; | |
6434 } | |
6435 #endif /* _MULTI_DATAMODEL */ | |
6436 | |
6437 #ifdef DEBUG | |
6438 if (retval) { | |
6439 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: cmd <%s> " | |
6440 "switch_to_cntlr_iocdata copyin failed", s)); | |
6441 } | |
6442 #endif | |
6443 | |
6444 return (retval); | |
6445 } | |
6446 | |
6447 | |
6448 /* | |
6449 * Routine to allocate memory for the path information structures. | |
6450 * It allocates two chunks of memory - one for keeping userland | |
6451 * pointers/values for path information and path properties, second for | |
6452 * keeping allocating kernel memory for path properties. These path | |
6453 * properties are finally copied to userland. | |
6454 */ | |
6455 /* ARGSUSED */ | |
6456 static int | |
6457 vhci_ioc_alloc_pathinfo(sv_path_info_t **upibuf, sv_path_info_t **kpibuf, | |
6458 uint_t num_paths, sv_iocdata_t *pioc, int mode, caddr_t s) | |
6459 { | |
6460 sv_path_info_t *pi; | |
6461 uint_t bufsize; | |
6462 int retval = 0; | |
6463 int index; | |
6464 | |
6465 /* Allocate memory */ | |
6466 *upibuf = (sv_path_info_t *) | |
6467 kmem_zalloc(sizeof (sv_path_info_t) * num_paths, KM_SLEEP); | |
6468 ASSERT(*upibuf != NULL); | |
6469 *kpibuf = (sv_path_info_t *) | |
6470 kmem_zalloc(sizeof (sv_path_info_t) * num_paths, KM_SLEEP); | |
6471 ASSERT(*kpibuf != NULL); | |
6472 | |
6473 /* | |
6474 * Get the path info structure from the user space. | |
6475 * We are interested in the following fields: | |
6476 * - user size of buffer for per path properties. | |
6477 * - user address of buffer for path info properties. | |
6478 * - user pointer for returning actual buffer size | |
6479 * Keep these fields in the 'upibuf' structures. | |
6480 * Allocate buffer for per path info properties in kernel | |
6481 * structure ('kpibuf'). | |
6482 * Size of these buffers will be equal to the size of buffers | |
6483 * in the user space. | |
6484 */ | |
6485 #ifdef _MULTI_DATAMODEL | |
6486 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6487 case DDI_MODEL_ILP32: | |
6488 { | |
6489 sv_path_info32_t *src; | |
6490 sv_path_info32_t pi32; | |
6491 | |
6492 src = (sv_path_info32_t *)pioc->ret_buf; | |
6493 pi = (sv_path_info_t *)*upibuf; | |
6494 for (index = 0; index < num_paths; index++, src++, pi++) { | |
6495 if (ddi_copyin(src, &pi32, sizeof (pi32), mode)) { | |
6496 retval = EFAULT; | |
6497 break; | |
6498 } | |
6499 | |
6500 pi->ret_prop.buf_size = | |
6501 (uint_t)pi32.ret_prop.buf_size; | |
6502 pi->ret_prop.ret_buf_size = | |
6503 (uint_t *)(uintptr_t)pi32.ret_prop.ret_buf_size; | |
6504 pi->ret_prop.buf = | |
6505 (caddr_t)(uintptr_t)pi32.ret_prop.buf; | |
6506 } | |
6507 break; | |
6508 } | |
6509 | |
6510 case DDI_MODEL_NONE: | |
6511 if (ddi_copyin(pioc->ret_buf, *upibuf, | |
6512 sizeof (sv_path_info_t) * num_paths, mode)) { | |
6513 retval = EFAULT; | |
6514 } | |
6515 break; | |
6516 } | |
6517 #else /* _MULTI_DATAMODEL */ | |
6518 if (ddi_copyin(pioc->ret_buf, *upibuf, | |
6519 sizeof (sv_path_info_t) * num_paths, mode)) { | |
6520 retval = EFAULT; | |
6521 } | |
6522 #endif /* _MULTI_DATAMODEL */ | |
6523 | |
6524 if (retval != 0) { | |
6525 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_alloc_path_info: " | |
6526 "ioctl <%s> normal: path_info copyin failed", s)); | |
6527 kmem_free(*upibuf, sizeof (sv_path_info_t) * num_paths); | |
6528 kmem_free(*kpibuf, sizeof (sv_path_info_t) * num_paths); | |
6529 *upibuf = NULL; | |
6530 *kpibuf = NULL; | |
6531 return (retval); | |
6532 } | |
6533 | |
6534 /* | |
6535 * Allocate memory for per path properties. | |
6536 */ | |
6537 for (index = 0, pi = *kpibuf; index < num_paths; index++, pi++) { | |
6538 bufsize = (*upibuf)[index].ret_prop.buf_size; | |
6539 | |
6540 if (bufsize && bufsize <= SV_PROP_MAX_BUF_SIZE) { | |
6541 pi->ret_prop.buf_size = bufsize; | |
6542 pi->ret_prop.buf = (caddr_t) | |
6543 kmem_zalloc(bufsize, KM_SLEEP); | |
6544 ASSERT(pi->ret_prop.buf != NULL); | |
6545 } else { | |
6546 pi->ret_prop.buf_size = 0; | |
6547 pi->ret_prop.buf = NULL; | |
6548 } | |
6549 | |
6550 if ((*upibuf)[index].ret_prop.ret_buf_size != NULL) { | |
6551 pi->ret_prop.ret_buf_size = (uint_t *)kmem_zalloc( | |
6552 sizeof (*pi->ret_prop.ret_buf_size), KM_SLEEP); | |
6553 ASSERT(pi->ret_prop.ret_buf_size != NULL); | |
6554 } else { | |
6555 pi->ret_prop.ret_buf_size = NULL; | |
6556 } | |
6557 } | |
6558 | |
6559 return (0); | |
6560 } | |
6561 | |
6562 | |
6563 /* | |
6564 * Routine to free memory for the path information structures. | |
6565 * This is the memory which was allocated earlier. | |
6566 */ | |
6567 /* ARGSUSED */ | |
6568 static void | |
6569 vhci_ioc_free_pathinfo(sv_path_info_t *upibuf, sv_path_info_t *kpibuf, | |
6570 uint_t num_paths) | |
6571 { | |
6572 sv_path_info_t *pi; | |
6573 int index; | |
6574 | |
6575 /* Free memory for per path properties */ | |
6576 for (index = 0, pi = kpibuf; index < num_paths; index++, pi++) { | |
6577 if (pi->ret_prop.ret_buf_size != NULL) { | |
6578 kmem_free(pi->ret_prop.ret_buf_size, | |
6579 sizeof (*pi->ret_prop.ret_buf_size)); | |
6580 } | |
6581 | |
6582 if (pi->ret_prop.buf != NULL) { | |
6583 kmem_free(pi->ret_prop.buf, pi->ret_prop.buf_size); | |
6584 } | |
6585 } | |
6586 | |
6587 /* Free memory for path info structures */ | |
6588 kmem_free(upibuf, sizeof (sv_path_info_t) * num_paths); | |
6589 kmem_free(kpibuf, sizeof (sv_path_info_t) * num_paths); | |
6590 } | |
6591 | |
6592 | |
6593 /* | |
6594 * Routine to copy path information and path properties to userland. | |
6595 */ | |
6596 /* ARGSUSED */ | |
6597 static int | |
6598 vhci_ioc_send_pathinfo(sv_path_info_t *upibuf, sv_path_info_t *kpibuf, | |
6599 uint_t num_paths, sv_iocdata_t *pioc, int mode, caddr_t s) | |
6600 { | |
6601 int retval = 0, index; | |
6602 sv_path_info_t *upi_ptr; | |
6603 sv_path_info32_t *upi32_ptr; | |
6604 | |
6605 #ifdef _MULTI_DATAMODEL | |
6606 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6607 case DDI_MODEL_ILP32: | |
6608 goto copy_32bit; | |
6609 | |
6610 case DDI_MODEL_NONE: | |
6611 goto copy_normal; | |
6612 } | |
6613 #else /* _MULTI_DATAMODEL */ | |
6614 | |
6615 goto copy_normal; | |
6616 | |
6617 #endif /* _MULTI_DATAMODEL */ | |
6618 | |
6619 copy_normal: | |
6620 | |
6621 /* | |
6622 * Copy path information and path properties to user land. | |
6623 * Pointer fields inside the path property structure were | |
6624 * saved in the 'upibuf' structure earlier. | |
6625 */ | |
6626 upi_ptr = pioc->ret_buf; | |
6627 for (index = 0; index < num_paths; index++) { | |
6628 if (ddi_copyout(kpibuf[index].device.ret_ct, | |
6629 upi_ptr[index].device.ret_ct, MAXPATHLEN, mode)) { | |
6630 retval = EFAULT; | |
6631 break; | |
6632 } | |
6633 | |
6634 if (ddi_copyout(kpibuf[index].ret_addr, | |
6635 upi_ptr[index].ret_addr, MAXNAMELEN, mode)) { | |
6636 retval = EFAULT; | |
6637 break; | |
6638 } | |
6639 | |
6640 if (ddi_copyout(&kpibuf[index].ret_state, | |
6641 &upi_ptr[index].ret_state, sizeof (kpibuf[index].ret_state), | |
6642 mode)) { | |
6643 retval = EFAULT; | |
6644 break; | |
6645 } | |
6646 | |
6647 if (ddi_copyout(&kpibuf[index].ret_ext_state, | |
6648 &upi_ptr[index].ret_ext_state, | |
6649 sizeof (kpibuf[index].ret_ext_state), mode)) { | |
6650 retval = EFAULT; | |
6651 break; | |
6652 } | |
6653 | |
6654 if ((kpibuf[index].ret_prop.ret_buf_size != NULL) && | |
6655 ddi_copyout(kpibuf[index].ret_prop.ret_buf_size, | |
6656 upibuf[index].ret_prop.ret_buf_size, | |
6657 sizeof (*upibuf[index].ret_prop.ret_buf_size), mode)) { | |
6658 retval = EFAULT; | |
6659 break; | |
6660 } | |
6661 | |
6662 if ((kpibuf[index].ret_prop.buf != NULL) && | |
6663 ddi_copyout(kpibuf[index].ret_prop.buf, | |
6664 upibuf[index].ret_prop.buf, | |
6665 upibuf[index].ret_prop.buf_size, mode)) { | |
6666 retval = EFAULT; | |
6667 break; | |
6668 } | |
6669 } | |
6670 | |
6671 #ifdef DEBUG | |
6672 if (retval) { | |
6673 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: ioctl <%s> " | |
6674 "normal: path_info copyout failed", s)); | |
6675 } | |
6676 #endif | |
6677 | |
6678 return (retval); | |
6679 | |
6680 copy_32bit: | |
6681 /* | |
6682 * Copy path information and path properties to user land. | |
6683 * Pointer fields inside the path property structure were | |
6684 * saved in the 'upibuf' structure earlier. | |
6685 */ | |
6686 upi32_ptr = (sv_path_info32_t *)pioc->ret_buf; | |
6687 for (index = 0; index < num_paths; index++) { | |
6688 if (ddi_copyout(kpibuf[index].device.ret_ct, | |
6689 upi32_ptr[index].device.ret_ct, MAXPATHLEN, mode)) { | |
6690 retval = EFAULT; | |
6691 break; | |
6692 } | |
6693 | |
6694 if (ddi_copyout(kpibuf[index].ret_addr, | |
6695 upi32_ptr[index].ret_addr, MAXNAMELEN, mode)) { | |
6696 retval = EFAULT; | |
6697 break; | |
6698 } | |
6699 | |
6700 if (ddi_copyout(&kpibuf[index].ret_state, | |
6701 &upi32_ptr[index].ret_state, | |
6702 sizeof (kpibuf[index].ret_state), mode)) { | |
6703 retval = EFAULT; | |
6704 break; | |
6705 } | |
6706 | |
6707 if (ddi_copyout(&kpibuf[index].ret_ext_state, | |
6708 &upi32_ptr[index].ret_ext_state, | |
6709 sizeof (kpibuf[index].ret_ext_state), mode)) { | |
6710 retval = EFAULT; | |
6711 break; | |
6712 } | |
6713 if ((kpibuf[index].ret_prop.ret_buf_size != NULL) && | |
6714 ddi_copyout(kpibuf[index].ret_prop.ret_buf_size, | |
6715 upibuf[index].ret_prop.ret_buf_size, | |
6716 sizeof (*upibuf[index].ret_prop.ret_buf_size), mode)) { | |
6717 retval = EFAULT; | |
6718 break; | |
6719 } | |
6720 | |
6721 if ((kpibuf[index].ret_prop.buf != NULL) && | |
6722 ddi_copyout(kpibuf[index].ret_prop.buf, | |
6723 upibuf[index].ret_prop.buf, | |
6724 upibuf[index].ret_prop.buf_size, mode)) { | |
6725 retval = EFAULT; | |
6726 break; | |
6727 } | |
6728 } | |
6729 | |
6730 #ifdef DEBUG | |
6731 if (retval) { | |
6732 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: ioctl <%s> " | |
6733 "normal: path_info copyout failed", s)); | |
6734 } | |
6735 #endif | |
6736 | |
6737 return (retval); | |
6738 } | |
6739 | |
6740 | |
6741 /* | |
6742 * vhci_failover() | |
6743 * This routine expects VHCI_HOLD_LUN before being invoked. It can be invoked | |
6744 * as MDI_FAILOVER_ASYNC or MDI_FAILOVER_SYNC. For Asynchronous failovers | |
6745 * this routine shall VHCI_RELEASE_LUN on exiting. For synchronous failovers | |
6746 * it is the callers responsibility to release lun. | |
6747 */ | |
6748 | |
6749 /* ARGSUSED */ | |
6750 static int | |
6751 vhci_failover(dev_info_t *vdip, dev_info_t *cdip, int flags) | |
6752 { | |
6753 char *guid; | |
6754 scsi_vhci_lun_t *vlun = NULL; | |
6755 struct scsi_vhci *vhci; | |
6756 mdi_pathinfo_t *pip, *npip; | |
6757 char *s_pclass, *pclass1, *pclass2, *pclass; | |
6758 char active_pclass_copy[255], *active_pclass_ptr; | |
6759 char *ptr1, *ptr2; | |
6760 mdi_pathinfo_state_t pi_state; | |
6761 uint32_t pi_ext_state; | |
6762 scsi_vhci_priv_t *svp; | |
6763 struct scsi_device *sd; | |
6764 struct scsi_failover_ops *sfo; | |
6765 int sps; /* mdi_select_path() status */ | |
6766 int activation_done = 0; | |
6767 int rval, retval = MDI_FAILURE; | |
6768 int reserve_pending, check_condition, UA_condition; | |
6769 struct scsi_pkt *pkt; | |
6770 struct buf *bp; | |
6771 | |
6772 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
6773 sd = ddi_get_driver_private(cdip); | |
6774 vlun = ADDR2VLUN(&sd->sd_address); | |
6775 ASSERT(vlun != 0); | |
6776 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
6777 guid = vlun->svl_lun_wwn; | |
6778 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(1): guid %s\n", guid)); | |
6779 vhci_log(CE_NOTE, vdip, "!Initiating failover for device %s " | |
6780 "(GUID %s)", ddi_node_name(cdip), guid); | |
6781 | |
6782 /* | |
6783 * Lets maintain a local copy of the vlun->svl_active_pclass | |
6784 * for the rest of the processing. Accessing the field | |
6785 * directly in the loop below causes loop logic to break | |
6786 * especially when the field gets updated by other threads | |
6787 * update path status etc and causes 'paths are not currently | |
6788 * available' condition to be declared prematurely. | |
6789 */ | |
6790 mutex_enter(&vlun->svl_mutex); | |
6791 if (vlun->svl_active_pclass != NULL) { | |
6792 (void) strlcpy(active_pclass_copy, vlun->svl_active_pclass, | |
6793 sizeof (active_pclass_copy)); | |
6794 active_pclass_ptr = &active_pclass_copy[0]; | |
6795 mutex_exit(&vlun->svl_mutex); | |
6796 if (vhci_quiesce_paths(vdip, cdip, vlun, guid, | |
6797 active_pclass_ptr) != 0) { | |
6798 retval = MDI_FAILURE; | |
6799 } | |
6800 } else { | |
6801 /* | |
6802 * can happen only when the available path to device | |
6803 * discovered is a STANDBY path. | |
6804 */ | |
6805 mutex_exit(&vlun->svl_mutex); | |
6806 active_pclass_copy[0] = '\0'; | |
6807 active_pclass_ptr = NULL; | |
6808 } | |
6809 | |
6810 sfo = vlun->svl_fops; | |
6811 ASSERT(sfo != NULL); | |
6812 pclass1 = s_pclass = active_pclass_ptr; | |
6813 VHCI_DEBUG(1, (CE_NOTE, NULL, "!(%s)failing over from %s\n", guid, | |
6814 (s_pclass == NULL ? "<none>" : s_pclass))); | |
6815 | |
6816 next_pathclass: | |
6817 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
6818 rval = sfo->sfo_pathclass_next(pclass1, &pclass2, |
4851 | 6819 vlun->svl_fops_ctpriv); |
6820 if (rval == ENOENT) { | |
6821 if (s_pclass == NULL) { | |
6822 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(4)(%s): " | |
6823 "failed, no more pathclasses\n", guid)); | |
6824 goto done; | |
6825 } else { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
6826 (void) sfo->sfo_pathclass_next(NULL, &pclass2, |
4851 | 6827 vlun->svl_fops_ctpriv); |
6828 } | |
6829 } else if (rval == EINVAL) { | |
6830 vhci_log(CE_NOTE, vdip, "!Failover operation failed for " | |
6831 "device %s (GUID %s): Invalid path-class %s", | |
6832 ddi_node_name(cdip), guid, | |
6833 ((pclass1 == NULL) ? "<none>" : pclass1)); | |
6834 goto done; | |
6835 } | |
6836 if ((s_pclass != NULL) && (strcmp(pclass2, s_pclass) == 0)) { | |
6837 /* | |
6838 * paths are not currently available | |
6839 */ | |
6840 vhci_log(CE_NOTE, vdip, "!Failover path currently unavailable" | |
6841 " for device %s (GUID %s)", | |
6842 ddi_node_name(cdip), guid); | |
6843 goto done; | |
6844 } | |
6845 pip = npip = NULL; | |
6846 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(5.2)(%s): considering " | |
6847 "%s as failover destination\n", guid, pclass2)); | |
6848 sps = mdi_select_path(cdip, NULL, MDI_SELECT_STANDBY_PATH, NULL, &npip); | |
6849 if ((npip == NULL) || (sps != MDI_SUCCESS)) { | |
6850 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(%s): no " | |
6851 "STANDBY paths found (status:%x)!\n", guid, sps)); | |
6852 pclass1 = pclass2; | |
6853 goto next_pathclass; | |
6854 } | |
6855 do { | |
6856 pclass = NULL; | |
6857 if ((mdi_prop_lookup_string(npip, "path-class", | |
6858 &pclass) != MDI_SUCCESS) || (strcmp(pclass2, | |
6859 pclass) != 0)) { | |
6860 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6861 "!vhci_failover(5.5)(%s): skipping path " | |
6862 "%p(%s)...\n", guid, (void *)npip, pclass)); | |
6863 pip = npip; | |
6864 sps = mdi_select_path(cdip, NULL, | |
6865 MDI_SELECT_STANDBY_PATH, pip, &npip); | |
6866 mdi_rele_path(pip); | |
6867 (void) mdi_prop_free(pclass); | |
6868 continue; | |
6869 } | |
6870 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(npip); | |
6871 | |
6872 /* | |
6873 * Issue READ at non-zer block on this STANDBY path. | |
6874 * Purple returns | |
6875 * 1. RESERVATION_CONFLICT if reservation is pending | |
6876 * 2. POR check condition if it reset happened. | |
6877 * 2. failover Check Conditions if one is already in progress. | |
6878 */ | |
6879 reserve_pending = 0; | |
6880 check_condition = 0; | |
6881 UA_condition = 0; | |
6882 | |
6883 bp = scsi_alloc_consistent_buf(&svp->svp_psd->sd_address, | |
6884 (struct buf *)NULL, DEV_BSIZE, B_READ, NULL, NULL); | |
6885 if (!bp) { | |
6886 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6887 "vhci_failover !No resources (buf)\n")); | |
6888 mdi_rele_path(npip); | |
6889 goto done; | |
6890 } | |
6891 pkt = scsi_init_pkt(&svp->svp_psd->sd_address, NULL, bp, | |
6892 CDB_GROUP1, sizeof (struct scsi_arq_status), 0, | |
6893 PKT_CONSISTENT, NULL, NULL); | |
6894 if (pkt) { | |
6895 (void) scsi_setup_cdb((union scsi_cdb *)(uintptr_t) | |
6896 pkt->pkt_cdbp, SCMD_READ, 1, 1, 0); | |
6897 pkt->pkt_flags = FLAG_NOINTR; | |
6898 check_path_again: | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
6899 pkt->pkt_path_instance = mdi_pi_get_path_instance(npip); |
4851 | 6900 pkt->pkt_time = 3*30; |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
6901 |
4851 | 6902 if (scsi_transport(pkt) == TRAN_ACCEPT) { |
6903 switch (pkt->pkt_reason) { | |
6904 case CMD_CMPLT: | |
6905 switch (SCBP_C(pkt)) { | |
6906 case STATUS_GOOD: | |
6907 /* Already failed over */ | |
6908 activation_done = 1; | |
6909 break; | |
6910 case STATUS_RESERVATION_CONFLICT: | |
6911 reserve_pending = 1; | |
6912 break; | |
6913 case STATUS_CHECK: | |
6914 check_condition = 1; | |
6915 break; | |
6916 } | |
6917 } | |
6918 } | |
6919 if (check_condition && | |
6920 (pkt->pkt_state & STATE_ARQ_DONE)) { | |
6921 struct scsi_extended_sense *sns = | |
6922 &(((struct scsi_arq_status *)(uintptr_t) | |
6923 (pkt->pkt_scbp))->sts_sensedata); | |
6924 if (sns->es_key == KEY_UNIT_ATTENTION && | |
6925 sns->es_add_code == 0x29) { | |
6926 /* Already failed over */ | |
6927 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6928 "!vhci_failover(7)(%s): " | |
6929 "path 0x%p POR UA condition\n", | |
6930 guid, (void *)npip)); | |
6931 if (UA_condition == 0) { | |
6932 UA_condition = 1; | |
6933 goto check_path_again; | |
6934 } | |
6935 } else { | |
6936 activation_done = 0; | |
6937 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6938 "!vhci_failover(%s): path 0x%p " | |
6939 "unhandled chkcond %x %x %x\n", | |
6940 guid, (void *)npip, sns->es_key, | |
6941 sns->es_add_code, | |
6942 sns->es_qual_code)); | |
6943 } | |
6944 } | |
6945 scsi_destroy_pkt(pkt); | |
6946 } | |
6947 scsi_free_consistent_buf(bp); | |
6948 | |
6949 if (activation_done) { | |
6950 mdi_rele_path(npip); | |
6951 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(7)(%s): " | |
6952 "path 0x%p already failedover\n", guid, | |
6953 (void *)npip)); | |
6954 break; | |
6955 } | |
6956 if (reserve_pending && (vlun->svl_xlf_capable == 0)) { | |
6957 (void) vhci_recovery_reset(vlun, | |
6958 &svp->svp_psd->sd_address, | |
6959 FALSE, VHCI_DEPTH_ALL); | |
6960 } | |
6961 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(6)(%s): " | |
6962 "activating path 0x%p(psd:%p)\n", guid, (void *)npip, | |
6963 (void *)svp->svp_psd)); | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
6964 if (sfo->sfo_path_activate(svp->svp_psd, pclass2, |
4851 | 6965 vlun->svl_fops_ctpriv) == 0) { |
6966 activation_done = 1; | |
6967 mdi_rele_path(npip); | |
6968 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(7)(%s): " | |
6969 "path 0x%p successfully activated\n", guid, | |
6970 (void *)npip)); | |
6971 break; | |
6972 } | |
6973 pip = npip; | |
6974 sps = mdi_select_path(cdip, NULL, MDI_SELECT_STANDBY_PATH, | |
6975 pip, &npip); | |
6976 mdi_rele_path(pip); | |
6977 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
6978 if (activation_done == 0) { | |
6979 pclass1 = pclass2; | |
6980 goto next_pathclass; | |
6981 } | |
6982 | |
6983 /* | |
6984 * if we are here, we have succeeded in activating path npip of | |
6985 * pathclass pclass2; let us validate all paths of pclass2 by | |
6986 * "ping"-ing each one and mark the good ones ONLINE | |
6987 * Also, set the state of the paths belonging to the previously | |
6988 * active pathclass to STANDBY | |
6989 */ | |
6990 pip = npip = NULL; | |
6991 sps = mdi_select_path(cdip, NULL, (MDI_SELECT_ONLINE_PATH | | |
6992 MDI_SELECT_STANDBY_PATH | MDI_SELECT_USER_DISABLE_PATH), | |
6993 NULL, &npip); | |
6994 if (npip == NULL || sps != MDI_SUCCESS) { | |
6995 VHCI_DEBUG(1, (CE_NOTE, NULL, "!Failover operation failed for " | |
6996 "device %s (GUID %s): paths may be busy\n", | |
6997 ddi_node_name(cdip), guid)); | |
6998 goto done; | |
6999 } | |
7000 do { | |
7001 (void) mdi_pi_get_state2(npip, &pi_state, &pi_ext_state); | |
7002 if (mdi_prop_lookup_string(npip, "path-class", &pclass) | |
7003 != MDI_SUCCESS) { | |
7004 pip = npip; | |
7005 sps = mdi_select_path(cdip, NULL, | |
7006 (MDI_SELECT_ONLINE_PATH | | |
7007 MDI_SELECT_STANDBY_PATH | | |
7008 MDI_SELECT_USER_DISABLE_PATH), | |
7009 pip, &npip); | |
7010 mdi_rele_path(pip); | |
7011 continue; | |
7012 } | |
7013 if (strcmp(pclass, pclass2) == 0) { | |
7014 if (pi_state == MDI_PATHINFO_STATE_STANDBY) { | |
7015 svp = (scsi_vhci_priv_t *) | |
7016 mdi_pi_get_vhci_private(npip); | |
7017 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7018 "!vhci_failover(8)(%s): " | |
7019 "pinging path 0x%p\n", | |
7020 guid, (void *)npip)); | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7021 if (sfo->sfo_path_ping(svp->svp_psd, |
4851 | 7022 vlun->svl_fops_ctpriv) == 1) { |
7023 mdi_pi_set_state(npip, | |
7024 MDI_PATHINFO_STATE_ONLINE); | |
7025 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7026 "!vhci_failover(9)(%s): " | |
7027 "path 0x%p ping successful, " | |
7028 "marked online\n", guid, | |
7029 (void *)npip)); | |
7030 MDI_PI_ERRSTAT(npip, MDI_PI_FAILTO); | |
7031 } | |
7032 } | |
7033 } else if ((s_pclass != NULL) && (strcmp(pclass, s_pclass) | |
7034 == 0)) { | |
7035 if (pi_state == MDI_PATHINFO_STATE_ONLINE) { | |
7036 mdi_pi_set_state(npip, | |
7037 MDI_PATHINFO_STATE_STANDBY); | |
7038 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7039 "!vhci_failover(10)(%s): path 0x%p marked " | |
7040 "STANDBY\n", guid, (void *)npip)); | |
7041 MDI_PI_ERRSTAT(npip, MDI_PI_FAILFROM); | |
7042 } | |
7043 } | |
7044 (void) mdi_prop_free(pclass); | |
7045 pip = npip; | |
7046 sps = mdi_select_path(cdip, NULL, (MDI_SELECT_ONLINE_PATH | | |
7047 MDI_SELECT_STANDBY_PATH|MDI_SELECT_USER_DISABLE_PATH), | |
7048 pip, &npip); | |
7049 mdi_rele_path(pip); | |
7050 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
7051 | |
7052 /* | |
7053 * Update the AccessState of related MP-API TPGs | |
7054 */ | |
7055 (void) vhci_mpapi_update_tpg_acc_state_for_lu(vhci, vlun); | |
7056 | |
7057 vhci_log(CE_NOTE, vdip, "!Failover operation completed successfully " | |
7058 "for device %s (GUID %s): failed over from %s to %s", | |
7059 ddi_node_name(cdip), guid, ((s_pclass == NULL) ? "<none>" : | |
7060 s_pclass), pclass2); | |
7061 ptr1 = kmem_alloc(strlen(pclass2)+1, KM_SLEEP); | |
7062 (void) strlcpy(ptr1, pclass2, (strlen(pclass2)+1)); | |
7063 mutex_enter(&vlun->svl_mutex); | |
7064 ptr2 = vlun->svl_active_pclass; | |
7065 vlun->svl_active_pclass = ptr1; | |
7066 mutex_exit(&vlun->svl_mutex); | |
7067 if (ptr2) { | |
7068 kmem_free(ptr2, strlen(ptr2)+1); | |
7069 } | |
7070 mutex_enter(&vhci->vhci_mutex); | |
7071 scsi_hba_reset_notify_callback(&vhci->vhci_mutex, | |
7072 &vhci->vhci_reset_notify_listf); | |
7073 /* All reservations are cleared upon these resets. */ | |
7074 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
7075 mutex_exit(&vhci->vhci_mutex); | |
7076 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(11): DONE! Active " | |
7077 "pathclass for %s is now %s\n", guid, pclass2)); | |
7078 retval = MDI_SUCCESS; | |
7079 | |
7080 done: | |
7081 if (flags == MDI_FAILOVER_ASYNC) { | |
7082 VHCI_RELEASE_LUN(vlun); | |
7083 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_failover(12): DONE! " | |
7084 "releasing lun, as failover was ASYNC\n")); | |
7085 } else { | |
7086 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_failover(12): DONE! " | |
7087 "NOT releasing lun, as failover was SYNC\n")); | |
7088 } | |
7089 return (retval); | |
7090 } | |
7091 | |
7092 /* | |
7093 * vhci_client_attached is called after the successful attach of a | |
7094 * client devinfo node. | |
7095 */ | |
7096 static void | |
7097 vhci_client_attached(dev_info_t *cdip) | |
7098 { | |
7099 mdi_pathinfo_t *pip; | |
7100 int circular; | |
7101 | |
7102 /* | |
7103 * At this point the client has attached and it's instance number is | |
7104 * valid, so we can set up kstats. We need to do this here because it | |
7105 * is possible for paths to go online prior to client attach, in which | |
7106 * case the call to vhci_kstat_create_pathinfo in vhci_pathinfo_online | |
7107 * was a noop. | |
7108 */ | |
7109 ndi_devi_enter(cdip, &circular); | |
7110 for (pip = mdi_get_next_phci_path(cdip, NULL); pip; | |
7111 pip = mdi_get_next_phci_path(cdip, pip)) | |
7112 vhci_kstat_create_pathinfo(pip); | |
7113 ndi_devi_exit(cdip, circular); | |
7114 } | |
7115 | |
7116 /* | |
7117 * quiesce all of the online paths | |
7118 */ | |
7119 static int | |
7120 vhci_quiesce_paths(dev_info_t *vdip, dev_info_t *cdip, scsi_vhci_lun_t *vlun, | |
7121 char *guid, char *active_pclass_ptr) | |
7122 { | |
7123 scsi_vhci_priv_t *svp; | |
7124 char *s_pclass = NULL; | |
7125 mdi_pathinfo_t *npip, *pip; | |
7126 int sps; | |
7127 | |
7128 /* quiesce currently active paths */ | |
7129 s_pclass = NULL; | |
7130 pip = npip = NULL; | |
7131 sps = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH, NULL, &npip); | |
7132 if ((npip == NULL) || (sps != MDI_SUCCESS)) { | |
7133 return (1); | |
7134 } | |
7135 do { | |
7136 if (mdi_prop_lookup_string(npip, "path-class", | |
7137 &s_pclass) != MDI_SUCCESS) { | |
7138 mdi_rele_path(npip); | |
7139 vhci_log(CE_NOTE, vdip, "!Failover operation failed " | |
7140 "for device %s (GUID %s) due to an internal " | |
7141 "error", ddi_node_name(cdip), guid); | |
7142 return (1); | |
7143 } | |
7144 if (strcmp(s_pclass, active_pclass_ptr) == 0) { | |
7145 /* | |
7146 * quiesce path. Free s_pclass since | |
7147 * we don't need it anymore | |
7148 */ | |
7149 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7150 "!vhci_failover(2)(%s): failing over " | |
7151 "from %s; quiescing path %p\n", | |
7152 guid, s_pclass, (void *)npip)); | |
7153 (void) mdi_prop_free(s_pclass); | |
7154 svp = (scsi_vhci_priv_t *) | |
7155 mdi_pi_get_vhci_private(npip); | |
7156 if (svp == NULL) { | |
7157 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7158 "!vhci_failover(2.5)(%s): no " | |
7159 "client priv! %p offlined?\n", | |
7160 guid, (void *)npip)); | |
7161 pip = npip; | |
7162 sps = mdi_select_path(cdip, NULL, | |
7163 MDI_SELECT_ONLINE_PATH, pip, &npip); | |
7164 mdi_rele_path(pip); | |
7165 continue; | |
7166 } | |
7167 if (scsi_abort(&svp->svp_psd->sd_address, NULL) | |
7168 == 0) { | |
7169 (void) vhci_recovery_reset(vlun, | |
7170 &svp->svp_psd->sd_address, FALSE, | |
7171 VHCI_DEPTH_TARGET); | |
7172 } | |
7173 mutex_enter(&svp->svp_mutex); | |
7174 if (svp->svp_cmds == 0) { | |
7175 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7176 "!vhci_failover(3)(%s):" | |
7177 "quiesced path %p\n", guid, (void *)npip)); | |
7178 } else { | |
7179 while (svp->svp_cmds != 0) { | |
7180 cv_wait(&svp->svp_cv, &svp->svp_mutex); | |
7181 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7182 "!vhci_failover(3.cv)(%s):" | |
7183 "quiesced path %p\n", guid, | |
7184 (void *)npip)); | |
7185 } | |
7186 } | |
7187 mutex_exit(&svp->svp_mutex); | |
7188 } else { | |
7189 /* | |
7190 * make sure we freeup the memory | |
7191 */ | |
7192 (void) mdi_prop_free(s_pclass); | |
7193 } | |
7194 pip = npip; | |
7195 sps = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH, | |
7196 pip, &npip); | |
7197 mdi_rele_path(pip); | |
7198 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
7199 return (0); | |
7200 } | |
7201 | |
7202 static struct scsi_vhci_lun * | |
7203 vhci_lun_lookup(dev_info_t *tgt_dip) | |
7204 { | |
7205 return ((struct scsi_vhci_lun *) | |
7206 mdi_client_get_vhci_private(tgt_dip)); | |
7207 } | |
7208 | |
7209 static struct scsi_vhci_lun * | |
7210 vhci_lun_lookup_alloc(dev_info_t *tgt_dip, char *guid, int *didalloc) | |
7211 { | |
7212 struct scsi_vhci_lun *svl; | |
7213 | |
7214 if (svl = vhci_lun_lookup(tgt_dip)) { | |
7215 return (svl); | |
7216 } | |
7217 | |
7218 svl = kmem_zalloc(sizeof (*svl), KM_SLEEP); | |
7219 svl->svl_lun_wwn = kmem_zalloc(strlen(guid)+1, KM_SLEEP); | |
7220 (void) strcpy(svl->svl_lun_wwn, guid); | |
7221 mutex_init(&svl->svl_mutex, NULL, MUTEX_DRIVER, NULL); | |
7222 cv_init(&svl->svl_cv, NULL, CV_DRIVER, NULL); | |
7223 sema_init(&svl->svl_pgr_sema, 1, NULL, SEMA_DRIVER, NULL); | |
7224 svl->svl_waiting_for_activepath = 1; | |
7225 svl->svl_sector_size = 1; | |
7226 mdi_client_set_vhci_private(tgt_dip, svl); | |
7227 *didalloc = 1; | |
7228 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7229 "vhci_lun_lookup_alloc: guid %s vlun 0x%p\n", | |
7230 guid, (void *)svl)); | |
7231 return (svl); | |
7232 } | |
7233 | |
7234 static void | |
7235 vhci_lun_free(dev_info_t *tgt_dip) | |
7236 { | |
7237 struct scsi_vhci_lun *dvlp; | |
7238 char *guid; | |
4882
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7239 struct scsi_device *sd; |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7240 |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7241 /* |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7242 * The scsi_device was set to driver private during child node |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7243 * initialization in the scsi_hba_bus_ctl(). |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7244 */ |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7245 sd = (struct scsi_device *)ddi_get_driver_private(tgt_dip); |
4851 | 7246 |
7247 dvlp = (struct scsi_vhci_lun *) | |
7248 mdi_client_get_vhci_private(tgt_dip); | |
7249 ASSERT(dvlp != NULL); | |
7250 | |
7251 mdi_client_set_vhci_private(tgt_dip, NULL); | |
7252 | |
7253 guid = dvlp->svl_lun_wwn; | |
7254 ASSERT(guid != NULL); | |
7255 VHCI_DEBUG(4, (CE_NOTE, NULL, "!vhci_lun_free: %s\n", guid)); | |
7256 | |
7257 mutex_enter(&dvlp->svl_mutex); | |
7258 if (dvlp->svl_active_pclass != NULL) { | |
7259 kmem_free(dvlp->svl_active_pclass, | |
7260 strlen(dvlp->svl_active_pclass)+1); | |
7261 } | |
7262 dvlp->svl_active_pclass = NULL; | |
7263 mutex_exit(&dvlp->svl_mutex); | |
7264 | |
7265 if (dvlp->svl_lun_wwn != NULL) { | |
7266 kmem_free(dvlp->svl_lun_wwn, strlen(dvlp->svl_lun_wwn)+1); | |
7267 } | |
7268 dvlp->svl_lun_wwn = NULL; | |
7269 | |
7270 if (dvlp->svl_fops_name) { | |
7271 kmem_free(dvlp->svl_fops_name, strlen(dvlp->svl_fops_name)+1); | |
7272 } | |
7273 dvlp->svl_fops_name = NULL; | |
7274 | |
6023
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
7275 if (dvlp->svl_fops_ctpriv != NULL) { |
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
7276 dvlp->svl_fops->sfo_device_unprobe(sd, dvlp->svl_fops_ctpriv); |
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
7277 } |
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
7278 |
4851 | 7279 if (dvlp->svl_flags & VLUN_TASK_D_ALIVE_FLG) |
7280 taskq_destroy(dvlp->svl_taskq); | |
7281 | |
7282 mutex_destroy(&dvlp->svl_mutex); | |
7283 cv_destroy(&dvlp->svl_cv); | |
7284 sema_destroy(&dvlp->svl_pgr_sema); | |
7285 kmem_free(dvlp, sizeof (*dvlp)); | |
4896
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7286 /* |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7287 * vhci_lun_free may be called before the tgt_dip |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7288 * initialization so check if the sd is NULL. |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7289 */ |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7290 if (sd != NULL) |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
7291 scsi_device_hba_private_set(sd, NULL); |
4851 | 7292 } |
7293 | |
7294 int | |
7295 vhci_do_scsi_cmd(struct scsi_pkt *pkt) | |
7296 { | |
7297 int err = 0; | |
7298 int retry_cnt = 0; | |
7299 struct scsi_extended_sense *sns; | |
7300 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7301 #ifdef DEBUG |
6962
225346ebbb42
6719151 scsi_vhci debug kernels spews a *lot* on the console during boot
rralphs
parents:
6941
diff
changeset
|
7302 if (vhci_debug > 5) { |
225346ebbb42
6719151 scsi_vhci debug kernels spews a *lot* on the console during boot
rralphs
parents:
6941
diff
changeset
|
7303 vhci_print_cdb(pkt->pkt_address.a_hba_tran->tran_hba_dip, |
225346ebbb42
6719151 scsi_vhci debug kernels spews a *lot* on the console during boot
rralphs
parents:
6941
diff
changeset
|
7304 CE_WARN, "Vhci command", pkt->pkt_cdbp); |
225346ebbb42
6719151 scsi_vhci debug kernels spews a *lot* on the console during boot
rralphs
parents:
6941
diff
changeset
|
7305 } |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7306 #endif |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7307 |
4851 | 7308 retry: |
7309 err = scsi_poll(pkt); | |
7310 if (err) { | |
7311 if (pkt->pkt_cdbp[0] == SCMD_RELEASE) { | |
7312 if (SCBP_C(pkt) == STATUS_RESERVATION_CONFLICT) { | |
7313 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7314 "!v_s_do_s_c: RELEASE conflict\n")); | |
7315 return (0); | |
7316 } | |
7317 } | |
7318 if (retry_cnt++ < 3) { | |
7319 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7320 "!v_s_do_s_c:retry packet 0x%p " | |
7321 "status 0x%x reason %s", | |
7322 (void *)pkt, SCBP_C(pkt), | |
7323 scsi_rname(pkt->pkt_reason))); | |
7324 if ((pkt->pkt_reason == CMD_CMPLT) && | |
7325 (SCBP_C(pkt) == STATUS_CHECK) && | |
7326 (pkt->pkt_state & STATE_ARQ_DONE)) { | |
7327 sns = &(((struct scsi_arq_status *)(uintptr_t) | |
7328 (pkt->pkt_scbp))->sts_sensedata); | |
7329 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7330 "!v_s_do_s_c:retry " | |
7331 "packet 0x%p sense data %s", (void *)pkt, | |
7332 scsi_sname(sns->es_key))); | |
7333 } | |
7334 goto retry; | |
7335 } | |
7336 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7337 "!v_s_do_s_c: failed transport 0x%p 0x%x", | |
7338 (void *)pkt, SCBP_C(pkt))); | |
7339 return (0); | |
7340 } | |
7341 | |
7342 switch (pkt->pkt_reason) { | |
7343 case CMD_TIMEOUT: | |
7344 VHCI_DEBUG(1, (CE_WARN, NULL, "!pkt timed " | |
7345 "out (pkt 0x%p)", (void *)pkt)); | |
7346 return (0); | |
7347 case CMD_CMPLT: | |
7348 switch (SCBP_C(pkt)) { | |
7349 case STATUS_GOOD: | |
7350 break; | |
7351 case STATUS_CHECK: | |
7352 if (pkt->pkt_state & STATE_ARQ_DONE) { | |
7353 sns = &((( | |
7354 struct scsi_arq_status *) | |
7355 (uintptr_t) | |
7356 (pkt->pkt_scbp))-> | |
7357 sts_sensedata); | |
7358 if ((sns->es_key == | |
7359 KEY_UNIT_ATTENTION) || | |
7360 (sns->es_key == | |
7361 KEY_NOT_READY)) { | |
7362 /* | |
7363 * clear unit attn. | |
7364 */ | |
7365 | |
7366 VHCI_DEBUG(1, | |
7367 (CE_WARN, NULL, | |
7368 "!v_s_do_s_c: " | |
7369 "retry " | |
7370 "packet 0x%p sense " | |
7371 "data %s", | |
7372 (void *)pkt, | |
7373 scsi_sname | |
7374 (sns->es_key))); | |
7375 goto retry; | |
7376 } | |
7377 VHCI_DEBUG(4, (CE_WARN, NULL, | |
7378 "!ARQ while " | |
7379 "transporting " | |
7380 "(pkt 0x%p)", | |
7381 (void *)pkt)); | |
7382 return (0); | |
7383 } | |
7384 return (0); | |
7385 default: | |
7386 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7387 "!Bad status returned " | |
7388 "(pkt 0x%p, status %x)", | |
7389 (void *)pkt, SCBP_C(pkt))); | |
7390 return (0); | |
7391 } | |
7392 break; | |
7393 case CMD_INCOMPLETE: | |
7394 case CMD_RESET: | |
7395 case CMD_ABORTED: | |
7396 case CMD_TRAN_ERR: | |
7397 if (retry_cnt++ < 1) { | |
7398 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7399 "!v_s_do_s_c: retry packet 0x%p %s", | |
7400 (void *)pkt, scsi_rname(pkt->pkt_reason))); | |
7401 goto retry; | |
7402 } | |
7403 /* FALLTHROUGH */ | |
7404 default: | |
7405 VHCI_DEBUG(1, (CE_WARN, NULL, "!pkt did not " | |
7406 "complete successfully (pkt 0x%p," | |
7407 "reason %x)", (void *)pkt, pkt->pkt_reason)); | |
7408 return (0); | |
7409 } | |
7410 return (1); | |
7411 } | |
7412 | |
7413 static int | |
7414 vhci_quiesce_lun(struct scsi_vhci_lun *vlun) | |
7415 { | |
7416 mdi_pathinfo_t *pip, *spip; | |
7417 dev_info_t *cdip; | |
7418 struct scsi_vhci_priv *svp; | |
7419 mdi_pathinfo_state_t pstate; | |
7420 uint32_t p_ext_state; | |
7421 int circular; | |
7422 | |
7423 cdip = vlun->svl_dip; | |
7424 pip = spip = NULL; | |
7425 ndi_devi_enter(cdip, &circular); | |
7426 pip = mdi_get_next_phci_path(cdip, NULL); | |
7427 while (pip != NULL) { | |
7428 (void) mdi_pi_get_state2(pip, &pstate, &p_ext_state); | |
7429 if (pstate != MDI_PATHINFO_STATE_ONLINE) { | |
7430 spip = pip; | |
7431 pip = mdi_get_next_phci_path(cdip, spip); | |
7432 continue; | |
7433 } | |
7434 mdi_hold_path(pip); | |
7435 ndi_devi_exit(cdip, circular); | |
7436 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
7437 mutex_enter(&svp->svp_mutex); | |
7438 while (svp->svp_cmds != 0) { | |
7439 if (cv_timedwait(&svp->svp_cv, &svp->svp_mutex, | |
7440 ddi_get_lbolt() + drv_usectohz | |
7441 (vhci_path_quiesce_timeout * 1000000)) == -1) { | |
7442 mutex_exit(&svp->svp_mutex); | |
7443 mdi_rele_path(pip); | |
7444 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7445 "Quiesce of lun is not successful " | |
7446 "vlun: 0x%p.", (void *)vlun)); | |
7447 return (0); | |
7448 } | |
7449 } | |
7450 mutex_exit(&svp->svp_mutex); | |
7451 ndi_devi_enter(cdip, &circular); | |
7452 spip = pip; | |
7453 pip = mdi_get_next_phci_path(cdip, spip); | |
7454 mdi_rele_path(spip); | |
7455 } | |
7456 ndi_devi_exit(cdip, circular); | |
7457 return (1); | |
7458 } | |
7459 | |
7460 static int | |
7461 vhci_pgr_validate_and_register(scsi_vhci_priv_t *svp) | |
7462 { | |
7463 scsi_vhci_lun_t *vlun; | |
7464 vhci_prout_t *prout; | |
7465 int rval, success; | |
7466 mdi_pathinfo_t *pip, *npip; | |
7467 scsi_vhci_priv_t *osvp; | |
7468 dev_info_t *cdip; | |
7469 uchar_t cdb_1; | |
7470 uchar_t temp_res_key[MHIOC_RESV_KEY_SIZE]; | |
7471 | |
7472 | |
7473 /* | |
7474 * see if there are any other paths available; if none, | |
7475 * then there is nothing to do. | |
7476 */ | |
7477 cdip = svp->svp_svl->svl_dip; | |
7478 rval = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH | | |
7479 MDI_SELECT_STANDBY_PATH, NULL, &pip); | |
7480 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
7481 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7482 "%s%d: vhci_pgr_validate_and_register: first path\n", | |
7483 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
7484 return (1); | |
7485 } | |
7486 | |
7487 vlun = svp->svp_svl; | |
7488 prout = &vlun->svl_prout; | |
7489 ASSERT(vlun->svl_pgr_active != 0); | |
7490 | |
7491 /* | |
7492 * When the path was busy/offlined, some other host might have | |
7493 * cleared this key. Validate key on some other path first. | |
7494 * If it fails, return failure. | |
7495 */ | |
7496 | |
7497 npip = pip; | |
7498 pip = NULL; | |
7499 success = 0; | |
7500 | |
7501 /* Save the res key */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7502 bcopy(prout->res_key, temp_res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7503 |
7504 /* | |
7505 * Sometimes CDB from application can be a Register_And_Ignore. | |
7506 * Instead of validation, this cdb would result in force registration. | |
7507 * Convert it to normal cdb for validation. | |
7508 * After that be sure to restore the cdb. | |
7509 */ | |
7510 cdb_1 = vlun->svl_cdb[1]; | |
7511 vlun->svl_cdb[1] &= 0xe0; | |
7512 | |
7513 do { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7514 osvp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(npip); |
4851 | 7515 if (osvp == NULL) { |
7516 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7517 "vhci_pgr_validate_and_register: no " | |
7518 "client priv! 0x%p offlined?\n", | |
7519 (void *)npip)); | |
7520 goto next_path_1; | |
7521 } | |
7522 | |
7523 if (osvp == svp) { | |
7524 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7525 "vhci_pgr_validate_and_register: same svp 0x%p" | |
7526 " npip 0x%p vlun 0x%p\n", | |
7527 (void *)svp, (void *)npip, (void *)vlun)); | |
7528 goto next_path_1; | |
7529 } | |
7530 | |
7531 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7532 "vhci_pgr_validate_and_register: First validate on" | |
7533 " osvp 0x%p being done. vlun 0x%p thread 0x%p Before bcopy" | |
7534 " cdb1 %x\n", (void *)osvp, (void *)vlun, | |
7535 (void *)curthread, vlun->svl_cdb[1])); | |
7536 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy:"); | |
7537 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7538 bcopy(prout->service_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7539 |
7540 VHCI_DEBUG(4, (CE_WARN, NULL, "vlun 0x%p After bcopy", | |
7541 (void *)vlun)); | |
7542 vhci_print_prout_keys(vlun, "v_pgr_val_reg: after bcopy: "); | |
7543 | |
7544 rval = vhci_do_prout(osvp); | |
7545 if (rval == 1) { | |
7546 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7547 "%s%d: vhci_pgr_validate_and_register: key" | |
7548 " validated thread 0x%p\n", ddi_driver_name(cdip), | |
7549 ddi_get_instance(cdip), (void *)curthread)); | |
7550 pip = npip; | |
7551 success = 1; | |
7552 break; | |
7553 } else { | |
7554 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7555 "vhci_pgr_validate_and_register: First validation" | |
7556 " on osvp 0x%p failed %x\n", (void *)osvp, rval)); | |
7557 vhci_print_prout_keys(vlun, "v_pgr_val_reg: failed:"); | |
7558 } | |
7559 | |
7560 /* | |
7561 * Try other paths | |
7562 */ | |
7563 next_path_1: | |
7564 pip = npip; | |
7565 rval = mdi_select_path(cdip, NULL, | |
7566 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, | |
7567 pip, &npip); | |
7568 mdi_rele_path(pip); | |
7569 } while ((rval == MDI_SUCCESS) && (npip != NULL)); | |
7570 | |
7571 | |
7572 /* Be sure to restore original cdb */ | |
7573 vlun->svl_cdb[1] = cdb_1; | |
7574 | |
7575 /* Restore the res_key */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7576 bcopy(temp_res_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7577 |
7578 /* | |
7579 * If key could not be registered on any path for the first time, | |
7580 * return success as online should still continue. | |
7581 */ | |
7582 if (success == 0) { | |
7583 return (1); | |
7584 } | |
7585 | |
7586 ASSERT(pip != NULL); | |
7587 | |
7588 /* | |
7589 * Force register on new path | |
7590 */ | |
7591 cdb_1 = vlun->svl_cdb[1]; /* store the cdb */ | |
7592 | |
7593 vlun->svl_cdb[1] &= 0xe0; | |
7594 vlun->svl_cdb[1] |= VHCI_PROUT_R_AND_IGNORE; | |
7595 | |
7596 vhci_print_prout_keys(vlun, "v_pgr_val_reg: keys before bcopy: "); | |
7597 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7598 bcopy(prout->active_service_key, prout->service_key, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7599 MHIOC_RESV_KEY_SIZE); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7600 bcopy(prout->active_res_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7601 |
7602 vhci_print_prout_keys(vlun, "v_pgr_val_reg:keys after bcopy: "); | |
7603 | |
7604 rval = vhci_do_prout(svp); | |
7605 vlun->svl_cdb[1] = cdb_1; /* restore the cdb */ | |
7606 if (rval != 1) { | |
7607 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7608 "vhci_pgr_validate_and_register: register on new" | |
7609 " path 0x%p svp 0x%p failed %x\n", | |
7610 (void *)pip, (void *)svp, rval)); | |
7611 vhci_print_prout_keys(vlun, "v_pgr_val_reg: reg failed: "); | |
7612 mdi_rele_path(pip); | |
7613 return (0); | |
7614 } | |
7615 | |
7616 if (bcmp(prout->service_key, zero_key, MHIOC_RESV_KEY_SIZE) == 0) { | |
7617 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7618 "vhci_pgr_validate_and_register: zero service key\n")); | |
7619 mdi_rele_path(pip); | |
7620 return (rval); | |
7621 } | |
7622 | |
7623 /* | |
7624 * While the key was force registered, some other host might have | |
7625 * cleared the key. Re-validate key on another pre-existing path | |
7626 * before declaring success. | |
7627 */ | |
7628 npip = pip; | |
7629 pip = NULL; | |
7630 | |
7631 /* | |
7632 * Sometimes CDB from application can be Register and Ignore. | |
7633 * Instead of validation, it would result in force registration. | |
7634 * Convert it to normal cdb for validation. | |
7635 * After that be sure to restore the cdb. | |
7636 */ | |
7637 cdb_1 = vlun->svl_cdb[1]; | |
7638 vlun->svl_cdb[1] &= 0xe0; | |
7639 success = 0; | |
7640 | |
7641 do { | |
7642 osvp = (scsi_vhci_priv_t *) | |
7643 mdi_pi_get_vhci_private(npip); | |
7644 if (osvp == NULL) { | |
7645 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7646 "vhci_pgr_validate_and_register: no " | |
7647 "client priv! 0x%p offlined?\n", | |
7648 (void *)npip)); | |
7649 goto next_path_2; | |
7650 } | |
7651 | |
7652 if (osvp == svp) { | |
7653 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7654 "vhci_pgr_validate_and_register: same osvp 0x%p" | |
7655 " npip 0x%p vlun 0x%p\n", | |
7656 (void *)svp, (void *)npip, (void *)vlun)); | |
7657 goto next_path_2; | |
7658 } | |
7659 | |
7660 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7661 "vhci_pgr_validate_and_register: Re-validation on" | |
7662 " osvp 0x%p being done. vlun 0x%p Before bcopy cdb1 %x\n", | |
7663 (void *)osvp, (void *)vlun, vlun->svl_cdb[1])); | |
7664 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy: "); | |
7665 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7666 bcopy(prout->service_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7667 |
7668 vhci_print_prout_keys(vlun, "v_pgr_val_reg: after bcopy: "); | |
7669 | |
7670 rval = vhci_do_prout(osvp); | |
7671 if (rval == 1) { | |
7672 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7673 "%s%d: vhci_pgr_validate_and_register: key" | |
7674 " validated thread 0x%p\n", ddi_driver_name(cdip), | |
7675 ddi_get_instance(cdip), (void *)curthread)); | |
7676 pip = npip; | |
7677 success = 1; | |
7678 break; | |
7679 } else { | |
7680 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7681 "vhci_pgr_validate_and_register: Re-validation on" | |
7682 " osvp 0x%p failed %x\n", (void *)osvp, rval)); | |
7683 vhci_print_prout_keys(vlun, | |
7684 "v_pgr_val_reg: reval failed: "); | |
7685 } | |
7686 | |
7687 /* | |
7688 * Try other paths | |
7689 */ | |
7690 next_path_2: | |
7691 pip = npip; | |
7692 rval = mdi_select_path(cdip, NULL, | |
7693 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, | |
7694 pip, &npip); | |
7695 mdi_rele_path(pip); | |
7696 } while ((rval == MDI_SUCCESS) && (npip != NULL)); | |
7697 | |
7698 /* Be sure to restore original cdb */ | |
7699 vlun->svl_cdb[1] = cdb_1; | |
7700 | |
7701 if (success == 1) { | |
7702 /* Successfully validated registration */ | |
7703 mdi_rele_path(pip); | |
7704 return (1); | |
7705 } | |
7706 | |
7707 VHCI_DEBUG(4, (CE_WARN, NULL, "key validation failed")); | |
7708 | |
7709 /* | |
7710 * key invalid, back out by registering key value of 0 | |
7711 */ | |
7712 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7713 "vhci_pgr_validate_and_register: backout on" | |
7714 " svp 0x%p being done\n", (void *)svp)); | |
7715 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy: "); | |
7716 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7717 bcopy(prout->service_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7718 bzero(prout->service_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7719 |
7720 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy: "); | |
7721 | |
7722 /* | |
7723 * Get a new path | |
7724 */ | |
7725 rval = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH | | |
7726 MDI_SELECT_STANDBY_PATH, NULL, &pip); | |
7727 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
7728 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7729 "%s%d: vhci_pgr_validate_and_register: no valid pip\n", | |
7730 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
7731 return (0); | |
7732 } | |
7733 | |
7734 if ((rval = vhci_do_prout(svp)) != 1) { | |
7735 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7736 "vhci_pgr_validate_and_register: backout on" | |
7737 " svp 0x%p failed\n", (void *)svp)); | |
7738 vhci_print_prout_keys(vlun, "backout failed"); | |
7739 | |
7740 VHCI_DEBUG(4, (CE_WARN, NULL, | |
7741 "%s%d: vhci_pgr_validate_and_register: key" | |
7742 " validation and backout failed", ddi_driver_name(cdip), | |
7743 ddi_get_instance(cdip))); | |
7744 if (rval == VHCI_PGR_ILLEGALOP) { | |
7745 VHCI_DEBUG(4, (CE_WARN, NULL, | |
7746 "%s%d: vhci_pgr_validate_and_register: key" | |
7747 " already cleared", ddi_driver_name(cdip), | |
7748 ddi_get_instance(cdip))); | |
7749 rval = 1; | |
7750 } else | |
7751 rval = 0; | |
7752 } else { | |
7753 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7754 "%s%d: vhci_pgr_validate_and_register: key" | |
7755 " validation failed, key backed out\n", | |
7756 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
7757 vhci_print_prout_keys(vlun, "v_pgr_val_reg: key backed out: "); | |
7758 } | |
7759 mdi_rele_path(pip); | |
7760 | |
7761 return (rval); | |
7762 } | |
7763 | |
7764 /* | |
7765 * taskq routine to dispatch a scsi cmd to vhci_scsi_start. This ensures | |
7766 * that vhci_scsi_start is not called in interrupt context. | |
7767 * As the upper layer gets TRAN_ACCEPT when the command is dispatched, we | |
7768 * need to complete the command if something goes wrong. | |
7769 */ | |
7770 static void | |
7771 vhci_dispatch_scsi_start(void *arg) | |
7772 { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7773 struct vhci_pkt *vpkt = (struct vhci_pkt *)arg; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7774 struct scsi_pkt *tpkt = vpkt->vpkt_tgt_pkt; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7775 int rval = TRAN_BUSY; |
4851 | 7776 |
7777 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_dispatch_scsi_start: sending" | |
7778 " scsi-2 reserve for 0x%p\n", | |
7779 (void *)ADDR2DIP(&(vpkt->vpkt_tgt_pkt->pkt_address)))); | |
7780 | |
7781 /* | |
7782 * To prevent the taskq from being called recursively we set the | |
7783 * the VHCI_PKT_THRU_TASKQ bit in the vhci_pkt_states. | |
7784 */ | |
7785 vpkt->vpkt_state |= VHCI_PKT_THRU_TASKQ; | |
7786 | |
7787 /* | |
7788 * Wait for the transport to get ready to send packets | |
7789 * and if it times out, it will return something other than | |
7790 * TRAN_BUSY. The vhci_reserve_delay may want to | |
7791 * get tuned for other transports and is therefore a global. | |
7792 * Using delay since this routine is called by taskq dispatch | |
7793 * and not called during interrupt context. | |
7794 */ | |
7795 while ((rval = vhci_scsi_start(&(vpkt->vpkt_tgt_pkt->pkt_address), | |
7796 vpkt->vpkt_tgt_pkt)) == TRAN_BUSY) { | |
7797 delay(drv_usectohz(vhci_reserve_delay)); | |
7798 } | |
7799 | |
7800 switch (rval) { | |
7801 case TRAN_ACCEPT: | |
7802 return; | |
7803 | |
7804 default: | |
7805 /* | |
7806 * This pkt shall be retried, and to ensure another taskq | |
7807 * is dispatched for it, clear the VHCI_PKT_THRU_TASKQ | |
7808 * flag. | |
7809 */ | |
7810 vpkt->vpkt_state &= ~VHCI_PKT_THRU_TASKQ; | |
7811 | |
7812 /* Ensure that the pkt is retried without a reset */ | |
7813 tpkt->pkt_reason = CMD_ABORTED; | |
7814 tpkt->pkt_statistics |= STAT_ABORTED; | |
7815 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_dispatch_scsi_start: " | |
7816 "TRAN_rval %d returned for dip 0x%p", rval, | |
7817 (void *)ADDR2DIP(&(vpkt->vpkt_tgt_pkt->pkt_address)))); | |
7818 break; | |
7819 } | |
7820 | |
7821 /* | |
7822 * vpkt_org_vpkt should always be NULL here if the retry command | |
7823 * has been successfully dispatched. If vpkt_org_vpkt != NULL at | |
7824 * this point, it is an error so restore the original vpkt and | |
7825 * return an error to the target driver so it can retry the | |
7826 * command as appropriate. | |
7827 */ | |
7828 if (vpkt->vpkt_org_vpkt != NULL) { | |
7829 struct vhci_pkt *new_vpkt = vpkt; | |
7830 scsi_vhci_priv_t *svp = (scsi_vhci_priv_t *) | |
7831 mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
7832 | |
7833 vpkt = vpkt->vpkt_org_vpkt; | |
7834 | |
7835 vpkt->vpkt_tgt_pkt->pkt_reason = tpkt->pkt_reason; | |
7836 vpkt->vpkt_tgt_pkt->pkt_statistics = tpkt->pkt_statistics; | |
7837 | |
7838 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
7839 new_vpkt->vpkt_tgt_pkt); | |
7840 | |
7841 tpkt = vpkt->vpkt_tgt_pkt; | |
7842 } | |
7843 | |
7844 if (tpkt->pkt_comp) { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7845 tpkt->pkt_comp(tpkt); |
4851 | 7846 } |
7847 } | |
7848 | |
7849 static void | |
7850 vhci_initiate_auto_failback(void *arg) | |
7851 { | |
7852 struct scsi_vhci_lun *vlun = (struct scsi_vhci_lun *)arg; | |
7853 dev_info_t *vdip, *cdip; | |
7854 int held; | |
7855 | |
7856 cdip = vlun->svl_dip; | |
7857 vdip = ddi_get_parent(cdip); | |
7858 | |
7859 VHCI_HOLD_LUN(vlun, VH_SLEEP, held); | |
7860 | |
7861 /* | |
7862 * Perform a final check to see if the active path class is indeed | |
7863 * not the prefered path class. As in the time the auto failback | |
7864 * was dispatched, an external failover could have been detected. | |
7865 * [Some other host could have detected this condition and triggered | |
7866 * the auto failback before]. | |
7867 * In such a case if we go ahead with failover we will be negating the | |
7868 * whole purpose of auto failback. | |
7869 */ | |
7870 mutex_enter(&vlun->svl_mutex); | |
7871 if (vlun->svl_active_pclass != NULL) { | |
7872 char *best_pclass; | |
7873 struct scsi_failover_ops *fo; | |
7874 | |
7875 fo = vlun->svl_fops; | |
7876 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7877 (void) fo->sfo_pathclass_next(NULL, &best_pclass, |
4851 | 7878 vlun->svl_fops_ctpriv); |
7879 if (strcmp(vlun->svl_active_pclass, best_pclass) == 0) { | |
7880 mutex_exit(&vlun->svl_mutex); | |
7881 VHCI_RELEASE_LUN(vlun); | |
7882 VHCI_DEBUG(1, (CE_NOTE, NULL, "Not initiating " | |
7883 "auto failback for %s as %s pathclass already " | |
7884 "active.\n", vlun->svl_lun_wwn, best_pclass)); | |
7885 return; | |
7886 } | |
7887 } | |
7888 mutex_exit(&vlun->svl_mutex); | |
7889 if (mdi_failover(vdip, vlun->svl_dip, MDI_FAILOVER_SYNC) | |
7890 == MDI_SUCCESS) { | |
7891 vhci_log(CE_NOTE, vdip, "!Auto failback operation " | |
7892 "succeeded for device %s (GUID %s)", | |
7893 ddi_node_name(cdip), vlun->svl_lun_wwn); | |
7894 } else { | |
7895 vhci_log(CE_NOTE, vdip, "!Auto failback operation " | |
7896 "failed for device %s (GUID %s)", | |
7897 ddi_node_name(cdip), vlun->svl_lun_wwn); | |
7898 } | |
7899 VHCI_RELEASE_LUN(vlun); | |
7900 } | |
7901 | |
7902 #ifdef DEBUG | |
7903 static void | |
7904 vhci_print_prin_keys(vhci_prin_readkeys_t *prin, int numkeys) | |
7905 { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7906 vhci_clean_print(NULL, 5, "Current PGR Keys", |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7907 (uchar_t *)prin, numkeys * 8); |
4851 | 7908 } |
7909 #endif | |
7910 | |
7911 static void | |
7912 vhci_print_prout_keys(scsi_vhci_lun_t *vlun, char *msg) | |
7913 { | |
7914 int i; | |
7915 vhci_prout_t *prout; | |
7916 char buf1[4*MHIOC_RESV_KEY_SIZE + 1]; | |
7917 char buf2[4*MHIOC_RESV_KEY_SIZE + 1]; | |
7918 char buf3[4*MHIOC_RESV_KEY_SIZE + 1]; | |
7919 char buf4[4*MHIOC_RESV_KEY_SIZE + 1]; | |
7920 | |
7921 prout = &vlun->svl_prout; | |
7922 | |
7923 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
7924 (void) sprintf(&buf1[4*i], "[%02x]", prout->res_key[i]); | |
7925 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
7926 (void) sprintf(&buf2[(4*i)], "[%02x]", prout->service_key[i]); | |
7927 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
7928 (void) sprintf(&buf3[4*i], "[%02x]", prout->active_res_key[i]); | |
7929 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
7930 (void) sprintf(&buf4[4*i], "[%02x]", | |
7931 prout->active_service_key[i]); | |
7932 | |
7933 /* Printing all in one go. Otherwise it will jumble up */ | |
7934 VHCI_DEBUG(5, (CE_CONT, NULL, "%s vlun 0x%p, thread 0x%p\n" | |
7935 "res_key: : %s\n" | |
7936 "service_key : %s\n" | |
7937 "active_res_key : %s\n" | |
7938 "active_service_key: %s\n", | |
7939 msg, (void *)vlun, (void *)curthread, buf1, buf2, buf3, buf4)); | |
7940 } | |
7941 | |
7942 /* | |
7943 * Called from vhci_scsi_start to update the pHCI pkt with target packet. | |
7944 */ | |
7945 static void | |
7946 vhci_update_pHCI_pkt(struct vhci_pkt *vpkt, struct scsi_pkt *pkt) | |
7947 { | |
7948 | |
7949 ASSERT(vpkt->vpkt_hba_pkt); | |
7950 | |
7951 vpkt->vpkt_hba_pkt->pkt_flags = pkt->pkt_flags; | |
7952 vpkt->vpkt_hba_pkt->pkt_flags |= FLAG_NOQUEUE; | |
7953 | |
7954 if ((vpkt->vpkt_hba_pkt->pkt_flags & FLAG_NOINTR) || | |
7955 MDI_PI_IS_SUSPENDED(vpkt->vpkt_path)) { | |
7956 /* | |
7957 * Polled Command is requested or HBA is in | |
7958 * suspended state | |
7959 */ | |
7960 vpkt->vpkt_hba_pkt->pkt_flags |= FLAG_NOINTR; | |
7961 vpkt->vpkt_hba_pkt->pkt_comp = NULL; | |
7962 } else { | |
7963 vpkt->vpkt_hba_pkt->pkt_comp = vhci_intr; | |
7964 } | |
7965 vpkt->vpkt_hba_pkt->pkt_time = pkt->pkt_time; | |
7966 bcopy(pkt->pkt_cdbp, vpkt->vpkt_hba_pkt->pkt_cdbp, | |
7967 vpkt->vpkt_tgt_init_cdblen); | |
7968 vpkt->vpkt_hba_pkt->pkt_resid = pkt->pkt_resid; | |
7969 | |
7970 /* Re-initialize the following pHCI packet state information */ | |
7971 vpkt->vpkt_hba_pkt->pkt_state = 0; | |
7972 vpkt->vpkt_hba_pkt->pkt_statistics = 0; | |
7973 vpkt->vpkt_hba_pkt->pkt_reason = 0; | |
7974 } | |
7975 | |
7976 static int | |
7977 vhci_scsi_bus_power(dev_info_t *parent, void *impl_arg, pm_bus_power_op_t op, | |
7978 void *arg, void *result) | |
7979 { | |
7980 int ret = DDI_SUCCESS; | |
7981 | |
7982 /* | |
7983 * Generic processing in MPxIO framework | |
7984 */ | |
7985 ret = mdi_bus_power(parent, impl_arg, op, arg, result); | |
7986 | |
7987 switch (ret) { | |
7988 case MDI_SUCCESS: | |
7989 ret = DDI_SUCCESS; | |
7990 break; | |
7991 case MDI_FAILURE: | |
7992 ret = DDI_FAILURE; | |
7993 break; | |
7994 default: | |
7995 break; | |
7996 } | |
7997 | |
7998 return (ret); | |
7999 } | |
8000 | |
8001 static int | |
8002 vhci_pHCI_cap(struct scsi_address *ap, char *cap, int val, int whom, | |
8003 mdi_pathinfo_t *pip) | |
8004 { | |
8005 dev_info_t *cdip; | |
8006 mdi_pathinfo_t *npip = NULL; | |
8007 scsi_vhci_priv_t *svp = NULL; | |
8008 struct scsi_address *pap = NULL; | |
8009 scsi_hba_tran_t *hba = NULL; | |
8010 int sps; | |
8011 int mps_flag; | |
8012 int rval = 0; | |
8013 | |
8014 mps_flag = (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH); | |
8015 if (pip) { | |
8016 /* | |
8017 * If the call is from vhci_pathinfo_state_change, | |
8018 * then this path was busy and is becoming ready to accept IO. | |
8019 */ | |
8020 ASSERT(ap != NULL); | |
8021 hba = ap->a_hba_tran; | |
8022 ASSERT(hba != NULL); | |
8023 rval = scsi_ifsetcap(ap, cap, val, whom); | |
8024 | |
8025 VHCI_DEBUG(2, (CE_NOTE, NULL, | |
8026 "!vhci_pHCI_cap: only on path %p, ap %p, rval %x\n", | |
8027 (void *)pip, (void *)ap, rval)); | |
8028 | |
8029 return (rval); | |
8030 } | |
8031 | |
8032 /* | |
8033 * Set capability on all the pHCIs. | |
8034 * If any path is busy, then the capability would be set by | |
8035 * vhci_pathinfo_state_change. | |
8036 */ | |
8037 | |
8038 cdip = ADDR2DIP(ap); | |
8039 ASSERT(cdip != NULL); | |
8040 sps = mdi_select_path(cdip, NULL, mps_flag, NULL, &pip); | |
8041 if ((sps != MDI_SUCCESS) || (pip == NULL)) { | |
8042 VHCI_DEBUG(2, (CE_WARN, NULL, | |
8043 "!vhci_pHCI_cap: Unable to get a path, dip 0x%p", | |
8044 (void *)cdip)); | |
8045 return (0); | |
8046 } | |
8047 | |
8048 again: | |
8049 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
8050 if (svp == NULL) { | |
8051 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_pHCI_cap: " | |
8052 "priv is NULL, pip 0x%p", (void *)pip)); | |
8053 mdi_rele_path(pip); | |
8054 return (rval); | |
8055 } | |
8056 | |
8057 if (svp->svp_psd == NULL) { | |
8058 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_pHCI_cap: " | |
8059 "psd is NULL, pip 0x%p, svp 0x%p", | |
8060 (void *)pip, (void *)svp)); | |
8061 mdi_rele_path(pip); | |
8062 return (rval); | |
8063 } | |
8064 | |
8065 pap = &svp->svp_psd->sd_address; | |
8066 ASSERT(pap != NULL); | |
8067 hba = pap->a_hba_tran; | |
8068 ASSERT(hba != NULL); | |
8069 | |
8070 if (hba->tran_setcap != NULL) { | |
8071 rval = scsi_ifsetcap(pap, cap, val, whom); | |
8072 | |
8073 VHCI_DEBUG(2, (CE_NOTE, NULL, | |
8074 "!vhci_pHCI_cap: path %p, ap %p, rval %x\n", | |
8075 (void *)pip, (void *)ap, rval)); | |
8076 | |
8077 /* | |
8078 * Select next path and issue the setcap, repeat | |
8079 * until all paths are exhausted | |
8080 */ | |
8081 sps = mdi_select_path(cdip, NULL, mps_flag, pip, &npip); | |
8082 if ((sps != MDI_SUCCESS) || (npip == NULL)) { | |
8083 mdi_rele_path(pip); | |
8084 return (1); | |
8085 } | |
8086 mdi_rele_path(pip); | |
8087 pip = npip; | |
8088 goto again; | |
8089 } | |
8090 mdi_rele_path(pip); | |
8091 return (rval); | |
8092 } | |
8093 | |
8094 static int | |
8095 vhci_scsi_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op, | |
8096 void *arg, dev_info_t **child) | |
8097 { | |
8098 char *guid; | |
8099 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8100 if (vhci_bus_config_debug) |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8101 flags |= NDI_DEVI_DEBUG; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8102 |
4851 | 8103 if (op == BUS_CONFIG_ONE || op == BUS_UNCONFIG_ONE) |
8104 guid = vhci_devnm_to_guid((char *)arg); | |
8105 else | |
8106 guid = NULL; | |
8107 | |
8108 if (mdi_vhci_bus_config(pdip, flags, op, arg, child, guid) | |
8109 == MDI_SUCCESS) | |
8110 return (NDI_SUCCESS); | |
8111 else | |
8112 return (NDI_FAILURE); | |
8113 } | |
8114 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8115 static int |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8116 vhci_scsi_bus_unconfig(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op, |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8117 void *arg) |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8118 { |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8119 if (vhci_bus_config_debug) |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8120 flags |= NDI_DEVI_DEBUG; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8121 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8122 return (ndi_busop_bus_unconfig(pdip, flags, op, arg)); |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8123 } |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8124 |
4851 | 8125 /* |
8126 * Take the original vhci_pkt, create a duplicate of the pkt for resending | |
8127 * as though it originated in ssd. | |
8128 */ | |
8129 static struct scsi_pkt * | |
8130 vhci_create_retry_pkt(struct vhci_pkt *vpkt) | |
8131 { | |
8132 struct vhci_pkt *new_vpkt = NULL; | |
8133 struct scsi_pkt *pkt = NULL; | |
8134 | |
8135 scsi_vhci_priv_t *svp = (scsi_vhci_priv_t *) | |
8136 mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
8137 | |
8138 /* | |
8139 * Ensure consistent data at completion time by setting PKT_CONSISTENT | |
8140 */ | |
8141 pkt = vhci_scsi_init_pkt(&svp->svp_psd->sd_address, pkt, | |
8142 vpkt->vpkt_tgt_init_bp, vpkt->vpkt_tgt_init_cdblen, | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8143 vpkt->vpkt_tgt_init_scblen, 0, PKT_CONSISTENT, NULL_FUNC, NULL); |
4851 | 8144 if (pkt != NULL) { |
8145 new_vpkt = TGTPKT2VHCIPKT(pkt); | |
8146 | |
8147 pkt->pkt_address = vpkt->vpkt_tgt_pkt->pkt_address; | |
8148 pkt->pkt_flags = vpkt->vpkt_tgt_pkt->pkt_flags; | |
8149 pkt->pkt_time = vpkt->vpkt_tgt_pkt->pkt_time; | |
8150 pkt->pkt_comp = vpkt->vpkt_tgt_pkt->pkt_comp; | |
8151 | |
8152 pkt->pkt_resid = 0; | |
8153 pkt->pkt_statistics = 0; | |
8154 pkt->pkt_reason = 0; | |
8155 | |
8156 bcopy(vpkt->vpkt_tgt_pkt->pkt_cdbp, | |
8157 pkt->pkt_cdbp, vpkt->vpkt_tgt_init_cdblen); | |
8158 | |
8159 /* | |
8160 * Save a pointer to the original vhci_pkt | |
8161 */ | |
8162 new_vpkt->vpkt_org_vpkt = vpkt; | |
8163 } | |
8164 | |
8165 return (pkt); | |
8166 } | |
8167 | |
8168 /* | |
8169 * Copy the successful completion information from the hba packet into | |
8170 * the original target pkt from the upper layer. Returns the original | |
8171 * vpkt and destroys the new vpkt from the internal retry. | |
8172 */ | |
8173 static struct vhci_pkt * | |
8174 vhci_sync_retry_pkt(struct vhci_pkt *vpkt) | |
8175 { | |
8176 struct vhci_pkt *ret_vpkt = NULL; | |
8177 struct scsi_pkt *tpkt = NULL; | |
8178 struct scsi_pkt *hba_pkt = NULL; | |
8179 scsi_vhci_priv_t *svp = (scsi_vhci_priv_t *) | |
8180 mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
8181 | |
8182 ASSERT(vpkt->vpkt_org_vpkt != NULL); | |
8183 VHCI_DEBUG(0, (CE_NOTE, NULL, "vhci_sync_retry_pkt: Retry pkt " | |
8184 "completed successfully!\n")); | |
8185 | |
8186 ret_vpkt = vpkt->vpkt_org_vpkt; | |
8187 tpkt = ret_vpkt->vpkt_tgt_pkt; | |
8188 hba_pkt = vpkt->vpkt_hba_pkt; | |
8189 | |
8190 /* | |
8191 * Copy the good status into the target driver's packet | |
8192 */ | |
8193 *(tpkt->pkt_scbp) = *(hba_pkt->pkt_scbp); | |
8194 tpkt->pkt_resid = hba_pkt->pkt_resid; | |
8195 tpkt->pkt_state = hba_pkt->pkt_state; | |
8196 tpkt->pkt_statistics = hba_pkt->pkt_statistics; | |
8197 tpkt->pkt_reason = hba_pkt->pkt_reason; | |
8198 | |
8199 /* | |
8200 * Destroy the internally created vpkt for the retry | |
8201 */ | |
8202 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
8203 vpkt->vpkt_tgt_pkt); | |
8204 | |
8205 return (ret_vpkt); | |
8206 } | |
8207 | |
8208 /* restart the request sense request */ | |
8209 static void | |
8210 vhci_uscsi_restart_sense(void *arg) | |
8211 { | |
8212 struct buf *rqbp; | |
8213 struct buf *bp; | |
8214 struct scsi_pkt *rqpkt = (struct scsi_pkt *)arg; | |
8215 mp_uscsi_cmd_t *mp_uscmdp; | |
8216 | |
8217 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8218 "vhci_uscsi_restart_sense: enter: rqpkt: %p", (void *)rqpkt)); | |
8219 | |
8220 if (scsi_transport(rqpkt) != TRAN_ACCEPT) { | |
8221 /* if it fails - need to wakeup the original command */ | |
8222 mp_uscmdp = rqpkt->pkt_private; | |
8223 bp = mp_uscmdp->cmdbp; | |
8224 rqbp = mp_uscmdp->rqbp; | |
8225 ASSERT(mp_uscmdp && bp && rqbp); | |
8226 scsi_free_consistent_buf(rqbp); | |
8227 scsi_destroy_pkt(rqpkt); | |
8228 bp->b_resid = bp->b_bcount; | |
8229 bioerror(bp, EIO); | |
8230 biodone(bp); | |
8231 } | |
8232 } | |
8233 | |
8234 /* | |
8235 * auto-rqsense is not enabled so we have to retrieve the request sense | |
8236 * manually. | |
8237 */ | |
8238 static int | |
8239 vhci_uscsi_send_sense(struct scsi_pkt *pkt, mp_uscsi_cmd_t *mp_uscmdp) | |
8240 { | |
8241 struct buf *rqbp, *cmdbp; | |
8242 struct scsi_pkt *rqpkt; | |
8243 int rval = 0; | |
8244 | |
8245 cmdbp = mp_uscmdp->cmdbp; | |
8246 ASSERT(cmdbp != NULL); | |
8247 | |
8248 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8249 "vhci_uscsi_send_sense: enter: bp: %p pkt: %p scmd: %p", | |
8250 (void *)cmdbp, (void *)pkt, (void *)mp_uscmdp)); | |
8251 /* set up the packet information and cdb */ | |
8252 if ((rqbp = scsi_alloc_consistent_buf(mp_uscmdp->ap, NULL, | |
8253 SENSE_LENGTH, B_READ, NULL, NULL)) == NULL) { | |
8254 return (-1); | |
8255 } | |
8256 | |
8257 if ((rqpkt = scsi_init_pkt(mp_uscmdp->ap, NULL, rqbp, | |
8258 CDB_GROUP0, 1, 0, PKT_CONSISTENT, NULL, NULL)) == NULL) { | |
8259 scsi_free_consistent_buf(rqbp); | |
8260 return (-1); | |
8261 } | |
8262 | |
8263 (void) scsi_setup_cdb((union scsi_cdb *)(intptr_t)rqpkt->pkt_cdbp, | |
8264 SCMD_REQUEST_SENSE, 0, SENSE_LENGTH, 0); | |
8265 | |
8266 mp_uscmdp->rqbp = rqbp; | |
8267 rqbp->b_private = mp_uscmdp; | |
8268 rqpkt->pkt_flags |= FLAG_SENSING; | |
8269 rqpkt->pkt_time = 60; | |
8270 rqpkt->pkt_comp = vhci_uscsi_iodone; | |
8271 rqpkt->pkt_private = mp_uscmdp; | |
8272 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8273 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8274 * NOTE: This code path is related to MPAPI uscsi(7I), so path |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8275 * selection is not based on path_instance. |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8276 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8277 if (scsi_pkt_allocated_correctly(rqpkt)) |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8278 rqpkt->pkt_path_instance = 0; |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8279 |
4851 | 8280 /* get her done */ |
8281 switch (scsi_transport(rqpkt)) { | |
8282 case TRAN_ACCEPT: | |
8283 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: " | |
8284 "transport accepted.")); | |
8285 break; | |
8286 case TRAN_BUSY: | |
8287 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: " | |
8288 "transport busy, setting timeout.")); | |
8289 vhci_restart_timeid = timeout(vhci_uscsi_restart_sense, rqpkt, | |
8290 (drv_usectohz(5 * 1000000))); | |
8291 break; | |
8292 default: | |
8293 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: " | |
8294 "transport failed")); | |
8295 scsi_free_consistent_buf(rqbp); | |
8296 scsi_destroy_pkt(rqpkt); | |
8297 rval = -1; | |
8298 } | |
8299 | |
8300 return (rval); | |
8301 } | |
8302 | |
8303 /* | |
8304 * done routine for the mpapi uscsi command - this is behaving as though | |
8305 * FLAG_DIAGNOSE is set meaning there are no retries except for a manual | |
8306 * request sense. | |
8307 */ | |
8308 void | |
8309 vhci_uscsi_iodone(struct scsi_pkt *pkt) | |
8310 { | |
8311 struct buf *bp; | |
8312 mp_uscsi_cmd_t *mp_uscmdp; | |
8313 struct uscsi_cmd *uscmdp; | |
8314 struct scsi_arq_status *arqstat; | |
8315 int err; | |
8316 | |
8317 mp_uscmdp = (mp_uscsi_cmd_t *)pkt->pkt_private; | |
8318 uscmdp = mp_uscmdp->uscmdp; | |
8319 bp = mp_uscmdp->cmdbp; | |
8320 ASSERT(bp != NULL); | |
8321 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8322 "vhci_uscsi_iodone: enter: bp: %p pkt: %p scmd: %p", | |
8323 (void *)bp, (void *)pkt, (void *)mp_uscmdp)); | |
8324 /* Save the status and the residual into the uscsi_cmd struct */ | |
8325 uscmdp->uscsi_status = ((*(pkt)->pkt_scbp) & STATUS_MASK); | |
8326 uscmdp->uscsi_resid = bp->b_resid; | |
8327 | |
8328 /* return on a very successful command */ | |
8329 if (pkt->pkt_reason == CMD_CMPLT && | |
8330 SCBP_C(pkt) == 0 && ((pkt->pkt_flags & FLAG_SENSING) == 0) && | |
8331 pkt->pkt_resid == 0) { | |
8332 mdi_pi_kstat_iosupdate(mp_uscmdp->pip, bp); | |
8333 scsi_destroy_pkt(pkt); | |
8334 biodone(bp); | |
8335 return; | |
8336 } | |
8337 VHCI_DEBUG(4, (CE_NOTE, NULL, "iodone: reason=0x%x " | |
8338 " pkt_resid=%ld pkt_state: 0x%x b_count: %ld b_resid: %ld", | |
8339 pkt->pkt_reason, pkt->pkt_resid, | |
8340 pkt->pkt_state, bp->b_bcount, bp->b_resid)); | |
8341 | |
8342 err = EIO; | |
8343 | |
8344 arqstat = (struct scsi_arq_status *)(intptr_t)(pkt->pkt_scbp); | |
8345 if (pkt->pkt_reason != CMD_CMPLT) { | |
8346 /* | |
8347 * The command did not complete. | |
8348 */ | |
8349 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8350 "vhci_uscsi_iodone: command did not complete." | |
8351 " reason: %x flag: %x", pkt->pkt_reason, pkt->pkt_flags)); | |
8352 if (pkt->pkt_flags & FLAG_SENSING) { | |
8353 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_TRANSERR); | |
8354 } else if (pkt->pkt_reason == CMD_TIMEOUT) { | |
8355 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_HARDERR); | |
8356 err = ETIMEDOUT; | |
8357 } | |
8358 } else if (pkt->pkt_state & STATE_ARQ_DONE && mp_uscmdp->arq_enabled) { | |
8359 /* | |
8360 * The auto-rqsense happened, and the packet has a filled-in | |
8361 * scsi_arq_status structure, pointed to by pkt_scbp. | |
8362 */ | |
8363 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8364 "vhci_uscsi_iodone: received auto-requested sense")); | |
8365 if (uscmdp->uscsi_flags & USCSI_RQENABLE) { | |
8366 /* get the amount of data to copy into rqbuf */ | |
8367 int rqlen = SENSE_LENGTH - arqstat->sts_rqpkt_resid; | |
8368 rqlen = min(((int)uscmdp->uscsi_rqlen), rqlen); | |
8369 uscmdp->uscsi_rqresid = uscmdp->uscsi_rqlen - rqlen; | |
8370 uscmdp->uscsi_rqstatus = | |
8371 *((char *)&arqstat->sts_rqpkt_status); | |
8372 if (uscmdp->uscsi_rqbuf && uscmdp->uscsi_rqlen && | |
8373 rqlen != 0) { | |
8374 bcopy(&(arqstat->sts_sensedata), | |
8375 uscmdp->uscsi_rqbuf, rqlen); | |
8376 } | |
8377 mdi_pi_kstat_iosupdate(mp_uscmdp->pip, bp); | |
8378 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8379 "vhci_uscsi_iodone: ARQ " | |
8380 "uscsi_rqstatus=0x%x uscsi_rqresid=%d rqlen: %d " | |
8381 "xfer: %d rqpkt_resid: %d\n", | |
8382 uscmdp->uscsi_rqstatus, uscmdp->uscsi_rqresid, | |
8383 uscmdp->uscsi_rqlen, rqlen, | |
8384 arqstat->sts_rqpkt_resid)); | |
8385 } | |
8386 } else if (pkt->pkt_flags & FLAG_SENSING) { | |
8387 struct buf *rqbp; | |
8388 struct scsi_status *rqstatus; | |
8389 | |
8390 rqstatus = (struct scsi_status *)pkt->pkt_scbp; | |
8391 /* a manual request sense was done - get the information */ | |
8392 if (uscmdp->uscsi_flags & USCSI_RQENABLE) { | |
8393 int rqlen = SENSE_LENGTH - pkt->pkt_resid; | |
8394 | |
8395 rqbp = mp_uscmdp->rqbp; | |
8396 /* get the amount of data to copy into rqbuf */ | |
8397 rqlen = min(((int)uscmdp->uscsi_rqlen), rqlen); | |
8398 uscmdp->uscsi_rqresid = uscmdp->uscsi_rqlen - rqlen; | |
8399 uscmdp->uscsi_rqstatus = *((char *)rqstatus); | |
8400 if (uscmdp->uscsi_rqlen && uscmdp->uscsi_rqbuf) { | |
8401 bcopy(rqbp->b_un.b_addr, uscmdp->uscsi_rqbuf, | |
8402 rqlen); | |
8403 } | |
8404 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_TRANSERR); | |
8405 scsi_free_consistent_buf(rqbp); | |
8406 } | |
8407 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_uscsi_iodone: FLAG_SENSING" | |
8408 "uscsi_rqstatus=0x%x uscsi_rqresid=%d\n", | |
8409 uscmdp->uscsi_rqstatus, uscmdp->uscsi_rqresid)); | |
8410 } else { | |
8411 struct scsi_status *status = | |
8412 (struct scsi_status *)pkt->pkt_scbp; | |
8413 /* | |
8414 * Command completed and we're not getting sense. Check for | |
8415 * errors and decide what to do next. | |
8416 */ | |
8417 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8418 "vhci_uscsi_iodone: command appears complete: reason: %x", | |
8419 pkt->pkt_reason)); | |
8420 if (status->sts_chk) { | |
8421 /* need to manually get the request sense */ | |
8422 if (vhci_uscsi_send_sense(pkt, mp_uscmdp) == 0) { | |
8423 scsi_destroy_pkt(pkt); | |
8424 return; | |
8425 } | |
8426 } else { | |
8427 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8428 "vhci_chk_err: appears complete")); | |
8429 err = 0; | |
8430 mdi_pi_kstat_iosupdate(mp_uscmdp->pip, bp); | |
8431 if (pkt->pkt_resid) { | |
8432 bp->b_resid += pkt->pkt_resid; | |
8433 } | |
8434 } | |
8435 } | |
8436 | |
8437 if (err) { | |
8438 if (bp->b_resid == 0) | |
8439 bp->b_resid = bp->b_bcount; | |
8440 bioerror(bp, err); | |
8441 bp->b_flags |= B_ERROR; | |
8442 } | |
8443 | |
8444 scsi_destroy_pkt(pkt); | |
8445 biodone(bp); | |
8446 | |
8447 VHCI_DEBUG(4, (CE_WARN, NULL, "vhci_uscsi_iodone: exit")); | |
8448 } | |
8449 | |
8450 /* | |
8451 * start routine for the mpapi uscsi command | |
8452 */ | |
8453 int | |
8454 vhci_uscsi_iostart(struct buf *bp) | |
8455 { | |
8456 struct scsi_pkt *pkt; | |
8457 struct uscsi_cmd *uscmdp; | |
8458 mp_uscsi_cmd_t *mp_uscmdp; | |
8459 int stat_size, rval; | |
8460 int retry = 0; | |
8461 | |
8462 ASSERT(bp->b_private != NULL); | |
8463 | |
8464 mp_uscmdp = (mp_uscsi_cmd_t *)bp->b_private; | |
8465 uscmdp = mp_uscmdp->uscmdp; | |
8466 if (uscmdp->uscsi_flags & USCSI_RQENABLE) { | |
8467 stat_size = SENSE_LENGTH; | |
8468 } else { | |
8469 stat_size = 1; | |
8470 } | |
8471 | |
8472 pkt = scsi_init_pkt(mp_uscmdp->ap, NULL, bp, uscmdp->uscsi_cdblen, | |
8473 stat_size, 0, 0, SLEEP_FUNC, NULL); | |
8474 if (pkt == NULL) { | |
8475 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8476 "vhci_uscsi_iostart: rval: EINVAL")); | |
8477 bp->b_resid = bp->b_bcount; | |
8478 uscmdp->uscsi_resid = bp->b_bcount; | |
8479 bioerror(bp, EINVAL); | |
8480 biodone(bp); | |
8481 return (EINVAL); | |
8482 } | |
8483 | |
8484 pkt->pkt_time = uscmdp->uscsi_timeout; | |
8485 bcopy(uscmdp->uscsi_cdb, pkt->pkt_cdbp, (size_t)uscmdp->uscsi_cdblen); | |
8486 pkt->pkt_comp = vhci_uscsi_iodone; | |
8487 pkt->pkt_private = mp_uscmdp; | |
8488 if (uscmdp->uscsi_flags & USCSI_SILENT) | |
8489 pkt->pkt_flags |= FLAG_SILENT; | |
8490 if (uscmdp->uscsi_flags & USCSI_ISOLATE) | |
8491 pkt->pkt_flags |= FLAG_ISOLATE; | |
8492 if (uscmdp->uscsi_flags & USCSI_DIAGNOSE) | |
8493 pkt->pkt_flags |= FLAG_DIAGNOSE; | |
8494 if (uscmdp->uscsi_flags & USCSI_RENEGOT) { | |
8495 pkt->pkt_flags |= FLAG_RENEGOTIATE_WIDE_SYNC; | |
8496 } | |
8497 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8498 "vhci_uscsi_iostart: ap: %p pkt: %p pcdbp: %p uscmdp: %p" | |
8499 " ucdbp: %p pcdblen: %d bp: %p count: %ld pip: %p" | |
8500 " stat_size: %d", | |
8501 (void *)mp_uscmdp->ap, (void *)pkt, (void *)pkt->pkt_cdbp, | |
8502 (void *)uscmdp, (void *)uscmdp->uscsi_cdb, pkt->pkt_cdblen, | |
8503 (void *)bp, bp->b_bcount, (void *)mp_uscmdp->pip, stat_size)); | |
8504 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8505 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8506 * NOTE: This code path is related to MPAPI uscsi(7I), so path |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8507 * selection is not based on path_instance. |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8508 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8509 if (scsi_pkt_allocated_correctly(pkt)) |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8510 pkt->pkt_path_instance = 0; |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8511 |
4851 | 8512 while (((rval = scsi_transport(pkt)) == TRAN_BUSY) && |
8513 retry < vhci_uscsi_retry_count) { | |
8514 delay(drv_usectohz(vhci_uscsi_delay)); | |
8515 retry++; | |
8516 } | |
8517 if (retry >= vhci_uscsi_retry_count) { | |
8518 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8519 "vhci_uscsi_iostart: tran_busy - retry: %d", retry)); | |
8520 } | |
8521 switch (rval) { | |
8522 case TRAN_ACCEPT: | |
8523 rval = 0; | |
8524 break; | |
8525 | |
8526 default: | |
8527 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8528 "vhci_uscsi_iostart: rval: %d count: %ld res: %ld", | |
8529 rval, bp->b_bcount, bp->b_resid)); | |
8530 bp->b_resid = bp->b_bcount; | |
8531 uscmdp->uscsi_resid = bp->b_bcount; | |
8532 bioerror(bp, EIO); | |
8533 scsi_destroy_pkt(pkt); | |
8534 biodone(bp); | |
8535 rval = EIO; | |
8536 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_TRANSERR); | |
8537 break; | |
8538 } | |
8539 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8540 "vhci_uscsi_iostart: exit: rval: %d", rval)); | |
8541 return (rval); | |
8542 } | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8543 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8544 #ifdef DEBUG |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8545 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8546 extern struct scsi_key_strings scsi_cmds[]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8547 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8548 static char * |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8549 vhci_print_scsi_cmd(char cmd) |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8550 { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8551 char tmp[64]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8552 char *cpnt; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8553 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8554 cpnt = scsi_cmd_name(cmd, scsi_cmds, tmp); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8555 /* tmp goes out of scope on return and caller sees garbage */ |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8556 if (cpnt == tmp) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8557 cpnt = "Unknown Command"; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8558 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8559 return (cpnt); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8560 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8561 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8562 extern uchar_t scsi_cdb_size[]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8563 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8564 static void |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8565 vhci_print_cdb(dev_info_t *dip, uint_t level, char *title, uchar_t *cdb) |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8566 { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8567 int len = scsi_cdb_size[CDB_GROUPID(cdb[0])]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8568 char buf[256]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8569 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8570 if (level == CE_NOTE) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8571 vhci_log(level, dip, "path cmd %s\n", |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8572 vhci_print_scsi_cmd(*cdb)); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8573 return; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8574 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8575 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8576 (void) sprintf(buf, "%s for cmd(%s)", title, vhci_print_scsi_cmd(*cdb)); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8577 vhci_clean_print(dip, level, buf, cdb, len); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8578 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8579 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8580 static void |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8581 vhci_clean_print(dev_info_t *dev, uint_t level, char *title, uchar_t *data, |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8582 int len) |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8583 { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8584 int i; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8585 int c; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8586 char *format; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8587 char buf[256]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8588 uchar_t byte; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8589 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8590 (void) sprintf(buf, "%s:\n", title); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8591 vhci_log(level, dev, "%s", buf); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8592 level = CE_CONT; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8593 for (i = 0; i < len; ) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8594 buf[0] = 0; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8595 for (c = 0; c < 8 && i < len; c++, i++) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8596 byte = (uchar_t)data[i]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8597 if (byte < 0x10) |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8598 format = "0x0%x "; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8599 else |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8600 format = "0x%x "; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8601 (void) sprintf(&buf[(int)strlen(buf)], format, byte); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8602 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8603 (void) sprintf(&buf[(int)strlen(buf)], "\n"); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8604 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8605 vhci_log(level, dev, "%s\n", buf); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8606 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8607 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8608 #endif |