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