Mercurial > illumos > illumos-gate
annotate usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c @ 12987:3086793bcf3c
6914412 FC initiator host panic when FC array mp_support change
author | Kevin Yu <Kevin.Yu@Sun.COM> |
---|---|
date | Sat, 31 Jul 2010 09:23:10 +0800 |
parents | b51957425f56 |
children | be896e318721 |
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 /* | |
12310
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
22 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
4851 | 23 */ |
24 | |
25 /* | |
26 * Multiplexed I/O SCSI vHCI implementation | |
27 */ | |
28 | |
29 #include <sys/conf.h> | |
30 #include <sys/file.h> | |
31 #include <sys/ddi.h> | |
32 #include <sys/sunddi.h> | |
33 #include <sys/scsi/scsi.h> | |
34 #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
|
35 #include <sys/scsi/impl/services.h> |
4851 | 36 #include <sys/sunmdi.h> |
37 #include <sys/mdi_impldefs.h> | |
38 #include <sys/scsi/adapters/scsi_vhci.h> | |
39 #include <sys/disp.h> | |
40 #include <sys/byteorder.h> | |
41 | |
42 extern uintptr_t scsi_callback_id; | |
43 extern ddi_dma_attr_t scsi_alloc_attr; | |
44 | |
45 #ifdef DEBUG | |
46 int vhci_debug = VHCI_DEBUG_DEFAULT_VAL; | |
47 #endif | |
48 | |
49 /* retry for the vhci_do_prout command when a not ready is returned */ | |
50 int vhci_prout_not_ready_retry = 180; | |
51 | |
52 /* | |
53 * These values are defined to support the internal retry of | |
54 * SCSI packets for better sense code handling. | |
55 */ | |
56 #define VHCI_CMD_CMPLT 0 | |
57 #define VHCI_CMD_RETRY 1 | |
58 #define VHCI_CMD_ERROR -1 | |
59 | |
60 #define PROPFLAGS (DDI_PROP_DONTPASS | DDI_PROP_NOTPROM) | |
61 #define VHCI_SCSI_PERR 0x47 | |
62 #define VHCI_PGR_ILLEGALOP -2 | |
63 #define VHCI_NUM_UPDATE_TASKQ 8 | |
6023
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
64 /* changed to 132 to accomodate HDS */ |
4851 | 65 |
66 /* | |
67 * Version Macros | |
68 */ | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7654
diff
changeset
|
69 #define VHCI_NAME_VERSION "SCSI VHCI Driver" |
4851 | 70 char vhci_version_name[] = VHCI_NAME_VERSION; |
71 | |
72 int vhci_first_time = 0; | |
73 clock_t vhci_to_ticks = 0; | |
74 int vhci_init_wait_timeout = VHCI_INIT_WAIT_TIMEOUT; | |
75 kcondvar_t vhci_cv; | |
76 kmutex_t vhci_global_mutex; | |
77 void *vhci_softstate = NULL; /* for soft state */ | |
78 | |
79 /* | |
80 * Flag to delay the retry of the reserve command | |
81 */ | |
82 int vhci_reserve_delay = 100000; | |
83 static int vhci_path_quiesce_timeout = 60; | |
84 static uchar_t zero_key[MHIOC_RESV_KEY_SIZE]; | |
85 | |
86 /* uscsi delay for a TRAN_BUSY */ | |
87 static int vhci_uscsi_delay = 100000; | |
88 static int vhci_uscsi_retry_count = 180; | |
89 /* uscsi_restart_sense timeout id in case it needs to get canceled */ | |
90 static timeout_id_t vhci_restart_timeid = 0; | |
91 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
92 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
|
93 |
4851 | 94 /* |
95 * Bidirectional map of 'target-port' to port id <pid> for support of | |
96 * iostat(1M) '-Xx' and '-Yx' output. | |
97 */ | |
98 static kmutex_t vhci_targetmap_mutex; | |
99 static uint_t vhci_targetmap_pid = 1; | |
100 static mod_hash_t *vhci_targetmap_bypid; /* <pid> -> 'target-port' */ | |
101 static mod_hash_t *vhci_targetmap_byport; /* 'target-port' -> <pid> */ | |
102 | |
103 /* | |
104 * functions exported by scsi_vhci struct cb_ops | |
105 */ | |
106 static int vhci_open(dev_t *, int, int, cred_t *); | |
107 static int vhci_close(dev_t, int, int, cred_t *); | |
108 static int vhci_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
109 | |
110 /* | |
111 * functions exported by scsi_vhci struct dev_ops | |
112 */ | |
113 static int vhci_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); | |
114 static int vhci_attach(dev_info_t *, ddi_attach_cmd_t); | |
115 static int vhci_detach(dev_info_t *, ddi_detach_cmd_t); | |
116 | |
117 /* | |
118 * functions exported by scsi_vhci scsi_hba_tran_t transport table | |
119 */ | |
120 static int vhci_scsi_tgt_init(dev_info_t *, dev_info_t *, | |
121 scsi_hba_tran_t *, struct scsi_device *); | |
122 static void vhci_scsi_tgt_free(dev_info_t *, dev_info_t *, scsi_hba_tran_t *, | |
123 struct scsi_device *); | |
124 static int vhci_pgr_register_start(scsi_vhci_lun_t *, struct scsi_pkt *); | |
125 static int vhci_scsi_start(struct scsi_address *, struct scsi_pkt *); | |
126 static int vhci_scsi_abort(struct scsi_address *, struct scsi_pkt *); | |
127 static int vhci_scsi_reset(struct scsi_address *, int); | |
128 static int vhci_scsi_reset_target(struct scsi_address *, int level, | |
129 uint8_t select_path); | |
130 static int vhci_scsi_reset_bus(struct scsi_address *); | |
131 static int vhci_scsi_getcap(struct scsi_address *, char *, int); | |
132 static int vhci_scsi_setcap(struct scsi_address *, char *, int, int); | |
133 static int vhci_commoncap(struct scsi_address *, char *, int, int, int); | |
134 static int vhci_pHCI_cap(struct scsi_address *ap, char *cap, int val, int whom, | |
135 mdi_pathinfo_t *pip); | |
136 static struct scsi_pkt *vhci_scsi_init_pkt(struct scsi_address *, | |
137 struct scsi_pkt *, struct buf *, int, int, int, int, int (*)(), caddr_t); | |
138 static void vhci_scsi_destroy_pkt(struct scsi_address *, struct scsi_pkt *); | |
139 static void vhci_scsi_dmafree(struct scsi_address *, struct scsi_pkt *); | |
140 static void vhci_scsi_sync_pkt(struct scsi_address *, struct scsi_pkt *); | |
141 static int vhci_scsi_reset_notify(struct scsi_address *, int, void (*)(caddr_t), | |
142 caddr_t); | |
143 static int vhci_scsi_get_bus_addr(struct scsi_device *, char *, int); | |
144 static int vhci_scsi_get_name(struct scsi_device *, char *, int); | |
145 static int vhci_scsi_bus_power(dev_info_t *, void *, pm_bus_power_op_t, | |
146 void *, void *); | |
147 static int vhci_scsi_bus_config(dev_info_t *, uint_t, ddi_bus_config_op_t, | |
148 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
|
149 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
|
150 void *); |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
151 static struct scsi_failover_ops *vhci_dev_fo(dev_info_t *, struct scsi_device *, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
152 void **, char **); |
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 *, | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
160 mdi_pathinfo_state_t, uint32_t, int); |
4851 | 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 *); | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
165 static int vhci_is_dev_supported(dev_info_t *, dev_info_t *, void *); |
4851 | 166 |
167 static int vhci_ctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
168 static int vhci_devctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
169 static int vhci_ioc_get_phci_path(sv_iocdata_t *, caddr_t, int, caddr_t); | |
170 static int vhci_ioc_get_client_path(sv_iocdata_t *, caddr_t, int, caddr_t); | |
171 static int vhci_ioc_get_paddr(sv_iocdata_t *, caddr_t, int, caddr_t); | |
172 static int vhci_ioc_send_client_path(caddr_t, sv_iocdata_t *, int, caddr_t); | |
173 static void vhci_ioc_devi_to_path(dev_info_t *, caddr_t); | |
174 static int vhci_get_phci_path_list(dev_info_t *, sv_path_info_t *, uint_t); | |
175 static int vhci_get_client_path_list(dev_info_t *, sv_path_info_t *, uint_t); | |
176 static int vhci_get_iocdata(const void *, sv_iocdata_t *, int, caddr_t); | |
177 static int vhci_get_iocswitchdata(const void *, sv_switch_to_cntlr_iocdata_t *, | |
178 int, caddr_t); | |
179 static int vhci_ioc_alloc_pathinfo(sv_path_info_t **, sv_path_info_t **, | |
180 uint_t, sv_iocdata_t *, int, caddr_t); | |
181 static void vhci_ioc_free_pathinfo(sv_path_info_t *, sv_path_info_t *, uint_t); | |
182 static int vhci_ioc_send_pathinfo(sv_path_info_t *, sv_path_info_t *, uint_t, | |
183 sv_iocdata_t *, int, caddr_t); | |
184 static int vhci_handle_ext_fo(struct scsi_pkt *, int); | |
185 static int vhci_efo_watch_cb(caddr_t, struct scsi_watch_result *); | |
186 static int vhci_quiesce_lun(struct scsi_vhci_lun *); | |
187 static int vhci_pgr_validate_and_register(scsi_vhci_priv_t *); | |
188 static void vhci_dispatch_scsi_start(void *); | |
189 static void vhci_efo_done(void *); | |
190 static void vhci_initiate_auto_failback(void *); | |
191 static void vhci_update_pHCI_pkt(struct vhci_pkt *, struct scsi_pkt *); | |
192 static int vhci_update_pathinfo(struct scsi_device *, mdi_pathinfo_t *, | |
193 struct scsi_failover_ops *, scsi_vhci_lun_t *, struct scsi_vhci *); | |
194 static void vhci_kstat_create_pathinfo(mdi_pathinfo_t *); | |
195 static int vhci_quiesce_paths(dev_info_t *, dev_info_t *, | |
196 scsi_vhci_lun_t *, char *, char *); | |
197 | |
198 static char *vhci_devnm_to_guid(char *); | |
199 static int vhci_bind_transport(struct scsi_address *, struct vhci_pkt *, | |
200 int, int (*func)(caddr_t)); | |
201 static void vhci_intr(struct scsi_pkt *); | |
202 static int vhci_do_prout(scsi_vhci_priv_t *); | |
203 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
|
204 static int vhci_do_prin(struct vhci_pkt **); |
4851 | 205 static struct scsi_pkt *vhci_create_retry_pkt(struct vhci_pkt *); |
206 static struct vhci_pkt *vhci_sync_retry_pkt(struct vhci_pkt *); | |
207 static struct scsi_vhci_lun *vhci_lun_lookup(dev_info_t *); | |
208 static struct scsi_vhci_lun *vhci_lun_lookup_alloc(dev_info_t *, char *, int *); | |
209 static void vhci_lun_free(dev_info_t *); | |
210 static int vhci_recovery_reset(scsi_vhci_lun_t *, struct scsi_address *, | |
211 uint8_t, uint8_t); | |
212 void vhci_update_pathstates(void *); | |
213 | |
214 #ifdef DEBUG | |
215 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
|
216 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
|
217 char *title, uchar_t *cdb); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
218 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
|
219 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
|
220 #endif |
4851 | 221 static void vhci_print_prout_keys(scsi_vhci_lun_t *, char *); |
222 static void vhci_uscsi_iodone(struct scsi_pkt *pkt); | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
223 static void vhci_invalidate_mpapi_lu(struct scsi_vhci *, scsi_vhci_lun_t *); |
4851 | 224 |
225 /* | |
226 * MP-API related functions | |
227 */ | |
228 extern int vhci_mpapi_init(struct scsi_vhci *); | |
229 extern void vhci_mpapi_add_dev_prod(struct scsi_vhci *, char *); | |
230 extern int vhci_mpapi_ctl(dev_t, int, intptr_t, int, cred_t *, int *); | |
231 extern void vhci_update_mpapi_data(struct scsi_vhci *, | |
232 scsi_vhci_lun_t *, mdi_pathinfo_t *); | |
233 extern void* vhci_get_mpapi_item(struct scsi_vhci *, mpapi_list_header_t *, | |
234 uint8_t, void*); | |
235 extern void vhci_mpapi_set_path_state(dev_info_t *, mdi_pathinfo_t *, int); | |
236 extern int vhci_mpapi_update_tpg_acc_state_for_lu(struct scsi_vhci *, | |
237 scsi_vhci_lun_t *); | |
238 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
239 #define VHCI_DMA_MAX_XFER_CAP INT_MAX |
4851 | 240 |
241 #define VHCI_MAX_PGR_RETRIES 3 | |
242 | |
243 /* | |
244 * Macros for the device-type mpxio options | |
245 */ | |
246 #define LOAD_BALANCE_OPTIONS "load-balance-options" | |
247 #define LOGICAL_BLOCK_REGION_SIZE "region-size" | |
248 #define MPXIO_OPTIONS_LIST "device-type-mpxio-options-list" | |
249 #define DEVICE_TYPE_STR "device-type" | |
250 #define isdigit(ch) ((ch) >= '0' && (ch) <= '9') | |
251 | |
252 static struct cb_ops vhci_cb_ops = { | |
253 vhci_open, /* open */ | |
254 vhci_close, /* close */ | |
255 nodev, /* strategy */ | |
256 nodev, /* print */ | |
257 nodev, /* dump */ | |
258 nodev, /* read */ | |
259 nodev, /* write */ | |
260 vhci_ioctl, /* ioctl */ | |
261 nodev, /* devmap */ | |
262 nodev, /* mmap */ | |
263 nodev, /* segmap */ | |
264 nochpoll, /* chpoll */ | |
265 ddi_prop_op, /* cb_prop_op */ | |
266 0, /* streamtab */ | |
267 D_NEW | D_MP, /* cb_flag */ | |
268 CB_REV, /* rev */ | |
269 nodev, /* aread */ | |
270 nodev /* awrite */ | |
271 }; | |
272 | |
273 static struct dev_ops vhci_ops = { | |
274 DEVO_REV, | |
275 0, | |
276 vhci_getinfo, | |
277 nulldev, /* identify */ | |
278 nulldev, /* probe */ | |
279 vhci_attach, /* attach and detach are mandatory */ | |
280 vhci_detach, | |
281 nodev, /* reset */ | |
282 &vhci_cb_ops, /* cb_ops */ | |
283 NULL, /* bus_ops */ | |
284 NULL, /* power */ | |
7656
2621e50fdf4a
PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents:
7654
diff
changeset
|
285 ddi_quiesce_not_needed, /* quiesce */ |
4851 | 286 }; |
287 | |
288 extern struct mod_ops mod_driverops; | |
289 | |
290 static struct modldrv modldrv = { | |
291 &mod_driverops, | |
292 vhci_version_name, /* module name */ | |
293 &vhci_ops | |
294 }; | |
295 | |
296 static struct modlinkage modlinkage = { | |
297 MODREV_1, | |
298 &modldrv, | |
299 NULL | |
300 }; | |
301 | |
302 static mdi_vhci_ops_t vhci_opinfo = { | |
303 MDI_VHCI_OPS_REV, | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
304 vhci_pathinfo_init, /* Pathinfo node init callback */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
305 vhci_pathinfo_uninit, /* Pathinfo uninit callback */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
306 vhci_pathinfo_state_change, /* Pathinfo node state change */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
307 vhci_failover, /* failover callback */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
308 vhci_client_attached, /* client attached callback */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
309 vhci_is_dev_supported /* is device supported by mdi */ |
4851 | 310 }; |
311 | |
312 /* | |
313 * The scsi_failover table defines an ordered set of 'fops' modules supported | |
314 * by scsi_vhci. Currently, initialize this table from the 'ddi-forceload' | |
315 * property specified in scsi_vhci.conf. | |
316 */ | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
317 static struct scsi_failover { |
4851 | 318 ddi_modhandle_t sf_mod; |
319 struct scsi_failover_ops *sf_sfo; | |
320 } *scsi_failover_table; | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
321 static uint_t scsi_nfailover; |
4851 | 322 |
323 int | |
324 _init(void) | |
325 { | |
326 int rval; | |
327 | |
328 /* | |
329 * Allocate soft state and prepare to do ddi_soft_state_zalloc() | |
330 * before registering with the transport first. | |
331 */ | |
332 if ((rval = ddi_soft_state_init(&vhci_softstate, | |
333 sizeof (struct scsi_vhci), 1)) != 0) { | |
334 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
335 "!_init:soft state init failed\n")); | |
336 return (rval); | |
337 } | |
338 | |
339 if ((rval = scsi_hba_init(&modlinkage)) != 0) { | |
340 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
341 "!_init: scsi hba init failed\n")); | |
342 ddi_soft_state_fini(&vhci_softstate); | |
343 return (rval); | |
344 } | |
345 | |
346 mutex_init(&vhci_global_mutex, NULL, MUTEX_DRIVER, NULL); | |
347 cv_init(&vhci_cv, NULL, CV_DRIVER, NULL); | |
348 | |
349 mutex_init(&vhci_targetmap_mutex, NULL, MUTEX_DRIVER, NULL); | |
350 vhci_targetmap_byport = mod_hash_create_strhash( | |
351 "vhci_targetmap_byport", 256, mod_hash_null_valdtor); | |
352 vhci_targetmap_bypid = mod_hash_create_idhash( | |
353 "vhci_targetmap_bypid", 256, mod_hash_null_valdtor); | |
354 | |
355 if ((rval = mod_install(&modlinkage)) != 0) { | |
356 VHCI_DEBUG(1, (CE_NOTE, NULL, "!_init: mod_install failed\n")); | |
357 if (vhci_targetmap_bypid) | |
358 mod_hash_destroy_idhash(vhci_targetmap_bypid); | |
359 if (vhci_targetmap_byport) | |
360 mod_hash_destroy_strhash(vhci_targetmap_byport); | |
361 mutex_destroy(&vhci_targetmap_mutex); | |
362 cv_destroy(&vhci_cv); | |
363 mutex_destroy(&vhci_global_mutex); | |
364 scsi_hba_fini(&modlinkage); | |
365 ddi_soft_state_fini(&vhci_softstate); | |
366 } | |
367 return (rval); | |
368 } | |
369 | |
370 | |
371 /* | |
372 * the system is done with us as a driver, so clean up | |
373 */ | |
374 int | |
375 _fini(void) | |
376 { | |
377 int rval; | |
378 | |
379 /* | |
380 * don't start cleaning up until we know that the module remove | |
381 * has worked -- if this works, then we know that each instance | |
382 * has successfully been DDI_DETACHed | |
383 */ | |
384 if ((rval = mod_remove(&modlinkage)) != 0) { | |
385 VHCI_DEBUG(4, (CE_NOTE, NULL, "!_fini: mod_remove failed\n")); | |
386 return (rval); | |
387 } | |
388 | |
389 if (vhci_targetmap_bypid) | |
390 mod_hash_destroy_idhash(vhci_targetmap_bypid); | |
391 if (vhci_targetmap_byport) | |
392 mod_hash_destroy_strhash(vhci_targetmap_byport); | |
393 mutex_destroy(&vhci_targetmap_mutex); | |
394 cv_destroy(&vhci_cv); | |
395 mutex_destroy(&vhci_global_mutex); | |
396 scsi_hba_fini(&modlinkage); | |
397 ddi_soft_state_fini(&vhci_softstate); | |
398 | |
399 return (rval); | |
400 } | |
401 | |
402 int | |
403 _info(struct modinfo *modinfop) | |
404 { | |
405 return (mod_info(&modlinkage, modinfop)); | |
406 } | |
407 | |
408 /* | |
409 * Lookup scsi_failover by "short name" of failover module. | |
410 */ | |
411 struct scsi_failover_ops * | |
412 vhci_failover_ops_by_name(char *name) | |
413 { | |
414 struct scsi_failover *sf; | |
415 | |
416 for (sf = scsi_failover_table; sf->sf_mod; sf++) { | |
417 if (sf->sf_sfo == NULL) | |
418 continue; | |
419 if (strcmp(sf->sf_sfo->sfo_name, name) == 0) | |
420 return (sf->sf_sfo); | |
421 } | |
422 return (NULL); | |
423 } | |
424 | |
425 /* | |
426 * Load all scsi_failover_ops 'fops' modules. | |
427 */ | |
428 static void | |
429 vhci_failover_modopen(struct scsi_vhci *vhci) | |
430 { | |
431 char **module; | |
432 int i; | |
433 struct scsi_failover *sf; | |
434 char **dt; | |
435 int e; | |
436 | |
437 if (scsi_failover_table) | |
438 return; | |
439 | |
440 /* Get the list of modules from scsi_vhci.conf */ | |
441 if (ddi_prop_lookup_string_array(DDI_DEV_T_ANY, | |
442 vhci->vhci_dip, DDI_PROP_DONTPASS, "ddi-forceload", | |
443 &module, &scsi_nfailover) != DDI_PROP_SUCCESS) { | |
444 cmn_err(CE_WARN, "scsi_vhci: " | |
445 "scsi_vhci.conf is missing 'ddi-forceload'"); | |
446 return; | |
447 } | |
448 if (scsi_nfailover == 0) { | |
449 cmn_err(CE_WARN, "scsi_vhci: " | |
450 "scsi_vhci.conf has empty 'ddi-forceload'"); | |
4949
f3b9c8c61dbe
6594740 vhci_failover_modopen leaks "ddi-forceload" property
cth
parents:
4896
diff
changeset
|
451 ddi_prop_free(module); |
4851 | 452 return; |
453 } | |
454 | |
455 /* allocate failover table based on number of modules */ | |
456 scsi_failover_table = (struct scsi_failover *) | |
457 kmem_zalloc(sizeof (struct scsi_failover) * (scsi_nfailover + 1), | |
458 KM_SLEEP); | |
459 | |
460 /* loop over modules specified in scsi_vhci.conf and open each module */ | |
461 for (i = 0, sf = scsi_failover_table; i < scsi_nfailover; i++) { | |
462 if (module[i] == NULL) | |
463 continue; | |
464 | |
465 sf->sf_mod = ddi_modopen(module[i], KRTLD_MODE_FIRST, &e); | |
466 if (sf->sf_mod == NULL) { | |
467 /* | |
468 * A module returns EEXIST if other software is | |
469 * supporting the intended function: for example | |
470 * the scsi_vhci_f_sum_emc module returns EEXIST | |
471 * from _init if EMC powerpath software is installed. | |
472 */ | |
473 if (e != EEXIST) | |
474 cmn_err(CE_WARN, "scsi_vhci: unable to open " | |
475 "module '%s', error %d", module[i], e); | |
476 continue; | |
477 } | |
478 sf->sf_sfo = ddi_modsym(sf->sf_mod, | |
479 "scsi_vhci_failover_ops", &e); | |
480 if (sf->sf_sfo == NULL) { | |
481 cmn_err(CE_WARN, "scsi_vhci: " | |
482 "unable to import 'scsi_failover_ops' from '%s', " | |
483 "error %d", module[i], e); | |
484 (void) ddi_modclose(sf->sf_mod); | |
485 sf->sf_mod = NULL; | |
486 continue; | |
487 } | |
488 | |
489 /* register vid/pid of devices supported with mpapi */ | |
490 for (dt = sf->sf_sfo->sfo_devices; *dt; dt++) | |
491 vhci_mpapi_add_dev_prod(vhci, *dt); | |
492 sf++; | |
493 } | |
494 | |
495 /* verify that at least the "well-known" modules were there */ | |
496 if (vhci_failover_ops_by_name(SFO_NAME_SYM) == NULL) | |
497 cmn_err(CE_WARN, "scsi_vhci: well-known module \"" | |
498 SFO_NAME_SYM "\" not defined in scsi_vhci.conf's " | |
499 "'ddi-forceload'"); | |
500 if (vhci_failover_ops_by_name(SFO_NAME_TPGS) == NULL) | |
501 cmn_err(CE_WARN, "scsi_vhci: well-known module \"" | |
502 SFO_NAME_TPGS "\" not defined in scsi_vhci.conf's " | |
503 "'ddi-forceload'"); | |
504 | |
505 /* call sfo_init for modules that need it */ | |
506 for (sf = scsi_failover_table; sf->sf_mod; sf++) { | |
507 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
|
508 sf->sf_sfo->sfo_init(); |
4851 | 509 } |
4949
f3b9c8c61dbe
6594740 vhci_failover_modopen leaks "ddi-forceload" property
cth
parents:
4896
diff
changeset
|
510 |
f3b9c8c61dbe
6594740 vhci_failover_modopen leaks "ddi-forceload" property
cth
parents:
4896
diff
changeset
|
511 ddi_prop_free(module); |
4851 | 512 } |
513 | |
514 /* | |
515 * unload all loaded scsi_failover_ops modules | |
516 */ | |
517 static void | |
518 vhci_failover_modclose() | |
519 { | |
520 struct scsi_failover *sf; | |
521 | |
522 for (sf = scsi_failover_table; sf->sf_mod; sf++) { | |
523 if ((sf->sf_mod == NULL) || (sf->sf_sfo == NULL)) | |
524 continue; | |
525 (void) ddi_modclose(sf->sf_mod); | |
526 sf->sf_mod = NULL; | |
527 sf->sf_sfo = NULL; | |
528 } | |
529 | |
530 if (scsi_failover_table && scsi_nfailover) | |
531 kmem_free(scsi_failover_table, | |
532 sizeof (struct scsi_failover) * (scsi_nfailover + 1)); | |
533 scsi_failover_table = NULL; | |
534 scsi_nfailover = 0; | |
535 } | |
536 | |
537 /* ARGSUSED */ | |
538 static int | |
539 vhci_open(dev_t *devp, int flag, int otype, cred_t *credp) | |
540 { | |
541 struct scsi_vhci *vhci; | |
542 | |
543 if (otype != OTYP_CHR) { | |
544 return (EINVAL); | |
545 } | |
546 | |
547 vhci = ddi_get_soft_state(vhci_softstate, MINOR2INST(getminor(*devp))); | |
548 if (vhci == NULL) { | |
549 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_open: failed ENXIO\n")); | |
550 return (ENXIO); | |
551 } | |
552 | |
553 mutex_enter(&vhci->vhci_mutex); | |
554 if ((flag & FEXCL) && (vhci->vhci_state & VHCI_STATE_OPEN)) { | |
555 mutex_exit(&vhci->vhci_mutex); | |
556 vhci_log(CE_NOTE, vhci->vhci_dip, | |
557 "!vhci%d: Already open\n", getminor(*devp)); | |
558 return (EBUSY); | |
559 } | |
560 | |
561 vhci->vhci_state |= VHCI_STATE_OPEN; | |
562 mutex_exit(&vhci->vhci_mutex); | |
563 return (0); | |
564 } | |
565 | |
566 | |
567 /* ARGSUSED */ | |
568 static int | |
569 vhci_close(dev_t dev, int flag, int otype, cred_t *credp) | |
570 { | |
571 struct scsi_vhci *vhci; | |
572 | |
573 if (otype != OTYP_CHR) { | |
574 return (EINVAL); | |
575 } | |
576 | |
577 vhci = ddi_get_soft_state(vhci_softstate, MINOR2INST(getminor(dev))); | |
578 if (vhci == NULL) { | |
579 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_close: failed ENXIO\n")); | |
580 return (ENXIO); | |
581 } | |
582 | |
583 mutex_enter(&vhci->vhci_mutex); | |
584 vhci->vhci_state &= ~VHCI_STATE_OPEN; | |
585 mutex_exit(&vhci->vhci_mutex); | |
586 | |
587 return (0); | |
588 } | |
589 | |
590 /* ARGSUSED */ | |
591 static int | |
592 vhci_ioctl(dev_t dev, int cmd, intptr_t data, int mode, | |
593 cred_t *credp, int *rval) | |
594 { | |
595 if (IS_DEVCTL(cmd)) { | |
596 return (vhci_devctl(dev, cmd, data, mode, credp, rval)); | |
597 } else if (cmd == MP_CMD) { | |
598 return (vhci_mpapi_ctl(dev, cmd, data, mode, credp, rval)); | |
599 } else { | |
600 return (vhci_ctl(dev, cmd, data, mode, credp, rval)); | |
601 } | |
602 } | |
603 | |
604 /* | |
605 * attach the module | |
606 */ | |
607 static int | |
608 vhci_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) | |
609 { | |
610 int rval = DDI_FAILURE; | |
611 int scsi_hba_attached = 0; | |
612 int vhci_attached = 0; | |
613 int mutex_initted = 0; | |
614 int instance; | |
615 struct scsi_vhci *vhci; | |
616 scsi_hba_tran_t *tran; | |
617 char cache_name_buf[64]; | |
618 char *data; | |
619 | |
620 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_attach: cmd=0x%x\n", cmd)); | |
621 | |
622 instance = ddi_get_instance(dip); | |
623 | |
624 switch (cmd) { | |
625 case DDI_ATTACH: | |
626 break; | |
627 | |
628 case DDI_RESUME: | |
629 case DDI_PM_RESUME: | |
630 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_attach: resume not yet" | |
631 "implemented\n")); | |
632 return (rval); | |
633 | |
634 default: | |
635 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
636 "!vhci_attach: unknown ddi command\n")); | |
637 return (rval); | |
638 } | |
639 | |
640 /* | |
641 * Allocate vhci data structure. | |
642 */ | |
643 if (ddi_soft_state_zalloc(vhci_softstate, instance) != DDI_SUCCESS) { | |
644 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
645 "soft state alloc failed\n")); | |
646 return (DDI_FAILURE); | |
647 } | |
648 | |
649 if ((vhci = ddi_get_soft_state(vhci_softstate, instance)) == NULL) { | |
650 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
651 "bad soft state\n")); | |
652 ddi_soft_state_free(vhci_softstate, instance); | |
653 return (DDI_FAILURE); | |
654 } | |
655 | |
656 /* Allocate packet cache */ | |
657 (void) snprintf(cache_name_buf, sizeof (cache_name_buf), | |
658 "vhci%d_cache", instance); | |
659 | |
660 mutex_init(&vhci->vhci_mutex, NULL, MUTEX_DRIVER, NULL); | |
661 mutex_initted++; | |
662 | |
663 /* | |
664 * Allocate a transport structure | |
665 */ | |
666 tran = scsi_hba_tran_alloc(dip, SCSI_HBA_CANSLEEP); | |
667 ASSERT(tran != NULL); | |
668 | |
669 vhci->vhci_tran = tran; | |
670 vhci->vhci_dip = dip; | |
671 vhci->vhci_instance = instance; | |
672 | |
673 tran->tran_hba_private = vhci; | |
674 tran->tran_tgt_init = vhci_scsi_tgt_init; | |
675 tran->tran_tgt_probe = NULL; | |
676 tran->tran_tgt_free = vhci_scsi_tgt_free; | |
677 | |
678 tran->tran_start = vhci_scsi_start; | |
679 tran->tran_abort = vhci_scsi_abort; | |
680 tran->tran_reset = vhci_scsi_reset; | |
681 tran->tran_getcap = vhci_scsi_getcap; | |
682 tran->tran_setcap = vhci_scsi_setcap; | |
683 tran->tran_init_pkt = vhci_scsi_init_pkt; | |
684 tran->tran_destroy_pkt = vhci_scsi_destroy_pkt; | |
685 tran->tran_dmafree = vhci_scsi_dmafree; | |
686 tran->tran_sync_pkt = vhci_scsi_sync_pkt; | |
687 tran->tran_reset_notify = vhci_scsi_reset_notify; | |
688 | |
689 tran->tran_get_bus_addr = vhci_scsi_get_bus_addr; | |
690 tran->tran_get_name = vhci_scsi_get_name; | |
691 tran->tran_bus_reset = NULL; | |
692 tran->tran_quiesce = NULL; | |
693 tran->tran_unquiesce = NULL; | |
694 | |
695 /* | |
696 * register event notification routines with scsa | |
697 */ | |
698 tran->tran_get_eventcookie = NULL; | |
699 tran->tran_add_eventcall = NULL; | |
700 tran->tran_remove_eventcall = NULL; | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
701 tran->tran_post_event = NULL; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
702 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
703 tran->tran_bus_power = vhci_scsi_bus_power; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
704 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
705 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
|
706 tran->tran_bus_unconfig = vhci_scsi_bus_unconfig; |
4851 | 707 |
708 /* | |
709 * Attach this instance with the mpxio framework | |
710 */ | |
711 if (mdi_vhci_register(MDI_HCI_CLASS_SCSI, dip, &vhci_opinfo, 0) | |
712 != MDI_SUCCESS) { | |
713 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
714 "mdi_vhci_register failed\n")); | |
715 goto attach_fail; | |
716 } | |
717 vhci_attached++; | |
718 | |
719 /* | |
720 * Attach this instance of the hba. | |
721 * | |
722 * Regarding dma attributes: Since scsi_vhci is a virtual scsi HBA | |
723 * driver, it has nothing to do with DMA. However, when calling | |
724 * scsi_hba_attach_setup() we need to pass something valid in the | |
725 * dma attributes parameter. So we just use scsi_alloc_attr. | |
726 * SCSA itself seems to care only for dma_attr_minxfer and | |
727 * dma_attr_burstsizes fields of dma attributes structure. | |
728 * It expects those fileds to be non-zero. | |
729 */ | |
730 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
|
731 SCSI_HBA_ADDR_COMPLEX) != DDI_SUCCESS) { |
4851 | 732 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" |
733 "hba attach failed\n")); | |
734 goto attach_fail; | |
735 } | |
736 scsi_hba_attached++; | |
737 | |
738 if (ddi_create_minor_node(dip, "devctl", S_IFCHR, | |
739 INST2DEVCTL(instance), DDI_NT_SCSI_NEXUS, 0) != DDI_SUCCESS) { | |
740 VHCI_DEBUG(1, (CE_NOTE, dip, "!vhci_attach:" | |
741 " ddi_create_minor_node failed\n")); | |
742 goto attach_fail; | |
743 } | |
744 | |
745 /* | |
746 * Set pm-want-child-notification property for | |
747 * power management of the phci and client | |
748 */ | |
749 if (ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP, | |
750 "pm-want-child-notification?", NULL, NULL) != DDI_PROP_SUCCESS) { | |
751 cmn_err(CE_WARN, | |
752 "%s%d fail to create pm-want-child-notification? prop", | |
753 ddi_driver_name(dip), ddi_get_instance(dip)); | |
754 goto attach_fail; | |
755 } | |
756 | |
757 vhci->vhci_taskq = taskq_create("vhci_taskq", 1, MINCLSYSPRI, 1, 4, 0); | |
758 vhci->vhci_update_pathstates_taskq = | |
759 taskq_create("vhci_update_pathstates", VHCI_NUM_UPDATE_TASKQ, | |
760 MINCLSYSPRI, 1, 4, 0); | |
761 ASSERT(vhci->vhci_taskq); | |
762 ASSERT(vhci->vhci_update_pathstates_taskq); | |
763 | |
764 /* | |
765 * Set appropriate configuration flags based on options set in | |
766 * conf file. | |
767 */ | |
768 vhci->vhci_conf_flags = 0; | |
769 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, PROPFLAGS, | |
770 "auto-failback", &data) == DDI_SUCCESS) { | |
771 if (strcmp(data, "enable") == 0) | |
772 vhci->vhci_conf_flags |= VHCI_CONF_FLAGS_AUTO_FAILBACK; | |
773 ddi_prop_free(data); | |
774 } | |
775 | |
776 if (!(vhci->vhci_conf_flags & VHCI_CONF_FLAGS_AUTO_FAILBACK)) | |
777 vhci_log(CE_NOTE, dip, "!Auto-failback capability " | |
778 "disabled through scsi_vhci.conf file."); | |
779 | |
780 /* | |
781 * Allocate an mpapi private structure | |
782 */ | |
783 vhci->mp_priv = kmem_zalloc(sizeof (mpapi_priv_t), KM_SLEEP); | |
784 if (vhci_mpapi_init(vhci) != 0) { | |
785 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_attach: " | |
786 "vhci_mpapi_init() failed")); | |
787 } | |
788 | |
789 vhci_failover_modopen(vhci); /* load failover modules */ | |
790 | |
791 ddi_report_dev(dip); | |
792 return (DDI_SUCCESS); | |
793 | |
794 attach_fail: | |
795 if (vhci_attached) | |
796 (void) mdi_vhci_unregister(dip, 0); | |
797 | |
798 if (scsi_hba_attached) | |
799 (void) scsi_hba_detach(dip); | |
800 | |
801 if (vhci->vhci_tran) | |
802 scsi_hba_tran_free(vhci->vhci_tran); | |
803 | |
804 if (mutex_initted) { | |
805 mutex_destroy(&vhci->vhci_mutex); | |
806 } | |
807 | |
808 ddi_soft_state_free(vhci_softstate, instance); | |
809 return (DDI_FAILURE); | |
810 } | |
811 | |
812 | |
813 /*ARGSUSED*/ | |
814 static int | |
815 vhci_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) | |
816 { | |
817 int instance = ddi_get_instance(dip); | |
818 scsi_hba_tran_t *tran; | |
819 struct scsi_vhci *vhci; | |
820 | |
821 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_detach: cmd=0x%x\n", cmd)); | |
822 | |
823 if ((tran = ddi_get_driver_private(dip)) == NULL) | |
824 return (DDI_FAILURE); | |
825 | |
826 vhci = TRAN2HBAPRIVATE(tran); | |
827 if (!vhci) { | |
828 return (DDI_FAILURE); | |
829 } | |
830 | |
831 switch (cmd) { | |
832 case DDI_DETACH: | |
833 break; | |
834 | |
835 case DDI_SUSPEND: | |
836 case DDI_PM_SUSPEND: | |
837 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_detach: suspend/pm not yet" | |
838 "implemented\n")); | |
839 return (DDI_FAILURE); | |
840 | |
841 default: | |
842 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
843 "!vhci_detach: unknown ddi command\n")); | |
844 return (DDI_FAILURE); | |
845 } | |
846 | |
847 (void) mdi_vhci_unregister(dip, 0); | |
848 (void) scsi_hba_detach(dip); | |
849 scsi_hba_tran_free(tran); | |
850 | |
851 if (ddi_prop_remove(DDI_DEV_T_NONE, dip, | |
852 "pm-want-child-notification?") != DDI_PROP_SUCCESS) { | |
853 cmn_err(CE_WARN, | |
854 "%s%d unable to remove prop pm-want_child_notification?", | |
855 ddi_driver_name(dip), ddi_get_instance(dip)); | |
856 } | |
857 if (vhci_restart_timeid != 0) { | |
858 (void) untimeout(vhci_restart_timeid); | |
859 } | |
860 vhci_restart_timeid = 0; | |
861 | |
862 mutex_destroy(&vhci->vhci_mutex); | |
863 vhci->vhci_dip = NULL; | |
864 vhci->vhci_tran = NULL; | |
865 taskq_destroy(vhci->vhci_taskq); | |
866 taskq_destroy(vhci->vhci_update_pathstates_taskq); | |
867 ddi_remove_minor_node(dip, NULL); | |
868 ddi_soft_state_free(vhci_softstate, instance); | |
869 | |
870 vhci_failover_modclose(); /* unload failover modules */ | |
871 return (DDI_SUCCESS); | |
872 } | |
873 | |
874 /* | |
875 * vhci_getinfo() | |
876 * Given the device number, return the devinfo pointer or the | |
877 * instance number. | |
878 * Note: always succeed DDI_INFO_DEVT2INSTANCE, even before attach. | |
879 */ | |
880 | |
881 /*ARGSUSED*/ | |
882 static int | |
883 vhci_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result) | |
884 { | |
885 struct scsi_vhci *vhcip; | |
886 int instance = MINOR2INST(getminor((dev_t)arg)); | |
887 | |
888 switch (cmd) { | |
889 case DDI_INFO_DEVT2DEVINFO: | |
890 vhcip = ddi_get_soft_state(vhci_softstate, instance); | |
891 if (vhcip != NULL) | |
892 *result = vhcip->vhci_dip; | |
893 else { | |
894 *result = NULL; | |
895 return (DDI_FAILURE); | |
896 } | |
897 break; | |
898 | |
899 case DDI_INFO_DEVT2INSTANCE: | |
900 *result = (void *)(uintptr_t)instance; | |
901 break; | |
902 | |
903 default: | |
904 return (DDI_FAILURE); | |
905 } | |
906 | |
907 return (DDI_SUCCESS); | |
908 } | |
909 | |
910 /*ARGSUSED*/ | |
911 static int | |
912 vhci_scsi_tgt_init(dev_info_t *hba_dip, dev_info_t *tgt_dip, | |
913 scsi_hba_tran_t *hba_tran, struct scsi_device *sd) | |
914 { | |
915 char *guid; | |
916 scsi_vhci_lun_t *vlun; | |
917 struct scsi_vhci *vhci; | |
918 clock_t from_ticks; | |
919 mdi_pathinfo_t *pip; | |
920 int rval; | |
921 | |
922 ASSERT(hba_dip != NULL); | |
923 ASSERT(tgt_dip != NULL); | |
924 | |
6777 | 925 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, tgt_dip, PROPFLAGS, |
926 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) { | |
927 /* | |
928 * This must be the .conf node without GUID property. | |
929 * The node under fp already inserts a delay, so we | |
930 * just return from here. We rely on this delay to have | |
931 * all dips be posted to the ndi hotplug thread's newdev | |
932 * list. This is necessary for the deferred attach | |
933 * mechanism to work and opens() done soon after boot to | |
934 * succeed. | |
935 */ | |
936 VHCI_DEBUG(4, (CE_WARN, hba_dip, "tgt_init: lun guid " | |
937 "property failed")); | |
938 return (DDI_NOT_WELL_FORMED); | |
939 } | |
940 | |
941 if (ndi_dev_is_persistent_node(tgt_dip) == 0) { | |
942 /* | |
943 * This must be .conf node with the GUID property. We don't | |
944 * merge property by ndi_merge_node() here because the | |
945 * devi_addr_buf of .conf node is "" always according the | |
946 * implementation of vhci_scsi_get_name_bus_addr(). | |
947 */ | |
948 ddi_set_name_addr(tgt_dip, NULL); | |
949 return (DDI_FAILURE); | |
950 } | |
951 | |
4851 | 952 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(hba_dip)); |
953 ASSERT(vhci != NULL); | |
954 | |
955 VHCI_DEBUG(4, (CE_NOTE, hba_dip, | |
956 "!tgt_init: called for %s (instance %d)\n", | |
957 ddi_driver_name(tgt_dip), ddi_get_instance(tgt_dip))); | |
958 | |
959 vlun = vhci_lun_lookup(tgt_dip); | |
960 | |
961 mutex_enter(&vhci_global_mutex); | |
962 | |
963 from_ticks = ddi_get_lbolt(); | |
964 if (vhci_to_ticks == 0) { | |
965 vhci_to_ticks = from_ticks + | |
966 drv_usectohz(vhci_init_wait_timeout); | |
967 } | |
968 | |
969 #if DEBUG | |
970 if (vlun) { | |
971 VHCI_DEBUG(1, (CE_WARN, hba_dip, "tgt_init: " | |
972 "vhci_scsi_tgt_init: guid %s : found vlun 0x%p " | |
973 "from_ticks %lx to_ticks %lx", | |
974 guid, (void *)vlun, from_ticks, vhci_to_ticks)); | |
975 } else { | |
976 VHCI_DEBUG(1, (CE_WARN, hba_dip, "tgt_init: " | |
977 "vhci_scsi_tgt_init: guid %s : vlun not found " | |
978 "from_ticks %lx to_ticks %lx", guid, from_ticks, | |
979 vhci_to_ticks)); | |
980 } | |
981 #endif | |
982 | |
983 rval = mdi_select_path(tgt_dip, NULL, | |
984 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), NULL, &pip); | |
985 if (rval == MDI_SUCCESS) { | |
986 mdi_rele_path(pip); | |
987 } | |
988 | |
989 /* | |
990 * Wait for the following conditions : | |
991 * 1. no vlun available yet | |
992 * 2. no path established | |
993 * 3. timer did not expire | |
994 */ | |
995 while ((vlun == NULL) || (mdi_client_get_path_count(tgt_dip) == 0) || | |
996 (rval != MDI_SUCCESS)) { | |
997 if (vlun && vlun->svl_not_supported) { | |
998 VHCI_DEBUG(1, (CE_WARN, hba_dip, "tgt_init: " | |
999 "vlun 0x%p lun guid %s not supported!", | |
1000 (void *)vlun, guid)); | |
1001 mutex_exit(&vhci_global_mutex); | |
1002 ddi_prop_free(guid); | |
1003 return (DDI_NOT_WELL_FORMED); | |
1004 } | |
1005 if ((vhci_first_time == 0) && (from_ticks >= vhci_to_ticks)) { | |
1006 vhci_first_time = 1; | |
1007 } | |
1008 if (vhci_first_time == 1) { | |
1009 VHCI_DEBUG(1, (CE_WARN, hba_dip, "vhci_scsi_tgt_init: " | |
1010 "no wait for %s. from_tick %lx, to_tick %lx", | |
1011 guid, from_ticks, vhci_to_ticks)); | |
1012 mutex_exit(&vhci_global_mutex); | |
1013 ddi_prop_free(guid); | |
1014 return (DDI_NOT_WELL_FORMED); | |
1015 } | |
1016 | |
1017 if (cv_timedwait(&vhci_cv, | |
1018 &vhci_global_mutex, vhci_to_ticks) == -1) { | |
1019 /* Timed out */ | |
1020 #ifdef DEBUG | |
1021 if (vlun == NULL) { | |
1022 VHCI_DEBUG(1, (CE_WARN, hba_dip, | |
1023 "tgt_init: no vlun for %s!", guid)); | |
1024 } else if (mdi_client_get_path_count(tgt_dip) == 0) { | |
1025 VHCI_DEBUG(1, (CE_WARN, hba_dip, | |
1026 "tgt_init: client path count is " | |
1027 "zero for %s!", guid)); | |
1028 } else { | |
1029 VHCI_DEBUG(1, (CE_WARN, hba_dip, | |
1030 "tgt_init: client path not " | |
1031 "available yet for %s!", guid)); | |
1032 } | |
1033 #endif /* DEBUG */ | |
1034 mutex_exit(&vhci_global_mutex); | |
1035 ddi_prop_free(guid); | |
1036 return (DDI_NOT_WELL_FORMED); | |
1037 } | |
1038 vlun = vhci_lun_lookup(tgt_dip); | |
1039 rval = mdi_select_path(tgt_dip, NULL, | |
1040 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), | |
1041 NULL, &pip); | |
1042 if (rval == MDI_SUCCESS) { | |
1043 mdi_rele_path(pip); | |
1044 } | |
1045 from_ticks = ddi_get_lbolt(); | |
1046 } | |
1047 mutex_exit(&vhci_global_mutex); | |
1048 | |
1049 ASSERT(vlun != NULL); | |
1050 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
|
1051 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
1052 scsi_device_hba_private_set(sd, vlun); |
4851 | 1053 |
1054 return (DDI_SUCCESS); | |
1055 } | |
1056 | |
1057 /*ARGSUSED*/ | |
1058 static void | |
1059 vhci_scsi_tgt_free(dev_info_t *hba_dip, dev_info_t *tgt_dip, | |
1060 scsi_hba_tran_t *hba_tran, struct scsi_device *sd) | |
1061 { | |
1062 } | |
1063 | |
1064 /* | |
1065 * a PGR register command has started; copy the info we need | |
1066 */ | |
1067 int | |
1068 vhci_pgr_register_start(scsi_vhci_lun_t *vlun, struct scsi_pkt *pkt) | |
1069 { | |
1070 struct vhci_pkt *vpkt = TGTPKT2VHCIPKT(pkt); | |
1071 void *addr; | |
1072 | |
1073 if (!vpkt->vpkt_tgt_init_bp) | |
1074 return (TRAN_BADPKT); | |
1075 | |
1076 addr = bp_mapin_common(vpkt->vpkt_tgt_init_bp, | |
1077 (vpkt->vpkt_flags & CFLAG_NOWAIT) ? VM_NOSLEEP : VM_SLEEP); | |
1078 if (addr == NULL) | |
1079 return (TRAN_BUSY); | |
1080 | |
1081 mutex_enter(&vlun->svl_mutex); | |
1082 | |
1083 vhci_print_prout_keys(vlun, "v_pgr_reg_start: before bcopy:"); | |
1084 | |
1085 bcopy(addr, &vlun->svl_prout, sizeof (vhci_prout_t) - | |
1086 (2 * MHIOC_RESV_KEY_SIZE*sizeof (char))); | |
1087 bcopy(pkt->pkt_cdbp, vlun->svl_cdb, sizeof (vlun->svl_cdb)); | |
1088 | |
1089 vhci_print_prout_keys(vlun, "v_pgr_reg_start: after bcopy:"); | |
1090 | |
1091 vlun->svl_time = pkt->pkt_time; | |
1092 vlun->svl_bcount = vpkt->vpkt_tgt_init_bp->b_bcount; | |
1093 vlun->svl_first_path = vpkt->vpkt_path; | |
1094 mutex_exit(&vlun->svl_mutex); | |
1095 return (0); | |
1096 } | |
1097 | |
1098 /* | |
1099 * Function name : vhci_scsi_start() | |
1100 * | |
1101 * Return Values : TRAN_FATAL_ERROR - vhci has been shutdown | |
1102 * or other fatal failure | |
1103 * preventing packet transportation | |
1104 * TRAN_BUSY - request queue is full | |
1105 * TRAN_ACCEPT - pkt has been submitted to phci | |
1106 * (or is held in the waitQ) | |
1107 * Description : Implements SCSA's tran_start() entry point for | |
1108 * packet transport | |
1109 * | |
1110 */ | |
1111 static int | |
1112 vhci_scsi_start(struct scsi_address *ap, struct scsi_pkt *pkt) | |
1113 { | |
1114 int rval = TRAN_ACCEPT; | |
1115 int instance, held; | |
1116 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
1117 struct scsi_vhci_lun *vlun = ADDR2VLUN(ap); | |
1118 struct vhci_pkt *vpkt = TGTPKT2VHCIPKT(pkt); | |
1119 int flags = 0; | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1120 scsi_vhci_priv_t *svp, *svp_resrv; |
4851 | 1121 dev_info_t *cdip; |
1122 client_lb_t lbp; | |
1123 int restore_lbp = 0; | |
1124 /* set if pkt is SCSI-II RESERVE cmd */ | |
1125 int pkt_reserve_cmd = 0; | |
1126 int reserve_failed = 0; | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1127 int resrv_instance = 0; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1128 mdi_pathinfo_t *pip; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1129 struct scsi_pkt *rel_pkt; |
4851 | 1130 |
1131 ASSERT(vhci != NULL); | |
1132 ASSERT(vpkt != NULL); | |
1133 ASSERT(vpkt->vpkt_state != VHCI_PKT_ISSUED); | |
1134 cdip = ADDR2DIP(ap); | |
1135 | |
1136 /* | |
1137 * Block IOs if LUN is held or QUIESCED for IOs. | |
1138 */ | |
1139 if ((VHCI_LUN_IS_HELD(vlun)) || | |
1140 ((vlun->svl_flags & VLUN_QUIESCED_FLG) == VLUN_QUIESCED_FLG)) { | |
1141 return (TRAN_BUSY); | |
1142 } | |
1143 | |
1144 /* | |
1145 * vhci_lun needs to be quiesced before SCSI-II RESERVE command | |
1146 * can be issued. This may require a cv_timedwait, which is | |
1147 * dangerous to perform in an interrupt context. So if this | |
1148 * is a RESERVE command a taskq is dispatched to service it. | |
1149 * This taskq shall again call vhci_scsi_start, but we shall be | |
1150 * sure its not in an interrupt context. | |
1151 */ | |
1152 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
1153 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
1154 if (!(vpkt->vpkt_state & VHCI_PKT_THRU_TASKQ)) { | |
1155 if (taskq_dispatch(vhci->vhci_taskq, | |
1156 vhci_dispatch_scsi_start, (void *) vpkt, | |
1157 KM_NOSLEEP)) { | |
1158 return (TRAN_ACCEPT); | |
1159 } else { | |
1160 return (TRAN_BUSY); | |
1161 } | |
1162 } | |
1163 | |
1164 /* | |
1165 * Here we ensure that simultaneous SCSI-II RESERVE cmds don't | |
1166 * get serviced for a lun. | |
1167 */ | |
1168 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
1169 if (!held) { | |
1170 return (TRAN_BUSY); | |
1171 } else if ((vlun->svl_flags & VLUN_QUIESCED_FLG) == | |
1172 VLUN_QUIESCED_FLG) { | |
1173 VHCI_RELEASE_LUN(vlun); | |
1174 return (TRAN_BUSY); | |
1175 } | |
1176 | |
1177 /* | |
1178 * To ensure that no IOs occur for this LUN for the duration | |
1179 * of this pkt set the VLUN_QUIESCED_FLG. | |
1180 * In case this routine needs to exit on error make sure that | |
1181 * this flag is cleared. | |
1182 */ | |
1183 vlun->svl_flags |= VLUN_QUIESCED_FLG; | |
1184 pkt_reserve_cmd = 1; | |
1185 | |
1186 /* | |
1187 * if this is a SCSI-II RESERVE command, set load balancing | |
1188 * policy to be ALTERNATE PATH to ensure that all subsequent | |
1189 * IOs are routed on the same path. This is because if commands | |
1190 * are routed across multiple paths then IOs on paths other than | |
1191 * the one on which the RESERVE was executed will get a | |
1192 * RESERVATION CONFLICT | |
1193 */ | |
1194 lbp = mdi_get_lb_policy(cdip); | |
1195 if (lbp != LOAD_BALANCE_NONE) { | |
1196 if (vhci_quiesce_lun(vlun) != 1) { | |
1197 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1198 VHCI_RELEASE_LUN(vlun); | |
1199 return (TRAN_FATAL_ERROR); | |
1200 } | |
1201 vlun->svl_lb_policy_save = lbp; | |
1202 if (mdi_set_lb_policy(cdip, LOAD_BALANCE_NONE) != | |
1203 MDI_SUCCESS) { | |
1204 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1205 VHCI_RELEASE_LUN(vlun); | |
1206 return (TRAN_FATAL_ERROR); | |
1207 } | |
1208 restore_lbp = 1; | |
1209 } | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1210 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1211 VHCI_DEBUG(2, (CE_NOTE, vhci->vhci_dip, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1212 "!vhci_scsi_start: sending SCSI-2 RESERVE, vlun 0x%p, " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1213 "svl_resrv_pip 0x%p, svl_flags: %x, lb_policy %x", |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1214 (void *)vlun, (void *)vlun->svl_resrv_pip, vlun->svl_flags, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1215 mdi_get_lb_policy(cdip))); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1216 |
4851 | 1217 /* |
1218 * See comments for VLUN_RESERVE_ACTIVE_FLG in scsi_vhci.h | |
1219 * To narrow this window where a reserve command may be sent | |
1220 * down an inactive path the path states first need to be | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1221 * updated. Before calling vhci_update_pathstates reset |
4851 | 1222 * VLUN_RESERVE_ACTIVE_FLG, just in case it was already set |
1223 * for this lun. This shall prevent an unnecessary reset | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1224 * from being sent out. Also remember currently reserved path |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1225 * just for a case the new reservation will go to another path. |
4851 | 1226 */ |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1227 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1228 resrv_instance = mdi_pi_get_path_instance( |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1229 vlun->svl_resrv_pip); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1230 } |
4851 | 1231 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; |
1232 vhci_update_pathstates((void *)vlun); | |
1233 } | |
1234 | |
1235 instance = ddi_get_instance(vhci->vhci_dip); | |
1236 | |
1237 /* | |
1238 * If the command is PRIN with action of zero, then the cmd | |
1239 * is reading PR keys which requires filtering on completion. | |
1240 * Data cache sync must be guaranteed. | |
1241 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1242 if ((pkt->pkt_cdbp[0] == SCMD_PRIN) && (pkt->pkt_cdbp[1] == 0) && |
4851 | 1243 (vpkt->vpkt_org_vpkt == NULL)) { |
1244 vpkt->vpkt_tgt_init_pkt_flags |= PKT_CONSISTENT; | |
1245 } | |
1246 | |
1247 /* | |
1248 * Do not defer bind for PKT_DMA_PARTIAL | |
1249 */ | |
1250 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1251 | |
1252 /* This is a non pkt_dma_partial case */ | |
1253 if ((rval = vhci_bind_transport( | |
1254 ap, vpkt, vpkt->vpkt_tgt_init_pkt_flags, NULL_FUNC)) | |
1255 != TRAN_ACCEPT) { | |
1256 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1257 "!vhci%d %x: failed to bind transport: " | |
1258 "vlun 0x%p pkt_reserved %x restore_lbp %x," | |
1259 "lbp %x", instance, rval, (void *)vlun, | |
1260 pkt_reserve_cmd, restore_lbp, lbp)); | |
1261 if (restore_lbp) | |
1262 (void) mdi_set_lb_policy(cdip, lbp); | |
1263 if (pkt_reserve_cmd) | |
1264 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1265 return (rval); | |
1266 } | |
1267 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
1268 "vhci_scsi_start: v_b_t called 0x%p\n", (void *)vpkt)); | |
1269 } | |
1270 ASSERT(vpkt->vpkt_hba_pkt != NULL); | |
1271 ASSERT(vpkt->vpkt_path != NULL); | |
1272 | |
1273 /* | |
1274 * This is the chance to adjust the pHCI's pkt and other information | |
1275 * from target driver's pkt. | |
1276 */ | |
1277 VHCI_DEBUG(8, (CE_NOTE, vhci->vhci_dip, "vhci_scsi_start vpkt %p\n", | |
1278 (void *)vpkt)); | |
1279 vhci_update_pHCI_pkt(vpkt, pkt); | |
1280 | |
1281 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
1282 if (vpkt->vpkt_path != vlun->svl_resrv_pip) { | |
1283 VHCI_DEBUG(1, (CE_WARN, vhci->vhci_dip, | |
1284 "!vhci_bind: reserve flag set for vlun 0x%p, but, " | |
1285 "pktpath 0x%p resrv path 0x%p differ. lb_policy %x", | |
1286 (void *)vlun, (void *)vpkt->vpkt_path, | |
1287 (void *)vlun->svl_resrv_pip, | |
1288 mdi_get_lb_policy(cdip))); | |
1289 reserve_failed = 1; | |
1290 } | |
1291 } | |
1292 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1293 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(vpkt->vpkt_path); |
4851 | 1294 if (svp == NULL || reserve_failed) { |
1295 if (pkt_reserve_cmd) { | |
1296 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1297 "!vhci_bind returned null svp vlun 0x%p", | |
1298 (void *)vlun)); | |
1299 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1300 if (restore_lbp) | |
1301 (void) mdi_set_lb_policy(cdip, lbp); | |
1302 } | |
1303 pkt_cleanup: | |
1304 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1305 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
1306 vpkt->vpkt_hba_pkt = NULL; | |
1307 if (vpkt->vpkt_path) { | |
1308 mdi_rele_path(vpkt->vpkt_path); | |
1309 vpkt->vpkt_path = NULL; | |
1310 } | |
1311 } | |
1312 if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
1313 (((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
|
1314 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { |
4851 | 1315 sema_v(&vlun->svl_pgr_sema); |
1316 } | |
1317 return (TRAN_BUSY); | |
1318 } | |
1319 | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1320 if ((resrv_instance != 0) && (resrv_instance != |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1321 mdi_pi_get_path_instance(vpkt->vpkt_path))) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1322 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1323 * This is an attempt to reserve vpkt->vpkt_path. But the |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1324 * previously reserved path referred by resrv_instance might |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1325 * still be reserved. Hence we will send a release command |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1326 * there in order to avoid a reservation conflict. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1327 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1328 VHCI_DEBUG(1, (CE_NOTE, vhci->vhci_dip, "!vhci_scsi_start: " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1329 "conflicting reservation on another path, vlun 0x%p, " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1330 "reserved instance %d, new instance: %d, pip: 0x%p", |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1331 (void *)vlun, resrv_instance, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1332 mdi_pi_get_path_instance(vpkt->vpkt_path), |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1333 (void *)vpkt->vpkt_path)); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1334 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1335 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1336 * In rare cases, the path referred by resrv_instance could |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1337 * disappear in the meantime. Calling mdi_select_path() below |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1338 * is an attempt to find out if the path still exists. It also |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1339 * ensures that the path will be held when the release is sent. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1340 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1341 rval = mdi_select_path(cdip, NULL, MDI_SELECT_PATH_INSTANCE, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1342 (void *)(intptr_t)resrv_instance, &pip); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1343 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1344 if ((rval == MDI_SUCCESS) && (pip != NULL)) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1345 svp_resrv = (scsi_vhci_priv_t *) |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1346 mdi_pi_get_vhci_private(pip); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1347 rel_pkt = scsi_init_pkt(&svp_resrv->svp_psd->sd_address, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1348 NULL, NULL, CDB_GROUP0, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1349 sizeof (struct scsi_arq_status), 0, 0, SLEEP_FUNC, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1350 NULL); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1351 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1352 if (rel_pkt == NULL) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1353 char *p_path; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1354 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1355 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1356 * This is very unlikely. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1357 * scsi_init_pkt(SLEEP_FUNC) does not fail |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1358 * because of resources. But in theory it could |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1359 * fail for some other reason. There is not an |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1360 * easy way how to recover though. Log a warning |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1361 * and return. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1362 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1363 p_path = kmem_zalloc(MAXPATHLEN, KM_SLEEP); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1364 vhci_log(CE_WARN, vhci->vhci_dip, "!Sending " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1365 "RELEASE(6) to %s failed, a potential " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1366 "reservation conflict ahead.", |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1367 ddi_pathname(mdi_pi_get_phci(pip), p_path)); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1368 kmem_free(p_path, MAXPATHLEN); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1369 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1370 if (restore_lbp) |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1371 (void) mdi_set_lb_policy(cdip, lbp); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1372 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1373 /* no need to check pkt_reserve_cmd here */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1374 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1375 return (TRAN_FATAL_ERROR); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1376 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1377 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1378 rel_pkt->pkt_cdbp[0] = SCMD_RELEASE; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1379 rel_pkt->pkt_time = 60; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1380 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1381 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1382 * Ignore the return value. If it will fail |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1383 * then most likely it is no longer reserved |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1384 * anyway. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1385 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1386 (void) vhci_do_scsi_cmd(rel_pkt); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1387 VHCI_DEBUG(1, (CE_NOTE, NULL, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1388 "!vhci_scsi_start: path 0x%p, issued SCSI-2" |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1389 " RELEASE\n", (void *)pip)); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1390 scsi_destroy_pkt(rel_pkt); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1391 mdi_rele_path(pip); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1392 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1393 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
1394 |
4851 | 1395 VHCI_INCR_PATH_CMDCOUNT(svp); |
1396 | |
1397 /* | |
1398 * Ensure that no other IOs raced ahead, while a RESERVE cmd was | |
1399 * QUIESCING the same lun. | |
1400 */ | |
1401 if ((!pkt_reserve_cmd) && | |
1402 ((vlun->svl_flags & VLUN_QUIESCED_FLG) == VLUN_QUIESCED_FLG)) { | |
1403 VHCI_DECR_PATH_CMDCOUNT(svp); | |
1404 goto pkt_cleanup; | |
1405 } | |
1406 | |
1407 if ((pkt->pkt_cdbp[0] == SCMD_PRIN) || | |
1408 (pkt->pkt_cdbp[0] == SCMD_PROUT)) { | |
1409 /* | |
1410 * currently this thread only handles running PGR | |
1411 * commands, so don't bother creating it unless | |
1412 * something interesting is going to happen (like | |
1413 * either a PGR out, or a PGR in with enough space | |
1414 * to hold the keys that are getting returned) | |
1415 */ | |
1416 mutex_enter(&vlun->svl_mutex); | |
1417 if (((vlun->svl_flags & VLUN_TASK_D_ALIVE_FLG) == 0) && | |
1418 (pkt->pkt_cdbp[0] == SCMD_PROUT)) { | |
1419 vlun->svl_taskq = taskq_create("vlun_pgr_task_daemon", | |
1420 1, MINCLSYSPRI, 1, 4, 0); | |
1421 vlun->svl_flags |= VLUN_TASK_D_ALIVE_FLG; | |
1422 } | |
1423 mutex_exit(&vlun->svl_mutex); | |
1424 if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
1425 (((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
|
1426 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { |
4851 | 1427 if (rval = vhci_pgr_register_start(vlun, pkt)) { |
1428 /* an error */ | |
1429 sema_v(&vlun->svl_pgr_sema); | |
1430 return (rval); | |
1431 } | |
1432 } | |
1433 } | |
1434 | |
1435 /* | |
1436 * SCSI-II RESERVE cmd is not expected in polled mode. | |
1437 * If this changes it needs to be handled for the polled scenario. | |
1438 */ | |
1439 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
|
1440 |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1441 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1442 * 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
|
1443 * 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
|
1444 * 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
|
1445 * the path_instance. |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1446 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
1447 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
|
1448 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
|
1449 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
|
1450 |
4851 | 1451 rval = scsi_transport(vpkt->vpkt_hba_pkt); |
1452 if (rval == TRAN_ACCEPT) { | |
1453 if (flags & FLAG_NOINTR) { | |
1454 struct scsi_pkt *tpkt = vpkt->vpkt_tgt_pkt; | |
1455 struct scsi_pkt *pkt = vpkt->vpkt_hba_pkt; | |
1456 | |
1457 ASSERT(tpkt != NULL); | |
1458 *(tpkt->pkt_scbp) = *(pkt->pkt_scbp); | |
1459 tpkt->pkt_resid = pkt->pkt_resid; | |
1460 tpkt->pkt_state = pkt->pkt_state; | |
1461 tpkt->pkt_statistics = pkt->pkt_statistics; | |
1462 tpkt->pkt_reason = pkt->pkt_reason; | |
1463 | |
1464 if ((*(pkt->pkt_scbp) == STATUS_CHECK) && | |
1465 (pkt->pkt_state & STATE_ARQ_DONE)) { | |
1466 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
1467 vpkt->vpkt_tgt_init_scblen); | |
1468 } | |
1469 | |
1470 VHCI_DECR_PATH_CMDCOUNT(svp); | |
1471 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1472 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
1473 vpkt->vpkt_hba_pkt = NULL; | |
1474 if (vpkt->vpkt_path) { | |
1475 mdi_rele_path(vpkt->vpkt_path); | |
1476 vpkt->vpkt_path = NULL; | |
1477 } | |
1478 } | |
1479 /* | |
1480 * This path will not automatically retry pkts | |
1481 * internally, therefore, vpkt_org_vpkt should | |
1482 * never be set. | |
1483 */ | |
1484 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
|
1485 scsi_hba_pkt_comp(tpkt); |
4851 | 1486 } |
1487 return (rval); | |
1488 } else if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
1489 (((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) || | |
1490 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { | |
1491 /* the command exited with bad status */ | |
1492 sema_v(&vlun->svl_pgr_sema); | |
1493 } else if (vpkt->vpkt_tgt_pkt->pkt_cdbp[0] == SCMD_PRIN) { | |
1494 /* the command exited with bad status */ | |
1495 sema_v(&vlun->svl_pgr_sema); | |
1496 } else if (pkt_reserve_cmd) { | |
1497 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1498 "!vhci_scsi_start: reserve failed vlun 0x%p", | |
1499 (void *)vlun)); | |
1500 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
1501 if (restore_lbp) | |
1502 (void) mdi_set_lb_policy(cdip, lbp); | |
1503 } | |
1504 | |
1505 ASSERT(vpkt->vpkt_hba_pkt != NULL); | |
1506 VHCI_DECR_PATH_CMDCOUNT(svp); | |
1507 | |
1508 /* Do not destroy phci packet information for PKT_DMA_PARTIAL */ | |
1509 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
1510 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
1511 vpkt->vpkt_hba_pkt = NULL; | |
1512 if (vpkt->vpkt_path) { | |
1513 MDI_PI_ERRSTAT(vpkt->vpkt_path, MDI_PI_TRANSERR); | |
1514 mdi_rele_path(vpkt->vpkt_path); | |
1515 vpkt->vpkt_path = NULL; | |
1516 } | |
1517 } | |
1518 return (TRAN_BUSY); | |
1519 } | |
1520 | |
1521 /* | |
1522 * Function name : vhci_scsi_reset() | |
1523 * | |
1524 * Return Values : 0 - reset failed | |
1525 * 1 - reset succeeded | |
1526 */ | |
1527 | |
1528 /* ARGSUSED */ | |
1529 static int | |
1530 vhci_scsi_reset(struct scsi_address *ap, int level) | |
1531 { | |
1532 int rval = 0; | |
1533 | |
1534 cmn_err(CE_WARN, "!vhci_scsi_reset 0x%x", level); | |
1535 if ((level == RESET_TARGET) || (level == RESET_LUN)) { | |
1536 return (vhci_scsi_reset_target(ap, level, TRUE)); | |
1537 } else if (level == RESET_ALL) { | |
1538 return (vhci_scsi_reset_bus(ap)); | |
1539 } | |
1540 | |
1541 return (rval); | |
1542 } | |
1543 | |
1544 /* | |
1545 * vhci_recovery_reset: | |
1546 * Issues reset to the device | |
1547 * Input: | |
1548 * vlun - vhci lun pointer of the device | |
1549 * ap - address of the device | |
1550 * select_path: | |
1551 * If select_path is FALSE, then the address specified in ap is | |
1552 * the path on which reset will be issued. | |
1553 * If select_path is TRUE, then path is obtained by calling | |
1554 * mdi_select_path. | |
1555 * | |
1556 * recovery_depth: | |
1557 * Caller can specify the level of reset. | |
1558 * VHCI_DEPTH_LUN - | |
1559 * Issues LUN RESET if device supports lun reset. | |
1560 * VHCI_DEPTH_TARGET - | |
1561 * If Lun Reset fails or the device does not support | |
1562 * Lun Reset, issues TARGET RESET | |
1563 * VHCI_DEPTH_ALL - | |
1564 * If Lun Reset fails or the device does not support | |
1565 * Lun Reset, issues TARGET RESET. | |
1566 * If TARGET RESET does not succeed, issues Bus Reset. | |
1567 */ | |
1568 | |
1569 static int | |
1570 vhci_recovery_reset(scsi_vhci_lun_t *vlun, struct scsi_address *ap, | |
1571 uint8_t select_path, uint8_t recovery_depth) | |
1572 { | |
1573 int ret = 0; | |
1574 | |
1575 ASSERT(ap != NULL); | |
1576 | |
1577 if (vlun && vlun->svl_support_lun_reset == 1) { | |
1578 ret = vhci_scsi_reset_target(ap, RESET_LUN, | |
1579 select_path); | |
1580 } | |
1581 | |
1582 recovery_depth--; | |
1583 | |
1584 if ((ret == 0) && recovery_depth) { | |
1585 ret = vhci_scsi_reset_target(ap, RESET_TARGET, | |
1586 select_path); | |
1587 recovery_depth--; | |
1588 } | |
1589 | |
1590 if ((ret == 0) && recovery_depth) { | |
1591 (void) scsi_reset(ap, RESET_ALL); | |
1592 } | |
1593 | |
1594 return (ret); | |
1595 } | |
1596 | |
1597 /* | |
1598 * Note: The scsi_address passed to this routine could be the scsi_address | |
1599 * 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
|
1600 * 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
|
1601 * 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
|
1602 * of the scsi_address passed in. |
4851 | 1603 */ |
1604 static int | |
1605 vhci_scsi_reset_target(struct scsi_address *ap, int level, uint8_t select_path) | |
1606 { | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
1607 dev_info_t *vdip, *cdip; |
4851 | 1608 mdi_pathinfo_t *pip = NULL; |
1609 mdi_pathinfo_t *npip = NULL; | |
1610 int rval = -1; | |
1611 scsi_vhci_priv_t *svp = NULL; | |
1612 struct scsi_address *pap = NULL; | |
1613 scsi_hba_tran_t *hba = NULL; | |
1614 int sps; | |
1615 struct scsi_vhci *vhci = NULL; | |
1616 | |
1617 if (select_path != TRUE) { | |
1618 ASSERT(ap != NULL); | |
1619 if (level == RESET_LUN) { | |
1620 hba = ap->a_hba_tran; | |
1621 ASSERT(hba != NULL); | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1622 return (hba->tran_reset(ap, RESET_LUN)); |
4851 | 1623 } |
1624 return (scsi_reset(ap, level)); | |
1625 } | |
1626 | |
8851
cf2ef2a74136
6801824 Panic in vhci_scsi_reset_target
Chris Liu <Chris.Liu@Sun.COM>
parents:
8335
diff
changeset
|
1627 cdip = ADDR2DIP(ap); |
4851 | 1628 ASSERT(cdip != NULL); |
1629 vdip = ddi_get_parent(cdip); | |
1630 ASSERT(vdip != NULL); | |
1631 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
1632 ASSERT(vhci != NULL); | |
1633 | |
1634 rval = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH, NULL, &pip); | |
1635 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
1636 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_scsi_reset_target: " | |
1637 "Unable to get a path, dip 0x%p", (void *)cdip)); | |
1638 return (0); | |
1639 } | |
1640 again: | |
1641 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
1642 if (svp == NULL) { | |
1643 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_scsi_reset_target: " | |
1644 "priv is NULL, pip 0x%p", (void *)pip)); | |
1645 mdi_rele_path(pip); | |
1646 return (0); | |
1647 } | |
1648 | |
1649 if (svp->svp_psd == NULL) { | |
1650 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_scsi_reset_target: " | |
1651 "psd is NULL, pip 0x%p, svp 0x%p", | |
1652 (void *)pip, (void *)svp)); | |
1653 mdi_rele_path(pip); | |
1654 return (0); | |
1655 } | |
1656 | |
1657 pap = &svp->svp_psd->sd_address; | |
1658 hba = pap->a_hba_tran; | |
1659 | |
1660 ASSERT(pap != NULL); | |
1661 ASSERT(hba != NULL); | |
1662 | |
1663 if (hba->tran_reset != NULL) { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1664 if (hba->tran_reset(pap, level) == 0) { |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
1665 vhci_log(CE_WARN, vdip, "!%s%d: " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
1666 "path %s, reset %d failed", |
4851 | 1667 ddi_driver_name(cdip), ddi_get_instance(cdip), |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
1668 mdi_pi_spathname(pip), level); |
4851 | 1669 |
1670 /* | |
1671 * Select next path and issue the reset, repeat | |
1672 * until all paths are exhausted | |
1673 */ | |
1674 sps = mdi_select_path(cdip, NULL, | |
1675 MDI_SELECT_ONLINE_PATH, pip, &npip); | |
1676 if ((sps != MDI_SUCCESS) || (npip == NULL)) { | |
1677 mdi_rele_path(pip); | |
1678 return (0); | |
1679 } | |
1680 mdi_rele_path(pip); | |
1681 pip = npip; | |
1682 goto again; | |
1683 } | |
1684 mdi_rele_path(pip); | |
1685 mutex_enter(&vhci->vhci_mutex); | |
1686 scsi_hba_reset_notify_callback(&vhci->vhci_mutex, | |
1687 &vhci->vhci_reset_notify_listf); | |
1688 mutex_exit(&vhci->vhci_mutex); | |
1689 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_scsi_reset_target: " | |
1690 "reset %d sent down pip:%p for cdip:%p\n", level, | |
1691 (void *)pip, (void *)cdip)); | |
1692 return (1); | |
1693 } | |
1694 mdi_rele_path(pip); | |
1695 return (0); | |
1696 } | |
1697 | |
1698 | |
1699 /* ARGSUSED */ | |
1700 static int | |
1701 vhci_scsi_reset_bus(struct scsi_address *ap) | |
1702 { | |
1703 return (1); | |
1704 } | |
1705 | |
1706 | |
1707 /* | |
1708 * called by vhci_getcap and vhci_setcap to get and set (respectively) | |
1709 * SCSI capabilities | |
1710 */ | |
1711 /* ARGSUSED */ | |
1712 static int | |
1713 vhci_commoncap(struct scsi_address *ap, char *cap, | |
1714 int val, int tgtonly, int doset) | |
1715 { | |
1716 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
1717 struct scsi_vhci_lun *vlun = ADDR2VLUN(ap); | |
1718 int cidx; | |
1719 int rval = 0; | |
1720 | |
1721 if (cap == (char *)0) { | |
1722 VHCI_DEBUG(3, (CE_WARN, vhci->vhci_dip, | |
1723 "!vhci_commoncap: invalid arg")); | |
1724 return (rval); | |
1725 } | |
1726 | |
4882
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1727 if (vlun == NULL) { |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1728 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
|
1729 "!vhci_commoncap: vlun is null")); |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1730 return (rval); |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1731 } |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
1732 |
4851 | 1733 if ((cidx = scsi_hba_lookup_capstr(cap)) == -1) { |
1734 return (UNDEFINED); | |
1735 } | |
1736 | |
1737 /* | |
1738 * Process setcap request. | |
1739 */ | |
1740 if (doset) { | |
1741 /* | |
1742 * At present, we can only set binary (0/1) values | |
1743 */ | |
1744 switch (cidx) { | |
1745 case SCSI_CAP_ARQ: | |
1746 if (val == 0) { | |
1747 rval = 0; | |
1748 } else { | |
1749 rval = 1; | |
1750 } | |
1751 break; | |
1752 | |
1753 case SCSI_CAP_LUN_RESET: | |
1754 if (tgtonly == 0) { | |
1755 VHCI_DEBUG(1, (CE_WARN, vhci->vhci_dip, | |
1756 "scsi_vhci_setcap: " | |
1757 "Returning error since whom = 0")); | |
1758 rval = -1; | |
1759 break; | |
1760 } | |
1761 /* | |
1762 * Set the capability accordingly. | |
1763 */ | |
1764 mutex_enter(&vlun->svl_mutex); | |
1765 vlun->svl_support_lun_reset = val; | |
1766 rval = val; | |
1767 mutex_exit(&vlun->svl_mutex); | |
1768 break; | |
1769 | |
1770 case SCSI_CAP_SECTOR_SIZE: | |
1771 mutex_enter(&vlun->svl_mutex); | |
1772 vlun->svl_sector_size = val; | |
1773 vlun->svl_setcap_done = 1; | |
1774 mutex_exit(&vlun->svl_mutex); | |
1775 (void) vhci_pHCI_cap(ap, cap, val, tgtonly, NULL); | |
1776 | |
1777 /* Always return success */ | |
1778 rval = 1; | |
1779 break; | |
1780 | |
1781 default: | |
1782 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1783 "!vhci_setcap: unsupported %d", cidx)); | |
1784 rval = UNDEFINED; | |
1785 break; | |
1786 } | |
1787 | |
1788 VHCI_DEBUG(6, (CE_NOTE, vhci->vhci_dip, | |
1789 "!set cap: cap=%s, val/tgtonly/doset/rval = " | |
1790 "0x%x/0x%x/0x%x/%d\n", | |
1791 cap, val, tgtonly, doset, rval)); | |
1792 | |
1793 } else { | |
1794 /* | |
1795 * Process getcap request. | |
1796 */ | |
1797 switch (cidx) { | |
1798 case SCSI_CAP_DMA_MAX: | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1799 /* |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1800 * 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
|
1801 * 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
|
1802 */ |
4851 | 1803 rval = (int)VHCI_DMA_MAX_XFER_CAP; |
1804 break; | |
1805 | |
1806 case SCSI_CAP_INITIATOR_ID: | |
1807 rval = 0x00; | |
1808 break; | |
1809 | |
1810 case SCSI_CAP_ARQ: | |
1811 case SCSI_CAP_RESET_NOTIFICATION: | |
1812 case SCSI_CAP_TAGGED_QING: | |
1813 rval = 1; | |
1814 break; | |
1815 | |
1816 case SCSI_CAP_SCSI_VERSION: | |
1817 rval = 3; | |
1818 break; | |
1819 | |
1820 case SCSI_CAP_INTERCONNECT_TYPE: | |
1821 rval = INTERCONNECT_FABRIC; | |
1822 break; | |
1823 | |
1824 case SCSI_CAP_LUN_RESET: | |
1825 /* | |
1826 * scsi_vhci will always return success for LUN reset. | |
1827 * When request for doing LUN reset comes | |
1828 * through scsi_reset entry point, at that time attempt | |
1829 * will be made to do reset through all the possible | |
1830 * paths. | |
1831 */ | |
1832 mutex_enter(&vlun->svl_mutex); | |
1833 rval = vlun->svl_support_lun_reset; | |
1834 mutex_exit(&vlun->svl_mutex); | |
1835 VHCI_DEBUG(4, (CE_WARN, vhci->vhci_dip, | |
1836 "scsi_vhci_getcap:" | |
1837 "Getting the Lun reset capability %d", rval)); | |
1838 break; | |
1839 | |
1840 case SCSI_CAP_SECTOR_SIZE: | |
1841 mutex_enter(&vlun->svl_mutex); | |
1842 rval = vlun->svl_sector_size; | |
1843 mutex_exit(&vlun->svl_mutex); | |
1844 break; | |
1845 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1846 case SCSI_CAP_CDB_LEN: |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1847 rval = VHCI_SCSI_CDB_SIZE; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1848 break; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1849 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1850 case SCSI_CAP_DMA_MAX_ARCH: |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1851 /* |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1852 * 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
|
1853 * 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
|
1854 */ |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1855 rval = 0; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1856 break; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
1857 |
4851 | 1858 default: |
1859 VHCI_DEBUG(6, (CE_WARN, vhci->vhci_dip, | |
1860 "!vhci_getcap: unsupported %d", cidx)); | |
1861 rval = UNDEFINED; | |
1862 break; | |
1863 } | |
1864 | |
1865 VHCI_DEBUG(6, (CE_NOTE, vhci->vhci_dip, | |
1866 "!get cap: cap=%s, val/tgtonly/doset/rval = " | |
1867 "0x%x/0x%x/0x%x/%d\n", | |
1868 cap, val, tgtonly, doset, rval)); | |
1869 } | |
1870 return (rval); | |
1871 } | |
1872 | |
1873 | |
1874 /* | |
1875 * Function name : vhci_scsi_getcap() | |
1876 * | |
1877 */ | |
1878 static int | |
1879 vhci_scsi_getcap(struct scsi_address *ap, char *cap, int whom) | |
1880 { | |
1881 return (vhci_commoncap(ap, cap, 0, whom, 0)); | |
1882 } | |
1883 | |
1884 static int | |
1885 vhci_scsi_setcap(struct scsi_address *ap, char *cap, int value, int whom) | |
1886 { | |
1887 return (vhci_commoncap(ap, cap, value, whom, 1)); | |
1888 } | |
1889 | |
1890 /* | |
1891 * Function name : vhci_scsi_abort() | |
1892 */ | |
1893 /* ARGSUSED */ | |
1894 static int | |
1895 vhci_scsi_abort(struct scsi_address *ap, struct scsi_pkt *pkt) | |
1896 { | |
1897 return (0); | |
1898 } | |
1899 | |
1900 /* | |
1901 * Function name : vhci_scsi_init_pkt | |
1902 * | |
1903 * Return Values : pointer to scsi_pkt, or NULL | |
1904 */ | |
1905 /* ARGSUSED */ | |
1906 static struct scsi_pkt * | |
1907 vhci_scsi_init_pkt(struct scsi_address *ap, struct scsi_pkt *pkt, | |
1908 struct buf *bp, int cmdlen, int statuslen, int tgtlen, | |
1909 int flags, int (*callback)(caddr_t), caddr_t arg) | |
1910 { | |
1911 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
1912 struct vhci_pkt *vpkt; | |
1913 int rval; | |
1914 int newpkt = 0; | |
1915 struct scsi_pkt *pktp; | |
1916 | |
1917 | |
1918 if (pkt == NULL) { | |
1919 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
|
1920 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
|
1921 ((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
|
1922 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
|
1923 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
|
1924 "!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
|
1925 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
|
1926 } |
4851 | 1927 } |
1928 | |
1929 pktp = scsi_hba_pkt_alloc(vhci->vhci_dip, | |
1930 ap, cmdlen, statuslen, tgtlen, sizeof (*vpkt), callback, | |
1931 arg); | |
1932 | |
1933 if (pktp == NULL) { | |
1934 return (NULL); | |
1935 } | |
1936 | |
1937 /* Get the vhci's private structure */ | |
1938 vpkt = (struct vhci_pkt *)(pktp->pkt_ha_private); | |
1939 ASSERT(vpkt); | |
1940 | |
1941 /* Save the target driver's packet */ | |
1942 vpkt->vpkt_tgt_pkt = pktp; | |
1943 | |
1944 /* | |
1945 * Save pkt_tgt_init_pkt fields if deferred binding | |
1946 * is needed or for other purposes. | |
1947 */ | |
1948 vpkt->vpkt_tgt_init_pkt_flags = flags; | |
1949 vpkt->vpkt_flags = (callback == NULL_FUNC) ? CFLAG_NOWAIT : 0; | |
1950 vpkt->vpkt_state = VHCI_PKT_IDLE; | |
1951 vpkt->vpkt_tgt_init_cdblen = cmdlen; | |
1952 vpkt->vpkt_tgt_init_scblen = statuslen; | |
1953 newpkt = 1; | |
1954 } else { /* pkt not NULL */ | |
1955 vpkt = pkt->pkt_ha_private; | |
1956 } | |
1957 | |
1958 VHCI_DEBUG(8, (CE_NOTE, NULL, "vhci_scsi_init_pkt " | |
1959 "vpkt %p flags %x\n", (void *)vpkt, flags)); | |
1960 | |
1961 /* Clear any stale error flags */ | |
1962 if (bp) { | |
1963 bioerror(bp, 0); | |
1964 } | |
1965 | |
1966 vpkt->vpkt_tgt_init_bp = bp; | |
1967 | |
1968 if (flags & PKT_DMA_PARTIAL) { | |
1969 | |
1970 /* | |
1971 * Immediate binding is needed. | |
1972 * Target driver may not set this flag in next invocation. | |
1973 * vhci has to remember this flag was set during first | |
1974 * invocation of vhci_scsi_init_pkt. | |
1975 */ | |
1976 vpkt->vpkt_flags |= CFLAG_DMA_PARTIAL; | |
1977 } | |
1978 | |
1979 if (vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) { | |
1980 | |
1981 /* | |
1982 * Re-initialize some of the target driver packet state | |
1983 * information. | |
1984 */ | |
1985 vpkt->vpkt_tgt_pkt->pkt_state = 0; | |
1986 vpkt->vpkt_tgt_pkt->pkt_statistics = 0; | |
1987 vpkt->vpkt_tgt_pkt->pkt_reason = 0; | |
1988 | |
1989 /* | |
1990 * Binding a vpkt->vpkt_path for this IO at init_time. | |
1991 * If an IO error happens later, target driver will clear | |
1992 * this vpkt->vpkt_path binding before re-init IO again. | |
1993 */ | |
1994 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
1995 "vhci_scsi_init_pkt: calling v_b_t %p, newpkt %d\n", | |
1996 (void *)vpkt, newpkt)); | |
1997 if (pkt && vpkt->vpkt_hba_pkt) { | |
1998 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
1999 "v_s_i_p calling update_pHCI_pkt resid %ld\n", | |
2000 pkt->pkt_resid)); | |
2001 vhci_update_pHCI_pkt(vpkt, pkt); | |
2002 } | |
2003 if (callback == SLEEP_FUNC) { | |
2004 rval = vhci_bind_transport( | |
2005 ap, vpkt, flags, callback); | |
2006 } else { | |
2007 rval = vhci_bind_transport( | |
2008 ap, vpkt, flags, NULL_FUNC); | |
2009 } | |
2010 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
2011 "vhci_scsi_init_pkt: v_b_t called 0x%p rval 0x%x\n", | |
2012 (void *)vpkt, rval)); | |
2013 if (bp) { | |
2014 if (rval == TRAN_FATAL_ERROR) { | |
2015 /* | |
2016 * No paths available. Could not bind | |
2017 * any pHCI. Setting EFAULT as a way | |
2018 * to indicate no DMA is mapped. | |
2019 */ | |
2020 bioerror(bp, EFAULT); | |
2021 } else { | |
2022 /* | |
2023 * Do not indicate any pHCI errors to | |
2024 * target driver otherwise. | |
2025 */ | |
2026 bioerror(bp, 0); | |
2027 } | |
2028 } | |
2029 if (rval != TRAN_ACCEPT) { | |
2030 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
2031 "vhci_scsi_init_pkt: " | |
2032 "v_b_t failed 0x%p newpkt %x\n", | |
2033 (void *)vpkt, newpkt)); | |
2034 if (newpkt) { | |
2035 scsi_hba_pkt_free(ap, | |
2036 vpkt->vpkt_tgt_pkt); | |
2037 } | |
2038 return (NULL); | |
2039 } | |
2040 ASSERT(vpkt->vpkt_hba_pkt != NULL); | |
2041 ASSERT(vpkt->vpkt_path != NULL); | |
2042 | |
2043 /* Update the resid for the target driver */ | |
2044 vpkt->vpkt_tgt_pkt->pkt_resid = | |
2045 vpkt->vpkt_hba_pkt->pkt_resid; | |
2046 } | |
2047 | |
2048 return (vpkt->vpkt_tgt_pkt); | |
2049 } | |
2050 | |
2051 /* | |
2052 * Function name : vhci_scsi_destroy_pkt | |
2053 * | |
2054 * Return Values : none | |
2055 */ | |
2056 static void | |
2057 vhci_scsi_destroy_pkt(struct scsi_address *ap, struct scsi_pkt *pkt) | |
2058 { | |
2059 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_ha_private; | |
2060 | |
2061 VHCI_DEBUG(8, (CE_NOTE, NULL, | |
2062 "vhci_scsi_destroy_pkt: vpkt 0x%p\n", (void *)vpkt)); | |
2063 | |
2064 vpkt->vpkt_tgt_init_pkt_flags = 0; | |
2065 if (vpkt->vpkt_hba_pkt) { | |
2066 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
2067 vpkt->vpkt_hba_pkt = NULL; | |
2068 } | |
2069 if (vpkt->vpkt_path) { | |
2070 mdi_rele_path(vpkt->vpkt_path); | |
2071 vpkt->vpkt_path = NULL; | |
2072 } | |
2073 | |
2074 ASSERT(vpkt->vpkt_state != VHCI_PKT_ISSUED); | |
2075 scsi_hba_pkt_free(ap, vpkt->vpkt_tgt_pkt); | |
2076 } | |
2077 | |
2078 /* | |
2079 * Function name : vhci_scsi_dmafree() | |
2080 * | |
2081 * Return Values : none | |
2082 */ | |
2083 /*ARGSUSED*/ | |
2084 static void | |
2085 vhci_scsi_dmafree(struct scsi_address *ap, struct scsi_pkt *pkt) | |
2086 { | |
2087 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_ha_private; | |
2088 | |
2089 VHCI_DEBUG(6, (CE_NOTE, NULL, | |
2090 "vhci_scsi_dmafree: vpkt 0x%p\n", (void *)vpkt)); | |
2091 | |
2092 ASSERT(vpkt != NULL); | |
2093 if (vpkt->vpkt_hba_pkt) { | |
2094 scsi_destroy_pkt(vpkt->vpkt_hba_pkt); | |
2095 vpkt->vpkt_hba_pkt = NULL; | |
2096 } | |
2097 if (vpkt->vpkt_path) { | |
2098 mdi_rele_path(vpkt->vpkt_path); | |
2099 vpkt->vpkt_path = NULL; | |
2100 } | |
2101 } | |
2102 | |
2103 /* | |
2104 * Function name : vhci_scsi_sync_pkt() | |
2105 * | |
2106 * Return Values : none | |
2107 */ | |
2108 /*ARGSUSED*/ | |
2109 static void | |
2110 vhci_scsi_sync_pkt(struct scsi_address *ap, struct scsi_pkt *pkt) | |
2111 { | |
2112 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_ha_private; | |
2113 | |
2114 ASSERT(vpkt != NULL); | |
2115 if (vpkt->vpkt_hba_pkt) { | |
2116 scsi_sync_pkt(vpkt->vpkt_hba_pkt); | |
2117 } | |
2118 } | |
2119 | |
2120 /* | |
2121 * routine for reset notification setup, to register or cancel. | |
2122 */ | |
2123 static int | |
2124 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
|
2125 void (*callback)(caddr_t), caddr_t arg) |
4851 | 2126 { |
2127 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
2128 return (scsi_hba_reset_notify_setup(ap, flag, callback, arg, | |
2129 &vhci->vhci_mutex, &vhci->vhci_reset_notify_listf)); | |
2130 } | |
2131 | |
2132 static int | |
2133 vhci_scsi_get_name_bus_addr(struct scsi_device *sd, | |
2134 char *name, int len, int bus_addr) | |
2135 { | |
2136 dev_info_t *cdip; | |
2137 char *guid; | |
2138 scsi_vhci_lun_t *vlun; | |
2139 | |
2140 ASSERT(sd != NULL); | |
2141 ASSERT(name != NULL); | |
2142 | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2143 *name = 0; |
4851 | 2144 cdip = sd->sd_dev; |
2145 | |
2146 ASSERT(cdip != NULL); | |
2147 | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2148 if (mdi_component_is_client(cdip, NULL) != MDI_SUCCESS) |
4851 | 2149 return (1); |
2150 | |
2151 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, cdip, PROPFLAGS, | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2152 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) |
4851 | 2153 return (1); |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2154 |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2155 /* |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2156 * Message is "sd# at scsi_vhci0: unit-address <guid>: <bus_addr>". |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2157 * <guid> bus_addr argument == 0 |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2158 * <bus_addr> bus_addr argument != 0 |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2159 * Since the <guid> is already provided with unit-address, we just |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2160 * provide failover module in <bus_addr> to keep output shorter. |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2161 */ |
4851 | 2162 vlun = ADDR2VLUN(&sd->sd_address); |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2163 if (bus_addr == 0) { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2164 /* report the guid: */ |
4851 | 2165 (void) snprintf(name, len, "g%s", guid); |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2166 } else if (vlun && vlun->svl_fops_name) { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2167 /* report the name of the failover module */ |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2168 (void) snprintf(name, len, "%s", vlun->svl_fops_name); |
4851 | 2169 } |
2170 | |
2171 ddi_prop_free(guid); | |
2172 return (1); | |
2173 } | |
2174 | |
2175 static int | |
2176 vhci_scsi_get_bus_addr(struct scsi_device *sd, char *name, int len) | |
2177 { | |
2178 return (vhci_scsi_get_name_bus_addr(sd, name, len, 1)); | |
2179 } | |
2180 | |
2181 static int | |
2182 vhci_scsi_get_name(struct scsi_device *sd, char *name, int len) | |
2183 { | |
2184 return (vhci_scsi_get_name_bus_addr(sd, name, len, 0)); | |
2185 } | |
2186 | |
2187 /* | |
2188 * Return a pointer to the guid part of the devnm. | |
2189 * devnm format is "nodename@busaddr", busaddr format is "gGUID". | |
2190 */ | |
2191 static char * | |
2192 vhci_devnm_to_guid(char *devnm) | |
2193 { | |
2194 char *cp = devnm; | |
2195 | |
2196 if (devnm == NULL) | |
2197 return (NULL); | |
2198 | |
2199 while (*cp != '\0' && *cp != '@') | |
2200 cp++; | |
2201 if (*cp == '@' && *(cp + 1) == 'g') | |
2202 return (cp + 2); | |
2203 return (NULL); | |
2204 } | |
2205 | |
2206 static int | |
2207 vhci_bind_transport(struct scsi_address *ap, struct vhci_pkt *vpkt, int flags, | |
2208 int (*func)(caddr_t)) | |
2209 { | |
2210 struct scsi_vhci *vhci = ADDR2VHCI(ap); | |
2211 dev_info_t *cdip = ADDR2DIP(ap); | |
2212 mdi_pathinfo_t *pip = NULL; | |
2213 mdi_pathinfo_t *npip = NULL; | |
2214 scsi_vhci_priv_t *svp = NULL; | |
2215 struct scsi_device *psd = NULL; | |
2216 struct scsi_address *address = NULL; | |
2217 struct scsi_pkt *pkt = NULL; | |
2218 int rval = -1; | |
2219 int pgr_sema_held = 0; | |
2220 int held; | |
2221 int mps_flag = MDI_SELECT_ONLINE_PATH; | |
2222 struct scsi_vhci_lun *vlun; | |
2223 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
|
2224 int path_instance = 0; |
4851 | 2225 |
2226 vlun = ADDR2VLUN(ap); | |
2227 ASSERT(vlun != 0); | |
2228 | |
2229 if ((vpkt->vpkt_tgt_pkt->pkt_cdbp[0] == SCMD_PROUT) && | |
2230 (((vpkt->vpkt_tgt_pkt->pkt_cdbp[1] & 0x1f) == | |
2231 VHCI_PROUT_REGISTER) || | |
2232 ((vpkt->vpkt_tgt_pkt->pkt_cdbp[1] & 0x1f) == | |
2233 VHCI_PROUT_R_AND_IGNORE))) { | |
2234 if (!sema_tryp(&vlun->svl_pgr_sema)) | |
2235 return (TRAN_BUSY); | |
2236 pgr_sema_held = 1; | |
2237 if (vlun->svl_first_path != NULL) { | |
2238 rval = mdi_select_path(cdip, NULL, | |
2239 MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH, | |
2240 NULL, &pip); | |
2241 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
2242 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2243 "vhci_bind_transport: path select fail\n")); | |
2244 } else { | |
2245 npip = pip; | |
2246 do { | |
2247 if (npip == vlun->svl_first_path) { | |
2248 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2249 "vhci_bind_transport: " | |
2250 "valid first path 0x%p\n", | |
2251 (void *) | |
2252 vlun->svl_first_path)); | |
2253 pip = vlun->svl_first_path; | |
2254 goto bind_path; | |
2255 } | |
2256 pip = npip; | |
2257 rval = mdi_select_path(cdip, NULL, | |
2258 MDI_SELECT_ONLINE_PATH | | |
2259 MDI_SELECT_STANDBY_PATH, | |
2260 pip, &npip); | |
2261 mdi_rele_path(pip); | |
2262 } while ((rval == MDI_SUCCESS) && | |
2263 (npip != NULL)); | |
2264 } | |
2265 } | |
2266 | |
2267 if (vlun->svl_first_path) { | |
2268 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2269 "vhci_bind_transport: invalid first path 0x%p\n", | |
2270 (void *)vlun->svl_first_path)); | |
2271 vlun->svl_first_path = NULL; | |
2272 } | |
2273 } else if (vpkt->vpkt_tgt_pkt->pkt_cdbp[0] == SCMD_PRIN) { | |
2274 if ((vpkt->vpkt_state & VHCI_PKT_THRU_TASKQ) == 0) { | |
2275 if (!sema_tryp(&vlun->svl_pgr_sema)) | |
2276 return (TRAN_BUSY); | |
2277 } | |
2278 pgr_sema_held = 1; | |
2279 } | |
2280 | |
2281 /* | |
2282 * If the path is already bound for PKT_PARTIAL_DMA case, | |
2283 * try to use the same path. | |
2284 */ | |
2285 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) && vpkt->vpkt_path) { | |
2286 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2287 "vhci_bind_transport: PKT_PARTIAL_DMA " | |
2288 "vpkt 0x%p, path 0x%p\n", | |
2289 (void *)vpkt, (void *)vpkt->vpkt_path)); | |
2290 pip = vpkt->vpkt_path; | |
2291 goto bind_path; | |
2292 } | |
2293 | |
2294 /* | |
7047
8e4f1d0e9dd8
6722672 sd does not clear pkt_path_instance when retrying commands
gap
parents:
6962
diff
changeset
|
2295 * 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
|
2296 * 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
|
2297 * specific instance. |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2298 * |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2299 * 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
|
2300 */ |
7121
4b91990abccd
6723122 assertion failed: (path_instance == 0) || (path_instance == mdi_pi_get_path_instance(vpkt->vpkt_path
rralphs
parents:
7047
diff
changeset
|
2301 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
|
2302 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
|
2303 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
|
2304 } |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2305 |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2306 /* |
4851 | 2307 * If reservation is active bind the transport directly to the pip |
2308 * with the reservation. | |
2309 */ | |
2310 if (vpkt->vpkt_hba_pkt == NULL) { | |
2311 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
2312 if (MDI_PI_IS_ONLINE(vlun->svl_resrv_pip)) { | |
2313 pip = vlun->svl_resrv_pip; | |
2314 mdi_hold_path(pip); | |
2315 vlun->svl_waiting_for_activepath = 0; | |
2316 rval = MDI_SUCCESS; | |
2317 goto bind_path; | |
2318 } else { | |
2319 if (pgr_sema_held) { | |
2320 sema_v(&vlun->svl_pgr_sema); | |
2321 } | |
2322 return (TRAN_BUSY); | |
2323 } | |
2324 } | |
2325 try_again: | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2326 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
|
2327 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
|
2328 (void *)(intptr_t)path_instance, &pip); |
4851 | 2329 if (rval == MDI_BUSY) { |
2330 if (pgr_sema_held) { | |
2331 sema_v(&vlun->svl_pgr_sema); | |
2332 } | |
2333 return (TRAN_BUSY); | |
2334 } else if (rval == MDI_DEVI_ONLINING) { | |
2335 /* | |
2336 * if we are here then we are in the midst of | |
2337 * an attach/probe of the client device. | |
2338 * We attempt to bind to ONLINE path if available, | |
2339 * else it is OK to bind to a STANDBY path (instead | |
2340 * of triggering a failover) because IO associated | |
2341 * with attach/probe (eg. INQUIRY, block 0 read) | |
2342 * are completed by targets even on passive paths | |
2343 * If no ONLINE paths available, it is important | |
2344 * to set svl_waiting_for_activepath for two | |
2345 * reasons: (1) avoid sense analysis in the | |
2346 * "external failure detection" codepath in | |
2347 * vhci_intr(). Failure to do so will result in | |
2348 * infinite loop (unless an ONLINE path becomes | |
2349 * available at some point) (2) avoid | |
2350 * unnecessary failover (see "---Waiting For Active | |
2351 * Path---" comment below). | |
2352 */ | |
2353 VHCI_DEBUG(1, (CE_NOTE, NULL, "!%p in onlining " | |
2354 "state\n", (void *)cdip)); | |
2355 pip = NULL; | |
2356 rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp, | |
2357 mps_flag, NULL, &pip); | |
2358 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
2359 if (vlun->svl_waiting_for_activepath == 0) { | |
2360 vlun->svl_waiting_for_activepath = 1; | |
2361 vlun->svl_wfa_time = ddi_get_time(); | |
2362 } | |
2363 mps_flag |= MDI_SELECT_STANDBY_PATH; | |
2364 rval = mdi_select_path(cdip, | |
2365 vpkt->vpkt_tgt_init_bp, | |
2366 mps_flag, NULL, &pip); | |
2367 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
2368 if (pgr_sema_held) { | |
2369 sema_v(&vlun->svl_pgr_sema); | |
2370 } | |
2371 return (TRAN_FATAL_ERROR); | |
2372 } | |
2373 goto bind_path; | |
2374 } | |
10967
0f20d1dba80d
6886050 scsav3: scsi_hba_pkt_comp should detect double completions of same packet
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
10696
diff
changeset
|
2375 } else if ((rval == MDI_FAILURE) || |
0f20d1dba80d
6886050 scsav3: scsi_hba_pkt_comp should detect double completions of same packet
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
10696
diff
changeset
|
2376 ((rval == MDI_NOPATH) && (path_instance))) { |
4851 | 2377 if (pgr_sema_held) { |
2378 sema_v(&vlun->svl_pgr_sema); | |
2379 } | |
2380 return (TRAN_FATAL_ERROR); | |
2381 } | |
2382 | |
2383 if ((pip == NULL) || (rval == MDI_NOPATH)) { | |
2384 while (vlun->svl_waiting_for_activepath) { | |
2385 /* | |
2386 * ---Waiting For Active Path--- | |
2387 * This device was discovered across a | |
2388 * passive path; lets wait for a little | |
2389 * bit, hopefully an active path will | |
2390 * show up obviating the need for a | |
2391 * failover | |
2392 */ | |
2393 tnow = ddi_get_time(); | |
2394 if (tnow - vlun->svl_wfa_time >= 60) { | |
2395 vlun->svl_waiting_for_activepath = 0; | |
2396 } else { | |
2397 drv_usecwait(1000); | |
2398 if (vlun->svl_waiting_for_activepath | |
2399 == 0) { | |
2400 /* | |
2401 * an active path has come | |
2402 * online! | |
2403 */ | |
2404 goto try_again; | |
2405 } | |
2406 } | |
2407 } | |
2408 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
2409 if (!held) { | |
2410 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2411 "!Lun not held\n")); | |
2412 if (pgr_sema_held) { | |
2413 sema_v(&vlun->svl_pgr_sema); | |
2414 } | |
2415 return (TRAN_BUSY); | |
2416 } | |
2417 /* | |
2418 * now that the LUN is stable, one last check | |
2419 * to make sure no other changes sneaked in | |
2420 * (like a path coming online or a | |
2421 * failover initiated by another thread) | |
2422 */ | |
2423 pip = NULL; | |
2424 rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp, | |
2425 0, NULL, &pip); | |
2426 if (pip != NULL) { | |
2427 VHCI_RELEASE_LUN(vlun); | |
2428 vlun->svl_waiting_for_activepath = 0; | |
2429 goto bind_path; | |
2430 } | |
2431 | |
2432 /* | |
2433 * Check if there is an ONLINE path OR a STANDBY path | |
2434 * available. If none is available, do not attempt | |
2435 * to do a failover, just return a fatal error at this | |
2436 * point. | |
2437 */ | |
2438 npip = NULL; | |
2439 rval = mdi_select_path(cdip, NULL, | |
2440 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), | |
2441 NULL, &npip); | |
2442 if ((npip == NULL) || (rval != MDI_SUCCESS)) { | |
2443 /* | |
2444 * No paths available, jus return FATAL error. | |
2445 */ | |
2446 VHCI_RELEASE_LUN(vlun); | |
2447 if (pgr_sema_held) { | |
2448 sema_v(&vlun->svl_pgr_sema); | |
2449 } | |
2450 return (TRAN_FATAL_ERROR); | |
2451 } | |
2452 mdi_rele_path(npip); | |
12310
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2453 if (!(vpkt->vpkt_state & VHCI_PKT_IN_FAILOVER)) { |
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2454 VHCI_DEBUG(1, (CE_NOTE, NULL, "!invoking " |
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2455 "mdi_failover\n")); |
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2456 rval = mdi_failover(vhci->vhci_dip, cdip, |
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2457 MDI_FAILOVER_ASYNC); |
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2458 } else { |
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2459 rval = vlun->svl_failover_status; |
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2460 } |
4851 | 2461 if (rval == MDI_FAILURE) { |
2462 VHCI_RELEASE_LUN(vlun); | |
2463 if (pgr_sema_held) { | |
2464 sema_v(&vlun->svl_pgr_sema); | |
2465 } | |
2466 return (TRAN_FATAL_ERROR); | |
2467 } else if (rval == MDI_BUSY) { | |
2468 VHCI_RELEASE_LUN(vlun); | |
2469 if (pgr_sema_held) { | |
2470 sema_v(&vlun->svl_pgr_sema); | |
2471 } | |
2472 return (TRAN_BUSY); | |
2473 } else { | |
2474 if (pgr_sema_held) { | |
2475 sema_v(&vlun->svl_pgr_sema); | |
2476 } | |
12310
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
2477 vpkt->vpkt_state |= VHCI_PKT_IN_FAILOVER; |
4851 | 2478 return (TRAN_BUSY); |
2479 } | |
2480 } | |
2481 vlun->svl_waiting_for_activepath = 0; | |
2482 bind_path: | |
2483 vpkt->vpkt_path = pip; | |
2484 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
2485 ASSERT(svp != NULL); | |
2486 | |
2487 psd = svp->svp_psd; | |
2488 ASSERT(psd != NULL); | |
2489 address = &psd->sd_address; | |
2490 } else { | |
2491 pkt = vpkt->vpkt_hba_pkt; | |
2492 address = &pkt->pkt_address; | |
2493 } | |
2494 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2495 /* 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
|
2496 ASSERT((path_instance == 0) || |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
2497 (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
|
2498 |
4851 | 2499 /* |
2500 * For PKT_PARTIAL_DMA case, call pHCI's scsi_init_pkt whenever | |
2501 * target driver calls vhci_scsi_init_pkt. | |
2502 */ | |
2503 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) && | |
2504 vpkt->vpkt_path && vpkt->vpkt_hba_pkt) { | |
2505 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2506 "vhci_bind_transport: PKT_PARTIAL_DMA " | |
2507 "vpkt 0x%p, path 0x%p hba_pkt 0x%p\n", | |
2508 (void *)vpkt, (void *)vpkt->vpkt_path, (void *)pkt)); | |
2509 pkt = vpkt->vpkt_hba_pkt; | |
2510 address = &pkt->pkt_address; | |
2511 } | |
2512 | |
2513 if (pkt == NULL || (vpkt->vpkt_flags & CFLAG_DMA_PARTIAL)) { | |
2514 pkt = scsi_init_pkt(address, pkt, | |
2515 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
|
2516 vpkt->vpkt_tgt_init_scblen, 0, flags, func, NULL); |
4851 | 2517 |
2518 if (pkt == NULL) { | |
2519 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2520 "!bind transport: 0x%p 0x%p 0x%p\n", | |
2521 (void *)vhci, (void *)psd, (void *)vpkt)); | |
2522 if ((vpkt->vpkt_hba_pkt == NULL) && vpkt->vpkt_path) { | |
2523 MDI_PI_ERRSTAT(vpkt->vpkt_path, | |
2524 MDI_PI_TRANSERR); | |
2525 mdi_rele_path(vpkt->vpkt_path); | |
2526 vpkt->vpkt_path = NULL; | |
2527 } | |
2528 if (pgr_sema_held) { | |
2529 sema_v(&vlun->svl_pgr_sema); | |
2530 } | |
2531 /* | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2532 * Consider it a fatal error if b_error is |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2533 * set as a result of DMA binding failure |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2534 * vs. a condition of being temporarily out of |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2535 * some resource |
4851 | 2536 */ |
11086
77c085f864d5
6892828 vhci panic while running fcinfo hba-port in initiator while testing COMSTAR FCoE testsuite
Victor Li <Victor.Li@Sun.COM>
parents:
11066
diff
changeset
|
2537 if (vpkt->vpkt_tgt_init_bp == NULL || |
77c085f864d5
6892828 vhci panic while running fcinfo hba-port in initiator while testing COMSTAR FCoE testsuite
Victor Li <Victor.Li@Sun.COM>
parents:
11066
diff
changeset
|
2538 geterror(vpkt->vpkt_tgt_init_bp)) |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2539 return (TRAN_FATAL_ERROR); |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2540 else |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
2541 return (TRAN_BUSY); |
4851 | 2542 } |
2543 } | |
2544 | |
2545 pkt->pkt_private = vpkt; | |
2546 vpkt->vpkt_hba_pkt = pkt; | |
2547 return (TRAN_ACCEPT); | |
2548 } | |
2549 | |
2550 | |
2551 /*PRINTFLIKE3*/ | |
2552 void | |
2553 vhci_log(int level, dev_info_t *dip, const char *fmt, ...) | |
2554 { | |
2555 char buf[256]; | |
2556 va_list ap; | |
2557 | |
2558 va_start(ap, fmt); | |
2559 (void) vsprintf(buf, fmt, ap); | |
2560 va_end(ap); | |
2561 | |
2562 scsi_log(dip, "scsi_vhci", level, buf); | |
2563 } | |
2564 | |
2565 /* do a PGR out with the information we've saved away */ | |
2566 static int | |
2567 vhci_do_prout(scsi_vhci_priv_t *svp) | |
2568 { | |
2569 | |
2570 struct scsi_pkt *new_pkt; | |
2571 struct buf *bp; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2572 scsi_vhci_lun_t *vlun = svp->svp_svl; |
4851 | 2573 int rval, retry, nr_retry, ua_retry; |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
2574 uint8_t *sns, skey; |
4851 | 2575 |
2576 bp = getrbuf(KM_SLEEP); | |
2577 bp->b_flags = B_WRITE; | |
2578 bp->b_resid = 0; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2579 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
|
2580 bp->b_bcount = vlun->svl_bcount; |
4851 | 2581 |
2582 VHCI_INCR_PATH_CMDCOUNT(svp); | |
2583 | |
2584 new_pkt = scsi_init_pkt(&svp->svp_psd->sd_address, NULL, bp, | |
2585 CDB_GROUP1, sizeof (struct scsi_arq_status), 0, 0, | |
2586 SLEEP_FUNC, NULL); | |
2587 if (new_pkt == NULL) { | |
2588 VHCI_DECR_PATH_CMDCOUNT(svp); | |
2589 freerbuf(bp); | |
2590 cmn_err(CE_WARN, "!vhci_do_prout: scsi_init_pkt failed"); | |
2591 return (0); | |
2592 } | |
2593 mutex_enter(&vlun->svl_mutex); | |
2594 bp->b_un.b_addr = (caddr_t)&vlun->svl_prout; | |
2595 bp->b_bcount = vlun->svl_bcount; | |
2596 bcopy(vlun->svl_cdb, new_pkt->pkt_cdbp, | |
2597 sizeof (vlun->svl_cdb)); | |
2598 new_pkt->pkt_time = vlun->svl_time; | |
2599 mutex_exit(&vlun->svl_mutex); | |
2600 new_pkt->pkt_flags = FLAG_NOINTR; | |
2601 | |
2602 ua_retry = nr_retry = retry = 0; | |
2603 again: | |
2604 rval = vhci_do_scsi_cmd(new_pkt); | |
2605 if (rval != 1) { | |
2606 if ((new_pkt->pkt_reason == CMD_CMPLT) && | |
2607 (SCBP_C(new_pkt) == STATUS_CHECK) && | |
2608 (new_pkt->pkt_state & STATE_ARQ_DONE)) { | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
2609 sns = (uint8_t *) |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
2610 &(((struct scsi_arq_status *)(uintptr_t) |
4851 | 2611 (new_pkt->pkt_scbp))->sts_sensedata); |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
2612 skey = scsi_sense_key(sns); |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
2613 if ((skey == KEY_UNIT_ATTENTION) || |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
2614 (skey == KEY_NOT_READY)) { |
4851 | 2615 int max_retry; |
2616 struct scsi_failover_ops *fops; | |
2617 fops = vlun->svl_fops; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2618 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
|
2619 sns, vlun->svl_fops_ctpriv); |
4851 | 2620 if (rval == SCSI_SENSE_NOT_READY) { |
2621 max_retry = vhci_prout_not_ready_retry; | |
2622 retry = nr_retry++; | |
2623 delay(1*drv_usectohz(1000000)); | |
2624 } else { | |
2625 /* chk for state change and update */ | |
2626 if (rval == SCSI_SENSE_STATE_CHANGED) { | |
2627 int held; | |
2628 VHCI_HOLD_LUN(vlun, | |
2629 VH_NOSLEEP, held); | |
2630 if (!held) { | |
2631 rval = TRAN_BUSY; | |
2632 } else { | |
2633 /* chk for alua first */ | |
2634 vhci_update_pathstates( | |
2635 (void *)vlun); | |
2636 } | |
2637 } | |
2638 retry = ua_retry++; | |
2639 max_retry = VHCI_MAX_PGR_RETRIES; | |
2640 } | |
2641 if (retry < max_retry) { | |
2642 VHCI_DEBUG(4, (CE_WARN, NULL, | |
2643 "!vhci_do_prout retry 0x%x " | |
2644 "(0x%x 0x%x 0x%x)", | |
2645 SCBP_C(new_pkt), | |
2646 new_pkt->pkt_cdbp[0], | |
2647 new_pkt->pkt_cdbp[1], | |
2648 new_pkt->pkt_cdbp[2])); | |
2649 goto again; | |
2650 } | |
2651 rval = 0; | |
2652 VHCI_DEBUG(4, (CE_WARN, NULL, | |
2653 "!vhci_do_prout 0x%x " | |
2654 "(0x%x 0x%x 0x%x)", | |
2655 SCBP_C(new_pkt), | |
2656 new_pkt->pkt_cdbp[0], | |
2657 new_pkt->pkt_cdbp[1], | |
2658 new_pkt->pkt_cdbp[2])); | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
2659 } else if (skey == KEY_ILLEGAL_REQUEST) |
4851 | 2660 rval = VHCI_PGR_ILLEGALOP; |
2661 } | |
2662 } else { | |
2663 rval = 1; | |
2664 } | |
2665 scsi_destroy_pkt(new_pkt); | |
2666 VHCI_DECR_PATH_CMDCOUNT(svp); | |
2667 freerbuf(bp); | |
2668 return (rval); | |
2669 } | |
2670 | |
2671 static void | |
2672 vhci_run_cmd(void *arg) | |
2673 { | |
2674 struct scsi_pkt *pkt = (struct scsi_pkt *)arg; | |
2675 struct scsi_pkt *tpkt; | |
2676 scsi_vhci_priv_t *svp; | |
2677 mdi_pathinfo_t *pip, *npip; | |
2678 scsi_vhci_lun_t *vlun; | |
2679 dev_info_t *cdip; | |
2680 scsi_vhci_priv_t *nsvp; | |
2681 int fail = 0; | |
2682 int rval; | |
2683 struct vhci_pkt *vpkt; | |
2684 uchar_t cdb_1; | |
2685 vhci_prout_t *prout; | |
2686 | |
2687 vpkt = (struct vhci_pkt *)pkt->pkt_private; | |
2688 tpkt = vpkt->vpkt_tgt_pkt; | |
2689 pip = vpkt->vpkt_path; | |
2690 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
2691 if (svp == NULL) { | |
2692 tpkt->pkt_reason = CMD_TRAN_ERR; | |
2693 tpkt->pkt_statistics = STAT_ABORTED; | |
2694 goto done; | |
2695 } | |
2696 vlun = svp->svp_svl; | |
2697 prout = &vlun->svl_prout; | |
2698 if (SCBP_C(pkt) != STATUS_GOOD) | |
2699 fail++; | |
2700 cdip = vlun->svl_dip; | |
2701 pip = npip = NULL; | |
2702 rval = mdi_select_path(cdip, NULL, | |
2703 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, NULL, &npip); | |
2704 if ((rval != MDI_SUCCESS) || (npip == NULL)) { | |
2705 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2706 "vhci_run_cmd: no path! 0x%p\n", (void *)svp)); | |
2707 tpkt->pkt_reason = CMD_TRAN_ERR; | |
2708 tpkt->pkt_statistics = STAT_ABORTED; | |
2709 goto done; | |
2710 } | |
2711 | |
2712 cdb_1 = vlun->svl_cdb[1]; | |
2713 vlun->svl_cdb[1] &= 0xe0; | |
2714 vlun->svl_cdb[1] |= VHCI_PROUT_R_AND_IGNORE; | |
2715 | |
2716 do { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2717 nsvp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(npip); |
4851 | 2718 if (nsvp == NULL) { |
2719 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
2720 "vhci_run_cmd: no " | |
2721 "client priv! 0x%p offlined?\n", | |
2722 (void *)npip)); | |
2723 goto next_path; | |
2724 } | |
2725 if (vlun->svl_first_path == npip) { | |
2726 goto next_path; | |
2727 } else { | |
2728 if (vhci_do_prout(nsvp) != 1) | |
2729 fail++; | |
2730 } | |
2731 next_path: | |
2732 pip = npip; | |
2733 rval = mdi_select_path(cdip, NULL, | |
2734 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, | |
2735 pip, &npip); | |
2736 mdi_rele_path(pip); | |
2737 } while ((rval == MDI_SUCCESS) && (npip != NULL)); | |
2738 | |
2739 vlun->svl_cdb[1] = cdb_1; | |
2740 | |
2741 if (fail) { | |
2742 VHCI_DEBUG(4, (CE_WARN, NULL, "%s%d: key registration failed, " | |
2743 "couldn't be replicated on all paths", | |
2744 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
2745 vhci_print_prout_keys(vlun, "vhci_run_cmd: "); | |
2746 | |
2747 if (SCBP_C(pkt) != STATUS_GOOD) { | |
2748 tpkt->pkt_reason = CMD_TRAN_ERR; | |
2749 tpkt->pkt_statistics = STAT_ABORTED; | |
2750 } | |
2751 } else { | |
2752 vlun->svl_pgr_active = 1; | |
2753 vhci_print_prout_keys(vlun, "vhci_run_cmd: before bcopy:"); | |
2754 | |
2755 bcopy((const void *)prout->service_key, | |
2756 (void *)prout->active_service_key, MHIOC_RESV_KEY_SIZE); | |
2757 bcopy((const void *)prout->res_key, | |
2758 (void *)prout->active_res_key, MHIOC_RESV_KEY_SIZE); | |
2759 | |
2760 vhci_print_prout_keys(vlun, "vhci_run_cmd: after bcopy:"); | |
2761 } | |
2762 done: | |
2763 if (SCBP_C(pkt) == STATUS_GOOD) | |
2764 vlun->svl_first_path = NULL; | |
2765 | |
2766 if (svp) | |
2767 VHCI_DECR_PATH_CMDCOUNT(svp); | |
2768 | |
2769 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
2770 scsi_destroy_pkt(pkt); | |
2771 vpkt->vpkt_hba_pkt = NULL; | |
2772 if (vpkt->vpkt_path) { | |
2773 mdi_rele_path(vpkt->vpkt_path); | |
2774 vpkt->vpkt_path = NULL; | |
2775 } | |
2776 } | |
2777 | |
2778 sema_v(&vlun->svl_pgr_sema); | |
2779 /* | |
2780 * The PROUT commands are not included in the automatic retry | |
2781 * mechanism, therefore, vpkt_org_vpkt should never be set here. | |
2782 */ | |
2783 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
|
2784 scsi_hba_pkt_comp(tpkt); |
4851 | 2785 } |
2786 | |
2787 /* | |
2788 * Get the keys registered with this target. Since we will have | |
2789 * registered the same key with multiple initiators, strip out | |
2790 * any duplicate keys. | |
2791 * | |
2792 * The pointers which will be used to filter the registered keys from | |
2793 * the device will be stored in filter_prin and filter_pkt. If the | |
2794 * allocation length of the buffer was sufficient for the number of | |
2795 * parameter data bytes available to be returned by the device then the | |
2796 * key filtering will use the keylist returned from the original | |
2797 * request. If the allocation length of the buffer was not sufficient, | |
2798 * then the filtering will use the keylist returned from the request | |
2799 * that is resent below. | |
2800 * | |
2801 * If the device returns an additional length field that is greater than | |
2802 * the allocation length of the buffer, then allocate a new buffer which | |
2803 * can accommodate the number of parameter data bytes available to be | |
2804 * returned. Resend the scsi PRIN command, filter out the duplicate | |
2805 * keys and return as many of the unique keys found that was originally | |
2806 * requested and set the additional length field equal to the data bytes | |
2807 * of unique reservation keys available to be returned. | |
2808 * | |
2809 * If the device returns an additional length field that is less than or | |
2810 * equal to the allocation length of the buffer, then all the available | |
2811 * keys registered were returned by the device. Filter out the | |
2812 * duplicate keys and return all of the unique keys found and set the | |
2813 * additional length field equal to the data bytes of the reservation | |
2814 * keys to be returned. | |
2815 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2816 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2817 #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
|
2818 |
4851 | 2819 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
|
2820 vhci_do_prin(struct vhci_pkt **intr_vpkt) |
4851 | 2821 { |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2822 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
|
2823 struct vhci_pkt *vpkt = *intr_vpkt; |
4851 | 2824 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
|
2825 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
|
2826 struct scsi_vhci *vhci = ADDR2VHCI(&vpkt->vpkt_tgt_pkt->pkt_address); |
4851 | 2827 |
2828 struct buf *new_bp = NULL; | |
2829 struct scsi_pkt *new_pkt = NULL; | |
2830 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
|
2831 uint32_t needed_length; |
4851 | 2832 int rval = VHCI_CMD_CMPLT; |
2833 uint32_t prin_length = 0; | |
2834 uint32_t svl_prin_length = 0; | |
2835 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2836 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
|
2837 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
|
2838 ASSERT(svp); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2839 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
|
2840 ASSERT(vlun); |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2841 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2842 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2843 * 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
|
2844 * 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
|
2845 * 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
|
2846 * 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
|
2847 * of efforts. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2848 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2849 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
|
2850 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
|
2851 goto exit; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2852 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2853 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2854 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
|
2855 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2856 * 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
|
2857 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2858 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
|
2859 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
|
2860 } else { |
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 * 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
|
2863 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2864 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
|
2865 vpkt->vpkt_tgt_init_bp->b_un.b_daddr; |
4851 | 2866 } |
2867 | |
2868 if (prin == NULL) { | |
2869 VHCI_DEBUG(5, (CE_WARN, NULL, | |
2870 "vhci_do_prin: bp_mapin_common failed.")); | |
2871 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
|
2872 goto fail; |
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 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2875 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
|
2876 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2877 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2878 * 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
|
2879 * 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
|
2880 * 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
|
2881 * 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
|
2882 * 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
|
2883 * 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
|
2884 * 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
|
2885 * 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
|
2886 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2887 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2888 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2889 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
|
2890 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
|
2891 "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
|
2892 "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
|
2893 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
|
2894 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2895 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2896 needed_length = prin_length + VHCI_PRIN_HEADER_SZ; |
4851 | 2897 |
2898 /* | |
2899 * If prin->length is greater than the byte count allocated in the | |
2900 * original buffer, then resend the request with enough buffer | |
2901 * allocated to get all of the available registered keys. | |
2902 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2903 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
|
2904 (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
|
2905 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2906 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
|
2907 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
|
2908 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
|
2909 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2910 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2911 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
|
2912 |
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 * 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
|
2915 * 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
|
2916 * 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
|
2917 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2918 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
|
2919 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
|
2920 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
|
2921 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
|
2922 scsi_free_consistent_buf(new_bp); |
4851 | 2923 } |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2924 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
|
2925 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
|
2926 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2927 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2928 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
|
2929 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
|
2930 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
|
2931 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2932 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
|
2933 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2934 new_vpkt->vpkt_tgt_init_bp = new_bp; |
4851 | 2935 } |
2936 | |
2937 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
|
2938 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2939 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2940 * 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
|
2941 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2942 mdi_pathinfo_t *path_holder = vpkt->vpkt_path; |
4851 | 2943 |
2944 /* | |
2945 * Release the old path because it does not matter which path | |
2946 * this command is sent down. This allows the normal bind | |
2947 * transport mechanism to be used. | |
2948 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2949 if (vpkt->vpkt_path != NULL) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2950 mdi_rele_path(vpkt->vpkt_path); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
2951 vpkt->vpkt_path = NULL; |
4851 | 2952 } |
2953 | |
2954 /* | |
2955 * Dispatch the retry command | |
2956 */ | |
2957 if (taskq_dispatch(vhci->vhci_taskq, vhci_dispatch_scsi_start, | |
2958 (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
|
2959 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
|
2960 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
|
2961 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
|
2962 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2963 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
|
2964 vhci_scsi_destroy_pkt(&new_pkt->pkt_address, new_pkt); |
4851 | 2965 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
|
2966 goto fail; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2967 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2968 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2969 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2970 * 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
|
2971 * 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
|
2972 * 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
|
2973 * 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
|
2974 * 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
|
2975 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2976 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
|
2977 goto exit; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2978 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2979 } |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2980 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2981 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
|
2982 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2983 * 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
|
2984 * packet returns. |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2985 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2986 int new; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2987 int old; |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
2988 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
|
2989 |
4851 | 2990 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
|
2991 num_keys)); |
4851 | 2992 |
2993 #ifdef DEBUG | |
2994 VHCI_DEBUG(5, (CE_NOTE, NULL, "vhci_do_prin: from storage\n")); | |
2995 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
|
2996 vhci_print_prin_keys(prin, num_keys); |
4851 | 2997 VHCI_DEBUG(5, (CE_NOTE, NULL, |
2998 "vhci_do_prin: MPxIO old keys:\n")); | |
2999 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
|
3000 vhci_print_prin_keys(&vlun->svl_prin, num_keys); |
4851 | 3001 #endif |
3002 | |
3003 /* | |
3004 * Filter out all duplicate keys returned from the device | |
3005 * We know that we use a different key for every host, so we | |
3006 * can simply strip out duplicates. Otherwise we would need to | |
3007 * do more bookkeeping to figure out which keys to strip out. | |
3008 */ | |
3009 | |
3010 new = 0; | |
3011 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3012 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3013 * 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
|
3014 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3015 if (num_keys > 0) { |
4851 | 3016 vlun->svl_prin.keylist[0] = prin->keylist[0]; |
3017 new++; | |
3018 } | |
3019 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3020 /* |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3021 * 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
|
3022 */ |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3023 for (old = 1; old < num_keys; old++) { |
4851 | 3024 int j; |
3025 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
|
3026 |
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3027 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
|
3028 break; |
4851 | 3029 for (j = 0; j < new; j++) { |
3030 if (bcmp(&prin->keylist[old], | |
3031 &vlun->svl_prin.keylist[j], | |
3032 sizeof (mhioc_resv_key_t)) == 0) { | |
3033 match = 1; | |
3034 break; | |
3035 } | |
3036 } | |
3037 if (!match) { | |
3038 vlun->svl_prin.keylist[new] = | |
3039 prin->keylist[old]; | |
3040 new++; | |
3041 } | |
3042 } | |
3043 | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3044 /* Stored Big Endian */ |
4851 | 3045 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
|
3046 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
|
3047 /* Stored Big Endian */ |
4851 | 3048 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
|
3049 svl_prin_length += VHCI_PRIN_HEADER_SZ; |
4851 | 3050 |
3051 /* | |
3052 * If we arrived at this point after issuing a retry, make sure | |
3053 * that we put everything back the way it originally was so | |
3054 * that the target driver can complete the command correctly. | |
3055 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3056 if (vpkt->vpkt_org_vpkt != NULL) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3057 new_bp = vpkt->vpkt_tgt_init_bp; |
4851 | 3058 |
3059 scsi_free_consistent_buf(new_bp); | |
3060 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3061 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
|
3062 *intr_vpkt = vpkt; |
4851 | 3063 |
3064 /* | |
3065 * Make sure the original buffer is mapped into kernel | |
3066 * space before we try to copy the filtered keys into | |
3067 * it. | |
3068 */ | |
3069 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
|
3070 vpkt->vpkt_tgt_init_bp, VM_NOSLEEP); |
4851 | 3071 } |
3072 | |
3073 /* | |
3074 * Now copy the desired number of prin keys into the original | |
3075 * target buffer. | |
3076 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3077 if (svl_prin_length <= vpkt->vpkt_tgt_init_bp->b_bcount) { |
4851 | 3078 /* |
3079 * It is safe to return all of the available unique | |
3080 * keys | |
3081 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3082 bcopy(&vlun->svl_prin, prin, svl_prin_length); |
4851 | 3083 } else { |
3084 /* | |
3085 * Not all of the available keys were requested by the | |
3086 * original command. | |
3087 */ | |
3088 bcopy(&vlun->svl_prin, prin, | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3089 vpkt->vpkt_tgt_init_bp->b_bcount); |
4851 | 3090 } |
3091 #ifdef DEBUG | |
3092 VHCI_DEBUG(5, (CE_NOTE, NULL, | |
3093 "vhci_do_prin: To Application:\n")); | |
3094 if (vhci_debug == 5) | |
3095 vhci_print_prin_keys(prin, new); | |
3096 VHCI_DEBUG(5, (CE_NOTE, NULL, | |
3097 "vhci_do_prin: MPxIO new keys:\n")); | |
3098 if (vhci_debug == 5) | |
3099 vhci_print_prin_keys(&vlun->svl_prin, new); | |
3100 #endif | |
3101 } | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3102 fail: |
4851 | 3103 if (rval == VHCI_CMD_ERROR) { |
3104 /* | |
3105 * If we arrived at this point after issuing a | |
3106 * retry, make sure that we put everything back | |
3107 * the way it originally was so that ssd can | |
3108 * complete the command correctly. | |
3109 */ | |
3110 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3111 if (vpkt->vpkt_org_vpkt != NULL) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3112 new_bp = vpkt->vpkt_tgt_init_bp; |
4851 | 3113 if (new_bp != NULL) { |
3114 scsi_free_consistent_buf(new_bp); | |
3115 } | |
3116 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3117 new_vpkt = vpkt; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3118 vpkt = vpkt->vpkt_org_vpkt; |
4851 | 3119 |
3120 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
3121 new_vpkt->vpkt_tgt_pkt); | |
3122 } | |
3123 | |
3124 /* | |
3125 * Mark this command completion as having an error so that | |
3126 * ssd will retry the command. | |
3127 */ | |
3128 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3129 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
|
3130 vpkt->vpkt_tgt_pkt->pkt_statistics |= STAT_ABORTED; |
4851 | 3131 |
3132 rval = VHCI_CMD_CMPLT; | |
3133 } | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3134 exit: |
4851 | 3135 /* |
3136 * Make sure that the semaphore is only released once. | |
3137 */ | |
3138 if (rval == VHCI_CMD_CMPLT) { | |
3139 sema_v(&vlun->svl_pgr_sema); | |
3140 } | |
3141 | |
3142 return (rval); | |
3143 } | |
3144 | |
3145 static void | |
3146 vhci_intr(struct scsi_pkt *pkt) | |
3147 { | |
3148 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_private; | |
3149 struct scsi_pkt *tpkt; | |
3150 scsi_vhci_priv_t *svp; | |
3151 scsi_vhci_lun_t *vlun; | |
3152 int rval, held; | |
3153 struct scsi_failover_ops *fops; | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3154 uint8_t *sns, skey, asc, ascq; |
4851 | 3155 mdi_pathinfo_t *lpath; |
3156 static char *timeout_err = "Command Timeout"; | |
3157 static char *parity_err = "Parity Error"; | |
3158 char *err_str = NULL; | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3159 dev_info_t *vdip, *cdip; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3160 char *cpath; |
4851 | 3161 |
3162 ASSERT(vpkt != NULL); | |
3163 tpkt = vpkt->vpkt_tgt_pkt; | |
3164 ASSERT(tpkt != NULL); | |
3165 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
3166 ASSERT(svp != NULL); | |
3167 vlun = svp->svp_svl; | |
3168 ASSERT(vlun != NULL); | |
3169 lpath = vpkt->vpkt_path; | |
3170 | |
3171 /* | |
3172 * sync up the target driver's pkt with the pkt that | |
3173 * we actually used | |
3174 */ | |
3175 *(tpkt->pkt_scbp) = *(pkt->pkt_scbp); | |
3176 tpkt->pkt_resid = pkt->pkt_resid; | |
3177 tpkt->pkt_state = pkt->pkt_state; | |
3178 tpkt->pkt_statistics = pkt->pkt_statistics; | |
3179 tpkt->pkt_reason = pkt->pkt_reason; | |
3180 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3181 /* 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
|
3182 if (scsi_pkt_allocated_correctly(tpkt)) { |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3183 if (scsi_pkt_allocated_correctly(pkt)) { |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3184 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3185 * If both packets were correctly allocated, |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3186 * return path returned by pHCI. |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3187 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3188 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
|
3189 } else { |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3190 /* 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
|
3191 tpkt->pkt_path_instance = |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3192 mdi_pi_get_path_instance(lpath); |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3193 } |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3194 } |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
3195 |
4851 | 3196 if (pkt->pkt_cdbp[0] == SCMD_PROUT && |
3197 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) || | |
3198 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE)) { | |
3199 if ((SCBP_C(pkt) != STATUS_GOOD) || | |
3200 (pkt->pkt_reason != CMD_CMPLT)) { | |
3201 sema_v(&vlun->svl_pgr_sema); | |
3202 } | |
3203 } else if (pkt->pkt_cdbp[0] == SCMD_PRIN) { | |
3204 if (pkt->pkt_reason != CMD_CMPLT || | |
3205 (SCBP_C(pkt) != STATUS_GOOD)) { | |
3206 sema_v(&vlun->svl_pgr_sema); | |
3207 } | |
3208 } | |
3209 | |
3210 switch (pkt->pkt_reason) { | |
3211 case CMD_CMPLT: | |
3212 /* | |
3213 * cmd completed successfully, check for scsi errors | |
3214 */ | |
3215 switch (*(pkt->pkt_scbp)) { | |
3216 case STATUS_CHECK: | |
3217 if (pkt->pkt_state & STATE_ARQ_DONE) { | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3218 sns = (uint8_t *) |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3219 &(((struct scsi_arq_status *)(uintptr_t) |
4851 | 3220 (pkt->pkt_scbp))->sts_sensedata); |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3221 skey = scsi_sense_key(sns); |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3222 asc = scsi_sense_asc(sns); |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3223 ascq = scsi_sense_ascq(sns); |
4851 | 3224 fops = vlun->svl_fops; |
3225 ASSERT(fops != NULL); | |
3226 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_intr: " | |
3227 "Received sns key %x esc %x escq %x\n", | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3228 skey, asc, ascq)); |
4851 | 3229 |
3230 if (vlun->svl_waiting_for_activepath == 1) { | |
3231 /* | |
3232 * if we are here it means we are | |
3233 * in the midst of a probe/attach | |
3234 * through a passive path; this | |
3235 * case is exempt from sense analysis | |
3236 * for detection of ext. failover | |
3237 * because that would unnecessarily | |
3238 * increase attach time. | |
3239 */ | |
3240 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
3241 vpkt->vpkt_tgt_init_scblen); | |
3242 break; | |
3243 } | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3244 if (asc == VHCI_SCSI_PERR) { |
4851 | 3245 /* |
3246 * parity error | |
3247 */ | |
3248 err_str = parity_err; | |
3249 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
3250 vpkt->vpkt_tgt_init_scblen); | |
3251 break; | |
3252 } | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3253 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
|
3254 sns, vlun->svl_fops_ctpriv); |
4851 | 3255 if ((rval == SCSI_SENSE_NOFAILOVER) || |
3256 (rval == SCSI_SENSE_UNKNOWN) || | |
3257 (rval == SCSI_SENSE_NOT_READY)) { | |
3258 bcopy(pkt->pkt_scbp, tpkt->pkt_scbp, | |
3259 vpkt->vpkt_tgt_init_scblen); | |
3260 break; | |
3261 } else if (rval == SCSI_SENSE_STATE_CHANGED) { | |
3262 struct scsi_vhci *vhci; | |
3263 vhci = ADDR2VHCI(&tpkt->pkt_address); | |
3264 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
3265 if (!held) { | |
3266 /* | |
3267 * looks like some other thread | |
3268 * has already detected this | |
3269 * condition | |
3270 */ | |
3271 tpkt->pkt_state &= | |
3272 ~STATE_ARQ_DONE; | |
3273 *(tpkt->pkt_scbp) = | |
3274 STATUS_BUSY; | |
3275 break; | |
3276 } | |
3277 (void) taskq_dispatch( | |
3278 vhci->vhci_update_pathstates_taskq, | |
3279 vhci_update_pathstates, | |
3280 (void *)vlun, KM_SLEEP); | |
3281 } else { | |
3282 /* | |
3283 * externally initiated failover | |
3284 * has occurred or is in progress | |
3285 */ | |
3286 VHCI_HOLD_LUN(vlun, VH_NOSLEEP, held); | |
3287 if (!held) { | |
3288 /* | |
3289 * looks like some other thread | |
3290 * has already detected this | |
3291 * condition | |
3292 */ | |
3293 tpkt->pkt_state &= | |
3294 ~STATE_ARQ_DONE; | |
3295 *(tpkt->pkt_scbp) = | |
3296 STATUS_BUSY; | |
3297 break; | |
3298 } else { | |
3299 rval = vhci_handle_ext_fo | |
3300 (pkt, rval); | |
3301 if (rval == BUSY_RETURN) { | |
3302 tpkt->pkt_state &= | |
3303 ~STATE_ARQ_DONE; | |
3304 *(tpkt->pkt_scbp) = | |
3305 STATUS_BUSY; | |
3306 break; | |
3307 } | |
3308 bcopy(pkt->pkt_scbp, | |
3309 tpkt->pkt_scbp, | |
3310 vpkt->vpkt_tgt_init_scblen); | |
3311 break; | |
3312 } | |
3313 } | |
3314 } | |
3315 break; | |
3316 | |
3317 /* | |
3318 * If this is a good SCSI-II RELEASE cmd completion then restore | |
3319 * the load balancing policy and reset VLUN_RESERVE_ACTIVE_FLG. | |
3320 * If this is a good SCSI-II RESERVE cmd completion then set | |
3321 * VLUN_RESERVE_ACTIVE_FLG. | |
3322 */ | |
3323 case STATUS_GOOD: | |
3324 if ((pkt->pkt_cdbp[0] == SCMD_RELEASE) || | |
3325 (pkt->pkt_cdbp[0] == SCMD_RELEASE_G1)) { | |
3326 (void) mdi_set_lb_policy(vlun->svl_dip, | |
3327 vlun->svl_lb_policy_save); | |
3328 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
3329 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3330 "!vhci_intr: vlun 0x%p release path 0x%p", | |
3331 (void *)vlun, (void *)vpkt->vpkt_path)); | |
3332 } | |
3333 | |
3334 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
3335 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
3336 vlun->svl_flags |= VLUN_RESERVE_ACTIVE_FLG; | |
3337 vlun->svl_resrv_pip = vpkt->vpkt_path; | |
3338 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3339 "!vhci_intr: vlun 0x%p reserved path 0x%p", | |
3340 (void *)vlun, (void *)vpkt->vpkt_path)); | |
3341 } | |
3342 break; | |
3343 | |
3344 case STATUS_RESERVATION_CONFLICT: | |
3345 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3346 "!vhci_intr: vlun 0x%p " | |
3347 "reserve conflict on path 0x%p", | |
3348 (void *)vlun, (void *)vpkt->vpkt_path)); | |
3349 /* FALLTHROUGH */ | |
3350 default: | |
3351 break; | |
3352 } | |
3353 | |
3354 /* | |
3355 * Update I/O completion statistics for the path | |
3356 */ | |
3357 mdi_pi_kstat_iosupdate(vpkt->vpkt_path, vpkt->vpkt_tgt_init_bp); | |
3358 | |
3359 /* | |
3360 * Command completed successfully, release the dma binding and | |
3361 * destroy the transport side of the packet. | |
3362 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3363 if ((pkt->pkt_cdbp[0] == SCMD_PROUT) && |
4851 | 3364 (((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
|
3365 ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE))) { |
4851 | 3366 if (SCBP_C(pkt) == STATUS_GOOD) { |
3367 ASSERT(vlun->svl_taskq); | |
3368 svp->svp_last_pkt_reason = pkt->pkt_reason; | |
3369 (void) taskq_dispatch(vlun->svl_taskq, | |
3370 vhci_run_cmd, pkt, KM_SLEEP); | |
3371 return; | |
3372 } | |
3373 } | |
3374 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
|
3375 (pkt->pkt_cdbp[0] == SCMD_PRIN) && vpkt->vpkt_tgt_init_bp) { |
4851 | 3376 /* |
3377 * If the action (value in byte 1 of the cdb) is zero, | |
3378 * we're reading keys, and that's the only condition | |
3379 * where we need to be concerned with filtering keys | |
3380 * and potential retries. Otherwise, we simply signal | |
3381 * the semaphore and move on. | |
3382 */ | |
3383 if (pkt->pkt_cdbp[1] == 0) { | |
3384 /* | |
3385 * If this is the completion of an internal | |
3386 * retry then we need to make sure that the | |
3387 * pkt and tpkt pointers are readjusted so | |
3388 * the calls to scsi_destroy_pkt and pkt_comp | |
3389 * below work * correctly. | |
3390 */ | |
3391 if (vpkt->vpkt_org_vpkt != NULL) { | |
3392 pkt = vpkt->vpkt_org_vpkt->vpkt_hba_pkt; | |
3393 tpkt = vpkt->vpkt_org_vpkt-> | |
3394 vpkt_tgt_pkt; | |
3395 | |
3396 /* | |
3397 * If this command was issued through | |
3398 * the taskq then we need to clear | |
3399 * this flag for proper processing in | |
3400 * the case of a retry from the target | |
3401 * driver. | |
3402 */ | |
3403 vpkt->vpkt_state &= | |
3404 ~VHCI_PKT_THRU_TASKQ; | |
3405 } | |
3406 | |
3407 /* | |
3408 * if vhci_do_prin returns VHCI_CMD_CMPLT then | |
3409 * vpkt will contain the address of the | |
3410 * original vpkt | |
3411 */ | |
7201
0259de900d45
6625553 BAD TRAP: type=31 rp=2a100297730 addr=0 mmu_fsr=0 occurred in module "genunix"
rralphs
parents:
7191
diff
changeset
|
3412 if (vhci_do_prin(&vpkt) == VHCI_CMD_RETRY) { |
4851 | 3413 /* |
3414 * The command has been resent to get | |
3415 * all the keys from the device. Don't | |
3416 * complete the command with ssd until | |
3417 * the retry completes. | |
3418 */ | |
3419 return; | |
3420 } | |
3421 } else { | |
3422 sema_v(&vlun->svl_pgr_sema); | |
3423 } | |
3424 } | |
3425 | |
3426 break; | |
3427 | |
3428 case CMD_TIMEOUT: | |
3429 if ((pkt->pkt_statistics & | |
3430 (STAT_BUS_RESET|STAT_DEV_RESET|STAT_ABORTED)) == 0) { | |
3431 | |
3432 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3433 "!scsi vhci timeout invoked\n")); | |
3434 | |
3435 (void) vhci_recovery_reset(vlun, &pkt->pkt_address, | |
3436 FALSE, VHCI_DEPTH_ALL); | |
3437 } | |
3438 MDI_PI_ERRSTAT(lpath, MDI_PI_TRANSERR); | |
3439 tpkt->pkt_statistics |= STAT_ABORTED; | |
3440 err_str = timeout_err; | |
3441 break; | |
3442 | |
3443 case CMD_TRAN_ERR: | |
3444 /* | |
3445 * This status is returned if the transport has sent the cmd | |
3446 * down the link to the target and then some error occurs. | |
3447 * In case of SCSI-II RESERVE cmd, we don't know if the | |
3448 * reservation been accepted by the target or not, so we need | |
3449 * to clear the reservation. | |
3450 */ | |
3451 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
3452 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
3453 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_intr received" | |
3454 " cmd_tran_err for scsi-2 reserve cmd\n")); | |
3455 if (!vhci_recovery_reset(vlun, &pkt->pkt_address, | |
3456 TRUE, VHCI_DEPTH_TARGET)) { | |
3457 VHCI_DEBUG(1, (CE_WARN, NULL, | |
3458 "!vhci_intr cmd_tran_err reset failed!")); | |
3459 } | |
3460 } | |
3461 break; | |
3462 | |
3463 case CMD_DEV_GONE: | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3464 /* |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3465 * If this is the last path then report CMD_DEV_GONE to the |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3466 * target driver, otherwise report BUSY to triggger retry. |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3467 */ |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3468 if (vlun->svl_dip && |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3469 (mdi_client_get_path_count(vlun->svl_dip) <= 1)) { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3470 struct scsi_vhci *vhci; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3471 vhci = ADDR2VHCI(&tpkt->pkt_address); |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3472 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_intr received " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3473 "cmd_dev_gone on last path\n")); |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3474 (void) vhci_invalidate_mpapi_lu(vhci, vlun); |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3475 break; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3476 } |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3477 |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3478 /* Report CMD_CMPLT-with-BUSY to cause retry. */ |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3479 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
|
3480 "cmd_dev_gone\n")); |
4851 | 3481 tpkt->pkt_reason = CMD_CMPLT; |
3482 tpkt->pkt_state = STATE_GOT_BUS | | |
3483 STATE_GOT_TARGET | STATE_SENT_CMD | | |
3484 STATE_GOT_STATUS; | |
3485 *(tpkt->pkt_scbp) = STATUS_BUSY; | |
3486 break; | |
3487 | |
3488 default: | |
3489 break; | |
3490 } | |
3491 | |
3492 /* | |
3493 * SCSI-II RESERVE cmd has been serviced by the lower layers clear | |
3494 * the flag so the lun is not QUIESCED any longer. | |
3495 * Also clear the VHCI_PKT_THRU_TASKQ flag, to ensure that if this pkt | |
3496 * is retried, a taskq shall again be dispatched to service it. Else | |
3497 * it may lead to a system hang if the retry is within interrupt | |
3498 * context. | |
3499 */ | |
3500 if ((pkt->pkt_cdbp[0] == SCMD_RESERVE) || | |
3501 (pkt->pkt_cdbp[0] == SCMD_RESERVE_G1)) { | |
3502 vlun->svl_flags &= ~VLUN_QUIESCED_FLG; | |
3503 vpkt->vpkt_state &= ~VHCI_PKT_THRU_TASKQ; | |
3504 } | |
3505 | |
3506 /* | |
3507 * vpkt_org_vpkt should always be NULL here if the retry command | |
3508 * has been successfully processed. If vpkt_org_vpkt != NULL at | |
3509 * this point, it is an error so restore the original vpkt and | |
3510 * return an error to the target driver so it can retry the | |
3511 * command as appropriate. | |
3512 */ | |
3513 if (vpkt->vpkt_org_vpkt != NULL) { | |
3514 struct vhci_pkt *new_vpkt = vpkt; | |
3515 vpkt = vpkt->vpkt_org_vpkt; | |
3516 | |
3517 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
3518 new_vpkt->vpkt_tgt_pkt); | |
3519 | |
3520 /* | |
3521 * Mark this command completion as having an error so that | |
3522 * ssd will retry the command. | |
3523 */ | |
3524 vpkt->vpkt_tgt_pkt->pkt_reason = CMD_ABORTED; | |
3525 vpkt->vpkt_tgt_pkt->pkt_statistics |= STAT_ABORTED; | |
3526 | |
3527 pkt = vpkt->vpkt_hba_pkt; | |
3528 tpkt = vpkt->vpkt_tgt_pkt; | |
3529 } | |
3530 | |
3531 if ((err_str != NULL) && (pkt->pkt_reason != | |
3532 svp->svp_last_pkt_reason)) { | |
3533 cdip = vlun->svl_dip; | |
3534 vdip = ddi_get_parent(cdip); | |
3535 cpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3536 vhci_log(CE_WARN, vdip, "!%s (%s%d): %s on path %s", |
4851 | 3537 ddi_pathname(cdip, cpath), ddi_driver_name(cdip), |
3538 ddi_get_instance(cdip), err_str, | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3539 mdi_pi_spathname(vpkt->vpkt_path)); |
4851 | 3540 kmem_free(cpath, MAXPATHLEN); |
3541 } | |
3542 svp->svp_last_pkt_reason = pkt->pkt_reason; | |
3543 VHCI_DECR_PATH_CMDCOUNT(svp); | |
3544 | |
3545 /* | |
3546 * For PARTIAL_DMA, vhci should not free the path. | |
3547 * Target driver will call into vhci_scsi_dmafree or | |
3548 * destroy pkt to release this path. | |
3549 */ | |
3550 if ((vpkt->vpkt_flags & CFLAG_DMA_PARTIAL) == 0) { | |
3551 scsi_destroy_pkt(pkt); | |
3552 vpkt->vpkt_hba_pkt = NULL; | |
3553 if (vpkt->vpkt_path) { | |
3554 mdi_rele_path(vpkt->vpkt_path); | |
3555 vpkt->vpkt_path = NULL; | |
3556 } | |
3557 } | |
3558 | |
9106
ee8f18cdafb2
6809527 scsi_hba_pkt_comp():More consumers
srivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>
parents:
8851
diff
changeset
|
3559 scsi_hba_pkt_comp(tpkt); |
4851 | 3560 } |
3561 | |
3562 /* | |
3563 * two possibilities: (1) failover has completed | |
3564 * or (2) is in progress; update our path states for | |
3565 * the former case; for the latter case, | |
3566 * initiate a scsi_watch request to | |
3567 * determine when failover completes - vlun is HELD | |
3568 * until failover completes; BUSY is returned to upper | |
3569 * layer in both the cases | |
3570 */ | |
3571 static int | |
3572 vhci_handle_ext_fo(struct scsi_pkt *pkt, int fostat) | |
3573 { | |
3574 struct vhci_pkt *vpkt = (struct vhci_pkt *)pkt->pkt_private; | |
3575 struct scsi_pkt *tpkt; | |
3576 scsi_vhci_priv_t *svp; | |
3577 scsi_vhci_lun_t *vlun; | |
3578 struct scsi_vhci *vhci; | |
3579 scsi_vhci_swarg_t *swarg; | |
3580 char *path; | |
3581 | |
3582 ASSERT(vpkt != NULL); | |
3583 tpkt = vpkt->vpkt_tgt_pkt; | |
3584 ASSERT(tpkt != NULL); | |
3585 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
3586 ASSERT(svp != NULL); | |
3587 vlun = svp->svp_svl; | |
3588 ASSERT(vlun != NULL); | |
3589 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
3590 | |
3591 vhci = ADDR2VHCI(&tpkt->pkt_address); | |
3592 | |
3593 if (fostat == SCSI_SENSE_INACTIVE) { | |
3594 VHCI_DEBUG(1, (CE_NOTE, NULL, "!Failover " | |
3595 "detected for %s; updating path states...\n", | |
3596 vlun->svl_lun_wwn)); | |
3597 /* | |
3598 * set the vlun flag to indicate to the task that the target | |
3599 * port group needs updating | |
3600 */ | |
3601 vlun->svl_flags |= VLUN_UPDATE_TPG; | |
3602 (void) taskq_dispatch(vhci->vhci_update_pathstates_taskq, | |
3603 vhci_update_pathstates, (void *)vlun, KM_SLEEP); | |
3604 } else { | |
3605 path = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
3606 vhci_log(CE_NOTE, ddi_get_parent(vlun->svl_dip), | |
3607 "!%s (%s%d): Waiting for externally initiated failover " | |
3608 "to complete", ddi_pathname(vlun->svl_dip, path), | |
3609 ddi_driver_name(vlun->svl_dip), | |
3610 ddi_get_instance(vlun->svl_dip)); | |
3611 kmem_free(path, MAXPATHLEN); | |
3612 swarg = kmem_alloc(sizeof (*swarg), KM_NOSLEEP); | |
3613 if (swarg == NULL) { | |
3614 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_handle_ext_fo: " | |
3615 "request packet allocation for %s failed....\n", | |
3616 vlun->svl_lun_wwn)); | |
3617 VHCI_RELEASE_LUN(vlun); | |
3618 return (PKT_RETURN); | |
3619 } | |
3620 swarg->svs_svp = svp; | |
3621 swarg->svs_tos = ddi_get_time(); | |
3622 swarg->svs_pi = vpkt->vpkt_path; | |
3623 swarg->svs_release_lun = 0; | |
3624 swarg->svs_done = 0; | |
3625 /* | |
3626 * place a hold on the path...we don't want it to | |
3627 * vanish while scsi_watch is in progress | |
3628 */ | |
3629 mdi_hold_path(vpkt->vpkt_path); | |
3630 svp->svp_sw_token = scsi_watch_request_submit(svp->svp_psd, | |
3631 VHCI_FOWATCH_INTERVAL, SENSE_LENGTH, vhci_efo_watch_cb, | |
3632 (caddr_t)swarg); | |
3633 } | |
3634 return (BUSY_RETURN); | |
3635 } | |
3636 | |
3637 /* | |
3638 * vhci_efo_watch_cb: | |
3639 * Callback from scsi_watch request to check the failover status. | |
3640 * Completion is either due to successful failover or timeout. | |
3641 * Upon successful completion, vhci_update_path_states is called. | |
3642 * For timeout condition, vhci_efo_done is called. | |
3643 * Always returns 0 to scsi_watch to keep retrying till vhci_efo_done | |
3644 * terminates this request properly in a separate thread. | |
3645 */ | |
3646 | |
3647 static int | |
3648 vhci_efo_watch_cb(caddr_t arg, struct scsi_watch_result *resultp) | |
3649 { | |
3650 struct scsi_status *statusp = resultp->statusp; | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
3651 uint8_t *sensep = (uint8_t *)resultp->sensep; |
4851 | 3652 struct scsi_pkt *pkt = resultp->pkt; |
3653 scsi_vhci_swarg_t *swarg; | |
3654 scsi_vhci_priv_t *svp; | |
3655 scsi_vhci_lun_t *vlun; | |
3656 struct scsi_vhci *vhci; | |
3657 dev_info_t *vdip; | |
3658 int rval, updt_paths; | |
3659 | |
3660 swarg = (scsi_vhci_swarg_t *)(uintptr_t)arg; | |
3661 svp = swarg->svs_svp; | |
3662 if (swarg->svs_done) { | |
3663 /* | |
3664 * Already completed failover or timedout. | |
3665 * Waiting for vhci_efo_done to terminate this scsi_watch. | |
3666 */ | |
3667 return (0); | |
3668 } | |
3669 | |
3670 ASSERT(svp != NULL); | |
3671 vlun = svp->svp_svl; | |
3672 ASSERT(vlun != NULL); | |
3673 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
3674 vlun->svl_efo_update_path = 0; | |
3675 vdip = ddi_get_parent(vlun->svl_dip); | |
3676 vhci = ddi_get_soft_state(vhci_softstate, | |
3677 ddi_get_instance(vdip)); | |
3678 | |
3679 updt_paths = 0; | |
3680 | |
3681 if (pkt->pkt_reason != CMD_CMPLT) { | |
3682 if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) { | |
3683 swarg->svs_release_lun = 1; | |
3684 goto done; | |
3685 } | |
3686 return (0); | |
3687 } | |
3688 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
|
3689 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
|
3690 vlun->svl_fops_ctpriv); |
4851 | 3691 switch (rval) { |
3692 /* | |
3693 * Only update path states in case path is definitely | |
3694 * inactive, or no failover occurred. For all other | |
3695 * check conditions continue pinging. A unexpected | |
3696 * check condition shouldn't cause pinging to complete | |
3697 * prematurely. | |
3698 */ | |
3699 case SCSI_SENSE_INACTIVE: | |
3700 case SCSI_SENSE_NOFAILOVER: | |
3701 updt_paths = 1; | |
3702 break; | |
3703 default: | |
3704 if ((ddi_get_time() - swarg->svs_tos) | |
3705 >= VHCI_EXTFO_TIMEOUT) { | |
3706 swarg->svs_release_lun = 1; | |
3707 goto done; | |
3708 } | |
3709 return (0); | |
3710 } | |
3711 } else if (*((unsigned char *)statusp) == | |
3712 STATUS_RESERVATION_CONFLICT) { | |
3713 updt_paths = 1; | |
3714 } else if ((*((unsigned char *)statusp)) & | |
3715 (STATUS_BUSY | STATUS_QFULL)) { | |
3716 return (0); | |
3717 } | |
3718 if ((*((unsigned char *)statusp) == STATUS_GOOD) || | |
3719 (updt_paths == 1)) { | |
3720 /* | |
3721 * we got here because we had detected an | |
3722 * externally initiated failover; things | |
3723 * have settled down now, so let's | |
3724 * start up a task to update the | |
3725 * path states and target port group | |
3726 */ | |
3727 vlun->svl_efo_update_path = 1; | |
3728 swarg->svs_done = 1; | |
3729 vlun->svl_swarg = swarg; | |
3730 vlun->svl_flags |= VLUN_UPDATE_TPG; | |
3731 (void) taskq_dispatch(vhci->vhci_update_pathstates_taskq, | |
3732 vhci_update_pathstates, (void *)vlun, | |
3733 KM_SLEEP); | |
3734 return (0); | |
3735 } | |
3736 if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) { | |
3737 swarg->svs_release_lun = 1; | |
3738 goto done; | |
3739 } | |
3740 return (0); | |
3741 done: | |
3742 swarg->svs_done = 1; | |
3743 (void) taskq_dispatch(vhci->vhci_taskq, | |
3744 vhci_efo_done, (void *)swarg, KM_SLEEP); | |
3745 return (0); | |
3746 } | |
3747 | |
3748 /* | |
3749 * vhci_efo_done: | |
3750 * cleanly terminates scsi_watch and free up resources. | |
3751 * Called as taskq function in vhci_efo_watch_cb for EFO timeout condition | |
3752 * or by vhci_update_path_states invoked during external initiated | |
3753 * failover completion. | |
3754 */ | |
3755 static void | |
3756 vhci_efo_done(void *arg) | |
3757 { | |
3758 scsi_vhci_lun_t *vlun; | |
3759 scsi_vhci_swarg_t *swarg = (scsi_vhci_swarg_t *)arg; | |
3760 scsi_vhci_priv_t *svp = swarg->svs_svp; | |
3761 ASSERT(svp); | |
3762 | |
3763 vlun = svp->svp_svl; | |
3764 ASSERT(vlun); | |
3765 | |
3766 /* Wait for clean termination of scsi_watch */ | |
3767 (void) scsi_watch_request_terminate(svp->svp_sw_token, | |
7191
174d749b3f22
6520112 simultaneous DKIOCSTATE calls causes panic
tl223370
parents:
7121
diff
changeset
|
3768 SCSI_WATCH_TERMINATE_ALL_WAIT); |
4851 | 3769 svp->svp_sw_token = NULL; |
3770 | |
3771 /* release path and freeup resources to indicate failover completion */ | |
3772 mdi_rele_path(swarg->svs_pi); | |
3773 if (swarg->svs_release_lun) { | |
3774 VHCI_RELEASE_LUN(vlun); | |
3775 } | |
3776 kmem_free((void *)swarg, sizeof (*swarg)); | |
3777 } | |
3778 | |
3779 /* | |
3780 * Update the path states | |
3781 * vlun should be HELD when this is invoked. | |
3782 * Calls vhci_efo_done to cleanup resources allocated for EFO. | |
3783 */ | |
3784 void | |
3785 vhci_update_pathstates(void *arg) | |
3786 { | |
3787 mdi_pathinfo_t *pip, *npip; | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3788 dev_info_t *dip; |
4851 | 3789 struct scsi_failover_ops *fo; |
3790 struct scsi_vhci_priv *svp; | |
3791 struct scsi_device *psd; | |
3792 struct scsi_path_opinfo opinfo; | |
3793 char *pclass, *tptr; | |
3794 struct scsi_vhci_lun *vlun = (struct scsi_vhci_lun *)arg; | |
3795 int sps; /* mdi_select_path() status */ | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3796 char *cpath; |
4851 | 3797 struct scsi_vhci *vhci; |
3798 struct scsi_pkt *pkt; | |
3799 struct buf *bp; | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3800 struct scsi_vhci_priv *svp_conflict = NULL; |
4851 | 3801 |
3802 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
3803 dip = vlun->svl_dip; | |
3804 pip = npip = NULL; | |
3805 | |
3806 vhci = ddi_get_soft_state(vhci_softstate, | |
3807 ddi_get_instance(ddi_get_parent(dip))); | |
3808 | |
3809 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
|
3810 MDI_SELECT_STANDBY_PATH | MDI_SELECT_NO_PREFERRED), NULL, &npip); |
4851 | 3811 if ((npip == NULL) || (sps != MDI_SUCCESS)) { |
3812 goto done; | |
3813 } | |
3814 | |
3815 fo = vlun->svl_fops; | |
3816 do { | |
3817 pip = npip; | |
3818 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
3819 psd = svp->svp_psd; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
3820 if (fo->sfo_path_get_opinfo(psd, &opinfo, |
4851 | 3821 vlun->svl_fops_ctpriv) != 0) { |
3822 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
|
3823 (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
|
3824 MDI_SELECT_NO_PREFERRED), pip, &npip); |
4851 | 3825 mdi_rele_path(pip); |
3826 continue; | |
3827 } | |
3828 | |
3829 if (mdi_prop_lookup_string(pip, "path-class", &pclass) != | |
3830 MDI_SUCCESS) { | |
3831 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3832 "!vhci_update_pathstates: prop lookup failed for " | |
3833 "path 0x%p\n", (void *)pip)); | |
3834 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
|
3835 (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
|
3836 MDI_SELECT_NO_PREFERRED), pip, &npip); |
4851 | 3837 mdi_rele_path(pip); |
3838 continue; | |
3839 } | |
3840 | |
3841 /* | |
3842 * Need to update the "path-class" property | |
3843 * value in the device tree if different | |
3844 * from the existing value. | |
3845 */ | |
3846 if (strcmp(pclass, opinfo.opinfo_path_attr) != 0) { | |
3847 (void) mdi_prop_update_string(pip, "path-class", | |
3848 opinfo.opinfo_path_attr); | |
3849 } | |
3850 | |
3851 /* | |
3852 * Only change the state if needed. i.e. Don't call | |
3853 * mdi_pi_set_state to ONLINE a path if its already | |
3854 * ONLINE. Same for STANDBY paths. | |
3855 */ | |
3856 | |
3857 if ((opinfo.opinfo_path_state == SCSI_PATH_ACTIVE || | |
3858 opinfo.opinfo_path_state == SCSI_PATH_ACTIVE_NONOPT)) { | |
3859 if (!(MDI_PI_IS_ONLINE(pip))) { | |
3860 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3861 "!vhci_update_pathstates: marking path" | |
3862 " 0x%p as ONLINE\n", (void *)pip)); | |
3863 cpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3864 vhci_log(CE_NOTE, ddi_get_parent(dip), "!%s " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3865 "(%s%d): path %s " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3866 "is now ONLINE because of " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3867 "an externally initiated failover", |
4851 | 3868 ddi_pathname(dip, cpath), |
3869 ddi_driver_name(dip), | |
3870 ddi_get_instance(dip), | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3871 mdi_pi_spathname(pip)); |
4851 | 3872 kmem_free(cpath, MAXPATHLEN); |
3873 mdi_pi_set_state(pip, | |
3874 MDI_PATHINFO_STATE_ONLINE); | |
3875 mdi_pi_set_preferred(pip, | |
3876 opinfo.opinfo_preferred); | |
3877 tptr = kmem_alloc(strlen | |
3878 (opinfo.opinfo_path_attr)+1, KM_SLEEP); | |
3879 (void) strlcpy(tptr, opinfo.opinfo_path_attr, | |
3880 (strlen(opinfo.opinfo_path_attr)+1)); | |
3881 mutex_enter(&vlun->svl_mutex); | |
3882 if (vlun->svl_active_pclass != NULL) { | |
3883 kmem_free(vlun->svl_active_pclass, | |
3884 strlen(vlun->svl_active_pclass)+1); | |
3885 } | |
3886 vlun->svl_active_pclass = tptr; | |
3887 if (vlun->svl_waiting_for_activepath) { | |
3888 vlun->svl_waiting_for_activepath = 0; | |
3889 } | |
3890 mutex_exit(&vlun->svl_mutex); | |
3891 } else if (MDI_PI_IS_ONLINE(pip)) { | |
3892 if (strcmp(pclass, opinfo.opinfo_path_attr) | |
3893 != 0) { | |
3894 mdi_pi_set_preferred(pip, | |
3895 opinfo.opinfo_preferred); | |
3896 mutex_enter(&vlun->svl_mutex); | |
3897 if (vlun->svl_active_pclass == NULL || | |
3898 strcmp(opinfo.opinfo_path_attr, | |
3899 vlun->svl_active_pclass) != 0) { | |
3900 mutex_exit(&vlun->svl_mutex); | |
3901 tptr = kmem_alloc(strlen | |
3902 (opinfo.opinfo_path_attr)+1, | |
3903 KM_SLEEP); | |
3904 (void) strlcpy(tptr, | |
3905 opinfo.opinfo_path_attr, | |
3906 (strlen | |
3907 (opinfo.opinfo_path_attr) | |
3908 +1)); | |
3909 mutex_enter(&vlun->svl_mutex); | |
3910 } else { | |
3911 /* | |
3912 * No need to update | |
3913 * svl_active_pclass | |
3914 */ | |
3915 tptr = NULL; | |
3916 mutex_exit(&vlun->svl_mutex); | |
3917 } | |
3918 if (tptr) { | |
3919 if (vlun->svl_active_pclass | |
3920 != NULL) { | |
3921 kmem_free(vlun-> | |
3922 svl_active_pclass, | |
3923 strlen(vlun-> | |
3924 svl_active_pclass) | |
3925 +1); | |
3926 } | |
3927 vlun->svl_active_pclass = tptr; | |
3928 mutex_exit(&vlun->svl_mutex); | |
3929 } | |
3930 } | |
3931 } | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3932 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3933 /* Check for Reservation Conflict */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3934 bp = scsi_alloc_consistent_buf( |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3935 &svp->svp_psd->sd_address, (struct buf *)NULL, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3936 DEV_BSIZE, B_READ, NULL, NULL); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3937 if (!bp) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3938 VHCI_DEBUG(1, (CE_NOTE, NULL, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3939 "!vhci_update_pathstates: No resources " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3940 "(buf)\n")); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3941 mdi_rele_path(pip); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3942 goto done; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3943 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3944 pkt = scsi_init_pkt(&svp->svp_psd->sd_address, NULL, bp, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3945 CDB_GROUP1, sizeof (struct scsi_arq_status), 0, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3946 PKT_CONSISTENT, NULL, NULL); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3947 if (pkt) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3948 (void) scsi_setup_cdb((union scsi_cdb *) |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3949 (uintptr_t)pkt->pkt_cdbp, SCMD_READ, 1, 1, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3950 0); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3951 pkt->pkt_time = 3*30; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3952 pkt->pkt_flags = FLAG_NOINTR; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3953 pkt->pkt_path_instance = |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3954 mdi_pi_get_path_instance(pip); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3955 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3956 if ((scsi_transport(pkt) == TRAN_ACCEPT) && |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3957 (pkt->pkt_reason == CMD_CMPLT) && |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3958 (SCBP_C(pkt) == |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3959 STATUS_RESERVATION_CONFLICT)) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3960 VHCI_DEBUG(1, (CE_NOTE, NULL, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3961 "!vhci_update_pathstates: reserv. " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3962 "conflict to be resolved on 0x%p\n", |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3963 (void *)pip)); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3964 svp_conflict = svp; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3965 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3966 scsi_destroy_pkt(pkt); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3967 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
3968 scsi_free_consistent_buf(bp); |
4851 | 3969 } else if ((opinfo.opinfo_path_state == SCSI_PATH_INACTIVE) && |
3970 !(MDI_PI_IS_STANDBY(pip))) { | |
3971 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
3972 "!vhci_update_pathstates: marking path" | |
3973 " 0x%p as STANDBY\n", (void *)pip)); | |
3974 cpath = kmem_alloc(MAXPATHLEN, KM_SLEEP); | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3975 vhci_log(CE_NOTE, ddi_get_parent(dip), "!%s " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3976 "(%s%d): path %s " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3977 "is now STANDBY because of " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3978 "an externally initiated failover", |
4851 | 3979 ddi_pathname(dip, cpath), |
3980 ddi_driver_name(dip), | |
3981 ddi_get_instance(dip), | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
3982 mdi_pi_spathname(pip)); |
4851 | 3983 kmem_free(cpath, MAXPATHLEN); |
3984 mdi_pi_set_state(pip, | |
3985 MDI_PATHINFO_STATE_STANDBY); | |
3986 mdi_pi_set_preferred(pip, | |
3987 opinfo.opinfo_preferred); | |
3988 mutex_enter(&vlun->svl_mutex); | |
3989 if (vlun->svl_active_pclass != NULL) { | |
3990 if (strcmp(vlun->svl_active_pclass, | |
3991 opinfo.opinfo_path_attr) == 0) { | |
3992 kmem_free(vlun-> | |
3993 svl_active_pclass, | |
3994 strlen(vlun-> | |
3995 svl_active_pclass)+1); | |
3996 vlun->svl_active_pclass = NULL; | |
3997 } | |
3998 } | |
3999 mutex_exit(&vlun->svl_mutex); | |
4000 } | |
4001 (void) mdi_prop_free(pclass); | |
4002 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
|
4003 (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
|
4004 MDI_SELECT_NO_PREFERRED), pip, &npip); |
4851 | 4005 mdi_rele_path(pip); |
4006 | |
4007 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
4008 | |
4009 /* | |
4010 * Check to see if this vlun has an active SCSI-II RESERVE. If so | |
4011 * clear the reservation by sending a reset, so the host doesn't | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4012 * receive a reservation conflict. The reset has to be sent via a |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4013 * working path. Let's use a path referred to by svp_conflict as it |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4014 * should be working. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4015 * Reset VLUN_RESERVE_ACTIVE_FLG for this vlun. Also notify ssd |
4851 | 4016 * of the reset, explicitly. |
4017 */ | |
4018 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4019 if (svp_conflict && (vlun->svl_xlf_capable == 0)) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4020 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_update_pathstates:" |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4021 " sending recovery reset on 0x%p, path_state: %x", |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4022 svp_conflict->svp_psd->sd_private, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4023 mdi_pi_get_state((mdi_pathinfo_t *) |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4024 svp_conflict->svp_psd->sd_private))); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4025 |
4851 | 4026 (void) vhci_recovery_reset(vlun, |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4027 &svp_conflict->svp_psd->sd_address, FALSE, |
4851 | 4028 VHCI_DEPTH_TARGET); |
4029 } | |
4030 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
4031 mutex_enter(&vhci->vhci_mutex); | |
4032 scsi_hba_reset_notify_callback(&vhci->vhci_mutex, | |
4033 &vhci->vhci_reset_notify_listf); | |
4034 mutex_exit(&vhci->vhci_mutex); | |
4035 } | |
4036 if (vlun->svl_flags & VLUN_UPDATE_TPG) { | |
4037 /* | |
4038 * Update the AccessState of related MP-API TPGs | |
4039 */ | |
4040 (void) vhci_mpapi_update_tpg_acc_state_for_lu(vhci, vlun); | |
4041 vlun->svl_flags &= ~VLUN_UPDATE_TPG; | |
4042 } | |
4043 done: | |
4044 if (vlun->svl_efo_update_path) { | |
4045 vlun->svl_efo_update_path = 0; | |
4046 vhci_efo_done(vlun->svl_swarg); | |
4047 vlun->svl_swarg = 0; | |
4048 } | |
4049 VHCI_RELEASE_LUN(vlun); | |
4050 } | |
4051 | |
4052 /* ARGSUSED */ | |
4053 static int | |
4054 vhci_pathinfo_init(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
4055 { | |
4056 scsi_hba_tran_t *hba = NULL; | |
4057 struct scsi_device *psd = NULL; | |
4058 scsi_vhci_lun_t *vlun = NULL; | |
4059 dev_info_t *pdip = NULL; | |
4060 dev_info_t *tgt_dip; | |
4061 struct scsi_vhci *vhci; | |
4062 char *guid; | |
4063 scsi_vhci_priv_t *svp = NULL; | |
4064 int rval = MDI_FAILURE; | |
4065 int vlun_alloced = 0; | |
4066 | |
4067 ASSERT(vdip != NULL); | |
4068 ASSERT(pip != NULL); | |
4069 | |
4070 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
4071 ASSERT(vhci != NULL); | |
4072 | |
4073 pdip = mdi_pi_get_phci(pip); | |
4074 ASSERT(pdip != NULL); | |
4075 | |
4076 hba = ddi_get_driver_private(pdip); | |
4077 ASSERT(hba != NULL); | |
4078 | |
4079 tgt_dip = mdi_pi_get_client(pip); | |
4080 ASSERT(tgt_dip != NULL); | |
4081 | |
4082 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, tgt_dip, PROPFLAGS, | |
4083 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) { | |
4084 VHCI_DEBUG(1, (CE_WARN, NULL, | |
4085 "vhci_pathinfo_init: lun guid property failed")); | |
4086 goto failure; | |
4087 } | |
4088 | |
4089 vlun = vhci_lun_lookup_alloc(tgt_dip, guid, &vlun_alloced); | |
4090 ddi_prop_free(guid); | |
4091 | |
4092 vlun->svl_dip = tgt_dip; | |
4093 | |
4094 svp = kmem_zalloc(sizeof (*svp), KM_SLEEP); | |
4095 svp->svp_svl = vlun; | |
4096 | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4097 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4098 * Initialize svl_lb_policy_save only for newly allocated vlun. Writing |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4099 * to svl_lb_policy_save later could accidentally overwrite saved lb |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4100 * policy. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4101 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4102 if (vlun_alloced) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4103 vlun->svl_lb_policy_save = mdi_get_lb_policy(tgt_dip); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4104 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4105 |
4851 | 4106 mutex_init(&svp->svp_mutex, NULL, MUTEX_DRIVER, NULL); |
4107 cv_init(&svp->svp_cv, NULL, CV_DRIVER, NULL); | |
4108 | |
4109 psd = kmem_zalloc(sizeof (*psd), KM_SLEEP); | |
4110 mutex_init(&psd->sd_mutex, NULL, MUTEX_DRIVER, NULL); | |
4111 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4112 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
|
4113 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4114 * 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
|
4115 * 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
|
4116 * 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
|
4117 * 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
|
4118 * 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
|
4119 * 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
|
4120 */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4121 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
|
4122 } 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
|
4123 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4124 * 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
|
4125 * 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
|
4126 */ |
4851 | 4127 scsi_hba_tran_t *clone = |
4128 kmem_alloc(sizeof (scsi_hba_tran_t), KM_SLEEP); | |
4129 bcopy(hba, clone, sizeof (scsi_hba_tran_t)); | |
4130 hba = clone; | |
4131 hba->tran_sd = psd; | |
4132 } else { | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4133 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4134 * 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
|
4135 * 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
|
4136 * 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
|
4137 */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4138 goto failure; |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4139 } |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4140 |
4851 | 4141 psd->sd_dev = tgt_dip; |
4142 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
|
4143 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4144 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4145 * 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
|
4146 * 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
|
4147 * 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
|
4148 */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4149 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
|
4150 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4151 /* |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4152 * 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
|
4153 * 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
|
4154 * 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
|
4155 * 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
|
4156 */ |
4851 | 4157 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
|
4158 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4159 /* 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
|
4160 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
|
4161 |
4851 | 4162 svp->svp_psd = psd; |
4163 mdi_pi_set_vhci_private(pip, (caddr_t)svp); | |
4164 | |
4165 /* | |
4166 * call hba's target init entry point if it exists | |
4167 */ | |
4168 if (hba->tran_tgt_init != NULL) { | |
11556
99144956c627
6913819 SCSAv3: pmcs_scsa_tran_tgt_free: alignment error panic
Reed <Reed.Liu@Sun.COM>
parents:
11086
diff
changeset
|
4169 psd->sd_tran_tgt_free_done = 0; |
4851 | 4170 if ((rval = (*hba->tran_tgt_init)(pdip, tgt_dip, |
4171 hba, psd)) != DDI_SUCCESS) { | |
4172 VHCI_DEBUG(1, (CE_WARN, pdip, | |
4173 "!vhci_pathinfo_init: tran_tgt_init failed for " | |
4174 "path=0x%p rval=%x", (void *)pip, rval)); | |
4175 goto failure; | |
4176 } | |
4177 } | |
4178 | |
4179 svp->svp_new_path = 1; | |
4180 | |
4181 VHCI_DEBUG(4, (CE_NOTE, NULL, "!vhci_pathinfo_init: path:%p\n", | |
4182 (void *)pip)); | |
4183 return (MDI_SUCCESS); | |
4184 | |
4185 failure: | |
4186 if (psd) { | |
4187 mutex_destroy(&psd->sd_mutex); | |
4188 kmem_free(psd, sizeof (*psd)); | |
4189 } | |
4190 if (svp) { | |
4191 mdi_pi_set_vhci_private(pip, NULL); | |
4192 mutex_destroy(&svp->svp_mutex); | |
4193 cv_destroy(&svp->svp_cv); | |
4194 kmem_free(svp, sizeof (*svp)); | |
4195 } | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4196 if (hba && (hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE)) |
4851 | 4197 kmem_free(hba, sizeof (scsi_hba_tran_t)); |
4198 | |
4199 if (vlun_alloced) | |
4200 vhci_lun_free(tgt_dip); | |
4201 | |
4202 return (rval); | |
4203 } | |
4204 | |
4205 /* ARGSUSED */ | |
4206 static int | |
4207 vhci_pathinfo_uninit(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
4208 { | |
4209 scsi_hba_tran_t *hba = NULL; | |
4210 struct scsi_device *psd = NULL; | |
4211 dev_info_t *pdip = NULL; | |
4212 dev_info_t *cdip = NULL; | |
4213 scsi_vhci_priv_t *svp = NULL; | |
4214 | |
4215 ASSERT(vdip != NULL); | |
4216 ASSERT(pip != NULL); | |
4217 | |
4218 pdip = mdi_pi_get_phci(pip); | |
4219 ASSERT(pdip != NULL); | |
4220 | |
4221 cdip = mdi_pi_get_client(pip); | |
4222 ASSERT(cdip != NULL); | |
4223 | |
4224 hba = ddi_get_driver_private(pdip); | |
4225 ASSERT(hba != NULL); | |
4226 | |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
4227 vhci_mpapi_set_path_state(vdip, pip, MP_DRVR_PATH_STATE_UNINIT); |
4851 | 4228 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); |
4229 if (svp == NULL) { | |
4230 /* path already freed. Nothing to do. */ | |
4231 return (MDI_SUCCESS); | |
4232 } | |
4233 | |
4234 psd = svp->svp_psd; | |
4235 ASSERT(psd != NULL); | |
4236 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4237 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
|
4238 /* Verify plumbing */ |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
4239 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
|
4240 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
|
4241 } 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
|
4242 /* Switch to cloned scsi_hba_tran(9S) structure */ |
4851 | 4243 hba = psd->sd_address.a_hba_tran; |
4244 ASSERT(hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE); | |
4245 ASSERT(hba->tran_sd == psd); | |
4246 } | |
4247 | |
11556
99144956c627
6913819 SCSAv3: pmcs_scsa_tran_tgt_free: alignment error panic
Reed <Reed.Liu@Sun.COM>
parents:
11086
diff
changeset
|
4248 if ((hba->tran_tgt_free != NULL) && !psd->sd_tran_tgt_free_done) { |
4851 | 4249 (*hba->tran_tgt_free) (pdip, cdip, hba, psd); |
11556
99144956c627
6913819 SCSAv3: pmcs_scsa_tran_tgt_free: alignment error panic
Reed <Reed.Liu@Sun.COM>
parents:
11086
diff
changeset
|
4250 psd->sd_tran_tgt_free_done = 1; |
4851 | 4251 } |
4252 mutex_destroy(&psd->sd_mutex); | |
4253 if (hba->tran_hba_flags & SCSI_HBA_TRAN_CLONE) { | |
4254 kmem_free(hba, sizeof (*hba)); | |
4255 } | |
4256 | |
4257 mdi_pi_set_vhci_private(pip, NULL); | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4258 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4259 /* |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4260 * Free the pathinfo related scsi_device inquiry data. Note that this |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4261 * matches what happens for scsi_hba.c devinfo case at uninitchild time. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4262 */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4263 if (psd->sd_inq) |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4264 kmem_free((caddr_t)psd->sd_inq, sizeof (struct scsi_inquiry)); |
4851 | 4265 kmem_free((caddr_t)psd, sizeof (*psd)); |
4266 | |
4267 mutex_destroy(&svp->svp_mutex); | |
4268 cv_destroy(&svp->svp_cv); | |
4269 kmem_free((caddr_t)svp, sizeof (*svp)); | |
4270 | |
4271 /* | |
4272 * If this is the last path to the client, | |
4273 * then free up the vlun as well. | |
4274 */ | |
4275 if (mdi_client_get_path_count(cdip) == 1) { | |
4276 vhci_lun_free(cdip); | |
4277 } | |
4278 | |
4279 VHCI_DEBUG(4, (CE_NOTE, NULL, "!vhci_pathinfo_uninit: path=0x%p\n", | |
4280 (void *)pip)); | |
4281 return (MDI_SUCCESS); | |
4282 } | |
4283 | |
4284 /* ARGSUSED */ | |
4285 static int | |
4286 vhci_pathinfo_state_change(dev_info_t *vdip, mdi_pathinfo_t *pip, | |
4287 mdi_pathinfo_state_t state, uint32_t ext_state, int flags) | |
4288 { | |
4289 int rval = MDI_SUCCESS; | |
4290 scsi_vhci_priv_t *svp; | |
4291 scsi_vhci_lun_t *vlun; | |
4292 int held; | |
4293 int op = (flags & 0xf00) >> 8; | |
4294 struct scsi_vhci *vhci; | |
4295 | |
4296 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
4297 | |
4298 if (flags & MDI_EXT_STATE_CHANGE) { | |
4299 /* | |
4300 * We do not want to issue any commands down the path in case | |
4301 * sync flag is set. Lower layers might not be ready to accept | |
4302 * any I/O commands. | |
4303 */ | |
4304 if (op == DRIVER_DISABLE) | |
4305 return (MDI_SUCCESS); | |
4306 | |
4307 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
4308 if (svp == NULL) { | |
4309 return (MDI_FAILURE); | |
4310 } | |
4311 vlun = svp->svp_svl; | |
4312 | |
4313 if (flags & MDI_BEFORE_STATE_CHANGE) { | |
4314 /* | |
4315 * Hold the LUN. | |
4316 */ | |
4317 VHCI_HOLD_LUN(vlun, VH_SLEEP, held); | |
4318 if (flags & MDI_DISABLE_OP) { | |
4319 /* | |
4320 * Issue scsi reset if it happens to be | |
4321 * reserved path. | |
4322 */ | |
4323 if (vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
4324 /* | |
4325 * if reservation pending on | |
4326 * this path, dont' mark the | |
4327 * path busy | |
4328 */ | |
4329 if (op == DRIVER_DISABLE_TRANSIENT) { | |
4330 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
4331 "!vhci_pathinfo" | |
4332 "_state_change (pip:%p): " | |
4333 " reservation: fail busy\n", | |
4334 (void *)pip)); | |
4335 return (MDI_FAILURE); | |
4336 } | |
4337 if (pip == vlun->svl_resrv_pip) { | |
4338 if (vhci_recovery_reset( | |
4339 svp->svp_svl, | |
4340 &svp->svp_psd->sd_address, | |
4341 TRUE, | |
4342 VHCI_DEPTH_TARGET) == 0) { | |
4343 VHCI_DEBUG(1, | |
4344 (CE_NOTE, NULL, | |
4345 "!vhci_pathinfo" | |
4346 "_state_change " | |
4347 " (pip:%p): " | |
4348 "reset failed, " | |
4349 "give up!\n", | |
4350 (void *)pip)); | |
4351 } | |
4352 vlun->svl_flags &= | |
4353 ~VLUN_RESERVE_ACTIVE_FLG; | |
4354 } | |
4355 } | |
4356 } else if (flags & MDI_ENABLE_OP) { | |
4357 if (((vhci->vhci_conf_flags & | |
4358 VHCI_CONF_FLAGS_AUTO_FAILBACK) == | |
4359 VHCI_CONF_FLAGS_AUTO_FAILBACK) && | |
4360 MDI_PI_IS_USER_DISABLE(pip) && | |
4361 MDI_PI_IS_STANDBY(pip)) { | |
4362 struct scsi_failover_ops *fo; | |
4363 char *best_pclass, *pclass = NULL; | |
4364 int best_class, rv; | |
4365 /* | |
4366 * Failback if enabling a standby path | |
4367 * and it is the primary class or | |
4368 * preferred class | |
4369 */ | |
4370 best_class = mdi_pi_get_preferred(pip); | |
4371 if (best_class == 0) { | |
4372 /* | |
4373 * if not preferred - compare | |
4374 * path-class with class | |
4375 */ | |
4376 fo = vlun->svl_fops; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4377 (void) fo->sfo_pathclass_next( |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4378 NULL, &best_pclass, |
4851 | 4379 vlun->svl_fops_ctpriv); |
4380 pclass = NULL; | |
4381 rv = mdi_prop_lookup_string(pip, | |
4382 "path-class", &pclass); | |
4383 if (rv != MDI_SUCCESS || | |
4384 pclass == NULL) { | |
4385 vhci_log(CE_NOTE, vdip, | |
4386 "!path-class " | |
4387 " lookup " | |
4388 "failed. rv: %d" | |
4389 "class: %p", rv, | |
4390 (void *)pclass); | |
4391 } else if (strncmp(pclass, | |
4392 best_pclass, | |
4393 strlen(best_pclass)) == 0) { | |
4394 best_class = 1; | |
4395 } | |
4396 if (rv == MDI_SUCCESS && | |
4397 pclass != NULL) { | |
4398 rv = mdi_prop_free( | |
4399 pclass); | |
4400 if (rv != | |
4401 DDI_PROP_SUCCESS) { | |
4402 vhci_log( | |
4403 CE_NOTE, | |
4404 vdip, | |
4405 "!path-" | |
4406 "class" | |
4407 " free" | |
4408 " failed" | |
4409 " rv: %d" | |
4410 " class: " | |
4411 "%p", | |
4412 rv, | |
4413 (void *) | |
4414 pclass); | |
4415 } | |
4416 } | |
4417 } | |
4418 if (best_class == 1) { | |
4419 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
4420 "preferred path: %p " | |
4421 "USER_DISABLE->USER_ENABLE " | |
4422 "transition for lun %s\n", | |
4423 (void *)pip, | |
4424 vlun->svl_lun_wwn)); | |
4425 (void) taskq_dispatch( | |
4426 vhci->vhci_taskq, | |
4427 vhci_initiate_auto_failback, | |
4428 (void *) vlun, KM_SLEEP); | |
4429 } | |
4430 } | |
4431 /* | |
4432 * if PGR is active, revalidate key and | |
4433 * register on this path also, if key is | |
4434 * still valid | |
4435 */ | |
4436 sema_p(&vlun->svl_pgr_sema); | |
4437 if (vlun->svl_pgr_active) | |
4438 (void) | |
4439 vhci_pgr_validate_and_register(svp); | |
4440 sema_v(&vlun->svl_pgr_sema); | |
4441 /* | |
4442 * Inform target driver about any | |
4443 * reservations to be reinstated if target | |
4444 * has dropped reservation during the busy | |
4445 * period. | |
4446 */ | |
4447 mutex_enter(&vhci->vhci_mutex); | |
4448 scsi_hba_reset_notify_callback( | |
4449 &vhci->vhci_mutex, | |
4450 &vhci->vhci_reset_notify_listf); | |
4451 mutex_exit(&vhci->vhci_mutex); | |
4452 } | |
4453 } | |
4454 if (flags & MDI_AFTER_STATE_CHANGE) { | |
4455 if (flags & MDI_ENABLE_OP) { | |
4456 mutex_enter(&vhci_global_mutex); | |
4457 cv_broadcast(&vhci_cv); | |
4458 mutex_exit(&vhci_global_mutex); | |
4459 } | |
4460 if (vlun->svl_setcap_done) { | |
4461 (void) vhci_pHCI_cap(&svp->svp_psd->sd_address, | |
4462 "sector-size", vlun->svl_sector_size, | |
4463 1, pip); | |
4464 } | |
4465 | |
4466 /* | |
4467 * Release the LUN | |
4468 */ | |
4469 VHCI_RELEASE_LUN(vlun); | |
4470 | |
4471 /* | |
4472 * Path transition is complete. | |
4473 * Run callback to indicate target driver to | |
4474 * retry to prevent IO starvation. | |
4475 */ | |
4476 if (scsi_callback_id != 0) { | |
4477 ddi_run_callback(&scsi_callback_id); | |
4478 } | |
4479 } | |
4480 } else { | |
4481 switch (state) { | |
4482 case MDI_PATHINFO_STATE_ONLINE: | |
4483 rval = vhci_pathinfo_online(vdip, pip, flags); | |
4484 break; | |
4485 | |
4486 case MDI_PATHINFO_STATE_OFFLINE: | |
4487 rval = vhci_pathinfo_offline(vdip, pip, flags); | |
4488 break; | |
4489 | |
4490 default: | |
4491 break; | |
4492 } | |
4493 /* | |
4494 * Path transition is complete. | |
4495 * Run callback to indicate target driver to | |
4496 * retry to prevent IO starvation. | |
4497 */ | |
4498 if ((rval == MDI_SUCCESS) && (scsi_callback_id != 0)) { | |
4499 ddi_run_callback(&scsi_callback_id); | |
4500 } | |
4501 return (rval); | |
4502 } | |
4503 | |
4504 return (MDI_SUCCESS); | |
4505 } | |
4506 | |
4507 /* | |
4508 * Parse the mpxio load balancing options. The datanameptr | |
4509 * will point to a string containing the load-balance-options value. | |
4510 * The load-balance-options value will be a property that | |
4511 * defines the load-balance algorithm and any arguments to that | |
4512 * algorithm. | |
4513 * For example: | |
4514 * device-type-mpxio-options-list= | |
4515 * "device-type=SUN SENA", "load-balance-options=logical-block-options" | |
4516 * "device-type=SUN SE6920", "round-robin-options"; | |
4517 * logical-block-options="load-balance=logical-block", "region-size=15"; | |
4518 * round-robin-options="load-balance=round-robin"; | |
4519 * | |
4520 * If the load-balance is not defined the load balance algorithm will | |
4521 * default to the global setting. There will be default values assigned | |
4522 * to the arguments (region-size=18) and if an argument is one | |
4523 * that is not known, it will be ignored. | |
4524 */ | |
4525 static void | |
4526 vhci_parse_mpxio_lb_options(dev_info_t *dip, dev_info_t *cdip, | |
4527 caddr_t datanameptr) | |
4528 { | |
4529 char *dataptr, *next_entry; | |
4530 caddr_t config_list = NULL; | |
4531 int config_list_len = 0, list_len = 0; | |
4532 int region_size = -1; | |
4533 client_lb_t load_balance; | |
4534 | |
4535 if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, datanameptr, | |
4536 (caddr_t)&config_list, &config_list_len) != DDI_PROP_SUCCESS) { | |
4537 return; | |
4538 } | |
4539 | |
4540 list_len = config_list_len; | |
4541 next_entry = config_list; | |
4542 while (config_list_len > 0) { | |
4543 dataptr = next_entry; | |
4544 | |
4545 if (strncmp(mdi_load_balance, dataptr, | |
4546 strlen(mdi_load_balance)) == 0) { | |
4547 /* get the load-balance scheme */ | |
4548 dataptr += strlen(mdi_load_balance) + 1; | |
4549 if (strcmp(dataptr, LOAD_BALANCE_PROP_RR) == 0) { | |
4550 (void) mdi_set_lb_policy(cdip, LOAD_BALANCE_RR); | |
4551 load_balance = LOAD_BALANCE_RR; | |
4552 } else if (strcmp(dataptr, | |
4553 LOAD_BALANCE_PROP_LBA) == 0) { | |
4554 (void) mdi_set_lb_policy(cdip, | |
4555 LOAD_BALANCE_LBA); | |
4556 load_balance = LOAD_BALANCE_LBA; | |
4557 } else if (strcmp(dataptr, | |
4558 LOAD_BALANCE_PROP_NONE) == 0) { | |
4559 (void) mdi_set_lb_policy(cdip, | |
4560 LOAD_BALANCE_NONE); | |
4561 load_balance = LOAD_BALANCE_NONE; | |
4562 } | |
4563 } else if (strncmp(dataptr, LOGICAL_BLOCK_REGION_SIZE, | |
4564 strlen(LOGICAL_BLOCK_REGION_SIZE)) == 0) { | |
4565 int i = 0; | |
4566 char *ptr; | |
4567 char *tmp; | |
4568 | |
4569 tmp = dataptr + (strlen(LOGICAL_BLOCK_REGION_SIZE) + 1); | |
4570 /* check for numeric value */ | |
4571 for (ptr = tmp; i < strlen(tmp); i++, ptr++) { | |
4572 if (!isdigit(*ptr)) { | |
4573 cmn_err(CE_WARN, | |
4574 "Illegal region size: %s." | |
4575 " Setting to default value: %d", | |
4576 tmp, | |
4577 LOAD_BALANCE_DEFAULT_REGION_SIZE); | |
4578 region_size = | |
4579 LOAD_BALANCE_DEFAULT_REGION_SIZE; | |
4580 break; | |
4581 } | |
4582 } | |
4583 if (i >= strlen(tmp)) { | |
4584 region_size = stoi(&tmp); | |
4585 } | |
4586 (void) mdi_set_lb_region_size(cdip, region_size); | |
4587 } | |
4588 config_list_len -= (strlen(next_entry) + 1); | |
4589 next_entry += strlen(next_entry) + 1; | |
4590 } | |
4591 #ifdef DEBUG | |
4592 if ((region_size >= 0) && (load_balance != LOAD_BALANCE_LBA)) { | |
4593 VHCI_DEBUG(1, (CE_NOTE, dip, | |
4594 "!vhci_parse_mpxio_lb_options: region-size: %d" | |
4595 "only valid for load-balance=logical-block\n", | |
4596 region_size)); | |
4597 } | |
4598 #endif | |
4599 if ((region_size == -1) && (load_balance == LOAD_BALANCE_LBA)) { | |
4600 VHCI_DEBUG(1, (CE_NOTE, dip, | |
4601 "!vhci_parse_mpxio_lb_options: No region-size" | |
4602 " defined load-balance=logical-block." | |
4603 " Default to: %d\n", LOAD_BALANCE_DEFAULT_REGION_SIZE)); | |
4604 (void) mdi_set_lb_region_size(cdip, | |
4605 LOAD_BALANCE_DEFAULT_REGION_SIZE); | |
4606 } | |
4607 if (list_len > 0) { | |
4608 kmem_free(config_list, list_len); | |
4609 } | |
4610 } | |
4611 | |
4612 /* | |
4613 * Parse the device-type-mpxio-options-list looking for the key of | |
4614 * "load-balance-options". If found, parse the load balancing options. | |
4615 * Check the comment of the vhci_get_device_type_mpxio_options() | |
4616 * for the device-type-mpxio-options-list. | |
4617 */ | |
4618 static void | |
4619 vhci_parse_mpxio_options(dev_info_t *dip, dev_info_t *cdip, | |
4620 caddr_t datanameptr, int list_len) | |
4621 { | |
4622 char *dataptr; | |
4623 int len; | |
4624 | |
4625 /* | |
4626 * get the data list | |
4627 */ | |
4628 dataptr = datanameptr; | |
4629 len = 0; | |
4630 while (len < list_len && | |
4631 strncmp(dataptr, DEVICE_TYPE_STR, strlen(DEVICE_TYPE_STR)) | |
4632 != 0) { | |
4633 if (strncmp(dataptr, LOAD_BALANCE_OPTIONS, | |
4634 strlen(LOAD_BALANCE_OPTIONS)) == 0) { | |
4635 len += strlen(LOAD_BALANCE_OPTIONS) + 1; | |
4636 dataptr += strlen(LOAD_BALANCE_OPTIONS) + 1; | |
4637 vhci_parse_mpxio_lb_options(dip, cdip, dataptr); | |
4638 } | |
4639 len += strlen(dataptr) + 1; | |
4640 dataptr += strlen(dataptr) + 1; | |
4641 } | |
4642 } | |
4643 | |
4644 /* | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4645 * Check the inquriy string returned from the device with the device-type |
4851 | 4646 * Check for the existence of the device-type-mpxio-options-list and |
4647 * if found parse the list checking for a match with the device-type | |
4648 * value and the inquiry string returned from the device. If a match | |
4649 * is found, parse the mpxio options list. The format of the | |
4650 * device-type-mpxio-options-list is: | |
4651 * device-type-mpxio-options-list= | |
4652 * "device-type=SUN SENA", "load-balance-options=logical-block-options" | |
4653 * "device-type=SUN SE6920", "round-robin-options"; | |
4654 * logical-block-options="load-balance=logical-block", "region-size=15"; | |
4655 * round-robin-options="load-balance=round-robin"; | |
4656 */ | |
4657 void | |
4658 vhci_get_device_type_mpxio_options(dev_info_t *dip, dev_info_t *cdip, | |
4659 struct scsi_device *devp) | |
4660 { | |
4661 | |
4662 caddr_t config_list = NULL; | |
4663 caddr_t vidptr, datanameptr; | |
4664 int vidlen, dupletlen = 0; | |
4665 int config_list_len = 0, len; | |
4666 struct scsi_inquiry *inq = devp->sd_inq; | |
4667 | |
4668 /* | |
4669 * look up the device-type-mpxio-options-list and walk thru | |
4670 * the list compare the vendor ids of the earlier inquiry command and | |
4671 * with those vids in the list if there is a match, lookup | |
4672 * the mpxio-options value | |
4673 */ | |
4674 if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, | |
4675 MPXIO_OPTIONS_LIST, | |
4676 (caddr_t)&config_list, &config_list_len) == DDI_PROP_SUCCESS) { | |
4677 | |
4678 /* | |
4679 * Compare vids in each duplet - if it matches, | |
4680 * parse the mpxio options list. | |
4681 */ | |
4682 for (len = config_list_len, vidptr = config_list; len > 0; | |
4683 len -= dupletlen) { | |
4684 | |
4685 dupletlen = 0; | |
4686 | |
4687 if (strlen(vidptr) != 0 && | |
4688 strncmp(vidptr, DEVICE_TYPE_STR, | |
4689 strlen(DEVICE_TYPE_STR)) == 0) { | |
4690 /* point to next duplet */ | |
4691 datanameptr = vidptr + strlen(vidptr) + 1; | |
4692 /* add len of this duplet */ | |
4693 dupletlen += strlen(vidptr) + 1; | |
4694 /* get to device type */ | |
4695 vidptr += strlen(DEVICE_TYPE_STR) + 1; | |
4696 vidlen = strlen(vidptr); | |
4697 if ((vidlen != 0) && | |
4698 bcmp(inq->inq_vid, vidptr, vidlen) == 0) { | |
4699 vhci_parse_mpxio_options(dip, cdip, | |
4700 datanameptr, len - dupletlen); | |
4701 break; | |
4702 } | |
4703 /* get to next duplet */ | |
4704 vidptr += strlen(vidptr) + 1; | |
4705 } | |
4706 /* get to the next device-type */ | |
4707 while (len - dupletlen > 0 && | |
4708 strlen(vidptr) != 0 && | |
4709 strncmp(vidptr, DEVICE_TYPE_STR, | |
4710 strlen(DEVICE_TYPE_STR)) != 0) { | |
4711 dupletlen += strlen(vidptr) + 1; | |
4712 vidptr += strlen(vidptr) + 1; | |
4713 } | |
4714 } | |
4715 if (config_list_len > 0) { | |
4716 kmem_free(config_list, config_list_len); | |
4717 } | |
4718 } | |
4719 } | |
4720 | |
4721 static int | |
4722 vhci_update_pathinfo(struct scsi_device *psd, mdi_pathinfo_t *pip, | |
4723 struct scsi_failover_ops *fo, | |
4724 scsi_vhci_lun_t *vlun, | |
4725 struct scsi_vhci *vhci) | |
4726 { | |
4727 struct scsi_path_opinfo opinfo; | |
4728 char *pclass, *best_pclass; | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4729 char *resrv_pclass = NULL; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4730 int force_rereserve = 0; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4731 int update_pathinfo_done = 0; |
4851 | 4732 |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4733 if (fo->sfo_path_get_opinfo(psd, &opinfo, vlun->svl_fops_ctpriv) != 0) { |
4851 | 4734 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_update_pathinfo: " |
4735 "Failed to get operation info for path:%p\n", (void *)pip)); | |
4736 return (MDI_FAILURE); | |
4737 } | |
4738 /* set the xlf capable flag in the vlun for future use */ | |
4739 vlun->svl_xlf_capable = opinfo.opinfo_xlf_capable; | |
4740 (void) mdi_prop_update_string(pip, "path-class", | |
4741 opinfo.opinfo_path_attr); | |
4742 | |
4743 pclass = opinfo.opinfo_path_attr; | |
4744 if (opinfo.opinfo_path_state == SCSI_PATH_ACTIVE) { | |
4745 mutex_enter(&vlun->svl_mutex); | |
4746 if (vlun->svl_active_pclass != NULL) { | |
4747 if (strcmp(vlun->svl_active_pclass, pclass) != 0) { | |
4748 mutex_exit(&vlun->svl_mutex); | |
4749 /* | |
4750 * Externally initiated failover has happened; | |
4751 * force the path state to be STANDBY/ONLINE, | |
4752 * next IO will trigger failover and thus | |
4753 * sync-up the pathstates. Reason we don't | |
4754 * sync-up immediately by invoking | |
4755 * vhci_update_pathstates() is because it | |
4756 * needs a VHCI_HOLD_LUN() and we don't | |
4757 * want to block here. | |
4758 * | |
4759 * Further, if the device is an ALUA device, | |
4760 * then failure to exactly match 'pclass' and | |
4761 * 'svl_active_pclass'(as is the case here) | |
4762 * indicates that the currently active path | |
4763 * is a 'non-optimized' path - which means | |
4764 * that 'svl_active_pclass' needs to be | |
4765 * replaced with opinfo.opinfo_path_state | |
4766 * value. | |
4767 */ | |
4768 | |
4769 if (SCSI_FAILOVER_IS_TPGS(vlun->svl_fops)) { | |
4770 char *tptr; | |
4771 | |
4772 /* | |
4773 * The device is ALUA compliant. The | |
4774 * state need to be changed to online | |
4775 * rather than standby state which is | |
4776 * done typically for a asymmetric | |
4777 * device that is non ALUA compliant. | |
4778 */ | |
4779 mdi_pi_set_state(pip, | |
4780 MDI_PATHINFO_STATE_ONLINE); | |
4781 tptr = kmem_alloc(strlen | |
4782 (opinfo.opinfo_path_attr)+1, | |
4783 KM_SLEEP); | |
4784 (void) strlcpy(tptr, | |
4785 opinfo.opinfo_path_attr, | |
4786 (strlen(opinfo.opinfo_path_attr) | |
4787 +1)); | |
4788 mutex_enter(&vlun->svl_mutex); | |
4789 kmem_free(vlun->svl_active_pclass, | |
4790 strlen(vlun->svl_active_pclass)+1); | |
4791 vlun->svl_active_pclass = tptr; | |
4792 mutex_exit(&vlun->svl_mutex); | |
4793 } else { | |
4794 /* | |
4795 * Non ALUA device case. | |
4796 */ | |
4797 mdi_pi_set_state(pip, | |
4798 MDI_PATHINFO_STATE_STANDBY); | |
4799 } | |
4800 vlun->svl_fo_support = opinfo.opinfo_mode; | |
4801 mdi_pi_set_preferred(pip, | |
4802 opinfo.opinfo_preferred); | |
12945
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4803 update_pathinfo_done = 1; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4804 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4805 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4806 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4807 * Find out a class of currently reserved path if there |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4808 * is any. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4809 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4810 if ((vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) && |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4811 mdi_prop_lookup_string(vlun->svl_resrv_pip, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4812 "path-class", &resrv_pclass) != MDI_SUCCESS) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4813 VHCI_DEBUG(1, (CE_NOTE, NULL, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4814 "!vhci_update_pathinfo: prop lookup " |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4815 "failed for path 0x%p\n", |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4816 (void *)vlun->svl_resrv_pip)); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4817 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4818 * Something is wrong with the reserved path. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4819 * We can't do much with that right here. Just |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4820 * force re-reservation to another path. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4821 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4822 force_rereserve = 1; |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4823 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4824 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4825 (void) fo->sfo_pathclass_next(NULL, &best_pclass, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4826 vlun->svl_fops_ctpriv); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4827 if ((force_rereserve == 1) || ((resrv_pclass != NULL) && |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4828 (strcmp(pclass, best_pclass) == 0) && |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4829 (strcmp(resrv_pclass, best_pclass) != 0))) { |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4830 /* |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4831 * Inform target driver that a reservation |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4832 * should be reinstated because the reserved |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4833 * path is not the most preferred one. |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4834 */ |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4835 mutex_enter(&vhci->vhci_mutex); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4836 scsi_hba_reset_notify_callback( |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4837 &vhci->vhci_mutex, |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4838 &vhci->vhci_reset_notify_listf); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4839 mutex_exit(&vhci->vhci_mutex); |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4840 } |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4841 |
b51957425f56
6935296 Host gets reservation conflict when I/O moves from not-optimized to optimized path
Milos Muzik <Milos.Muzik@Sun.COM>
parents:
12310
diff
changeset
|
4842 if (update_pathinfo_done == 1) { |
4851 | 4843 return (MDI_SUCCESS); |
4844 } | |
4845 } else { | |
4846 char *tptr; | |
4847 | |
4848 /* | |
4849 * lets release the mutex before we try to | |
4850 * allocate since the potential to sleep is | |
4851 * possible. | |
4852 */ | |
4853 mutex_exit(&vlun->svl_mutex); | |
4854 tptr = kmem_alloc(strlen(pclass)+1, KM_SLEEP); | |
4855 (void) strlcpy(tptr, pclass, (strlen(pclass)+1)); | |
4856 mutex_enter(&vlun->svl_mutex); | |
4857 vlun->svl_active_pclass = tptr; | |
4858 } | |
4859 mutex_exit(&vlun->svl_mutex); | |
4860 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_ONLINE); | |
4861 vlun->svl_waiting_for_activepath = 0; | |
4862 } else if (opinfo.opinfo_path_state == SCSI_PATH_ACTIVE_NONOPT) { | |
4863 mutex_enter(&vlun->svl_mutex); | |
4864 if (vlun->svl_active_pclass == NULL) { | |
4865 char *tptr; | |
4866 | |
4867 mutex_exit(&vlun->svl_mutex); | |
4868 tptr = kmem_alloc(strlen(pclass)+1, KM_SLEEP); | |
4869 (void) strlcpy(tptr, pclass, (strlen(pclass)+1)); | |
4870 mutex_enter(&vlun->svl_mutex); | |
4871 vlun->svl_active_pclass = tptr; | |
4872 } | |
4873 mutex_exit(&vlun->svl_mutex); | |
4874 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_ONLINE); | |
4875 vlun->svl_waiting_for_activepath = 0; | |
4876 } else if (opinfo.opinfo_path_state == SCSI_PATH_INACTIVE) { | |
4877 mutex_enter(&vlun->svl_mutex); | |
4878 if (vlun->svl_active_pclass != NULL) { | |
4879 if (strcmp(vlun->svl_active_pclass, pclass) == 0) { | |
4880 mutex_exit(&vlun->svl_mutex); | |
4881 /* | |
4882 * externally initiated failover has happened; | |
4883 * force state to ONLINE (see comment above) | |
4884 */ | |
4885 mdi_pi_set_state(pip, | |
4886 MDI_PATHINFO_STATE_ONLINE); | |
4887 vlun->svl_fo_support = opinfo.opinfo_mode; | |
4888 mdi_pi_set_preferred(pip, | |
4889 opinfo.opinfo_preferred); | |
4890 return (MDI_SUCCESS); | |
4891 } | |
4892 } | |
4893 mutex_exit(&vlun->svl_mutex); | |
4894 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_STANDBY); | |
4895 | |
4896 /* | |
4897 * Initiate auto-failback, if enabled, for path if path-state | |
4898 * is transitioning from OFFLINE->STANDBY and pathclass is the | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4899 * preferred pathclass for this storage. |
4851 | 4900 * NOTE: In case where opinfo_path_state is SCSI_PATH_ACTIVE |
4901 * (above), where the pi state is set to STANDBY, we don't | |
4902 * initiate auto-failback as the next IO shall take care of. | |
4903 * this. See comment above. | |
4904 */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
4905 (void) fo->sfo_pathclass_next(NULL, &best_pclass, |
4851 | 4906 vlun->svl_fops_ctpriv); |
4907 if (((vhci->vhci_conf_flags & VHCI_CONF_FLAGS_AUTO_FAILBACK) == | |
4908 VHCI_CONF_FLAGS_AUTO_FAILBACK) && | |
9667
dde823a17c3c
6661528 With mpt patch 125081-14 installed, a server reboot cause error messages and volume failover on 6540
Chris Liu <Chris.Liu@Sun.COM>
parents:
9304
diff
changeset
|
4909 (strcmp(pclass, best_pclass) == 0) && |
4851 | 4910 ((MDI_PI_OLD_STATE(pip) == MDI_PATHINFO_STATE_OFFLINE)|| |
4911 (MDI_PI_OLD_STATE(pip) == MDI_PATHINFO_STATE_INIT))) { | |
4912 VHCI_DEBUG(1, (CE_NOTE, NULL, "%s pathclass path: %p" | |
4913 " OFFLINE->STANDBY transition for lun %s\n", | |
4914 best_pclass, (void *)pip, vlun->svl_lun_wwn)); | |
4915 (void) taskq_dispatch(vhci->vhci_taskq, | |
4916 vhci_initiate_auto_failback, (void *) vlun, | |
4917 KM_SLEEP); | |
4918 } | |
4919 } | |
4920 vlun->svl_fo_support = opinfo.opinfo_mode; | |
4921 mdi_pi_set_preferred(pip, opinfo.opinfo_preferred); | |
4922 | |
4923 VHCI_DEBUG(8, (CE_NOTE, NULL, "vhci_update_pathinfo: opinfo_rev = %x," | |
4924 " opinfo_path_state = %x opinfo_preferred = %x, opinfo_mode = %x\n", | |
4925 opinfo.opinfo_rev, opinfo.opinfo_path_state, | |
4926 opinfo.opinfo_preferred, opinfo.opinfo_mode)); | |
4927 | |
4928 return (MDI_SUCCESS); | |
4929 } | |
4930 | |
4931 /* | |
4932 * Form the kstat name and and call mdi_pi_kstat_create() | |
4933 */ | |
4934 void | |
4935 vhci_kstat_create_pathinfo(mdi_pathinfo_t *pip) | |
4936 { | |
4937 dev_info_t *tgt_dip; | |
4938 dev_info_t *pdip; | |
4939 char *guid; | |
4940 char *target_port, *target_port_dup; | |
4941 char ks_name[KSTAT_STRLEN]; | |
4942 uint_t pid; | |
4943 int by_id; | |
4944 mod_hash_val_t hv; | |
4945 | |
4946 | |
4947 /* return if we have already allocated kstats */ | |
4948 if (mdi_pi_kstat_exists(pip)) | |
4949 return; | |
4950 | |
4951 /* | |
4952 * We need instance numbers to create a kstat name, return if we don't | |
4953 * have instance numbers assigned yet. | |
4954 */ | |
4955 tgt_dip = mdi_pi_get_client(pip); | |
4956 pdip = mdi_pi_get_phci(pip); | |
4957 if ((ddi_get_instance(tgt_dip) == -1) || (ddi_get_instance(pdip) == -1)) | |
4958 return; | |
4959 | |
4960 /* | |
4961 * A path oriented kstat has a ks_name of the form: | |
4962 * | |
4963 * <client-driver><instance>.t<pid>.<pHCI-driver><instance> | |
4964 * | |
4965 * We maintain a bidirectional 'target-port' to <pid> map, | |
4966 * called targetmap. All pathinfo nodes with the same | |
4967 * 'target-port' map to the same <pid>. The iostat(1M) code, | |
4968 * when parsing a path oriented kstat name, uses the <pid> as | |
4969 * a SCSI_VHCI_GET_TARGET_LONGNAME ioctl argument in order | |
4970 * to get the 'target-port'. For KSTAT_FLAG_PERSISTENT kstats, | |
4971 * this ioctl needs to translate a <pid> to a 'target-port' | |
4972 * even after all pathinfo nodes associated with the | |
4973 * 'target-port' have been destroyed. This is needed to support | |
4974 * consistent first-iteration activity-since-boot iostat(1M) | |
4975 * output. Because of this requirement, the mapping can't be | |
4976 * based on pathinfo information in a devinfo snapshot. | |
4977 */ | |
4978 | |
4979 /* determine 'target-port' */ | |
4980 if (mdi_prop_lookup_string(pip, | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
4981 SCSI_ADDR_PROP_TARGET_PORT, &target_port) == MDI_SUCCESS) { |
4851 | 4982 target_port_dup = i_ddi_strdup(target_port, KM_SLEEP); |
4983 (void) mdi_prop_free(target_port); | |
4984 by_id = 1; | |
4985 } else { | |
4986 /* | |
4987 * If the pHCI did not set up 'target-port' on this | |
4988 * pathinfo node, assume that our client is the only | |
4989 * one with paths to the device by using the guid | |
4990 * value as the 'target-port'. Since no other client | |
4991 * will have the same guid, no other client will use | |
4992 * the same <pid>. NOTE: a client with an instance | |
4993 * number always has a guid. | |
4994 */ | |
4995 (void) ddi_prop_lookup_string(DDI_DEV_T_ANY, tgt_dip, | |
4996 PROPFLAGS, MDI_CLIENT_GUID_PROP, &guid); | |
4997 target_port_dup = i_ddi_strdup(guid, KM_SLEEP); | |
4998 ddi_prop_free(guid); | |
4999 | |
5000 /* | |
5001 * For this type of mapping we don't want the | |
5002 * <id> -> 'target-port' mapping to be made. This | |
5003 * will cause the SCSI_VHCI_GET_TARGET_LONGNAME ioctl | |
5004 * to fail, and the iostat(1M) long '-n' output will | |
5005 * still use the <pid>. We do this because we just | |
5006 * made up the 'target-port' using the guid, and we | |
5007 * don't want to expose that fact in iostat output. | |
5008 */ | |
5009 by_id = 0; | |
5010 } | |
5011 | |
5012 /* find/establish <pid> given 'target-port' */ | |
5013 mutex_enter(&vhci_targetmap_mutex); | |
5014 if (mod_hash_find(vhci_targetmap_byport, | |
5015 (mod_hash_key_t)target_port_dup, &hv) == 0) { | |
5016 pid = (int)(intptr_t)hv; /* mapping exists */ | |
5017 } else { | |
5018 pid = vhci_targetmap_pid++; /* new mapping */ | |
5019 | |
5020 (void) mod_hash_insert(vhci_targetmap_byport, | |
5021 (mod_hash_key_t)target_port_dup, | |
5022 (mod_hash_val_t)(intptr_t)pid); | |
5023 if (by_id) { | |
5024 (void) mod_hash_insert(vhci_targetmap_bypid, | |
5025 (mod_hash_key_t)(uintptr_t)pid, | |
5026 (mod_hash_val_t)(uintptr_t)target_port_dup); | |
5027 } | |
5028 target_port_dup = NULL; /* owned by hash */ | |
5029 } | |
5030 mutex_exit(&vhci_targetmap_mutex); | |
5031 | |
5032 /* form kstat name */ | |
5033 (void) snprintf(ks_name, KSTAT_STRLEN, "%s%d.t%d.%s%d", | |
5034 ddi_driver_name(tgt_dip), ddi_get_instance(tgt_dip), | |
5035 pid, ddi_driver_name(pdip), ddi_get_instance(pdip)); | |
5036 | |
5037 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_path_online: path:%p " | |
5038 "kstat %s: pid %x <-> port %s\n", (void *)pip, | |
5039 ks_name, pid, target_port_dup)); | |
5040 if (target_port_dup) | |
5041 kmem_free(target_port_dup, strlen(target_port_dup) + 1); | |
5042 | |
5043 /* call mdi to create kstats with the name we built */ | |
5044 (void) mdi_pi_kstat_create(pip, ks_name); | |
5045 } | |
5046 | |
5047 /* ARGSUSED */ | |
5048 static int | |
5049 vhci_pathinfo_online(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
5050 { | |
5051 scsi_hba_tran_t *hba = NULL; | |
5052 struct scsi_device *psd = NULL; | |
5053 scsi_vhci_lun_t *vlun = NULL; | |
5054 dev_info_t *pdip = NULL; | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5055 dev_info_t *cdip; |
4851 | 5056 dev_info_t *tgt_dip; |
5057 struct scsi_vhci *vhci; | |
5058 char *guid; | |
5059 struct scsi_failover_ops *sfo; | |
5060 scsi_vhci_priv_t *svp = NULL; | |
5061 struct scsi_address *ap; | |
5062 struct scsi_pkt *pkt; | |
5063 int rval = MDI_FAILURE; | |
5064 mpapi_item_list_t *list_ptr; | |
5065 mpapi_lu_data_t *ld; | |
5066 | |
5067 ASSERT(vdip != NULL); | |
5068 ASSERT(pip != NULL); | |
5069 | |
5070 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
5071 ASSERT(vhci != NULL); | |
5072 | |
5073 pdip = mdi_pi_get_phci(pip); | |
5074 hba = ddi_get_driver_private(pdip); | |
5075 ASSERT(hba != NULL); | |
5076 | |
5077 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
5078 ASSERT(svp != NULL); | |
5079 | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5080 cdip = mdi_pi_get_client(pip); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5081 ASSERT(cdip != NULL); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5082 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, cdip, PROPFLAGS, |
4851 | 5083 MDI_CLIENT_GUID_PROP, &guid) != DDI_SUCCESS) { |
5084 VHCI_DEBUG(1, (CE_WARN, NULL, "vhci_path_online: lun guid " | |
5085 "property failed")); | |
5086 goto failure; | |
5087 } | |
5088 | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5089 vlun = vhci_lun_lookup(cdip); |
4851 | 5090 ASSERT(vlun != NULL); |
5091 | |
5092 ddi_prop_free(guid); | |
5093 | |
5094 vlun->svl_dip = mdi_pi_get_client(pip); | |
5095 ASSERT(vlun->svl_dip != NULL); | |
5096 | |
5097 psd = svp->svp_psd; | |
5098 ASSERT(psd != NULL); | |
5099 | |
12987
3086793bcf3c
6914412 FC initiator host panic when FC array mp_support change
Kevin Yu <Kevin.Yu@Sun.COM>
parents:
12945
diff
changeset
|
5100 ap = &psd->sd_address; |
3086793bcf3c
6914412 FC initiator host panic when FC array mp_support change
Kevin Yu <Kevin.Yu@Sun.COM>
parents:
12945
diff
changeset
|
5101 |
4851 | 5102 /* |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5103 * Get inquiry data into pathinfo related scsi_device structure. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5104 * Free sq_inq when pathinfo related scsi_device structure is destroyed |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5105 * by vhci_pathinfo_uninit(). In other words, vhci maintains its own |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5106 * copy of scsi_device and scsi_inquiry data on a per-path basis. |
4851 | 5107 */ |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5108 if (scsi_probe(psd, SLEEP_FUNC) != SCSIPROBE_EXISTS) { |
4851 | 5109 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_pathinfo_online: " |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5110 "scsi_probe failed path:%p rval:%x\n", (void *)pip, rval)); |
4851 | 5111 rval = MDI_FAILURE; |
5112 goto failure; | |
5113 } | |
5114 | |
5115 /* | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5116 * See if we have a failover module to support the device. |
4851 | 5117 * |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5118 * We re-probe to determine the failover ops for each path. This |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5119 * is done in case there are any path-specific side-effects associated |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5120 * with the sfo_device_probe implementation. |
4851 | 5121 * |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5122 * Give the first successfull sfo_device_probe the opportunity to |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5123 * establish 'ctpriv', vlun/client private data. The ctpriv will |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5124 * then be passed into the failover module on all other sfo_device_*() |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5125 * operations (and must be freed by sfo_device_unprobe implementation). |
4851 | 5126 * |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5127 * NOTE: While sfo_device_probe is done once per path, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5128 * sfo_device_unprobe only occurs once - when the vlun is destroyed. |
4851 | 5129 * |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5130 * NOTE: We don't currently support per-path fops private data |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5131 * mechanism. |
4851 | 5132 */ |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5133 sfo = vhci_dev_fo(vdip, psd, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5134 &vlun->svl_fops_ctpriv, &vlun->svl_fops_name); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5135 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5136 /* check path configuration result with current vlun state */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5137 if (((sfo && vlun->svl_fops) && (sfo != vlun->svl_fops)) || |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5138 (sfo && vlun->svl_not_supported) || |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5139 ((sfo == NULL) && vlun->svl_fops)) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5140 /* Getting different results for different paths. */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5141 VHCI_DEBUG(1, (CE_NOTE, vhci->vhci_dip, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5142 "!vhci_pathinfo_online: dev (path 0x%p) contradiction\n", |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5143 (void *)pip)); |
11032
f786e11b2123
6876552 Remove CE_PANIC on failover contradiction
Chris Liu <Chris.Liu@Sun.COM>
parents:
10967
diff
changeset
|
5144 cmn_err(CE_WARN, "scsi_vhci: failover contradiction: " |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5145 "'%s'.vs.'%s': path %s\n", |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5146 vlun->svl_fops ? vlun->svl_fops->sfo_name : "NULL", |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5147 sfo ? sfo->sfo_name : "NULL", mdi_pi_pathname(pip)); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5148 vlun->svl_not_supported = 1; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5149 rval = MDI_NOT_SUPPORTED; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5150 goto done; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5151 } else if (sfo == NULL) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5152 /* No failover module - device not supported under vHCI. */ |
4851 | 5153 VHCI_DEBUG(1, (CE_NOTE, vhci->vhci_dip, |
5154 "!vhci_pathinfo_online: dev (path 0x%p) not " | |
5155 "supported\n", (void *)pip)); | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5156 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5157 /* XXX does this contradict vhci_is_dev_supported ? */ |
4851 | 5158 vlun->svl_not_supported = 1; |
5159 rval = MDI_NOT_SUPPORTED; | |
5160 goto done; | |
5161 } | |
5162 | |
5163 /* failover supported for device - save failover_ops in vlun */ | |
5164 vlun->svl_fops = sfo; | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5165 ASSERT(vlun->svl_fops_name != NULL); |
4851 | 5166 |
5167 /* | |
5168 * Obtain the device-type based mpxio options as specified in | |
5169 * scsi_vhci.conf file. | |
5170 * | |
5171 * NOTE: currently, the end result is a call to | |
5172 * mdi_set_lb_region_size(). | |
5173 */ | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5174 tgt_dip = psd->sd_dev; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
5175 ASSERT(tgt_dip != NULL); |
4851 | 5176 vhci_get_device_type_mpxio_options(vdip, tgt_dip, psd); |
5177 | |
5178 /* | |
5179 * if PGR is active, revalidate key and register on this path also, | |
5180 * if key is still valid | |
5181 */ | |
5182 sema_p(&vlun->svl_pgr_sema); | |
5183 if (vlun->svl_pgr_active) { | |
5184 rval = vhci_pgr_validate_and_register(svp); | |
5185 if (rval != 1) { | |
5186 rval = MDI_FAILURE; | |
5187 sema_v(&vlun->svl_pgr_sema); | |
5188 goto failure; | |
5189 } | |
5190 } | |
5191 sema_v(&vlun->svl_pgr_sema); | |
5192 | |
5193 if (svp->svp_new_path) { | |
5194 /* | |
5195 * Last chance to perform any cleanup operations on this | |
5196 * new path before making this path completely online. | |
5197 */ | |
5198 svp->svp_new_path = 0; | |
5199 | |
5200 /* | |
5201 * If scsi_vhci knows the lun is alread RESERVE'd, | |
5202 * then skip the issue of RELEASE on new path. | |
5203 */ | |
5204 if ((vlun->svl_flags & VLUN_RESERVE_ACTIVE_FLG) == 0) { | |
5205 /* | |
5206 * Issue SCSI-2 RELEASE only for the first time on | |
5207 * a new path just in case the host rebooted and | |
5208 * a reservation is still pending on this path. | |
5209 * IBM Shark storage does not clear RESERVE upon | |
5210 * host reboot. | |
5211 */ | |
5212 pkt = scsi_init_pkt(ap, NULL, NULL, CDB_GROUP0, | |
5213 sizeof (struct scsi_arq_status), 0, 0, | |
5214 SLEEP_FUNC, NULL); | |
5215 if (pkt == NULL) { | |
5216 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5217 "!vhci_pathinfo_online: " | |
5218 "Release init_pkt failed :%p\n", | |
5219 (void *)pip)); | |
5220 rval = MDI_FAILURE; | |
5221 goto failure; | |
5222 } | |
5223 pkt->pkt_cdbp[0] = SCMD_RELEASE; | |
5224 pkt->pkt_time = 60; | |
5225 | |
5226 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5227 "!vhci_path_online: path:%p " | |
5228 "Issued SCSI-2 RELEASE\n", (void *)pip)); | |
5229 | |
5230 /* Ignore the return value */ | |
5231 (void) vhci_do_scsi_cmd(pkt); | |
5232 scsi_destroy_pkt(pkt); | |
5233 } | |
5234 } | |
5235 | |
5236 rval = vhci_update_pathinfo(psd, pip, sfo, vlun, vhci); | |
5237 if (rval == MDI_FAILURE) { | |
5238 goto failure; | |
5239 } | |
5240 | |
5241 /* Initialize MP-API data */ | |
5242 vhci_update_mpapi_data(vhci, vlun, pip); | |
5243 | |
5244 /* | |
5245 * MP-API also needs the Inquiry data to be maintained in the | |
5246 * mp_vendor_prop_t structure, so find the lun and update its | |
5247 * structure with this data. | |
5248 */ | |
5249 list_ptr = (mpapi_item_list_t *)vhci_get_mpapi_item(vhci, NULL, | |
5250 MP_OBJECT_TYPE_MULTIPATH_LU, (void *)vlun); | |
5251 ld = (mpapi_lu_data_t *)list_ptr->item->idata; | |
5252 if (ld != NULL) { | |
5253 bcopy(psd->sd_inq->inq_vid, ld->prop.prodInfo.vendor, 8); | |
5254 bcopy(psd->sd_inq->inq_pid, ld->prop.prodInfo.product, 16); | |
5255 bcopy(psd->sd_inq->inq_revision, ld->prop.prodInfo.revision, 4); | |
5256 } else { | |
5257 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_pathinfo_online: " | |
5258 "mpapi_lu_data_t is NULL")); | |
5259 } | |
5260 | |
5261 /* create kstats for path */ | |
5262 vhci_kstat_create_pathinfo(pip); | |
5263 | |
5264 done: | |
5265 mutex_enter(&vhci_global_mutex); | |
5266 cv_broadcast(&vhci_cv); | |
5267 mutex_exit(&vhci_global_mutex); | |
5268 | |
5269 if (vlun->svl_setcap_done) { | |
5270 (void) vhci_pHCI_cap(ap, "sector-size", | |
5271 vlun->svl_sector_size, 1, pip); | |
5272 } | |
5273 | |
5274 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_path_online: path:%p\n", | |
5275 (void *)pip)); | |
5276 | |
5277 failure: | |
5278 return (rval); | |
5279 } | |
5280 | |
5281 /* | |
5282 * path offline handler. Release all bindings that will not be | |
5283 * released by the normal packet transport/completion code path. | |
5284 * Since we don't (presently) keep any bindings alive outside of | |
5285 * the in-transport packets (which will be released on completion) | |
5286 * there is not much to do here. | |
5287 */ | |
5288 /* ARGSUSED */ | |
5289 static int | |
5290 vhci_pathinfo_offline(dev_info_t *vdip, mdi_pathinfo_t *pip, int flags) | |
5291 { | |
5292 scsi_hba_tran_t *hba = NULL; | |
5293 struct scsi_device *psd = NULL; | |
5294 dev_info_t *pdip = NULL; | |
5295 dev_info_t *cdip = NULL; | |
5296 scsi_vhci_priv_t *svp = NULL; | |
5297 | |
5298 ASSERT(vdip != NULL); | |
5299 ASSERT(pip != NULL); | |
5300 | |
5301 pdip = mdi_pi_get_phci(pip); | |
5302 ASSERT(pdip != NULL); | |
5303 if (pdip == NULL) { | |
5304 VHCI_DEBUG(1, (CE_WARN, vdip, "Invalid path 0x%p: NULL " | |
5305 "phci dip", (void *)pip)); | |
5306 return (MDI_FAILURE); | |
5307 } | |
5308 | |
5309 cdip = mdi_pi_get_client(pip); | |
5310 ASSERT(cdip != NULL); | |
5311 if (cdip == NULL) { | |
5312 VHCI_DEBUG(1, (CE_WARN, vdip, "Invalid path 0x%p: NULL " | |
5313 "client dip", (void *)pip)); | |
5314 return (MDI_FAILURE); | |
5315 } | |
5316 | |
5317 hba = ddi_get_driver_private(pdip); | |
5318 ASSERT(hba != NULL); | |
5319 | |
5320 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
5321 if (svp == NULL) { | |
5322 /* | |
5323 * mdi_pathinfo node in INIT state can have vHCI private | |
5324 * information set to null | |
5325 */ | |
5326 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5327 "svp is NULL for pip 0x%p\n", (void *)pip)); | |
5328 return (MDI_SUCCESS); | |
5329 } | |
5330 | |
5331 psd = svp->svp_psd; | |
5332 ASSERT(psd != NULL); | |
5333 | |
5334 mutex_enter(&svp->svp_mutex); | |
5335 | |
5336 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5337 "%d cmds pending on path: 0x%p\n", svp->svp_cmds, (void *)pip)); | |
5338 while (svp->svp_cmds != 0) { | |
11066
cebb50cbe4f9
PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling
Rafael Vanoni <rafael.vanoni@sun.com>
parents:
11032
diff
changeset
|
5339 if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex, |
cebb50cbe4f9
PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling
Rafael Vanoni <rafael.vanoni@sun.com>
parents:
11032
diff
changeset
|
5340 drv_usectohz(vhci_path_quiesce_timeout * 1000000), |
cebb50cbe4f9
PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling
Rafael Vanoni <rafael.vanoni@sun.com>
parents:
11032
diff
changeset
|
5341 TR_CLOCK_TICK) == -1) { |
4851 | 5342 /* |
5343 * The timeout time reached without the condition | |
5344 * being signaled. | |
5345 */ | |
5346 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5347 "Timeout reached on path 0x%p without the cond\n", | |
5348 (void *)pip)); | |
5349 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: " | |
5350 "%d cmds still pending on path: 0x%p\n", | |
5351 svp->svp_cmds, (void *)pip)); | |
5352 break; | |
5353 } | |
5354 } | |
5355 mutex_exit(&svp->svp_mutex); | |
5356 | |
5357 /* | |
5358 * Check to see if this vlun has an active SCSI-II RESERVE. And this | |
5359 * is the pip for the path that has been reserved. | |
5360 * If so clear the reservation by sending a reset, so the host will not | |
5361 * get a reservation conflict. Reset the flag VLUN_RESERVE_ACTIVE_FLG | |
5362 * for this lun. Also a reset notify is sent to the target driver | |
5363 * just in case the POR check condition is cleared by some other layer | |
5364 * in the stack. | |
5365 */ | |
5366 if (svp->svp_svl->svl_flags & VLUN_RESERVE_ACTIVE_FLG) { | |
5367 if (pip == svp->svp_svl->svl_resrv_pip) { | |
5368 if (vhci_recovery_reset(svp->svp_svl, | |
5369 &svp->svp_psd->sd_address, TRUE, | |
5370 VHCI_DEPTH_TARGET) == 0) { | |
5371 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5372 "!vhci_pathinfo_offline (pip:%p):" | |
5373 "reset failed, retrying\n", (void *)pip)); | |
5374 delay(1*drv_usectohz(1000000)); | |
5375 if (vhci_recovery_reset(svp->svp_svl, | |
5376 &svp->svp_psd->sd_address, TRUE, | |
5377 VHCI_DEPTH_TARGET) == 0) { | |
5378 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5379 "!vhci_pathinfo_offline " | |
5380 "(pip:%p): reset failed, " | |
5381 "giving up!\n", (void *)pip)); | |
5382 } | |
5383 } | |
5384 svp->svp_svl->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
5385 } | |
5386 } | |
5387 | |
5388 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_OFFLINE); | |
5389 vhci_mpapi_set_path_state(vdip, pip, MP_DRVR_PATH_STATE_REMOVED); | |
5390 | |
5391 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
5392 "!vhci_pathinfo_offline: offlined path 0x%p\n", (void *)pip)); | |
5393 return (MDI_SUCCESS); | |
5394 } | |
5395 | |
5396 | |
5397 /* | |
5398 * routine for SCSI VHCI IOCTL implementation. | |
5399 */ | |
5400 /* ARGSUSED */ | |
5401 static int | |
5402 vhci_ctl(dev_t dev, int cmd, intptr_t data, int mode, cred_t *credp, int *rval) | |
5403 { | |
5404 struct scsi_vhci *vhci; | |
5405 dev_info_t *vdip; | |
5406 mdi_pathinfo_t *pip; | |
5407 int instance, held; | |
5408 int retval = 0; | |
5409 caddr_t phci_path = NULL, client_path = NULL; | |
5410 caddr_t paddr = NULL; | |
5411 sv_iocdata_t ioc; | |
5412 sv_iocdata_t *pioc = &ioc; | |
5413 sv_switch_to_cntlr_iocdata_t iocsc; | |
5414 sv_switch_to_cntlr_iocdata_t *piocsc = &iocsc; | |
5415 caddr_t s; | |
5416 scsi_vhci_lun_t *vlun; | |
5417 struct scsi_failover_ops *fo; | |
5418 char *pclass; | |
5419 | |
5420 /* Check for validity of vhci structure */ | |
5421 vhci = ddi_get_soft_state(vhci_softstate, MINOR2INST(getminor(dev))); | |
5422 if (vhci == NULL) { | |
5423 return (ENXIO); | |
5424 } | |
5425 | |
5426 mutex_enter(&vhci->vhci_mutex); | |
5427 if ((vhci->vhci_state & VHCI_STATE_OPEN) == 0) { | |
5428 mutex_exit(&vhci->vhci_mutex); | |
5429 return (ENXIO); | |
5430 } | |
5431 mutex_exit(&vhci->vhci_mutex); | |
5432 | |
5433 /* Get the vhci dip */ | |
5434 vdip = vhci->vhci_dip; | |
5435 ASSERT(vdip != NULL); | |
5436 instance = ddi_get_instance(vdip); | |
5437 | |
5438 /* Allocate memory for getting parameters from userland */ | |
5439 phci_path = kmem_zalloc(MAXPATHLEN, KM_SLEEP); | |
5440 client_path = kmem_zalloc(MAXPATHLEN, KM_SLEEP); | |
5441 paddr = kmem_zalloc(MAXNAMELEN, KM_SLEEP); | |
5442 | |
5443 /* | |
5444 * Set a local variable indicating the ioctl name. Used for | |
5445 * printing debug strings. | |
5446 */ | |
5447 switch (cmd) { | |
5448 case SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO: | |
5449 s = "GET_CLIENT_MULTIPATH_INFO"; | |
5450 break; | |
5451 | |
5452 case SCSI_VHCI_GET_PHCI_MULTIPATH_INFO: | |
5453 s = "GET_PHCI_MULTIPATH_INFO"; | |
5454 break; | |
5455 | |
5456 case SCSI_VHCI_GET_CLIENT_NAME: | |
5457 s = "GET_CLIENT_NAME"; | |
5458 break; | |
5459 | |
5460 case SCSI_VHCI_PATH_ONLINE: | |
5461 s = "PATH_ONLINE"; | |
5462 break; | |
5463 | |
5464 case SCSI_VHCI_PATH_OFFLINE: | |
5465 s = "PATH_OFFLINE"; | |
5466 break; | |
5467 | |
5468 case SCSI_VHCI_PATH_STANDBY: | |
5469 s = "PATH_STANDBY"; | |
5470 break; | |
5471 | |
5472 case SCSI_VHCI_PATH_TEST: | |
5473 s = "PATH_TEST"; | |
5474 break; | |
5475 | |
5476 case SCSI_VHCI_SWITCH_TO_CNTLR: | |
5477 s = "SWITCH_TO_CNTLR"; | |
5478 break; | |
5479 case SCSI_VHCI_PATH_DISABLE: | |
5480 s = "PATH_DISABLE"; | |
5481 break; | |
5482 case SCSI_VHCI_PATH_ENABLE: | |
5483 s = "PATH_ENABLE"; | |
5484 break; | |
5485 | |
5486 case SCSI_VHCI_GET_TARGET_LONGNAME: | |
5487 s = "GET_TARGET_LONGNAME"; | |
5488 break; | |
5489 | |
5490 #ifdef DEBUG | |
5491 case SCSI_VHCI_CONFIGURE_PHCI: | |
5492 s = "CONFIGURE_PHCI"; | |
5493 break; | |
5494 | |
5495 case SCSI_VHCI_UNCONFIGURE_PHCI: | |
5496 s = "UNCONFIGURE_PHCI"; | |
5497 break; | |
5498 #endif | |
5499 | |
5500 default: | |
5501 s = "Unknown"; | |
5502 vhci_log(CE_NOTE, vdip, | |
5503 "!vhci%d: ioctl %x (unsupported ioctl)", instance, cmd); | |
5504 retval = ENOTSUP; | |
5505 break; | |
5506 } | |
5507 if (retval != 0) { | |
5508 goto end; | |
5509 } | |
5510 | |
5511 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci%d: ioctl <%s>", instance, s)); | |
5512 | |
5513 /* | |
5514 * Get IOCTL parameters from userland | |
5515 */ | |
5516 switch (cmd) { | |
5517 case SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO: | |
5518 case SCSI_VHCI_GET_PHCI_MULTIPATH_INFO: | |
5519 case SCSI_VHCI_GET_CLIENT_NAME: | |
5520 case SCSI_VHCI_PATH_ONLINE: | |
5521 case SCSI_VHCI_PATH_OFFLINE: | |
5522 case SCSI_VHCI_PATH_STANDBY: | |
5523 case SCSI_VHCI_PATH_TEST: | |
5524 case SCSI_VHCI_PATH_DISABLE: | |
5525 case SCSI_VHCI_PATH_ENABLE: | |
5526 case SCSI_VHCI_GET_TARGET_LONGNAME: | |
5527 #ifdef DEBUG | |
5528 case SCSI_VHCI_CONFIGURE_PHCI: | |
5529 case SCSI_VHCI_UNCONFIGURE_PHCI: | |
5530 #endif | |
5531 retval = vhci_get_iocdata((const void *)data, pioc, mode, s); | |
5532 break; | |
5533 | |
5534 case SCSI_VHCI_SWITCH_TO_CNTLR: | |
5535 retval = vhci_get_iocswitchdata((const void *)data, piocsc, | |
5536 mode, s); | |
5537 break; | |
5538 } | |
5539 if (retval != 0) { | |
5540 goto end; | |
5541 } | |
5542 | |
5543 | |
5544 /* | |
5545 * Process the IOCTL | |
5546 */ | |
5547 switch (cmd) { | |
5548 case SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO: | |
5549 { | |
5550 uint_t num_paths; /* Num paths to client dev */ | |
5551 sv_path_info_t *upibuf = NULL; /* To keep userland values */ | |
5552 sv_path_info_t *kpibuf = NULL; /* Kernel data for ioctls */ | |
5553 dev_info_t *cdip; /* Client device dip */ | |
5554 | |
5555 if (pioc->ret_elem == NULL) { | |
5556 retval = EINVAL; | |
5557 break; | |
5558 } | |
5559 | |
5560 /* Get client device path from user land */ | |
5561 if (vhci_ioc_get_client_path(pioc, client_path, mode, s)) { | |
5562 retval = EFAULT; | |
5563 break; | |
5564 } | |
5565 | |
5566 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5567 "client <%s>", s, client_path)); | |
5568 | |
5569 /* Get number of paths to this client device */ | |
5570 if ((cdip = mdi_client_path2devinfo(vdip, client_path)) | |
5571 == NULL) { | |
5572 retval = ENXIO; | |
5573 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5574 "client dip doesn't exist. invalid path <%s>", | |
5575 s, client_path)); | |
5576 break; | |
5577 } | |
5578 num_paths = mdi_client_get_path_count(cdip); | |
5579 | |
5580 if (ddi_copyout(&num_paths, pioc->ret_elem, | |
5581 sizeof (num_paths), mode)) { | |
5582 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5583 "num_paths copyout failed", s)); | |
5584 retval = EFAULT; | |
5585 break; | |
5586 } | |
5587 | |
5588 /* If user just wanted num_paths, then return */ | |
5589 if (pioc->buf_elem == 0 || pioc->ret_buf == NULL || | |
5590 num_paths == 0) { | |
5591 break; | |
5592 } | |
5593 | |
5594 /* Set num_paths to value as much as can be sent to userland */ | |
5595 if (num_paths > pioc->buf_elem) { | |
5596 num_paths = pioc->buf_elem; | |
5597 } | |
5598 | |
5599 /* Allocate memory and get userland pointers */ | |
5600 if (vhci_ioc_alloc_pathinfo(&upibuf, &kpibuf, num_paths, | |
5601 pioc, mode, s) != 0) { | |
5602 retval = EFAULT; | |
5603 break; | |
5604 } | |
5605 ASSERT(upibuf != NULL); | |
5606 ASSERT(kpibuf != NULL); | |
5607 | |
5608 /* | |
5609 * Get the path information and send it to userland. | |
5610 */ | |
5611 if (vhci_get_client_path_list(cdip, kpibuf, num_paths) | |
5612 != MDI_SUCCESS) { | |
5613 retval = ENXIO; | |
5614 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5615 break; | |
5616 } | |
5617 | |
5618 if (vhci_ioc_send_pathinfo(upibuf, kpibuf, num_paths, | |
5619 pioc, mode, s)) { | |
5620 retval = EFAULT; | |
5621 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5622 break; | |
5623 } | |
5624 | |
5625 /* Free the memory allocated for path information */ | |
5626 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5627 break; | |
5628 } | |
5629 | |
5630 case SCSI_VHCI_GET_PHCI_MULTIPATH_INFO: | |
5631 { | |
5632 uint_t num_paths; /* Num paths to client dev */ | |
5633 sv_path_info_t *upibuf = NULL; /* To keep userland values */ | |
5634 sv_path_info_t *kpibuf = NULL; /* Kernel data for ioctls */ | |
5635 dev_info_t *pdip; /* PHCI device dip */ | |
5636 | |
5637 if (pioc->ret_elem == NULL) { | |
5638 retval = EINVAL; | |
5639 break; | |
5640 } | |
5641 | |
5642 /* Get PHCI device path from user land */ | |
5643 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
5644 retval = EFAULT; | |
5645 break; | |
5646 } | |
5647 | |
5648 VHCI_DEBUG(6, (CE_WARN, vdip, | |
5649 "!vhci_ioctl: ioctl <%s> phci <%s>", s, phci_path)); | |
5650 | |
5651 /* Get number of devices associated with this PHCI device */ | |
5652 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5653 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5654 "phci dip doesn't exist. invalid path <%s>", | |
5655 s, phci_path)); | |
5656 retval = ENXIO; | |
5657 break; | |
5658 } | |
5659 | |
5660 num_paths = mdi_phci_get_path_count(pdip); | |
5661 | |
5662 if (ddi_copyout(&num_paths, pioc->ret_elem, | |
5663 sizeof (num_paths), mode)) { | |
5664 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5665 "num_paths copyout failed", s)); | |
5666 retval = EFAULT; | |
5667 break; | |
5668 } | |
5669 | |
5670 /* If user just wanted num_paths, then return */ | |
5671 if (pioc->buf_elem == 0 || pioc->ret_buf == NULL || | |
5672 num_paths == 0) { | |
5673 break; | |
5674 } | |
5675 | |
5676 /* Set num_paths to value as much as can be sent to userland */ | |
5677 if (num_paths > pioc->buf_elem) { | |
5678 num_paths = pioc->buf_elem; | |
5679 } | |
5680 | |
5681 /* Allocate memory and get userland pointers */ | |
5682 if (vhci_ioc_alloc_pathinfo(&upibuf, &kpibuf, num_paths, | |
5683 pioc, mode, s) != 0) { | |
5684 retval = EFAULT; | |
5685 break; | |
5686 } | |
5687 ASSERT(upibuf != NULL); | |
5688 ASSERT(kpibuf != NULL); | |
5689 | |
5690 /* | |
5691 * Get the path information and send it to userland. | |
5692 */ | |
5693 if (vhci_get_phci_path_list(pdip, kpibuf, num_paths) | |
5694 != MDI_SUCCESS) { | |
5695 retval = ENXIO; | |
5696 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5697 break; | |
5698 } | |
5699 | |
5700 if (vhci_ioc_send_pathinfo(upibuf, kpibuf, num_paths, | |
5701 pioc, mode, s)) { | |
5702 retval = EFAULT; | |
5703 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5704 break; | |
5705 } | |
5706 | |
5707 /* Free the memory allocated for path information */ | |
5708 vhci_ioc_free_pathinfo(upibuf, kpibuf, num_paths); | |
5709 break; | |
5710 } | |
5711 | |
5712 case SCSI_VHCI_GET_CLIENT_NAME: | |
5713 { | |
5714 dev_info_t *cdip, *pdip; | |
5715 | |
5716 /* Get PHCI path and device address from user land */ | |
5717 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s) || | |
5718 vhci_ioc_get_paddr(pioc, paddr, mode, s)) { | |
5719 retval = EFAULT; | |
5720 break; | |
5721 } | |
5722 | |
5723 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5724 "phci <%s>, paddr <%s>", s, phci_path, paddr)); | |
5725 | |
5726 /* Get the PHCI dip */ | |
5727 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5728 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5729 "phci dip doesn't exist. invalid path <%s>", | |
5730 s, phci_path)); | |
5731 retval = ENXIO; | |
5732 break; | |
5733 } | |
5734 | |
5735 if ((pip = mdi_pi_find(pdip, NULL, paddr)) == NULL) { | |
5736 VHCI_DEBUG(1, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5737 "pathinfo doesn't exist. invalid device addr", s)); | |
5738 retval = ENXIO; | |
5739 break; | |
5740 } | |
5741 | |
5742 /* Get the client device pathname and send to userland */ | |
5743 cdip = mdi_pi_get_client(pip); | |
5744 vhci_ioc_devi_to_path(cdip, client_path); | |
5745 | |
5746 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5747 "client <%s>", s, client_path)); | |
5748 | |
5749 if (vhci_ioc_send_client_path(client_path, pioc, mode, s)) { | |
5750 retval = EFAULT; | |
5751 break; | |
5752 } | |
5753 break; | |
5754 } | |
5755 | |
5756 case SCSI_VHCI_PATH_ONLINE: | |
5757 case SCSI_VHCI_PATH_OFFLINE: | |
5758 case SCSI_VHCI_PATH_STANDBY: | |
5759 case SCSI_VHCI_PATH_TEST: | |
5760 { | |
5761 dev_info_t *pdip; /* PHCI dip */ | |
5762 | |
5763 /* Get PHCI path and device address from user land */ | |
5764 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s) || | |
5765 vhci_ioc_get_paddr(pioc, paddr, mode, s)) { | |
5766 retval = EFAULT; | |
5767 break; | |
5768 } | |
5769 | |
5770 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5771 "phci <%s>, paddr <%s>", s, phci_path, paddr)); | |
5772 | |
5773 /* Get the PHCI dip */ | |
5774 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5775 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5776 "phci dip doesn't exist. invalid path <%s>", | |
5777 s, phci_path)); | |
5778 retval = ENXIO; | |
5779 break; | |
5780 } | |
5781 | |
5782 if ((pip = mdi_pi_find(pdip, NULL, paddr)) == NULL) { | |
5783 VHCI_DEBUG(1, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5784 "pathinfo doesn't exist. invalid device addr", s)); | |
5785 retval = ENXIO; | |
5786 break; | |
5787 } | |
5788 | |
5789 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5790 "Calling MDI function to change device state", s)); | |
5791 | |
5792 switch (cmd) { | |
5793 case SCSI_VHCI_PATH_ONLINE: | |
5794 retval = mdi_pi_online(pip, 0); | |
5795 break; | |
5796 | |
5797 case SCSI_VHCI_PATH_OFFLINE: | |
5798 retval = mdi_pi_offline(pip, 0); | |
5799 break; | |
5800 | |
5801 case SCSI_VHCI_PATH_STANDBY: | |
5802 retval = mdi_pi_standby(pip, 0); | |
5803 break; | |
5804 | |
5805 case SCSI_VHCI_PATH_TEST: | |
5806 break; | |
5807 } | |
5808 break; | |
5809 } | |
5810 | |
5811 case SCSI_VHCI_SWITCH_TO_CNTLR: | |
5812 { | |
5813 dev_info_t *cdip; | |
5814 struct scsi_device *devp; | |
5815 | |
5816 /* Get the client device pathname */ | |
5817 if (ddi_copyin(piocsc->client, client_path, | |
5818 MAXPATHLEN, mode)) { | |
5819 VHCI_DEBUG(2, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5820 "client_path copyin failed", s)); | |
5821 retval = EFAULT; | |
5822 break; | |
5823 } | |
5824 | |
5825 /* Get the path class to which user wants to switch */ | |
5826 if (ddi_copyin(piocsc->class, paddr, MAXNAMELEN, mode)) { | |
5827 VHCI_DEBUG(2, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
5828 "controller_class copyin failed", s)); | |
5829 retval = EFAULT; | |
5830 break; | |
5831 } | |
5832 | |
5833 /* Perform validity checks */ | |
5834 if ((cdip = mdi_client_path2devinfo(vdip, | |
5835 client_path)) == NULL) { | |
5836 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5837 "client dip doesn't exist. invalid path <%s>", | |
5838 s, client_path)); | |
5839 retval = ENXIO; | |
5840 break; | |
5841 } | |
5842 | |
5843 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: Calling MDI func " | |
5844 "to switch controller")); | |
5845 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: client <%s> " | |
5846 "class <%s>", client_path, paddr)); | |
5847 | |
5848 if (strcmp(paddr, PCLASS_PRIMARY) && | |
5849 strcmp(paddr, PCLASS_SECONDARY)) { | |
5850 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5851 "invalid path class <%s>", s, paddr)); | |
5852 retval = ENXIO; | |
5853 break; | |
5854 } | |
5855 | |
5856 devp = ddi_get_driver_private(cdip); | |
5857 if (devp == NULL) { | |
5858 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5859 "invalid scsi device <%s>", s, client_path)); | |
5860 retval = ENXIO; | |
5861 break; | |
5862 } | |
5863 vlun = ADDR2VLUN(&devp->sd_address); | |
5864 ASSERT(vlun); | |
5865 | |
5866 /* | |
5867 * Checking to see if device has only one pclass, PRIMARY. | |
5868 * If so this device doesn't support failovers. Assumed | |
5869 * that the devices with one pclass is PRIMARY, as thats the | |
5870 * case today. If this is not true and in future other | |
5871 * symmetric devices are supported with other pclass, this | |
5872 * IOCTL shall have to be overhauled anyways as now the only | |
5873 * arguments it accepts are PRIMARY and SECONDARY. | |
5874 */ | |
5875 fo = vlun->svl_fops; | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
5876 if (fo->sfo_pathclass_next(PCLASS_PRIMARY, &pclass, |
4851 | 5877 vlun->svl_fops_ctpriv)) { |
5878 retval = ENOTSUP; | |
5879 break; | |
5880 } | |
5881 | |
5882 VHCI_HOLD_LUN(vlun, VH_SLEEP, held); | |
5883 mutex_enter(&vlun->svl_mutex); | |
5884 if (vlun->svl_active_pclass != NULL) { | |
5885 if (strcmp(vlun->svl_active_pclass, paddr) == 0) { | |
5886 mutex_exit(&vlun->svl_mutex); | |
5887 retval = EALREADY; | |
5888 VHCI_RELEASE_LUN(vlun); | |
5889 break; | |
5890 } | |
5891 } | |
5892 mutex_exit(&vlun->svl_mutex); | |
5893 /* Call mdi function to cause a switch over */ | |
5894 retval = mdi_failover(vdip, cdip, MDI_FAILOVER_SYNC); | |
5895 if (retval == MDI_SUCCESS) { | |
5896 retval = 0; | |
5897 } else if (retval == MDI_BUSY) { | |
5898 retval = EBUSY; | |
5899 } else { | |
5900 retval = EIO; | |
5901 } | |
5902 VHCI_RELEASE_LUN(vlun); | |
5903 break; | |
5904 } | |
5905 | |
5906 case SCSI_VHCI_PATH_ENABLE: | |
5907 case SCSI_VHCI_PATH_DISABLE: | |
5908 { | |
5909 dev_info_t *cdip, *pdip; | |
5910 | |
5911 /* | |
5912 * Get client device path from user land | |
5913 */ | |
5914 if (vhci_ioc_get_client_path(pioc, client_path, mode, s)) { | |
5915 retval = EFAULT; | |
5916 break; | |
5917 } | |
5918 | |
5919 /* | |
5920 * Get Phci device path from user land | |
5921 */ | |
5922 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
5923 retval = EFAULT; | |
5924 break; | |
5925 } | |
5926 | |
5927 /* | |
5928 * Get the devinfo for the Phci. | |
5929 */ | |
5930 if ((pdip = mdi_phci_path2devinfo(vdip, phci_path)) == NULL) { | |
5931 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5932 "phci dip doesn't exist. invalid path <%s>", | |
5933 s, phci_path)); | |
5934 retval = ENXIO; | |
5935 break; | |
5936 } | |
5937 | |
5938 /* | |
5939 * If the client path is set to /scsi_vhci then we need | |
5940 * to do the operation on all the clients so set cdip to NULL. | |
5941 * Else, try to get the client dip. | |
5942 */ | |
5943 if (strcmp(client_path, "/scsi_vhci") == 0) { | |
5944 cdip = NULL; | |
5945 } else { | |
5946 if ((cdip = mdi_client_path2devinfo(vdip, | |
5947 client_path)) == NULL) { | |
5948 retval = ENXIO; | |
5949 VHCI_DEBUG(1, (CE_WARN, NULL, | |
5950 "!vhci_ioctl: ioctl <%s> client dip " | |
5951 "doesn't exist. invalid path <%s>", | |
5952 s, client_path)); | |
5953 break; | |
5954 } | |
5955 } | |
5956 | |
5957 if (cmd == SCSI_VHCI_PATH_ENABLE) | |
5958 retval = mdi_pi_enable(cdip, pdip, USER_DISABLE); | |
5959 else | |
5960 retval = mdi_pi_disable(cdip, pdip, USER_DISABLE); | |
5961 | |
5962 break; | |
5963 } | |
5964 | |
5965 case SCSI_VHCI_GET_TARGET_LONGNAME: | |
5966 { | |
5967 uint_t pid = pioc->buf_elem; | |
5968 char *target_port; | |
5969 mod_hash_val_t hv; | |
5970 | |
5971 /* targetmap lookup of 'target-port' by <pid> */ | |
5972 if (mod_hash_find(vhci_targetmap_bypid, | |
5973 (mod_hash_key_t)(uintptr_t)pid, &hv) != 0) { | |
5974 /* | |
5975 * NOTE: failure to find the mapping is OK for guid | |
5976 * based 'target-port' values. | |
5977 */ | |
5978 VHCI_DEBUG(3, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5979 "targetport mapping doesn't exist: pid %d", | |
5980 s, pid)); | |
5981 retval = ENXIO; | |
5982 break; | |
5983 } | |
5984 | |
5985 /* copyout 'target-port' result */ | |
5986 target_port = (char *)hv; | |
5987 if (copyoutstr(target_port, pioc->addr, MAXNAMELEN, NULL)) { | |
5988 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
5989 "targetport copyout failed: len: %d", | |
5990 s, (int)strlen(target_port))); | |
5991 retval = EFAULT; | |
5992 } | |
5993 break; | |
5994 } | |
5995 | |
5996 #ifdef DEBUG | |
5997 case SCSI_VHCI_CONFIGURE_PHCI: | |
5998 { | |
5999 dev_info_t *pdip; | |
6000 | |
6001 /* Get PHCI path and device address from user land */ | |
6002 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
6003 retval = EFAULT; | |
6004 break; | |
6005 } | |
6006 | |
6007 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
6008 "phci <%s>", s, phci_path)); | |
6009 | |
6010 /* Get the PHCI dip */ | |
6011 if ((pdip = e_ddi_hold_devi_by_path(phci_path, 0)) == NULL) { | |
6012 VHCI_DEBUG(3, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
6013 "phci dip doesn't exist. invalid path <%s>", | |
6014 s, phci_path)); | |
6015 retval = ENXIO; | |
6016 break; | |
6017 } | |
6018 | |
6019 if (ndi_devi_config(pdip, | |
6020 NDI_DEVFS_CLEAN|NDI_DEVI_PERSIST) != NDI_SUCCESS) { | |
6021 retval = EIO; | |
6022 } | |
6023 | |
6024 ddi_release_devi(pdip); | |
6025 break; | |
6026 } | |
6027 | |
6028 case SCSI_VHCI_UNCONFIGURE_PHCI: | |
6029 { | |
6030 dev_info_t *pdip; | |
6031 | |
6032 /* Get PHCI path and device address from user land */ | |
6033 if (vhci_ioc_get_phci_path(pioc, phci_path, mode, s)) { | |
6034 retval = EFAULT; | |
6035 break; | |
6036 } | |
6037 | |
6038 VHCI_DEBUG(6, (CE_WARN, vdip, "!vhci_ioctl: ioctl <%s> " | |
6039 "phci <%s>", s, phci_path)); | |
6040 | |
6041 /* Get the PHCI dip */ | |
6042 if ((pdip = e_ddi_hold_devi_by_path(phci_path, 0)) == NULL) { | |
6043 VHCI_DEBUG(3, (CE_WARN, NULL, "!vhci_ioctl: ioctl <%s> " | |
6044 "phci dip doesn't exist. invalid path <%s>", | |
6045 s, phci_path)); | |
6046 retval = ENXIO; | |
6047 break; | |
6048 } | |
6049 | |
6050 if (ndi_devi_unconfig(pdip, | |
6051 NDI_DEVI_REMOVE|NDI_DEVFS_CLEAN) != NDI_SUCCESS) { | |
6052 retval = EBUSY; | |
6053 } | |
6054 | |
6055 ddi_release_devi(pdip); | |
6056 break; | |
6057 } | |
6058 #endif | |
6059 } | |
6060 | |
6061 end: | |
6062 /* Free the memory allocated above */ | |
6063 if (phci_path != NULL) { | |
6064 kmem_free(phci_path, MAXPATHLEN); | |
6065 } | |
6066 if (client_path != NULL) { | |
6067 kmem_free(client_path, MAXPATHLEN); | |
6068 } | |
6069 if (paddr != NULL) { | |
6070 kmem_free(paddr, MAXNAMELEN); | |
6071 } | |
6072 return (retval); | |
6073 } | |
6074 | |
6075 /* | |
6076 * devctl IOCTL support for client device DR | |
6077 */ | |
6078 /* ARGSUSED */ | |
6079 int | |
6080 vhci_devctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, | |
6081 int *rvalp) | |
6082 { | |
6083 dev_info_t *self; | |
6084 dev_info_t *child; | |
6085 scsi_hba_tran_t *hba; | |
6086 struct devctl_iocdata *dcp; | |
6087 struct scsi_vhci *vhci; | |
6088 int rv = 0; | |
6089 int retval = 0; | |
6090 scsi_vhci_priv_t *svp; | |
6091 mdi_pathinfo_t *pip; | |
6092 | |
6093 if ((vhci = ddi_get_soft_state(vhci_softstate, | |
6094 MINOR2INST(getminor(dev)))) == NULL) | |
6095 return (ENXIO); | |
6096 | |
6097 /* | |
6098 * check if :devctl minor device has been opened | |
6099 */ | |
6100 mutex_enter(&vhci->vhci_mutex); | |
6101 if ((vhci->vhci_state & VHCI_STATE_OPEN) == 0) { | |
6102 mutex_exit(&vhci->vhci_mutex); | |
6103 return (ENXIO); | |
6104 } | |
6105 mutex_exit(&vhci->vhci_mutex); | |
6106 | |
6107 self = vhci->vhci_dip; | |
6108 hba = ddi_get_driver_private(self); | |
6109 if (hba == NULL) | |
6110 return (ENXIO); | |
6111 | |
6112 /* | |
6113 * We can use the generic implementation for these ioctls | |
6114 */ | |
6115 switch (cmd) { | |
6116 case DEVCTL_DEVICE_GETSTATE: | |
6117 case DEVCTL_DEVICE_ONLINE: | |
6118 case DEVCTL_DEVICE_OFFLINE: | |
6119 case DEVCTL_DEVICE_REMOVE: | |
6120 case DEVCTL_BUS_GETSTATE: | |
6121 return (ndi_devctl_ioctl(self, cmd, arg, mode, 0)); | |
6122 } | |
6123 | |
6124 /* | |
6125 * read devctl ioctl data | |
6126 */ | |
6127 if (ndi_dc_allochdl((void *)arg, &dcp) != NDI_SUCCESS) | |
6128 return (EFAULT); | |
6129 | |
6130 switch (cmd) { | |
6131 | |
6132 case DEVCTL_DEVICE_RESET: | |
6133 /* | |
6134 * lookup and hold child device | |
6135 */ | |
6136 if ((child = ndi_devi_find(self, ndi_dc_getname(dcp), | |
6137 ndi_dc_getaddr(dcp))) == NULL) { | |
6138 rv = ENXIO; | |
6139 break; | |
6140 } | |
6141 retval = mdi_select_path(child, NULL, | |
6142 (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH), | |
6143 NULL, &pip); | |
6144 if ((retval != MDI_SUCCESS) || (pip == NULL)) { | |
6145 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioctl:" | |
6146 "Unable to get a path, dip 0x%p", (void *)child)); | |
6147 rv = ENXIO; | |
6148 break; | |
6149 } | |
6150 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
6151 if (vhci_recovery_reset(svp->svp_svl, | |
6152 &svp->svp_psd->sd_address, TRUE, | |
6153 VHCI_DEPTH_TARGET) == 0) { | |
6154 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6155 "!vhci_ioctl(pip:%p): " | |
6156 "reset failed\n", (void *)pip)); | |
6157 rv = ENXIO; | |
6158 } | |
6159 mdi_rele_path(pip); | |
6160 break; | |
6161 | |
6162 case DEVCTL_BUS_QUIESCE: | |
6163 case DEVCTL_BUS_UNQUIESCE: | |
6164 case DEVCTL_BUS_RESET: | |
6165 case DEVCTL_BUS_RESETALL: | |
6166 #ifdef DEBUG | |
6167 case DEVCTL_BUS_CONFIGURE: | |
6168 case DEVCTL_BUS_UNCONFIGURE: | |
6169 #endif | |
6170 rv = ENOTSUP; | |
6171 break; | |
6172 | |
6173 default: | |
6174 rv = ENOTTY; | |
6175 } /* end of outer switch */ | |
6176 | |
6177 ndi_dc_freehdl(dcp); | |
6178 return (rv); | |
6179 } | |
6180 | |
6181 /* | |
6182 * Routine to get the PHCI pathname from ioctl structures in userland | |
6183 */ | |
6184 /* ARGSUSED */ | |
6185 static int | |
6186 vhci_ioc_get_phci_path(sv_iocdata_t *pioc, caddr_t phci_path, | |
6187 int mode, caddr_t s) | |
6188 { | |
6189 int retval = 0; | |
6190 | |
6191 if (ddi_copyin(pioc->phci, phci_path, MAXPATHLEN, mode)) { | |
6192 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_get_phci: ioctl <%s> " | |
6193 "phci_path copyin failed", s)); | |
6194 retval = EFAULT; | |
6195 } | |
6196 return (retval); | |
6197 | |
6198 } | |
6199 | |
6200 | |
6201 /* | |
6202 * Routine to get the Client device pathname from ioctl structures in userland | |
6203 */ | |
6204 /* ARGSUSED */ | |
6205 static int | |
6206 vhci_ioc_get_client_path(sv_iocdata_t *pioc, caddr_t client_path, | |
6207 int mode, caddr_t s) | |
6208 { | |
6209 int retval = 0; | |
6210 | |
6211 if (ddi_copyin(pioc->client, client_path, MAXPATHLEN, mode)) { | |
6212 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_get_client: " | |
6213 "ioctl <%s> client_path copyin failed", s)); | |
6214 retval = EFAULT; | |
6215 } | |
6216 return (retval); | |
6217 } | |
6218 | |
6219 | |
6220 /* | |
6221 * Routine to get physical device address from ioctl structure in userland | |
6222 */ | |
6223 /* ARGSUSED */ | |
6224 static int | |
6225 vhci_ioc_get_paddr(sv_iocdata_t *pioc, caddr_t paddr, int mode, caddr_t s) | |
6226 { | |
6227 int retval = 0; | |
6228 | |
6229 if (ddi_copyin(pioc->addr, paddr, MAXNAMELEN, mode)) { | |
6230 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_get_paddr: " | |
6231 "ioctl <%s> device addr copyin failed", s)); | |
6232 retval = EFAULT; | |
6233 } | |
6234 return (retval); | |
6235 } | |
6236 | |
6237 | |
6238 /* | |
6239 * Routine to send client device pathname to userland. | |
6240 */ | |
6241 /* ARGSUSED */ | |
6242 static int | |
6243 vhci_ioc_send_client_path(caddr_t client_path, sv_iocdata_t *pioc, | |
6244 int mode, caddr_t s) | |
6245 { | |
6246 int retval = 0; | |
6247 | |
6248 if (ddi_copyout(client_path, pioc->client, MAXPATHLEN, mode)) { | |
6249 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_ioc_send_client: " | |
6250 "ioctl <%s> client_path copyout failed", s)); | |
6251 retval = EFAULT; | |
6252 } | |
6253 return (retval); | |
6254 } | |
6255 | |
6256 | |
6257 /* | |
6258 * Routine to translated dev_info pointer (dip) to device pathname. | |
6259 */ | |
6260 static void | |
6261 vhci_ioc_devi_to_path(dev_info_t *dip, caddr_t path) | |
6262 { | |
6263 (void) ddi_pathname(dip, path); | |
6264 } | |
6265 | |
6266 | |
6267 /* | |
6268 * vhci_get_phci_path_list: | |
6269 * get information about devices associated with a | |
6270 * given PHCI device. | |
6271 * | |
6272 * Return Values: | |
6273 * path information elements | |
6274 */ | |
6275 int | |
6276 vhci_get_phci_path_list(dev_info_t *pdip, sv_path_info_t *pibuf, | |
6277 uint_t num_elems) | |
6278 { | |
6279 uint_t count, done; | |
6280 mdi_pathinfo_t *pip; | |
6281 sv_path_info_t *ret_pip; | |
6282 int status; | |
6283 size_t prop_size; | |
6284 int circular; | |
6285 | |
6286 /* | |
6287 * Get the PHCI structure and retrieve the path information | |
6288 * from the GUID hash table. | |
6289 */ | |
6290 | |
6291 ret_pip = pibuf; | |
6292 count = 0; | |
6293 | |
6294 ndi_devi_enter(pdip, &circular); | |
6295 | |
6296 done = (count >= num_elems); | |
6297 pip = mdi_get_next_client_path(pdip, NULL); | |
6298 while (pip && !done) { | |
6299 mdi_pi_lock(pip); | |
6300 (void) ddi_pathname(mdi_pi_get_phci(pip), | |
6301 ret_pip->device.ret_phci); | |
6302 (void) strcpy(ret_pip->ret_addr, mdi_pi_get_addr(pip)); | |
6303 (void) mdi_pi_get_state2(pip, &ret_pip->ret_state, | |
6304 &ret_pip->ret_ext_state); | |
6305 | |
6306 status = mdi_prop_size(pip, &prop_size); | |
6307 if (status == MDI_SUCCESS && ret_pip->ret_prop.ret_buf_size) { | |
6308 *ret_pip->ret_prop.ret_buf_size = (uint_t)prop_size; | |
6309 } | |
6310 | |
6311 #ifdef DEBUG | |
6312 if (status != MDI_SUCCESS) { | |
6313 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6314 "!vhci_get_phci_path_list: " | |
6315 "phci <%s>, prop size failure 0x%x", | |
6316 ret_pip->device.ret_phci, status)); | |
6317 } | |
6318 #endif /* DEBUG */ | |
6319 | |
6320 | |
6321 if (status == MDI_SUCCESS && ret_pip->ret_prop.buf && | |
6322 prop_size && ret_pip->ret_prop.buf_size >= prop_size) { | |
6323 status = mdi_prop_pack(pip, | |
6324 &ret_pip->ret_prop.buf, | |
6325 ret_pip->ret_prop.buf_size); | |
6326 | |
6327 #ifdef DEBUG | |
6328 if (status != MDI_SUCCESS) { | |
6329 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6330 "!vhci_get_phci_path_list: " | |
6331 "phci <%s>, prop pack failure 0x%x", | |
6332 ret_pip->device.ret_phci, status)); | |
6333 } | |
6334 #endif /* DEBUG */ | |
6335 } | |
6336 | |
6337 mdi_pi_unlock(pip); | |
6338 pip = mdi_get_next_client_path(pdip, pip); | |
6339 ret_pip++; | |
6340 count++; | |
6341 done = (count >= num_elems); | |
6342 } | |
6343 | |
6344 ndi_devi_exit(pdip, circular); | |
6345 | |
6346 return (MDI_SUCCESS); | |
6347 } | |
6348 | |
6349 | |
6350 /* | |
6351 * vhci_get_client_path_list: | |
6352 * get information about various paths associated with a | |
6353 * given client device. | |
6354 * | |
6355 * Return Values: | |
6356 * path information elements | |
6357 */ | |
6358 int | |
6359 vhci_get_client_path_list(dev_info_t *cdip, sv_path_info_t *pibuf, | |
6360 uint_t num_elems) | |
6361 { | |
6362 uint_t count, done; | |
6363 mdi_pathinfo_t *pip; | |
6364 sv_path_info_t *ret_pip; | |
6365 int status; | |
6366 size_t prop_size; | |
6367 int circular; | |
6368 | |
6369 ret_pip = pibuf; | |
6370 count = 0; | |
6371 | |
6372 ndi_devi_enter(cdip, &circular); | |
6373 | |
6374 done = (count >= num_elems); | |
6375 pip = mdi_get_next_phci_path(cdip, NULL); | |
6376 while (pip && !done) { | |
6377 mdi_pi_lock(pip); | |
6378 (void) ddi_pathname(mdi_pi_get_phci(pip), | |
6379 ret_pip->device.ret_phci); | |
6380 (void) strcpy(ret_pip->ret_addr, mdi_pi_get_addr(pip)); | |
6381 (void) mdi_pi_get_state2(pip, &ret_pip->ret_state, | |
6382 &ret_pip->ret_ext_state); | |
6383 | |
6384 status = mdi_prop_size(pip, &prop_size); | |
6385 if (status == MDI_SUCCESS && ret_pip->ret_prop.ret_buf_size) { | |
6386 *ret_pip->ret_prop.ret_buf_size = (uint_t)prop_size; | |
6387 } | |
6388 | |
6389 #ifdef DEBUG | |
6390 if (status != MDI_SUCCESS) { | |
6391 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6392 "!vhci_get_client_path_list: " | |
6393 "phci <%s>, prop size failure 0x%x", | |
6394 ret_pip->device.ret_phci, status)); | |
6395 } | |
6396 #endif /* DEBUG */ | |
6397 | |
6398 | |
6399 if (status == MDI_SUCCESS && ret_pip->ret_prop.buf && | |
6400 prop_size && ret_pip->ret_prop.buf_size >= prop_size) { | |
6401 status = mdi_prop_pack(pip, | |
6402 &ret_pip->ret_prop.buf, | |
6403 ret_pip->ret_prop.buf_size); | |
6404 | |
6405 #ifdef DEBUG | |
6406 if (status != MDI_SUCCESS) { | |
6407 VHCI_DEBUG(2, (CE_WARN, NULL, | |
6408 "!vhci_get_client_path_list: " | |
6409 "phci <%s>, prop pack failure 0x%x", | |
6410 ret_pip->device.ret_phci, status)); | |
6411 } | |
6412 #endif /* DEBUG */ | |
6413 } | |
6414 | |
6415 mdi_pi_unlock(pip); | |
6416 pip = mdi_get_next_phci_path(cdip, pip); | |
6417 ret_pip++; | |
6418 count++; | |
6419 done = (count >= num_elems); | |
6420 } | |
6421 | |
6422 ndi_devi_exit(cdip, circular); | |
6423 | |
6424 return (MDI_SUCCESS); | |
6425 } | |
6426 | |
6427 | |
6428 /* | |
6429 * Routine to get ioctl argument structure from userland. | |
6430 */ | |
6431 /* ARGSUSED */ | |
6432 static int | |
6433 vhci_get_iocdata(const void *data, sv_iocdata_t *pioc, int mode, caddr_t s) | |
6434 { | |
6435 int retval = 0; | |
6436 | |
6437 #ifdef _MULTI_DATAMODEL | |
6438 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6439 case DDI_MODEL_ILP32: | |
6440 { | |
6441 sv_iocdata32_t ioc32; | |
6442 | |
6443 if (ddi_copyin(data, &ioc32, sizeof (ioc32), mode)) { | |
6444 retval = EFAULT; | |
6445 break; | |
6446 } | |
6447 pioc->client = (caddr_t)(uintptr_t)ioc32.client; | |
6448 pioc->phci = (caddr_t)(uintptr_t)ioc32.phci; | |
6449 pioc->addr = (caddr_t)(uintptr_t)ioc32.addr; | |
6450 pioc->buf_elem = (uint_t)ioc32.buf_elem; | |
6451 pioc->ret_buf = (sv_path_info_t *)(uintptr_t)ioc32.ret_buf; | |
6452 pioc->ret_elem = (uint_t *)(uintptr_t)ioc32.ret_elem; | |
6453 break; | |
6454 } | |
6455 | |
6456 case DDI_MODEL_NONE: | |
6457 if (ddi_copyin(data, pioc, sizeof (*pioc), mode)) { | |
6458 retval = EFAULT; | |
6459 break; | |
6460 } | |
6461 break; | |
6462 } | |
6463 #else /* _MULTI_DATAMODEL */ | |
6464 if (ddi_copyin(data, pioc, sizeof (*pioc), mode)) { | |
6465 retval = EFAULT; | |
6466 } | |
6467 #endif /* _MULTI_DATAMODEL */ | |
6468 | |
6469 #ifdef DEBUG | |
6470 if (retval) { | |
6471 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: cmd <%s> " | |
6472 "iocdata copyin failed", s)); | |
6473 } | |
6474 #endif | |
6475 | |
6476 return (retval); | |
6477 } | |
6478 | |
6479 | |
6480 /* | |
6481 * Routine to get the ioctl argument for ioctl causing controller switchover. | |
6482 */ | |
6483 /* ARGSUSED */ | |
6484 static int | |
6485 vhci_get_iocswitchdata(const void *data, sv_switch_to_cntlr_iocdata_t *piocsc, | |
6486 int mode, caddr_t s) | |
6487 { | |
6488 int retval = 0; | |
6489 | |
6490 #ifdef _MULTI_DATAMODEL | |
6491 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6492 case DDI_MODEL_ILP32: | |
6493 { | |
6494 sv_switch_to_cntlr_iocdata32_t ioc32; | |
6495 | |
6496 if (ddi_copyin(data, &ioc32, sizeof (ioc32), mode)) { | |
6497 retval = EFAULT; | |
6498 break; | |
6499 } | |
6500 piocsc->client = (caddr_t)(uintptr_t)ioc32.client; | |
6501 piocsc->class = (caddr_t)(uintptr_t)ioc32.class; | |
6502 break; | |
6503 } | |
6504 | |
6505 case DDI_MODEL_NONE: | |
6506 if (ddi_copyin(data, piocsc, sizeof (*piocsc), mode)) { | |
6507 retval = EFAULT; | |
6508 } | |
6509 break; | |
6510 } | |
6511 #else /* _MULTI_DATAMODEL */ | |
6512 if (ddi_copyin(data, piocsc, sizeof (*piocsc), mode)) { | |
6513 retval = EFAULT; | |
6514 } | |
6515 #endif /* _MULTI_DATAMODEL */ | |
6516 | |
6517 #ifdef DEBUG | |
6518 if (retval) { | |
6519 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: cmd <%s> " | |
6520 "switch_to_cntlr_iocdata copyin failed", s)); | |
6521 } | |
6522 #endif | |
6523 | |
6524 return (retval); | |
6525 } | |
6526 | |
6527 | |
6528 /* | |
6529 * Routine to allocate memory for the path information structures. | |
6530 * It allocates two chunks of memory - one for keeping userland | |
6531 * pointers/values for path information and path properties, second for | |
6532 * keeping allocating kernel memory for path properties. These path | |
6533 * properties are finally copied to userland. | |
6534 */ | |
6535 /* ARGSUSED */ | |
6536 static int | |
6537 vhci_ioc_alloc_pathinfo(sv_path_info_t **upibuf, sv_path_info_t **kpibuf, | |
6538 uint_t num_paths, sv_iocdata_t *pioc, int mode, caddr_t s) | |
6539 { | |
6540 sv_path_info_t *pi; | |
6541 uint_t bufsize; | |
6542 int retval = 0; | |
6543 int index; | |
6544 | |
6545 /* Allocate memory */ | |
6546 *upibuf = (sv_path_info_t *) | |
6547 kmem_zalloc(sizeof (sv_path_info_t) * num_paths, KM_SLEEP); | |
6548 ASSERT(*upibuf != NULL); | |
6549 *kpibuf = (sv_path_info_t *) | |
6550 kmem_zalloc(sizeof (sv_path_info_t) * num_paths, KM_SLEEP); | |
6551 ASSERT(*kpibuf != NULL); | |
6552 | |
6553 /* | |
6554 * Get the path info structure from the user space. | |
6555 * We are interested in the following fields: | |
6556 * - user size of buffer for per path properties. | |
6557 * - user address of buffer for path info properties. | |
6558 * - user pointer for returning actual buffer size | |
6559 * Keep these fields in the 'upibuf' structures. | |
6560 * Allocate buffer for per path info properties in kernel | |
6561 * structure ('kpibuf'). | |
6562 * Size of these buffers will be equal to the size of buffers | |
6563 * in the user space. | |
6564 */ | |
6565 #ifdef _MULTI_DATAMODEL | |
6566 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6567 case DDI_MODEL_ILP32: | |
6568 { | |
6569 sv_path_info32_t *src; | |
6570 sv_path_info32_t pi32; | |
6571 | |
6572 src = (sv_path_info32_t *)pioc->ret_buf; | |
6573 pi = (sv_path_info_t *)*upibuf; | |
6574 for (index = 0; index < num_paths; index++, src++, pi++) { | |
6575 if (ddi_copyin(src, &pi32, sizeof (pi32), mode)) { | |
6576 retval = EFAULT; | |
6577 break; | |
6578 } | |
6579 | |
6580 pi->ret_prop.buf_size = | |
6581 (uint_t)pi32.ret_prop.buf_size; | |
6582 pi->ret_prop.ret_buf_size = | |
6583 (uint_t *)(uintptr_t)pi32.ret_prop.ret_buf_size; | |
6584 pi->ret_prop.buf = | |
6585 (caddr_t)(uintptr_t)pi32.ret_prop.buf; | |
6586 } | |
6587 break; | |
6588 } | |
6589 | |
6590 case DDI_MODEL_NONE: | |
6591 if (ddi_copyin(pioc->ret_buf, *upibuf, | |
6592 sizeof (sv_path_info_t) * num_paths, mode)) { | |
6593 retval = EFAULT; | |
6594 } | |
6595 break; | |
6596 } | |
6597 #else /* _MULTI_DATAMODEL */ | |
6598 if (ddi_copyin(pioc->ret_buf, *upibuf, | |
6599 sizeof (sv_path_info_t) * num_paths, mode)) { | |
6600 retval = EFAULT; | |
6601 } | |
6602 #endif /* _MULTI_DATAMODEL */ | |
6603 | |
6604 if (retval != 0) { | |
6605 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_alloc_path_info: " | |
6606 "ioctl <%s> normal: path_info copyin failed", s)); | |
6607 kmem_free(*upibuf, sizeof (sv_path_info_t) * num_paths); | |
6608 kmem_free(*kpibuf, sizeof (sv_path_info_t) * num_paths); | |
6609 *upibuf = NULL; | |
6610 *kpibuf = NULL; | |
6611 return (retval); | |
6612 } | |
6613 | |
6614 /* | |
6615 * Allocate memory for per path properties. | |
6616 */ | |
6617 for (index = 0, pi = *kpibuf; index < num_paths; index++, pi++) { | |
6618 bufsize = (*upibuf)[index].ret_prop.buf_size; | |
6619 | |
6620 if (bufsize && bufsize <= SV_PROP_MAX_BUF_SIZE) { | |
6621 pi->ret_prop.buf_size = bufsize; | |
6622 pi->ret_prop.buf = (caddr_t) | |
6623 kmem_zalloc(bufsize, KM_SLEEP); | |
6624 ASSERT(pi->ret_prop.buf != NULL); | |
6625 } else { | |
6626 pi->ret_prop.buf_size = 0; | |
6627 pi->ret_prop.buf = NULL; | |
6628 } | |
6629 | |
6630 if ((*upibuf)[index].ret_prop.ret_buf_size != NULL) { | |
6631 pi->ret_prop.ret_buf_size = (uint_t *)kmem_zalloc( | |
6632 sizeof (*pi->ret_prop.ret_buf_size), KM_SLEEP); | |
6633 ASSERT(pi->ret_prop.ret_buf_size != NULL); | |
6634 } else { | |
6635 pi->ret_prop.ret_buf_size = NULL; | |
6636 } | |
6637 } | |
6638 | |
6639 return (0); | |
6640 } | |
6641 | |
6642 | |
6643 /* | |
6644 * Routine to free memory for the path information structures. | |
6645 * This is the memory which was allocated earlier. | |
6646 */ | |
6647 /* ARGSUSED */ | |
6648 static void | |
6649 vhci_ioc_free_pathinfo(sv_path_info_t *upibuf, sv_path_info_t *kpibuf, | |
6650 uint_t num_paths) | |
6651 { | |
6652 sv_path_info_t *pi; | |
6653 int index; | |
6654 | |
6655 /* Free memory for per path properties */ | |
6656 for (index = 0, pi = kpibuf; index < num_paths; index++, pi++) { | |
6657 if (pi->ret_prop.ret_buf_size != NULL) { | |
6658 kmem_free(pi->ret_prop.ret_buf_size, | |
6659 sizeof (*pi->ret_prop.ret_buf_size)); | |
6660 } | |
6661 | |
6662 if (pi->ret_prop.buf != NULL) { | |
6663 kmem_free(pi->ret_prop.buf, pi->ret_prop.buf_size); | |
6664 } | |
6665 } | |
6666 | |
6667 /* Free memory for path info structures */ | |
6668 kmem_free(upibuf, sizeof (sv_path_info_t) * num_paths); | |
6669 kmem_free(kpibuf, sizeof (sv_path_info_t) * num_paths); | |
6670 } | |
6671 | |
6672 | |
6673 /* | |
6674 * Routine to copy path information and path properties to userland. | |
6675 */ | |
6676 /* ARGSUSED */ | |
6677 static int | |
6678 vhci_ioc_send_pathinfo(sv_path_info_t *upibuf, sv_path_info_t *kpibuf, | |
6679 uint_t num_paths, sv_iocdata_t *pioc, int mode, caddr_t s) | |
6680 { | |
6681 int retval = 0, index; | |
6682 sv_path_info_t *upi_ptr; | |
6683 sv_path_info32_t *upi32_ptr; | |
6684 | |
6685 #ifdef _MULTI_DATAMODEL | |
6686 switch (ddi_model_convert_from(mode & FMODELS)) { | |
6687 case DDI_MODEL_ILP32: | |
6688 goto copy_32bit; | |
6689 | |
6690 case DDI_MODEL_NONE: | |
6691 goto copy_normal; | |
6692 } | |
6693 #else /* _MULTI_DATAMODEL */ | |
6694 | |
6695 goto copy_normal; | |
6696 | |
6697 #endif /* _MULTI_DATAMODEL */ | |
6698 | |
6699 copy_normal: | |
6700 | |
6701 /* | |
6702 * Copy path information and path properties to user land. | |
6703 * Pointer fields inside the path property structure were | |
6704 * saved in the 'upibuf' structure earlier. | |
6705 */ | |
6706 upi_ptr = pioc->ret_buf; | |
6707 for (index = 0; index < num_paths; index++) { | |
6708 if (ddi_copyout(kpibuf[index].device.ret_ct, | |
6709 upi_ptr[index].device.ret_ct, MAXPATHLEN, mode)) { | |
6710 retval = EFAULT; | |
6711 break; | |
6712 } | |
6713 | |
6714 if (ddi_copyout(kpibuf[index].ret_addr, | |
6715 upi_ptr[index].ret_addr, MAXNAMELEN, mode)) { | |
6716 retval = EFAULT; | |
6717 break; | |
6718 } | |
6719 | |
6720 if (ddi_copyout(&kpibuf[index].ret_state, | |
6721 &upi_ptr[index].ret_state, sizeof (kpibuf[index].ret_state), | |
6722 mode)) { | |
6723 retval = EFAULT; | |
6724 break; | |
6725 } | |
6726 | |
6727 if (ddi_copyout(&kpibuf[index].ret_ext_state, | |
6728 &upi_ptr[index].ret_ext_state, | |
6729 sizeof (kpibuf[index].ret_ext_state), mode)) { | |
6730 retval = EFAULT; | |
6731 break; | |
6732 } | |
6733 | |
6734 if ((kpibuf[index].ret_prop.ret_buf_size != NULL) && | |
6735 ddi_copyout(kpibuf[index].ret_prop.ret_buf_size, | |
6736 upibuf[index].ret_prop.ret_buf_size, | |
6737 sizeof (*upibuf[index].ret_prop.ret_buf_size), mode)) { | |
6738 retval = EFAULT; | |
6739 break; | |
6740 } | |
6741 | |
6742 if ((kpibuf[index].ret_prop.buf != NULL) && | |
6743 ddi_copyout(kpibuf[index].ret_prop.buf, | |
6744 upibuf[index].ret_prop.buf, | |
6745 upibuf[index].ret_prop.buf_size, mode)) { | |
6746 retval = EFAULT; | |
6747 break; | |
6748 } | |
6749 } | |
6750 | |
6751 #ifdef DEBUG | |
6752 if (retval) { | |
6753 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: ioctl <%s> " | |
6754 "normal: path_info copyout failed", s)); | |
6755 } | |
6756 #endif | |
6757 | |
6758 return (retval); | |
6759 | |
6760 copy_32bit: | |
6761 /* | |
6762 * Copy path information and path properties to user land. | |
6763 * Pointer fields inside the path property structure were | |
6764 * saved in the 'upibuf' structure earlier. | |
6765 */ | |
6766 upi32_ptr = (sv_path_info32_t *)pioc->ret_buf; | |
6767 for (index = 0; index < num_paths; index++) { | |
6768 if (ddi_copyout(kpibuf[index].device.ret_ct, | |
6769 upi32_ptr[index].device.ret_ct, MAXPATHLEN, mode)) { | |
6770 retval = EFAULT; | |
6771 break; | |
6772 } | |
6773 | |
6774 if (ddi_copyout(kpibuf[index].ret_addr, | |
6775 upi32_ptr[index].ret_addr, MAXNAMELEN, mode)) { | |
6776 retval = EFAULT; | |
6777 break; | |
6778 } | |
6779 | |
6780 if (ddi_copyout(&kpibuf[index].ret_state, | |
6781 &upi32_ptr[index].ret_state, | |
6782 sizeof (kpibuf[index].ret_state), mode)) { | |
6783 retval = EFAULT; | |
6784 break; | |
6785 } | |
6786 | |
6787 if (ddi_copyout(&kpibuf[index].ret_ext_state, | |
6788 &upi32_ptr[index].ret_ext_state, | |
6789 sizeof (kpibuf[index].ret_ext_state), mode)) { | |
6790 retval = EFAULT; | |
6791 break; | |
6792 } | |
6793 if ((kpibuf[index].ret_prop.ret_buf_size != NULL) && | |
6794 ddi_copyout(kpibuf[index].ret_prop.ret_buf_size, | |
6795 upibuf[index].ret_prop.ret_buf_size, | |
6796 sizeof (*upibuf[index].ret_prop.ret_buf_size), mode)) { | |
6797 retval = EFAULT; | |
6798 break; | |
6799 } | |
6800 | |
6801 if ((kpibuf[index].ret_prop.buf != NULL) && | |
6802 ddi_copyout(kpibuf[index].ret_prop.buf, | |
6803 upibuf[index].ret_prop.buf, | |
6804 upibuf[index].ret_prop.buf_size, mode)) { | |
6805 retval = EFAULT; | |
6806 break; | |
6807 } | |
6808 } | |
6809 | |
6810 #ifdef DEBUG | |
6811 if (retval) { | |
6812 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_get_ioc: ioctl <%s> " | |
6813 "normal: path_info copyout failed", s)); | |
6814 } | |
6815 #endif | |
6816 | |
6817 return (retval); | |
6818 } | |
6819 | |
6820 | |
6821 /* | |
6822 * vhci_failover() | |
6823 * This routine expects VHCI_HOLD_LUN before being invoked. It can be invoked | |
6824 * as MDI_FAILOVER_ASYNC or MDI_FAILOVER_SYNC. For Asynchronous failovers | |
6825 * this routine shall VHCI_RELEASE_LUN on exiting. For synchronous failovers | |
6826 * it is the callers responsibility to release lun. | |
6827 */ | |
6828 | |
6829 /* ARGSUSED */ | |
6830 static int | |
6831 vhci_failover(dev_info_t *vdip, dev_info_t *cdip, int flags) | |
6832 { | |
6833 char *guid; | |
6834 scsi_vhci_lun_t *vlun = NULL; | |
6835 struct scsi_vhci *vhci; | |
6836 mdi_pathinfo_t *pip, *npip; | |
6837 char *s_pclass, *pclass1, *pclass2, *pclass; | |
6838 char active_pclass_copy[255], *active_pclass_ptr; | |
6839 char *ptr1, *ptr2; | |
6840 mdi_pathinfo_state_t pi_state; | |
6841 uint32_t pi_ext_state; | |
6842 scsi_vhci_priv_t *svp; | |
6843 struct scsi_device *sd; | |
6844 struct scsi_failover_ops *sfo; | |
6845 int sps; /* mdi_select_path() status */ | |
6846 int activation_done = 0; | |
6847 int rval, retval = MDI_FAILURE; | |
6848 int reserve_pending, check_condition, UA_condition; | |
6849 struct scsi_pkt *pkt; | |
6850 struct buf *bp; | |
6851 | |
6852 vhci = ddi_get_soft_state(vhci_softstate, ddi_get_instance(vdip)); | |
6853 sd = ddi_get_driver_private(cdip); | |
6854 vlun = ADDR2VLUN(&sd->sd_address); | |
6855 ASSERT(vlun != 0); | |
6856 ASSERT(VHCI_LUN_IS_HELD(vlun)); | |
6857 guid = vlun->svl_lun_wwn; | |
6858 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(1): guid %s\n", guid)); | |
6859 vhci_log(CE_NOTE, vdip, "!Initiating failover for device %s " | |
6860 "(GUID %s)", ddi_node_name(cdip), guid); | |
6861 | |
6862 /* | |
6863 * Lets maintain a local copy of the vlun->svl_active_pclass | |
6864 * for the rest of the processing. Accessing the field | |
6865 * directly in the loop below causes loop logic to break | |
6866 * especially when the field gets updated by other threads | |
6867 * update path status etc and causes 'paths are not currently | |
6868 * available' condition to be declared prematurely. | |
6869 */ | |
6870 mutex_enter(&vlun->svl_mutex); | |
6871 if (vlun->svl_active_pclass != NULL) { | |
6872 (void) strlcpy(active_pclass_copy, vlun->svl_active_pclass, | |
6873 sizeof (active_pclass_copy)); | |
6874 active_pclass_ptr = &active_pclass_copy[0]; | |
6875 mutex_exit(&vlun->svl_mutex); | |
6876 if (vhci_quiesce_paths(vdip, cdip, vlun, guid, | |
6877 active_pclass_ptr) != 0) { | |
6878 retval = MDI_FAILURE; | |
6879 } | |
6880 } else { | |
6881 /* | |
6882 * can happen only when the available path to device | |
6883 * discovered is a STANDBY path. | |
6884 */ | |
6885 mutex_exit(&vlun->svl_mutex); | |
6886 active_pclass_copy[0] = '\0'; | |
6887 active_pclass_ptr = NULL; | |
6888 } | |
6889 | |
6890 sfo = vlun->svl_fops; | |
6891 ASSERT(sfo != NULL); | |
6892 pclass1 = s_pclass = active_pclass_ptr; | |
6893 VHCI_DEBUG(1, (CE_NOTE, NULL, "!(%s)failing over from %s\n", guid, | |
6894 (s_pclass == NULL ? "<none>" : s_pclass))); | |
6895 | |
6896 next_pathclass: | |
6897 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
6898 rval = sfo->sfo_pathclass_next(pclass1, &pclass2, |
4851 | 6899 vlun->svl_fops_ctpriv); |
6900 if (rval == ENOENT) { | |
6901 if (s_pclass == NULL) { | |
6902 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(4)(%s): " | |
6903 "failed, no more pathclasses\n", guid)); | |
6904 goto done; | |
6905 } else { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
6906 (void) sfo->sfo_pathclass_next(NULL, &pclass2, |
4851 | 6907 vlun->svl_fops_ctpriv); |
6908 } | |
6909 } else if (rval == EINVAL) { | |
6910 vhci_log(CE_NOTE, vdip, "!Failover operation failed for " | |
6911 "device %s (GUID %s): Invalid path-class %s", | |
6912 ddi_node_name(cdip), guid, | |
6913 ((pclass1 == NULL) ? "<none>" : pclass1)); | |
6914 goto done; | |
6915 } | |
6916 if ((s_pclass != NULL) && (strcmp(pclass2, s_pclass) == 0)) { | |
6917 /* | |
6918 * paths are not currently available | |
6919 */ | |
6920 vhci_log(CE_NOTE, vdip, "!Failover path currently unavailable" | |
6921 " for device %s (GUID %s)", | |
6922 ddi_node_name(cdip), guid); | |
6923 goto done; | |
6924 } | |
6925 pip = npip = NULL; | |
6926 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(5.2)(%s): considering " | |
6927 "%s as failover destination\n", guid, pclass2)); | |
6928 sps = mdi_select_path(cdip, NULL, MDI_SELECT_STANDBY_PATH, NULL, &npip); | |
6929 if ((npip == NULL) || (sps != MDI_SUCCESS)) { | |
6930 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(%s): no " | |
6931 "STANDBY paths found (status:%x)!\n", guid, sps)); | |
6932 pclass1 = pclass2; | |
6933 goto next_pathclass; | |
6934 } | |
6935 do { | |
6936 pclass = NULL; | |
6937 if ((mdi_prop_lookup_string(npip, "path-class", | |
6938 &pclass) != MDI_SUCCESS) || (strcmp(pclass2, | |
6939 pclass) != 0)) { | |
6940 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6941 "!vhci_failover(5.5)(%s): skipping path " | |
6942 "%p(%s)...\n", guid, (void *)npip, pclass)); | |
6943 pip = npip; | |
6944 sps = mdi_select_path(cdip, NULL, | |
6945 MDI_SELECT_STANDBY_PATH, pip, &npip); | |
6946 mdi_rele_path(pip); | |
6947 (void) mdi_prop_free(pclass); | |
6948 continue; | |
6949 } | |
6950 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(npip); | |
6951 | |
6952 /* | |
6953 * Issue READ at non-zer block on this STANDBY path. | |
6954 * Purple returns | |
6955 * 1. RESERVATION_CONFLICT if reservation is pending | |
6956 * 2. POR check condition if it reset happened. | |
6957 * 2. failover Check Conditions if one is already in progress. | |
6958 */ | |
6959 reserve_pending = 0; | |
6960 check_condition = 0; | |
6961 UA_condition = 0; | |
6962 | |
6963 bp = scsi_alloc_consistent_buf(&svp->svp_psd->sd_address, | |
6964 (struct buf *)NULL, DEV_BSIZE, B_READ, NULL, NULL); | |
6965 if (!bp) { | |
6966 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
6967 "vhci_failover !No resources (buf)\n")); | |
6968 mdi_rele_path(npip); | |
6969 goto done; | |
6970 } | |
6971 pkt = scsi_init_pkt(&svp->svp_psd->sd_address, NULL, bp, | |
6972 CDB_GROUP1, sizeof (struct scsi_arq_status), 0, | |
6973 PKT_CONSISTENT, NULL, NULL); | |
6974 if (pkt) { | |
6975 (void) scsi_setup_cdb((union scsi_cdb *)(uintptr_t) | |
6976 pkt->pkt_cdbp, SCMD_READ, 1, 1, 0); | |
6977 pkt->pkt_flags = FLAG_NOINTR; | |
6978 check_path_again: | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
6979 pkt->pkt_path_instance = mdi_pi_get_path_instance(npip); |
4851 | 6980 pkt->pkt_time = 3*30; |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
6981 |
4851 | 6982 if (scsi_transport(pkt) == TRAN_ACCEPT) { |
6983 switch (pkt->pkt_reason) { | |
6984 case CMD_CMPLT: | |
6985 switch (SCBP_C(pkt)) { | |
6986 case STATUS_GOOD: | |
6987 /* Already failed over */ | |
6988 activation_done = 1; | |
6989 break; | |
6990 case STATUS_RESERVATION_CONFLICT: | |
6991 reserve_pending = 1; | |
6992 break; | |
6993 case STATUS_CHECK: | |
6994 check_condition = 1; | |
6995 break; | |
6996 } | |
6997 } | |
6998 } | |
6999 if (check_condition && | |
7000 (pkt->pkt_state & STATE_ARQ_DONE)) { | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7001 uint8_t *sns, skey, asc, ascq; |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7002 sns = (uint8_t *) |
4851 | 7003 &(((struct scsi_arq_status *)(uintptr_t) |
7004 (pkt->pkt_scbp))->sts_sensedata); | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7005 skey = scsi_sense_key(sns); |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7006 asc = scsi_sense_asc(sns); |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7007 ascq = scsi_sense_ascq(sns); |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7008 if (skey == KEY_UNIT_ATTENTION && |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7009 asc == 0x29) { |
4851 | 7010 /* Already failed over */ |
7011 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7012 "!vhci_failover(7)(%s): " | |
7013 "path 0x%p POR UA condition\n", | |
7014 guid, (void *)npip)); | |
7015 if (UA_condition == 0) { | |
7016 UA_condition = 1; | |
7017 goto check_path_again; | |
7018 } | |
7019 } else { | |
7020 activation_done = 0; | |
7021 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7022 "!vhci_failover(%s): path 0x%p " | |
7023 "unhandled chkcond %x %x %x\n", | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7024 guid, (void *)npip, skey, |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7025 asc, ascq)); |
4851 | 7026 } |
7027 } | |
7028 scsi_destroy_pkt(pkt); | |
7029 } | |
7030 scsi_free_consistent_buf(bp); | |
7031 | |
7032 if (activation_done) { | |
7033 mdi_rele_path(npip); | |
7034 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(7)(%s): " | |
7035 "path 0x%p already failedover\n", guid, | |
7036 (void *)npip)); | |
7037 break; | |
7038 } | |
7039 if (reserve_pending && (vlun->svl_xlf_capable == 0)) { | |
7040 (void) vhci_recovery_reset(vlun, | |
7041 &svp->svp_psd->sd_address, | |
7042 FALSE, VHCI_DEPTH_ALL); | |
7043 } | |
7044 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(6)(%s): " | |
7045 "activating path 0x%p(psd:%p)\n", guid, (void *)npip, | |
7046 (void *)svp->svp_psd)); | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7047 if (sfo->sfo_path_activate(svp->svp_psd, pclass2, |
4851 | 7048 vlun->svl_fops_ctpriv) == 0) { |
7049 activation_done = 1; | |
7050 mdi_rele_path(npip); | |
7051 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(7)(%s): " | |
7052 "path 0x%p successfully activated\n", guid, | |
7053 (void *)npip)); | |
7054 break; | |
7055 } | |
7056 pip = npip; | |
7057 sps = mdi_select_path(cdip, NULL, MDI_SELECT_STANDBY_PATH, | |
7058 pip, &npip); | |
7059 mdi_rele_path(pip); | |
7060 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
7061 if (activation_done == 0) { | |
7062 pclass1 = pclass2; | |
7063 goto next_pathclass; | |
7064 } | |
7065 | |
7066 /* | |
7067 * if we are here, we have succeeded in activating path npip of | |
7068 * pathclass pclass2; let us validate all paths of pclass2 by | |
7069 * "ping"-ing each one and mark the good ones ONLINE | |
7070 * Also, set the state of the paths belonging to the previously | |
7071 * active pathclass to STANDBY | |
7072 */ | |
7073 pip = npip = NULL; | |
7074 sps = mdi_select_path(cdip, NULL, (MDI_SELECT_ONLINE_PATH | | |
7075 MDI_SELECT_STANDBY_PATH | MDI_SELECT_USER_DISABLE_PATH), | |
7076 NULL, &npip); | |
7077 if (npip == NULL || sps != MDI_SUCCESS) { | |
7078 VHCI_DEBUG(1, (CE_NOTE, NULL, "!Failover operation failed for " | |
7079 "device %s (GUID %s): paths may be busy\n", | |
7080 ddi_node_name(cdip), guid)); | |
7081 goto done; | |
7082 } | |
7083 do { | |
7084 (void) mdi_pi_get_state2(npip, &pi_state, &pi_ext_state); | |
7085 if (mdi_prop_lookup_string(npip, "path-class", &pclass) | |
7086 != MDI_SUCCESS) { | |
7087 pip = npip; | |
7088 sps = mdi_select_path(cdip, NULL, | |
7089 (MDI_SELECT_ONLINE_PATH | | |
7090 MDI_SELECT_STANDBY_PATH | | |
7091 MDI_SELECT_USER_DISABLE_PATH), | |
7092 pip, &npip); | |
7093 mdi_rele_path(pip); | |
7094 continue; | |
7095 } | |
7096 if (strcmp(pclass, pclass2) == 0) { | |
7097 if (pi_state == MDI_PATHINFO_STATE_STANDBY) { | |
7098 svp = (scsi_vhci_priv_t *) | |
7099 mdi_pi_get_vhci_private(npip); | |
7100 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7101 "!vhci_failover(8)(%s): " | |
7102 "pinging path 0x%p\n", | |
7103 guid, (void *)npip)); | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7104 if (sfo->sfo_path_ping(svp->svp_psd, |
4851 | 7105 vlun->svl_fops_ctpriv) == 1) { |
7106 mdi_pi_set_state(npip, | |
7107 MDI_PATHINFO_STATE_ONLINE); | |
7108 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7109 "!vhci_failover(9)(%s): " | |
7110 "path 0x%p ping successful, " | |
7111 "marked online\n", guid, | |
7112 (void *)npip)); | |
7113 MDI_PI_ERRSTAT(npip, MDI_PI_FAILTO); | |
7114 } | |
7115 } | |
7116 } else if ((s_pclass != NULL) && (strcmp(pclass, s_pclass) | |
7117 == 0)) { | |
7118 if (pi_state == MDI_PATHINFO_STATE_ONLINE) { | |
7119 mdi_pi_set_state(npip, | |
7120 MDI_PATHINFO_STATE_STANDBY); | |
7121 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7122 "!vhci_failover(10)(%s): path 0x%p marked " | |
7123 "STANDBY\n", guid, (void *)npip)); | |
7124 MDI_PI_ERRSTAT(npip, MDI_PI_FAILFROM); | |
7125 } | |
7126 } | |
7127 (void) mdi_prop_free(pclass); | |
7128 pip = npip; | |
7129 sps = mdi_select_path(cdip, NULL, (MDI_SELECT_ONLINE_PATH | | |
7130 MDI_SELECT_STANDBY_PATH|MDI_SELECT_USER_DISABLE_PATH), | |
7131 pip, &npip); | |
7132 mdi_rele_path(pip); | |
7133 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
7134 | |
7135 /* | |
7136 * Update the AccessState of related MP-API TPGs | |
7137 */ | |
7138 (void) vhci_mpapi_update_tpg_acc_state_for_lu(vhci, vlun); | |
7139 | |
7140 vhci_log(CE_NOTE, vdip, "!Failover operation completed successfully " | |
7141 "for device %s (GUID %s): failed over from %s to %s", | |
7142 ddi_node_name(cdip), guid, ((s_pclass == NULL) ? "<none>" : | |
7143 s_pclass), pclass2); | |
7144 ptr1 = kmem_alloc(strlen(pclass2)+1, KM_SLEEP); | |
7145 (void) strlcpy(ptr1, pclass2, (strlen(pclass2)+1)); | |
7146 mutex_enter(&vlun->svl_mutex); | |
7147 ptr2 = vlun->svl_active_pclass; | |
7148 vlun->svl_active_pclass = ptr1; | |
7149 mutex_exit(&vlun->svl_mutex); | |
7150 if (ptr2) { | |
7151 kmem_free(ptr2, strlen(ptr2)+1); | |
7152 } | |
7153 mutex_enter(&vhci->vhci_mutex); | |
7154 scsi_hba_reset_notify_callback(&vhci->vhci_mutex, | |
7155 &vhci->vhci_reset_notify_listf); | |
7156 /* All reservations are cleared upon these resets. */ | |
7157 vlun->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG; | |
7158 mutex_exit(&vhci->vhci_mutex); | |
7159 VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_failover(11): DONE! Active " | |
7160 "pathclass for %s is now %s\n", guid, pclass2)); | |
7161 retval = MDI_SUCCESS; | |
7162 | |
7163 done: | |
12310
f87d8e83d301
6896190 "Failover completed successfully" is printed a few times while failover is actually failed on a TPG
Victor Li <Victor.Li@Sun.COM>
parents:
11911
diff
changeset
|
7164 vlun->svl_failover_status = retval; |
4851 | 7165 if (flags == MDI_FAILOVER_ASYNC) { |
7166 VHCI_RELEASE_LUN(vlun); | |
7167 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_failover(12): DONE! " | |
7168 "releasing lun, as failover was ASYNC\n")); | |
7169 } else { | |
7170 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_failover(12): DONE! " | |
7171 "NOT releasing lun, as failover was SYNC\n")); | |
7172 } | |
7173 return (retval); | |
7174 } | |
7175 | |
7176 /* | |
7177 * vhci_client_attached is called after the successful attach of a | |
7178 * client devinfo node. | |
7179 */ | |
7180 static void | |
7181 vhci_client_attached(dev_info_t *cdip) | |
7182 { | |
7183 mdi_pathinfo_t *pip; | |
7184 int circular; | |
7185 | |
7186 /* | |
7187 * At this point the client has attached and it's instance number is | |
7188 * valid, so we can set up kstats. We need to do this here because it | |
7189 * is possible for paths to go online prior to client attach, in which | |
7190 * case the call to vhci_kstat_create_pathinfo in vhci_pathinfo_online | |
7191 * was a noop. | |
7192 */ | |
7193 ndi_devi_enter(cdip, &circular); | |
7194 for (pip = mdi_get_next_phci_path(cdip, NULL); pip; | |
7195 pip = mdi_get_next_phci_path(cdip, pip)) | |
7196 vhci_kstat_create_pathinfo(pip); | |
7197 ndi_devi_exit(cdip, circular); | |
7198 } | |
7199 | |
7200 /* | |
7201 * quiesce all of the online paths | |
7202 */ | |
7203 static int | |
7204 vhci_quiesce_paths(dev_info_t *vdip, dev_info_t *cdip, scsi_vhci_lun_t *vlun, | |
7205 char *guid, char *active_pclass_ptr) | |
7206 { | |
7207 scsi_vhci_priv_t *svp; | |
7208 char *s_pclass = NULL; | |
7209 mdi_pathinfo_t *npip, *pip; | |
7210 int sps; | |
7211 | |
7212 /* quiesce currently active paths */ | |
7213 s_pclass = NULL; | |
7214 pip = npip = NULL; | |
7215 sps = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH, NULL, &npip); | |
7216 if ((npip == NULL) || (sps != MDI_SUCCESS)) { | |
7217 return (1); | |
7218 } | |
7219 do { | |
7220 if (mdi_prop_lookup_string(npip, "path-class", | |
7221 &s_pclass) != MDI_SUCCESS) { | |
7222 mdi_rele_path(npip); | |
7223 vhci_log(CE_NOTE, vdip, "!Failover operation failed " | |
7224 "for device %s (GUID %s) due to an internal " | |
7225 "error", ddi_node_name(cdip), guid); | |
7226 return (1); | |
7227 } | |
7228 if (strcmp(s_pclass, active_pclass_ptr) == 0) { | |
7229 /* | |
7230 * quiesce path. Free s_pclass since | |
7231 * we don't need it anymore | |
7232 */ | |
7233 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7234 "!vhci_failover(2)(%s): failing over " | |
7235 "from %s; quiescing path %p\n", | |
7236 guid, s_pclass, (void *)npip)); | |
7237 (void) mdi_prop_free(s_pclass); | |
7238 svp = (scsi_vhci_priv_t *) | |
7239 mdi_pi_get_vhci_private(npip); | |
7240 if (svp == NULL) { | |
7241 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7242 "!vhci_failover(2.5)(%s): no " | |
7243 "client priv! %p offlined?\n", | |
7244 guid, (void *)npip)); | |
7245 pip = npip; | |
7246 sps = mdi_select_path(cdip, NULL, | |
7247 MDI_SELECT_ONLINE_PATH, pip, &npip); | |
7248 mdi_rele_path(pip); | |
7249 continue; | |
7250 } | |
7251 if (scsi_abort(&svp->svp_psd->sd_address, NULL) | |
7252 == 0) { | |
7253 (void) vhci_recovery_reset(vlun, | |
7254 &svp->svp_psd->sd_address, FALSE, | |
7255 VHCI_DEPTH_TARGET); | |
7256 } | |
7257 mutex_enter(&svp->svp_mutex); | |
7258 if (svp->svp_cmds == 0) { | |
7259 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7260 "!vhci_failover(3)(%s):" | |
7261 "quiesced path %p\n", guid, (void *)npip)); | |
7262 } else { | |
7263 while (svp->svp_cmds != 0) { | |
7264 cv_wait(&svp->svp_cv, &svp->svp_mutex); | |
7265 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7266 "!vhci_failover(3.cv)(%s):" | |
7267 "quiesced path %p\n", guid, | |
7268 (void *)npip)); | |
7269 } | |
7270 } | |
7271 mutex_exit(&svp->svp_mutex); | |
7272 } else { | |
7273 /* | |
7274 * make sure we freeup the memory | |
7275 */ | |
7276 (void) mdi_prop_free(s_pclass); | |
7277 } | |
7278 pip = npip; | |
7279 sps = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH, | |
7280 pip, &npip); | |
7281 mdi_rele_path(pip); | |
7282 } while ((npip != NULL) && (sps == MDI_SUCCESS)); | |
7283 return (0); | |
7284 } | |
7285 | |
7286 static struct scsi_vhci_lun * | |
7287 vhci_lun_lookup(dev_info_t *tgt_dip) | |
7288 { | |
7289 return ((struct scsi_vhci_lun *) | |
7290 mdi_client_get_vhci_private(tgt_dip)); | |
7291 } | |
7292 | |
7293 static struct scsi_vhci_lun * | |
7294 vhci_lun_lookup_alloc(dev_info_t *tgt_dip, char *guid, int *didalloc) | |
7295 { | |
7296 struct scsi_vhci_lun *svl; | |
7297 | |
7298 if (svl = vhci_lun_lookup(tgt_dip)) { | |
7299 return (svl); | |
7300 } | |
7301 | |
7302 svl = kmem_zalloc(sizeof (*svl), KM_SLEEP); | |
7303 svl->svl_lun_wwn = kmem_zalloc(strlen(guid)+1, KM_SLEEP); | |
7304 (void) strcpy(svl->svl_lun_wwn, guid); | |
7305 mutex_init(&svl->svl_mutex, NULL, MUTEX_DRIVER, NULL); | |
7306 cv_init(&svl->svl_cv, NULL, CV_DRIVER, NULL); | |
7307 sema_init(&svl->svl_pgr_sema, 1, NULL, SEMA_DRIVER, NULL); | |
7308 svl->svl_waiting_for_activepath = 1; | |
7309 svl->svl_sector_size = 1; | |
7310 mdi_client_set_vhci_private(tgt_dip, svl); | |
7311 *didalloc = 1; | |
7312 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7313 "vhci_lun_lookup_alloc: guid %s vlun 0x%p\n", | |
7314 guid, (void *)svl)); | |
7315 return (svl); | |
7316 } | |
7317 | |
7318 static void | |
7319 vhci_lun_free(dev_info_t *tgt_dip) | |
7320 { | |
7321 struct scsi_vhci_lun *dvlp; | |
7322 char *guid; | |
4882
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7323 struct scsi_device *sd; |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7324 |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7325 /* |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7326 * 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
|
7327 * 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
|
7328 */ |
272a171bc996
6531069 SCSI2 (tc_mhioctkown test cases) testing are showing UNRESOLVED results for ST2530
jw149990
parents:
4851
diff
changeset
|
7329 sd = (struct scsi_device *)ddi_get_driver_private(tgt_dip); |
4851 | 7330 |
7331 dvlp = (struct scsi_vhci_lun *) | |
7332 mdi_client_get_vhci_private(tgt_dip); | |
7333 ASSERT(dvlp != NULL); | |
7334 | |
7335 mdi_client_set_vhci_private(tgt_dip, NULL); | |
7336 | |
7337 guid = dvlp->svl_lun_wwn; | |
7338 ASSERT(guid != NULL); | |
7339 VHCI_DEBUG(4, (CE_NOTE, NULL, "!vhci_lun_free: %s\n", guid)); | |
7340 | |
7341 mutex_enter(&dvlp->svl_mutex); | |
7342 if (dvlp->svl_active_pclass != NULL) { | |
7343 kmem_free(dvlp->svl_active_pclass, | |
7344 strlen(dvlp->svl_active_pclass)+1); | |
7345 } | |
7346 dvlp->svl_active_pclass = NULL; | |
7347 mutex_exit(&dvlp->svl_mutex); | |
7348 | |
7349 if (dvlp->svl_lun_wwn != NULL) { | |
7350 kmem_free(dvlp->svl_lun_wwn, strlen(dvlp->svl_lun_wwn)+1); | |
7351 } | |
7352 dvlp->svl_lun_wwn = NULL; | |
7353 | |
7354 if (dvlp->svl_fops_name) { | |
7355 kmem_free(dvlp->svl_fops_name, strlen(dvlp->svl_fops_name)+1); | |
7356 } | |
7357 dvlp->svl_fops_name = NULL; | |
7358 | |
10098
14f64874e00c
6855459 Null pointer panic in the scsi_vhci module snv build 115 sparc
wl202157@icefox
parents:
9667
diff
changeset
|
7359 if (dvlp->svl_fops_ctpriv != NULL && |
14f64874e00c
6855459 Null pointer panic in the scsi_vhci module snv build 115 sparc
wl202157@icefox
parents:
9667
diff
changeset
|
7360 dvlp->svl_fops != NULL) { |
6023
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
7361 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
|
7362 } |
9adf47ae28c4
6634757 add support for the HDS midrange array subsystem
cm136836
parents:
4949
diff
changeset
|
7363 |
4851 | 7364 if (dvlp->svl_flags & VLUN_TASK_D_ALIVE_FLG) |
7365 taskq_destroy(dvlp->svl_taskq); | |
7366 | |
7367 mutex_destroy(&dvlp->svl_mutex); | |
7368 cv_destroy(&dvlp->svl_cv); | |
7369 sema_destroy(&dvlp->svl_pgr_sema); | |
7370 kmem_free(dvlp, sizeof (*dvlp)); | |
4896
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7371 /* |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7372 * vhci_lun_free may be called before the tgt_dip |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7373 * initialization so check if the sd is NULL. |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7374 */ |
ff3edba9ce8c
6594084 fixing of 6591973 could cause system panic.
jw149990
parents:
4882
diff
changeset
|
7375 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
|
7376 scsi_device_hba_private_set(sd, NULL); |
4851 | 7377 } |
7378 | |
7379 int | |
7380 vhci_do_scsi_cmd(struct scsi_pkt *pkt) | |
7381 { | |
7382 int err = 0; | |
7383 int retry_cnt = 0; | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7384 uint8_t *sns, skey; |
4851 | 7385 |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7386 #ifdef DEBUG |
6962
225346ebbb42
6719151 scsi_vhci debug kernels spews a *lot* on the console during boot
rralphs
parents:
6941
diff
changeset
|
7387 if (vhci_debug > 5) { |
225346ebbb42
6719151 scsi_vhci debug kernels spews a *lot* on the console during boot
rralphs
parents:
6941
diff
changeset
|
7388 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
|
7389 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
|
7390 } |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7391 #endif |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7392 |
4851 | 7393 retry: |
7394 err = scsi_poll(pkt); | |
7395 if (err) { | |
7396 if (pkt->pkt_cdbp[0] == SCMD_RELEASE) { | |
7397 if (SCBP_C(pkt) == STATUS_RESERVATION_CONFLICT) { | |
7398 VHCI_DEBUG(1, (CE_NOTE, NULL, | |
7399 "!v_s_do_s_c: RELEASE conflict\n")); | |
7400 return (0); | |
7401 } | |
7402 } | |
11911
1ff4cad6d0b8
6932833 vhci_do_scsi_cmd retry not enough
Chris Liu <Chris.Liu@Sun.COM>
parents:
11556
diff
changeset
|
7403 if (retry_cnt++ < 6) { |
4851 | 7404 VHCI_DEBUG(1, (CE_WARN, NULL, |
7405 "!v_s_do_s_c:retry packet 0x%p " | |
7406 "status 0x%x reason %s", | |
7407 (void *)pkt, SCBP_C(pkt), | |
7408 scsi_rname(pkt->pkt_reason))); | |
7409 if ((pkt->pkt_reason == CMD_CMPLT) && | |
7410 (SCBP_C(pkt) == STATUS_CHECK) && | |
7411 (pkt->pkt_state & STATE_ARQ_DONE)) { | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7412 sns = (uint8_t *) |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7413 &(((struct scsi_arq_status *)(uintptr_t) |
4851 | 7414 (pkt->pkt_scbp))->sts_sensedata); |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7415 skey = scsi_sense_key(sns); |
4851 | 7416 VHCI_DEBUG(1, (CE_WARN, NULL, |
7417 "!v_s_do_s_c:retry " | |
7418 "packet 0x%p sense data %s", (void *)pkt, | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7419 scsi_sname(skey))); |
4851 | 7420 } |
7421 goto retry; | |
7422 } | |
7423 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7424 "!v_s_do_s_c: failed transport 0x%p 0x%x", | |
7425 (void *)pkt, SCBP_C(pkt))); | |
7426 return (0); | |
7427 } | |
7428 | |
7429 switch (pkt->pkt_reason) { | |
7430 case CMD_TIMEOUT: | |
7431 VHCI_DEBUG(1, (CE_WARN, NULL, "!pkt timed " | |
7432 "out (pkt 0x%p)", (void *)pkt)); | |
7433 return (0); | |
7434 case CMD_CMPLT: | |
7435 switch (SCBP_C(pkt)) { | |
7436 case STATUS_GOOD: | |
7437 break; | |
7438 case STATUS_CHECK: | |
7439 if (pkt->pkt_state & STATE_ARQ_DONE) { | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7440 sns = (uint8_t *)&((( |
4851 | 7441 struct scsi_arq_status *) |
7442 (uintptr_t) | |
7443 (pkt->pkt_scbp))-> | |
7444 sts_sensedata); | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7445 skey = scsi_sense_key(sns); |
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7446 if ((skey == |
4851 | 7447 KEY_UNIT_ATTENTION) || |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7448 (skey == |
4851 | 7449 KEY_NOT_READY)) { |
7450 /* | |
7451 * clear unit attn. | |
7452 */ | |
7453 | |
7454 VHCI_DEBUG(1, | |
7455 (CE_WARN, NULL, | |
7456 "!v_s_do_s_c: " | |
7457 "retry " | |
7458 "packet 0x%p sense " | |
7459 "data %s", | |
7460 (void *)pkt, | |
7461 scsi_sname | |
9304
ff96a286a5d4
6783286 STMS: Host loses access to data on >1TB volumes when there's an external failover on asymm arrays
wl202157@icefox
parents:
9167
diff
changeset
|
7462 (skey))); |
4851 | 7463 goto retry; |
7464 } | |
7465 VHCI_DEBUG(4, (CE_WARN, NULL, | |
7466 "!ARQ while " | |
7467 "transporting " | |
7468 "(pkt 0x%p)", | |
7469 (void *)pkt)); | |
7470 return (0); | |
7471 } | |
7472 return (0); | |
7473 default: | |
7474 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7475 "!Bad status returned " | |
7476 "(pkt 0x%p, status %x)", | |
7477 (void *)pkt, SCBP_C(pkt))); | |
7478 return (0); | |
7479 } | |
7480 break; | |
7481 case CMD_INCOMPLETE: | |
7482 case CMD_RESET: | |
7483 case CMD_ABORTED: | |
7484 case CMD_TRAN_ERR: | |
7485 if (retry_cnt++ < 1) { | |
7486 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7487 "!v_s_do_s_c: retry packet 0x%p %s", | |
7488 (void *)pkt, scsi_rname(pkt->pkt_reason))); | |
7489 goto retry; | |
7490 } | |
7491 /* FALLTHROUGH */ | |
7492 default: | |
7493 VHCI_DEBUG(1, (CE_WARN, NULL, "!pkt did not " | |
7494 "complete successfully (pkt 0x%p," | |
7495 "reason %x)", (void *)pkt, pkt->pkt_reason)); | |
7496 return (0); | |
7497 } | |
7498 return (1); | |
7499 } | |
7500 | |
7501 static int | |
7502 vhci_quiesce_lun(struct scsi_vhci_lun *vlun) | |
7503 { | |
7504 mdi_pathinfo_t *pip, *spip; | |
7505 dev_info_t *cdip; | |
7506 struct scsi_vhci_priv *svp; | |
7507 mdi_pathinfo_state_t pstate; | |
7508 uint32_t p_ext_state; | |
7509 int circular; | |
7510 | |
7511 cdip = vlun->svl_dip; | |
7512 pip = spip = NULL; | |
7513 ndi_devi_enter(cdip, &circular); | |
7514 pip = mdi_get_next_phci_path(cdip, NULL); | |
7515 while (pip != NULL) { | |
7516 (void) mdi_pi_get_state2(pip, &pstate, &p_ext_state); | |
7517 if (pstate != MDI_PATHINFO_STATE_ONLINE) { | |
7518 spip = pip; | |
7519 pip = mdi_get_next_phci_path(cdip, spip); | |
7520 continue; | |
7521 } | |
7522 mdi_hold_path(pip); | |
7523 ndi_devi_exit(cdip, circular); | |
7524 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
7525 mutex_enter(&svp->svp_mutex); | |
7526 while (svp->svp_cmds != 0) { | |
11066
cebb50cbe4f9
PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling
Rafael Vanoni <rafael.vanoni@sun.com>
parents:
11032
diff
changeset
|
7527 if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex, |
cebb50cbe4f9
PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling
Rafael Vanoni <rafael.vanoni@sun.com>
parents:
11032
diff
changeset
|
7528 drv_usectohz(vhci_path_quiesce_timeout * 1000000), |
cebb50cbe4f9
PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling
Rafael Vanoni <rafael.vanoni@sun.com>
parents:
11032
diff
changeset
|
7529 TR_CLOCK_TICK) == -1) { |
4851 | 7530 mutex_exit(&svp->svp_mutex); |
7531 mdi_rele_path(pip); | |
7532 VHCI_DEBUG(1, (CE_WARN, NULL, | |
7533 "Quiesce of lun is not successful " | |
7534 "vlun: 0x%p.", (void *)vlun)); | |
7535 return (0); | |
7536 } | |
7537 } | |
7538 mutex_exit(&svp->svp_mutex); | |
7539 ndi_devi_enter(cdip, &circular); | |
7540 spip = pip; | |
7541 pip = mdi_get_next_phci_path(cdip, spip); | |
7542 mdi_rele_path(spip); | |
7543 } | |
7544 ndi_devi_exit(cdip, circular); | |
7545 return (1); | |
7546 } | |
7547 | |
7548 static int | |
7549 vhci_pgr_validate_and_register(scsi_vhci_priv_t *svp) | |
7550 { | |
7551 scsi_vhci_lun_t *vlun; | |
7552 vhci_prout_t *prout; | |
7553 int rval, success; | |
7554 mdi_pathinfo_t *pip, *npip; | |
7555 scsi_vhci_priv_t *osvp; | |
7556 dev_info_t *cdip; | |
7557 uchar_t cdb_1; | |
7558 uchar_t temp_res_key[MHIOC_RESV_KEY_SIZE]; | |
7559 | |
7560 | |
7561 /* | |
7562 * see if there are any other paths available; if none, | |
7563 * then there is nothing to do. | |
7564 */ | |
7565 cdip = svp->svp_svl->svl_dip; | |
7566 rval = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH | | |
7567 MDI_SELECT_STANDBY_PATH, NULL, &pip); | |
7568 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
7569 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7570 "%s%d: vhci_pgr_validate_and_register: first path\n", | |
7571 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
7572 return (1); | |
7573 } | |
7574 | |
7575 vlun = svp->svp_svl; | |
7576 prout = &vlun->svl_prout; | |
7577 ASSERT(vlun->svl_pgr_active != 0); | |
7578 | |
7579 /* | |
7580 * When the path was busy/offlined, some other host might have | |
7581 * cleared this key. Validate key on some other path first. | |
7582 * If it fails, return failure. | |
7583 */ | |
7584 | |
7585 npip = pip; | |
7586 pip = NULL; | |
7587 success = 0; | |
7588 | |
7589 /* Save the res key */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7590 bcopy(prout->res_key, temp_res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7591 |
7592 /* | |
7593 * Sometimes CDB from application can be a Register_And_Ignore. | |
7594 * Instead of validation, this cdb would result in force registration. | |
7595 * Convert it to normal cdb for validation. | |
7596 * After that be sure to restore the cdb. | |
7597 */ | |
7598 cdb_1 = vlun->svl_cdb[1]; | |
7599 vlun->svl_cdb[1] &= 0xe0; | |
7600 | |
7601 do { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7602 osvp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(npip); |
4851 | 7603 if (osvp == NULL) { |
7604 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7605 "vhci_pgr_validate_and_register: no " | |
7606 "client priv! 0x%p offlined?\n", | |
7607 (void *)npip)); | |
7608 goto next_path_1; | |
7609 } | |
7610 | |
7611 if (osvp == svp) { | |
7612 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7613 "vhci_pgr_validate_and_register: same svp 0x%p" | |
7614 " npip 0x%p vlun 0x%p\n", | |
7615 (void *)svp, (void *)npip, (void *)vlun)); | |
7616 goto next_path_1; | |
7617 } | |
7618 | |
7619 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7620 "vhci_pgr_validate_and_register: First validate on" | |
7621 " osvp 0x%p being done. vlun 0x%p thread 0x%p Before bcopy" | |
7622 " cdb1 %x\n", (void *)osvp, (void *)vlun, | |
7623 (void *)curthread, vlun->svl_cdb[1])); | |
7624 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy:"); | |
7625 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7626 bcopy(prout->service_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7627 |
7628 VHCI_DEBUG(4, (CE_WARN, NULL, "vlun 0x%p After bcopy", | |
7629 (void *)vlun)); | |
7630 vhci_print_prout_keys(vlun, "v_pgr_val_reg: after bcopy: "); | |
7631 | |
7632 rval = vhci_do_prout(osvp); | |
7633 if (rval == 1) { | |
7634 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7635 "%s%d: vhci_pgr_validate_and_register: key" | |
7636 " validated thread 0x%p\n", ddi_driver_name(cdip), | |
7637 ddi_get_instance(cdip), (void *)curthread)); | |
7638 pip = npip; | |
7639 success = 1; | |
7640 break; | |
7641 } else { | |
7642 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7643 "vhci_pgr_validate_and_register: First validation" | |
7644 " on osvp 0x%p failed %x\n", (void *)osvp, rval)); | |
7645 vhci_print_prout_keys(vlun, "v_pgr_val_reg: failed:"); | |
7646 } | |
7647 | |
7648 /* | |
7649 * Try other paths | |
7650 */ | |
7651 next_path_1: | |
7652 pip = npip; | |
7653 rval = mdi_select_path(cdip, NULL, | |
7654 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, | |
7655 pip, &npip); | |
7656 mdi_rele_path(pip); | |
7657 } while ((rval == MDI_SUCCESS) && (npip != NULL)); | |
7658 | |
7659 | |
7660 /* Be sure to restore original cdb */ | |
7661 vlun->svl_cdb[1] = cdb_1; | |
7662 | |
7663 /* Restore the res_key */ | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7664 bcopy(temp_res_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7665 |
7666 /* | |
7667 * If key could not be registered on any path for the first time, | |
7668 * return success as online should still continue. | |
7669 */ | |
7670 if (success == 0) { | |
7671 return (1); | |
7672 } | |
7673 | |
7674 ASSERT(pip != NULL); | |
7675 | |
7676 /* | |
7677 * Force register on new path | |
7678 */ | |
7679 cdb_1 = vlun->svl_cdb[1]; /* store the cdb */ | |
7680 | |
7681 vlun->svl_cdb[1] &= 0xe0; | |
7682 vlun->svl_cdb[1] |= VHCI_PROUT_R_AND_IGNORE; | |
7683 | |
7684 vhci_print_prout_keys(vlun, "v_pgr_val_reg: keys before bcopy: "); | |
7685 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7686 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
|
7687 MHIOC_RESV_KEY_SIZE); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7688 bcopy(prout->active_res_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7689 |
7690 vhci_print_prout_keys(vlun, "v_pgr_val_reg:keys after bcopy: "); | |
7691 | |
7692 rval = vhci_do_prout(svp); | |
7693 vlun->svl_cdb[1] = cdb_1; /* restore the cdb */ | |
7694 if (rval != 1) { | |
7695 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7696 "vhci_pgr_validate_and_register: register on new" | |
7697 " path 0x%p svp 0x%p failed %x\n", | |
7698 (void *)pip, (void *)svp, rval)); | |
7699 vhci_print_prout_keys(vlun, "v_pgr_val_reg: reg failed: "); | |
7700 mdi_rele_path(pip); | |
7701 return (0); | |
7702 } | |
7703 | |
7704 if (bcmp(prout->service_key, zero_key, MHIOC_RESV_KEY_SIZE) == 0) { | |
7705 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7706 "vhci_pgr_validate_and_register: zero service key\n")); | |
7707 mdi_rele_path(pip); | |
7708 return (rval); | |
7709 } | |
7710 | |
7711 /* | |
7712 * While the key was force registered, some other host might have | |
7713 * cleared the key. Re-validate key on another pre-existing path | |
7714 * before declaring success. | |
7715 */ | |
7716 npip = pip; | |
7717 pip = NULL; | |
7718 | |
7719 /* | |
7720 * Sometimes CDB from application can be Register and Ignore. | |
7721 * Instead of validation, it would result in force registration. | |
7722 * Convert it to normal cdb for validation. | |
7723 * After that be sure to restore the cdb. | |
7724 */ | |
7725 cdb_1 = vlun->svl_cdb[1]; | |
7726 vlun->svl_cdb[1] &= 0xe0; | |
7727 success = 0; | |
7728 | |
7729 do { | |
7730 osvp = (scsi_vhci_priv_t *) | |
7731 mdi_pi_get_vhci_private(npip); | |
7732 if (osvp == NULL) { | |
7733 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7734 "vhci_pgr_validate_and_register: no " | |
7735 "client priv! 0x%p offlined?\n", | |
7736 (void *)npip)); | |
7737 goto next_path_2; | |
7738 } | |
7739 | |
7740 if (osvp == svp) { | |
7741 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7742 "vhci_pgr_validate_and_register: same osvp 0x%p" | |
7743 " npip 0x%p vlun 0x%p\n", | |
7744 (void *)svp, (void *)npip, (void *)vlun)); | |
7745 goto next_path_2; | |
7746 } | |
7747 | |
7748 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7749 "vhci_pgr_validate_and_register: Re-validation on" | |
7750 " osvp 0x%p being done. vlun 0x%p Before bcopy cdb1 %x\n", | |
7751 (void *)osvp, (void *)vlun, vlun->svl_cdb[1])); | |
7752 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy: "); | |
7753 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7754 bcopy(prout->service_key, prout->res_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7755 |
7756 vhci_print_prout_keys(vlun, "v_pgr_val_reg: after bcopy: "); | |
7757 | |
7758 rval = vhci_do_prout(osvp); | |
7759 if (rval == 1) { | |
7760 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7761 "%s%d: vhci_pgr_validate_and_register: key" | |
7762 " validated thread 0x%p\n", ddi_driver_name(cdip), | |
7763 ddi_get_instance(cdip), (void *)curthread)); | |
7764 pip = npip; | |
7765 success = 1; | |
7766 break; | |
7767 } else { | |
7768 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7769 "vhci_pgr_validate_and_register: Re-validation on" | |
7770 " osvp 0x%p failed %x\n", (void *)osvp, rval)); | |
7771 vhci_print_prout_keys(vlun, | |
7772 "v_pgr_val_reg: reval failed: "); | |
7773 } | |
7774 | |
7775 /* | |
7776 * Try other paths | |
7777 */ | |
7778 next_path_2: | |
7779 pip = npip; | |
7780 rval = mdi_select_path(cdip, NULL, | |
7781 MDI_SELECT_ONLINE_PATH|MDI_SELECT_STANDBY_PATH, | |
7782 pip, &npip); | |
7783 mdi_rele_path(pip); | |
7784 } while ((rval == MDI_SUCCESS) && (npip != NULL)); | |
7785 | |
7786 /* Be sure to restore original cdb */ | |
7787 vlun->svl_cdb[1] = cdb_1; | |
7788 | |
7789 if (success == 1) { | |
7790 /* Successfully validated registration */ | |
7791 mdi_rele_path(pip); | |
7792 return (1); | |
7793 } | |
7794 | |
7795 VHCI_DEBUG(4, (CE_WARN, NULL, "key validation failed")); | |
7796 | |
7797 /* | |
7798 * key invalid, back out by registering key value of 0 | |
7799 */ | |
7800 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7801 "vhci_pgr_validate_and_register: backout on" | |
7802 " svp 0x%p being done\n", (void *)svp)); | |
7803 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy: "); | |
7804 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7805 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
|
7806 bzero(prout->service_key, MHIOC_RESV_KEY_SIZE); |
4851 | 7807 |
7808 vhci_print_prout_keys(vlun, "v_pgr_val_reg: before bcopy: "); | |
7809 | |
7810 /* | |
7811 * Get a new path | |
7812 */ | |
7813 rval = mdi_select_path(cdip, NULL, MDI_SELECT_ONLINE_PATH | | |
7814 MDI_SELECT_STANDBY_PATH, NULL, &pip); | |
7815 if ((rval != MDI_SUCCESS) || (pip == NULL)) { | |
7816 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7817 "%s%d: vhci_pgr_validate_and_register: no valid pip\n", | |
7818 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
7819 return (0); | |
7820 } | |
7821 | |
7822 if ((rval = vhci_do_prout(svp)) != 1) { | |
7823 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7824 "vhci_pgr_validate_and_register: backout on" | |
7825 " svp 0x%p failed\n", (void *)svp)); | |
7826 vhci_print_prout_keys(vlun, "backout failed"); | |
7827 | |
7828 VHCI_DEBUG(4, (CE_WARN, NULL, | |
7829 "%s%d: vhci_pgr_validate_and_register: key" | |
7830 " validation and backout failed", ddi_driver_name(cdip), | |
7831 ddi_get_instance(cdip))); | |
7832 if (rval == VHCI_PGR_ILLEGALOP) { | |
7833 VHCI_DEBUG(4, (CE_WARN, NULL, | |
7834 "%s%d: vhci_pgr_validate_and_register: key" | |
7835 " already cleared", ddi_driver_name(cdip), | |
7836 ddi_get_instance(cdip))); | |
7837 rval = 1; | |
7838 } else | |
7839 rval = 0; | |
7840 } else { | |
7841 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
7842 "%s%d: vhci_pgr_validate_and_register: key" | |
7843 " validation failed, key backed out\n", | |
7844 ddi_driver_name(cdip), ddi_get_instance(cdip))); | |
7845 vhci_print_prout_keys(vlun, "v_pgr_val_reg: key backed out: "); | |
7846 } | |
7847 mdi_rele_path(pip); | |
7848 | |
7849 return (rval); | |
7850 } | |
7851 | |
7852 /* | |
7853 * taskq routine to dispatch a scsi cmd to vhci_scsi_start. This ensures | |
7854 * that vhci_scsi_start is not called in interrupt context. | |
7855 * As the upper layer gets TRAN_ACCEPT when the command is dispatched, we | |
7856 * need to complete the command if something goes wrong. | |
7857 */ | |
7858 static void | |
7859 vhci_dispatch_scsi_start(void *arg) | |
7860 { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7861 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
|
7862 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
|
7863 int rval = TRAN_BUSY; |
4851 | 7864 |
7865 VHCI_DEBUG(6, (CE_NOTE, NULL, "!vhci_dispatch_scsi_start: sending" | |
7866 " scsi-2 reserve for 0x%p\n", | |
7867 (void *)ADDR2DIP(&(vpkt->vpkt_tgt_pkt->pkt_address)))); | |
7868 | |
7869 /* | |
7870 * To prevent the taskq from being called recursively we set the | |
7871 * the VHCI_PKT_THRU_TASKQ bit in the vhci_pkt_states. | |
7872 */ | |
7873 vpkt->vpkt_state |= VHCI_PKT_THRU_TASKQ; | |
7874 | |
7875 /* | |
7876 * Wait for the transport to get ready to send packets | |
7877 * and if it times out, it will return something other than | |
7878 * TRAN_BUSY. The vhci_reserve_delay may want to | |
7879 * get tuned for other transports and is therefore a global. | |
7880 * Using delay since this routine is called by taskq dispatch | |
7881 * and not called during interrupt context. | |
7882 */ | |
7883 while ((rval = vhci_scsi_start(&(vpkt->vpkt_tgt_pkt->pkt_address), | |
7884 vpkt->vpkt_tgt_pkt)) == TRAN_BUSY) { | |
7885 delay(drv_usectohz(vhci_reserve_delay)); | |
7886 } | |
7887 | |
7888 switch (rval) { | |
7889 case TRAN_ACCEPT: | |
7890 return; | |
7891 | |
7892 default: | |
7893 /* | |
7894 * This pkt shall be retried, and to ensure another taskq | |
7895 * is dispatched for it, clear the VHCI_PKT_THRU_TASKQ | |
7896 * flag. | |
7897 */ | |
7898 vpkt->vpkt_state &= ~VHCI_PKT_THRU_TASKQ; | |
7899 | |
7900 /* Ensure that the pkt is retried without a reset */ | |
7901 tpkt->pkt_reason = CMD_ABORTED; | |
7902 tpkt->pkt_statistics |= STAT_ABORTED; | |
7903 VHCI_DEBUG(1, (CE_WARN, NULL, "!vhci_dispatch_scsi_start: " | |
7904 "TRAN_rval %d returned for dip 0x%p", rval, | |
7905 (void *)ADDR2DIP(&(vpkt->vpkt_tgt_pkt->pkt_address)))); | |
7906 break; | |
7907 } | |
7908 | |
7909 /* | |
7910 * vpkt_org_vpkt should always be NULL here if the retry command | |
7911 * has been successfully dispatched. If vpkt_org_vpkt != NULL at | |
7912 * this point, it is an error so restore the original vpkt and | |
7913 * return an error to the target driver so it can retry the | |
7914 * command as appropriate. | |
7915 */ | |
7916 if (vpkt->vpkt_org_vpkt != NULL) { | |
7917 struct vhci_pkt *new_vpkt = vpkt; | |
7918 scsi_vhci_priv_t *svp = (scsi_vhci_priv_t *) | |
7919 mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
7920 | |
7921 vpkt = vpkt->vpkt_org_vpkt; | |
7922 | |
7923 vpkt->vpkt_tgt_pkt->pkt_reason = tpkt->pkt_reason; | |
7924 vpkt->vpkt_tgt_pkt->pkt_statistics = tpkt->pkt_statistics; | |
7925 | |
7926 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
7927 new_vpkt->vpkt_tgt_pkt); | |
7928 | |
7929 tpkt = vpkt->vpkt_tgt_pkt; | |
7930 } | |
7931 | |
9106
ee8f18cdafb2
6809527 scsi_hba_pkt_comp():More consumers
srivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>
parents:
8851
diff
changeset
|
7932 scsi_hba_pkt_comp(tpkt); |
4851 | 7933 } |
7934 | |
7935 static void | |
7936 vhci_initiate_auto_failback(void *arg) | |
7937 { | |
7938 struct scsi_vhci_lun *vlun = (struct scsi_vhci_lun *)arg; | |
7939 dev_info_t *vdip, *cdip; | |
7940 int held; | |
7941 | |
7942 cdip = vlun->svl_dip; | |
7943 vdip = ddi_get_parent(cdip); | |
7944 | |
7945 VHCI_HOLD_LUN(vlun, VH_SLEEP, held); | |
7946 | |
7947 /* | |
7948 * Perform a final check to see if the active path class is indeed | |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
7949 * not the preferred path class. As in the time the auto failback |
4851 | 7950 * was dispatched, an external failover could have been detected. |
7951 * [Some other host could have detected this condition and triggered | |
7952 * the auto failback before]. | |
7953 * In such a case if we go ahead with failover we will be negating the | |
7954 * whole purpose of auto failback. | |
7955 */ | |
7956 mutex_enter(&vlun->svl_mutex); | |
7957 if (vlun->svl_active_pclass != NULL) { | |
7958 char *best_pclass; | |
7959 struct scsi_failover_ops *fo; | |
7960 | |
7961 fo = vlun->svl_fops; | |
7962 | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7963 (void) fo->sfo_pathclass_next(NULL, &best_pclass, |
4851 | 7964 vlun->svl_fops_ctpriv); |
7965 if (strcmp(vlun->svl_active_pclass, best_pclass) == 0) { | |
7966 mutex_exit(&vlun->svl_mutex); | |
7967 VHCI_RELEASE_LUN(vlun); | |
7968 VHCI_DEBUG(1, (CE_NOTE, NULL, "Not initiating " | |
7969 "auto failback for %s as %s pathclass already " | |
7970 "active.\n", vlun->svl_lun_wwn, best_pclass)); | |
7971 return; | |
7972 } | |
7973 } | |
7974 mutex_exit(&vlun->svl_mutex); | |
7975 if (mdi_failover(vdip, vlun->svl_dip, MDI_FAILOVER_SYNC) | |
7976 == MDI_SUCCESS) { | |
7977 vhci_log(CE_NOTE, vdip, "!Auto failback operation " | |
7978 "succeeded for device %s (GUID %s)", | |
7979 ddi_node_name(cdip), vlun->svl_lun_wwn); | |
7980 } else { | |
7981 vhci_log(CE_NOTE, vdip, "!Auto failback operation " | |
7982 "failed for device %s (GUID %s)", | |
7983 ddi_node_name(cdip), vlun->svl_lun_wwn); | |
7984 } | |
7985 VHCI_RELEASE_LUN(vlun); | |
7986 } | |
7987 | |
7988 #ifdef DEBUG | |
7989 static void | |
7990 vhci_print_prin_keys(vhci_prin_readkeys_t *prin, int numkeys) | |
7991 { | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
7992 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
|
7993 (uchar_t *)prin, numkeys * 8); |
4851 | 7994 } |
7995 #endif | |
7996 | |
7997 static void | |
7998 vhci_print_prout_keys(scsi_vhci_lun_t *vlun, char *msg) | |
7999 { | |
8000 int i; | |
8001 vhci_prout_t *prout; | |
8002 char buf1[4*MHIOC_RESV_KEY_SIZE + 1]; | |
8003 char buf2[4*MHIOC_RESV_KEY_SIZE + 1]; | |
8004 char buf3[4*MHIOC_RESV_KEY_SIZE + 1]; | |
8005 char buf4[4*MHIOC_RESV_KEY_SIZE + 1]; | |
8006 | |
8007 prout = &vlun->svl_prout; | |
8008 | |
8009 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
8010 (void) sprintf(&buf1[4*i], "[%02x]", prout->res_key[i]); | |
8011 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
8012 (void) sprintf(&buf2[(4*i)], "[%02x]", prout->service_key[i]); | |
8013 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
8014 (void) sprintf(&buf3[4*i], "[%02x]", prout->active_res_key[i]); | |
8015 for (i = 0; i < MHIOC_RESV_KEY_SIZE; i++) | |
8016 (void) sprintf(&buf4[4*i], "[%02x]", | |
8017 prout->active_service_key[i]); | |
8018 | |
8019 /* Printing all in one go. Otherwise it will jumble up */ | |
8020 VHCI_DEBUG(5, (CE_CONT, NULL, "%s vlun 0x%p, thread 0x%p\n" | |
8021 "res_key: : %s\n" | |
8022 "service_key : %s\n" | |
8023 "active_res_key : %s\n" | |
8024 "active_service_key: %s\n", | |
8025 msg, (void *)vlun, (void *)curthread, buf1, buf2, buf3, buf4)); | |
8026 } | |
8027 | |
8028 /* | |
8029 * Called from vhci_scsi_start to update the pHCI pkt with target packet. | |
8030 */ | |
8031 static void | |
8032 vhci_update_pHCI_pkt(struct vhci_pkt *vpkt, struct scsi_pkt *pkt) | |
8033 { | |
8034 | |
8035 ASSERT(vpkt->vpkt_hba_pkt); | |
8036 | |
8037 vpkt->vpkt_hba_pkt->pkt_flags = pkt->pkt_flags; | |
8038 vpkt->vpkt_hba_pkt->pkt_flags |= FLAG_NOQUEUE; | |
8039 | |
8040 if ((vpkt->vpkt_hba_pkt->pkt_flags & FLAG_NOINTR) || | |
8041 MDI_PI_IS_SUSPENDED(vpkt->vpkt_path)) { | |
8042 /* | |
8043 * Polled Command is requested or HBA is in | |
8044 * suspended state | |
8045 */ | |
8046 vpkt->vpkt_hba_pkt->pkt_flags |= FLAG_NOINTR; | |
8047 vpkt->vpkt_hba_pkt->pkt_comp = NULL; | |
8048 } else { | |
8049 vpkt->vpkt_hba_pkt->pkt_comp = vhci_intr; | |
8050 } | |
8051 vpkt->vpkt_hba_pkt->pkt_time = pkt->pkt_time; | |
8052 bcopy(pkt->pkt_cdbp, vpkt->vpkt_hba_pkt->pkt_cdbp, | |
8053 vpkt->vpkt_tgt_init_cdblen); | |
8054 vpkt->vpkt_hba_pkt->pkt_resid = pkt->pkt_resid; | |
8055 | |
8056 /* Re-initialize the following pHCI packet state information */ | |
8057 vpkt->vpkt_hba_pkt->pkt_state = 0; | |
8058 vpkt->vpkt_hba_pkt->pkt_statistics = 0; | |
8059 vpkt->vpkt_hba_pkt->pkt_reason = 0; | |
8060 } | |
8061 | |
8062 static int | |
8063 vhci_scsi_bus_power(dev_info_t *parent, void *impl_arg, pm_bus_power_op_t op, | |
8064 void *arg, void *result) | |
8065 { | |
8066 int ret = DDI_SUCCESS; | |
8067 | |
8068 /* | |
8069 * Generic processing in MPxIO framework | |
8070 */ | |
8071 ret = mdi_bus_power(parent, impl_arg, op, arg, result); | |
8072 | |
8073 switch (ret) { | |
8074 case MDI_SUCCESS: | |
8075 ret = DDI_SUCCESS; | |
8076 break; | |
8077 case MDI_FAILURE: | |
8078 ret = DDI_FAILURE; | |
8079 break; | |
8080 default: | |
8081 break; | |
8082 } | |
8083 | |
8084 return (ret); | |
8085 } | |
8086 | |
8087 static int | |
8088 vhci_pHCI_cap(struct scsi_address *ap, char *cap, int val, int whom, | |
8089 mdi_pathinfo_t *pip) | |
8090 { | |
8091 dev_info_t *cdip; | |
8092 mdi_pathinfo_t *npip = NULL; | |
8093 scsi_vhci_priv_t *svp = NULL; | |
8094 struct scsi_address *pap = NULL; | |
8095 scsi_hba_tran_t *hba = NULL; | |
8096 int sps; | |
8097 int mps_flag; | |
8098 int rval = 0; | |
8099 | |
8100 mps_flag = (MDI_SELECT_ONLINE_PATH | MDI_SELECT_STANDBY_PATH); | |
8101 if (pip) { | |
8102 /* | |
8103 * If the call is from vhci_pathinfo_state_change, | |
8104 * then this path was busy and is becoming ready to accept IO. | |
8105 */ | |
8106 ASSERT(ap != NULL); | |
8107 hba = ap->a_hba_tran; | |
8108 ASSERT(hba != NULL); | |
8109 rval = scsi_ifsetcap(ap, cap, val, whom); | |
8110 | |
8111 VHCI_DEBUG(2, (CE_NOTE, NULL, | |
8112 "!vhci_pHCI_cap: only on path %p, ap %p, rval %x\n", | |
8113 (void *)pip, (void *)ap, rval)); | |
8114 | |
8115 return (rval); | |
8116 } | |
8117 | |
8118 /* | |
8119 * Set capability on all the pHCIs. | |
8120 * If any path is busy, then the capability would be set by | |
8121 * vhci_pathinfo_state_change. | |
8122 */ | |
8123 | |
8124 cdip = ADDR2DIP(ap); | |
8125 ASSERT(cdip != NULL); | |
8126 sps = mdi_select_path(cdip, NULL, mps_flag, NULL, &pip); | |
8127 if ((sps != MDI_SUCCESS) || (pip == NULL)) { | |
8128 VHCI_DEBUG(2, (CE_WARN, NULL, | |
8129 "!vhci_pHCI_cap: Unable to get a path, dip 0x%p", | |
8130 (void *)cdip)); | |
8131 return (0); | |
8132 } | |
8133 | |
8134 again: | |
8135 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip); | |
8136 if (svp == NULL) { | |
8137 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_pHCI_cap: " | |
8138 "priv is NULL, pip 0x%p", (void *)pip)); | |
8139 mdi_rele_path(pip); | |
8140 return (rval); | |
8141 } | |
8142 | |
8143 if (svp->svp_psd == NULL) { | |
8144 VHCI_DEBUG(2, (CE_WARN, NULL, "!vhci_pHCI_cap: " | |
8145 "psd is NULL, pip 0x%p, svp 0x%p", | |
8146 (void *)pip, (void *)svp)); | |
8147 mdi_rele_path(pip); | |
8148 return (rval); | |
8149 } | |
8150 | |
8151 pap = &svp->svp_psd->sd_address; | |
8152 ASSERT(pap != NULL); | |
8153 hba = pap->a_hba_tran; | |
8154 ASSERT(hba != NULL); | |
8155 | |
8156 if (hba->tran_setcap != NULL) { | |
8157 rval = scsi_ifsetcap(pap, cap, val, whom); | |
8158 | |
8159 VHCI_DEBUG(2, (CE_NOTE, NULL, | |
8160 "!vhci_pHCI_cap: path %p, ap %p, rval %x\n", | |
8161 (void *)pip, (void *)ap, rval)); | |
8162 | |
8163 /* | |
8164 * Select next path and issue the setcap, repeat | |
8165 * until all paths are exhausted | |
8166 */ | |
8167 sps = mdi_select_path(cdip, NULL, mps_flag, pip, &npip); | |
8168 if ((sps != MDI_SUCCESS) || (npip == NULL)) { | |
8169 mdi_rele_path(pip); | |
8170 return (1); | |
8171 } | |
8172 mdi_rele_path(pip); | |
8173 pip = npip; | |
8174 goto again; | |
8175 } | |
8176 mdi_rele_path(pip); | |
8177 return (rval); | |
8178 } | |
8179 | |
8180 static int | |
8181 vhci_scsi_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op, | |
8182 void *arg, dev_info_t **child) | |
8183 { | |
8184 char *guid; | |
8185 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8186 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
|
8187 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
|
8188 |
4851 | 8189 if (op == BUS_CONFIG_ONE || op == BUS_UNCONFIG_ONE) |
8190 guid = vhci_devnm_to_guid((char *)arg); | |
8191 else | |
8192 guid = NULL; | |
8193 | |
8194 if (mdi_vhci_bus_config(pdip, flags, op, arg, child, guid) | |
8195 == MDI_SUCCESS) | |
8196 return (NDI_SUCCESS); | |
8197 else | |
8198 return (NDI_FAILURE); | |
8199 } | |
8200 | |
8335
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8201 static int |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8202 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
|
8203 void *arg) |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8204 { |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8205 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
|
8206 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
|
8207 |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8208 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
|
8209 } |
2b50eb467f7f
PSARC/2008/675 SCSI_HBA_ADDR_COMPLEX SCSA data structure linkage
Chris Horne <Chris.Horne@Sun.COM>
parents:
7656
diff
changeset
|
8210 |
4851 | 8211 /* |
8212 * Take the original vhci_pkt, create a duplicate of the pkt for resending | |
8213 * as though it originated in ssd. | |
8214 */ | |
8215 static struct scsi_pkt * | |
8216 vhci_create_retry_pkt(struct vhci_pkt *vpkt) | |
8217 { | |
8218 struct vhci_pkt *new_vpkt = NULL; | |
8219 struct scsi_pkt *pkt = NULL; | |
8220 | |
8221 scsi_vhci_priv_t *svp = (scsi_vhci_priv_t *) | |
8222 mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
8223 | |
8224 /* | |
8225 * Ensure consistent data at completion time by setting PKT_CONSISTENT | |
8226 */ | |
8227 pkt = vhci_scsi_init_pkt(&svp->svp_psd->sd_address, pkt, | |
8228 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
|
8229 vpkt->vpkt_tgt_init_scblen, 0, PKT_CONSISTENT, NULL_FUNC, NULL); |
4851 | 8230 if (pkt != NULL) { |
8231 new_vpkt = TGTPKT2VHCIPKT(pkt); | |
8232 | |
8233 pkt->pkt_address = vpkt->vpkt_tgt_pkt->pkt_address; | |
8234 pkt->pkt_flags = vpkt->vpkt_tgt_pkt->pkt_flags; | |
8235 pkt->pkt_time = vpkt->vpkt_tgt_pkt->pkt_time; | |
8236 pkt->pkt_comp = vpkt->vpkt_tgt_pkt->pkt_comp; | |
8237 | |
8238 pkt->pkt_resid = 0; | |
8239 pkt->pkt_statistics = 0; | |
8240 pkt->pkt_reason = 0; | |
8241 | |
8242 bcopy(vpkt->vpkt_tgt_pkt->pkt_cdbp, | |
8243 pkt->pkt_cdbp, vpkt->vpkt_tgt_init_cdblen); | |
8244 | |
8245 /* | |
8246 * Save a pointer to the original vhci_pkt | |
8247 */ | |
8248 new_vpkt->vpkt_org_vpkt = vpkt; | |
8249 } | |
8250 | |
8251 return (pkt); | |
8252 } | |
8253 | |
8254 /* | |
8255 * Copy the successful completion information from the hba packet into | |
8256 * the original target pkt from the upper layer. Returns the original | |
8257 * vpkt and destroys the new vpkt from the internal retry. | |
8258 */ | |
8259 static struct vhci_pkt * | |
8260 vhci_sync_retry_pkt(struct vhci_pkt *vpkt) | |
8261 { | |
8262 struct vhci_pkt *ret_vpkt = NULL; | |
8263 struct scsi_pkt *tpkt = NULL; | |
8264 struct scsi_pkt *hba_pkt = NULL; | |
8265 scsi_vhci_priv_t *svp = (scsi_vhci_priv_t *) | |
8266 mdi_pi_get_vhci_private(vpkt->vpkt_path); | |
8267 | |
8268 ASSERT(vpkt->vpkt_org_vpkt != NULL); | |
8269 VHCI_DEBUG(0, (CE_NOTE, NULL, "vhci_sync_retry_pkt: Retry pkt " | |
8270 "completed successfully!\n")); | |
8271 | |
8272 ret_vpkt = vpkt->vpkt_org_vpkt; | |
8273 tpkt = ret_vpkt->vpkt_tgt_pkt; | |
8274 hba_pkt = vpkt->vpkt_hba_pkt; | |
8275 | |
8276 /* | |
8277 * Copy the good status into the target driver's packet | |
8278 */ | |
8279 *(tpkt->pkt_scbp) = *(hba_pkt->pkt_scbp); | |
8280 tpkt->pkt_resid = hba_pkt->pkt_resid; | |
8281 tpkt->pkt_state = hba_pkt->pkt_state; | |
8282 tpkt->pkt_statistics = hba_pkt->pkt_statistics; | |
8283 tpkt->pkt_reason = hba_pkt->pkt_reason; | |
8284 | |
8285 /* | |
8286 * Destroy the internally created vpkt for the retry | |
8287 */ | |
8288 vhci_scsi_destroy_pkt(&svp->svp_psd->sd_address, | |
8289 vpkt->vpkt_tgt_pkt); | |
8290 | |
8291 return (ret_vpkt); | |
8292 } | |
8293 | |
8294 /* restart the request sense request */ | |
8295 static void | |
8296 vhci_uscsi_restart_sense(void *arg) | |
8297 { | |
8298 struct buf *rqbp; | |
8299 struct buf *bp; | |
8300 struct scsi_pkt *rqpkt = (struct scsi_pkt *)arg; | |
8301 mp_uscsi_cmd_t *mp_uscmdp; | |
8302 | |
8303 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8304 "vhci_uscsi_restart_sense: enter: rqpkt: %p", (void *)rqpkt)); | |
8305 | |
8306 if (scsi_transport(rqpkt) != TRAN_ACCEPT) { | |
8307 /* if it fails - need to wakeup the original command */ | |
8308 mp_uscmdp = rqpkt->pkt_private; | |
8309 bp = mp_uscmdp->cmdbp; | |
8310 rqbp = mp_uscmdp->rqbp; | |
8311 ASSERT(mp_uscmdp && bp && rqbp); | |
8312 scsi_free_consistent_buf(rqbp); | |
8313 scsi_destroy_pkt(rqpkt); | |
8314 bp->b_resid = bp->b_bcount; | |
8315 bioerror(bp, EIO); | |
8316 biodone(bp); | |
8317 } | |
8318 } | |
8319 | |
8320 /* | |
8321 * auto-rqsense is not enabled so we have to retrieve the request sense | |
8322 * manually. | |
8323 */ | |
8324 static int | |
8325 vhci_uscsi_send_sense(struct scsi_pkt *pkt, mp_uscsi_cmd_t *mp_uscmdp) | |
8326 { | |
8327 struct buf *rqbp, *cmdbp; | |
8328 struct scsi_pkt *rqpkt; | |
8329 int rval = 0; | |
8330 | |
8331 cmdbp = mp_uscmdp->cmdbp; | |
8332 ASSERT(cmdbp != NULL); | |
8333 | |
8334 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8335 "vhci_uscsi_send_sense: enter: bp: %p pkt: %p scmd: %p", | |
8336 (void *)cmdbp, (void *)pkt, (void *)mp_uscmdp)); | |
8337 /* set up the packet information and cdb */ | |
8338 if ((rqbp = scsi_alloc_consistent_buf(mp_uscmdp->ap, NULL, | |
8339 SENSE_LENGTH, B_READ, NULL, NULL)) == NULL) { | |
8340 return (-1); | |
8341 } | |
8342 | |
8343 if ((rqpkt = scsi_init_pkt(mp_uscmdp->ap, NULL, rqbp, | |
8344 CDB_GROUP0, 1, 0, PKT_CONSISTENT, NULL, NULL)) == NULL) { | |
8345 scsi_free_consistent_buf(rqbp); | |
8346 return (-1); | |
8347 } | |
8348 | |
8349 (void) scsi_setup_cdb((union scsi_cdb *)(intptr_t)rqpkt->pkt_cdbp, | |
8350 SCMD_REQUEST_SENSE, 0, SENSE_LENGTH, 0); | |
8351 | |
8352 mp_uscmdp->rqbp = rqbp; | |
8353 rqbp->b_private = mp_uscmdp; | |
8354 rqpkt->pkt_flags |= FLAG_SENSING; | |
8355 rqpkt->pkt_time = 60; | |
8356 rqpkt->pkt_comp = vhci_uscsi_iodone; | |
8357 rqpkt->pkt_private = mp_uscmdp; | |
8358 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8359 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8360 * 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
|
8361 * 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
|
8362 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8363 if (scsi_pkt_allocated_correctly(rqpkt)) |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8364 rqpkt->pkt_path_instance = 0; |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8365 |
4851 | 8366 /* get her done */ |
8367 switch (scsi_transport(rqpkt)) { | |
8368 case TRAN_ACCEPT: | |
8369 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: " | |
8370 "transport accepted.")); | |
8371 break; | |
8372 case TRAN_BUSY: | |
8373 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: " | |
8374 "transport busy, setting timeout.")); | |
8375 vhci_restart_timeid = timeout(vhci_uscsi_restart_sense, rqpkt, | |
8376 (drv_usectohz(5 * 1000000))); | |
8377 break; | |
8378 default: | |
8379 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: " | |
8380 "transport failed")); | |
8381 scsi_free_consistent_buf(rqbp); | |
8382 scsi_destroy_pkt(rqpkt); | |
8383 rval = -1; | |
8384 } | |
8385 | |
8386 return (rval); | |
8387 } | |
8388 | |
8389 /* | |
8390 * done routine for the mpapi uscsi command - this is behaving as though | |
8391 * FLAG_DIAGNOSE is set meaning there are no retries except for a manual | |
8392 * request sense. | |
8393 */ | |
8394 void | |
8395 vhci_uscsi_iodone(struct scsi_pkt *pkt) | |
8396 { | |
8397 struct buf *bp; | |
8398 mp_uscsi_cmd_t *mp_uscmdp; | |
8399 struct uscsi_cmd *uscmdp; | |
8400 struct scsi_arq_status *arqstat; | |
8401 int err; | |
8402 | |
8403 mp_uscmdp = (mp_uscsi_cmd_t *)pkt->pkt_private; | |
8404 uscmdp = mp_uscmdp->uscmdp; | |
8405 bp = mp_uscmdp->cmdbp; | |
8406 ASSERT(bp != NULL); | |
8407 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8408 "vhci_uscsi_iodone: enter: bp: %p pkt: %p scmd: %p", | |
8409 (void *)bp, (void *)pkt, (void *)mp_uscmdp)); | |
8410 /* Save the status and the residual into the uscsi_cmd struct */ | |
8411 uscmdp->uscsi_status = ((*(pkt)->pkt_scbp) & STATUS_MASK); | |
8412 uscmdp->uscsi_resid = bp->b_resid; | |
8413 | |
8414 /* return on a very successful command */ | |
8415 if (pkt->pkt_reason == CMD_CMPLT && | |
8416 SCBP_C(pkt) == 0 && ((pkt->pkt_flags & FLAG_SENSING) == 0) && | |
8417 pkt->pkt_resid == 0) { | |
8418 mdi_pi_kstat_iosupdate(mp_uscmdp->pip, bp); | |
8419 scsi_destroy_pkt(pkt); | |
8420 biodone(bp); | |
8421 return; | |
8422 } | |
8423 VHCI_DEBUG(4, (CE_NOTE, NULL, "iodone: reason=0x%x " | |
8424 " pkt_resid=%ld pkt_state: 0x%x b_count: %ld b_resid: %ld", | |
8425 pkt->pkt_reason, pkt->pkt_resid, | |
8426 pkt->pkt_state, bp->b_bcount, bp->b_resid)); | |
8427 | |
8428 err = EIO; | |
8429 | |
8430 arqstat = (struct scsi_arq_status *)(intptr_t)(pkt->pkt_scbp); | |
8431 if (pkt->pkt_reason != CMD_CMPLT) { | |
8432 /* | |
8433 * The command did not complete. | |
8434 */ | |
8435 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8436 "vhci_uscsi_iodone: command did not complete." | |
8437 " reason: %x flag: %x", pkt->pkt_reason, pkt->pkt_flags)); | |
8438 if (pkt->pkt_flags & FLAG_SENSING) { | |
8439 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_TRANSERR); | |
8440 } else if (pkt->pkt_reason == CMD_TIMEOUT) { | |
8441 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_HARDERR); | |
8442 err = ETIMEDOUT; | |
8443 } | |
8444 } else if (pkt->pkt_state & STATE_ARQ_DONE && mp_uscmdp->arq_enabled) { | |
8445 /* | |
8446 * The auto-rqsense happened, and the packet has a filled-in | |
8447 * scsi_arq_status structure, pointed to by pkt_scbp. | |
8448 */ | |
8449 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8450 "vhci_uscsi_iodone: received auto-requested sense")); | |
8451 if (uscmdp->uscsi_flags & USCSI_RQENABLE) { | |
8452 /* get the amount of data to copy into rqbuf */ | |
8453 int rqlen = SENSE_LENGTH - arqstat->sts_rqpkt_resid; | |
8454 rqlen = min(((int)uscmdp->uscsi_rqlen), rqlen); | |
8455 uscmdp->uscsi_rqresid = uscmdp->uscsi_rqlen - rqlen; | |
8456 uscmdp->uscsi_rqstatus = | |
8457 *((char *)&arqstat->sts_rqpkt_status); | |
8458 if (uscmdp->uscsi_rqbuf && uscmdp->uscsi_rqlen && | |
8459 rqlen != 0) { | |
8460 bcopy(&(arqstat->sts_sensedata), | |
8461 uscmdp->uscsi_rqbuf, rqlen); | |
8462 } | |
8463 mdi_pi_kstat_iosupdate(mp_uscmdp->pip, bp); | |
8464 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8465 "vhci_uscsi_iodone: ARQ " | |
8466 "uscsi_rqstatus=0x%x uscsi_rqresid=%d rqlen: %d " | |
8467 "xfer: %d rqpkt_resid: %d\n", | |
8468 uscmdp->uscsi_rqstatus, uscmdp->uscsi_rqresid, | |
8469 uscmdp->uscsi_rqlen, rqlen, | |
8470 arqstat->sts_rqpkt_resid)); | |
8471 } | |
8472 } else if (pkt->pkt_flags & FLAG_SENSING) { | |
8473 struct buf *rqbp; | |
8474 struct scsi_status *rqstatus; | |
8475 | |
8476 rqstatus = (struct scsi_status *)pkt->pkt_scbp; | |
8477 /* a manual request sense was done - get the information */ | |
8478 if (uscmdp->uscsi_flags & USCSI_RQENABLE) { | |
8479 int rqlen = SENSE_LENGTH - pkt->pkt_resid; | |
8480 | |
8481 rqbp = mp_uscmdp->rqbp; | |
8482 /* get the amount of data to copy into rqbuf */ | |
8483 rqlen = min(((int)uscmdp->uscsi_rqlen), rqlen); | |
8484 uscmdp->uscsi_rqresid = uscmdp->uscsi_rqlen - rqlen; | |
8485 uscmdp->uscsi_rqstatus = *((char *)rqstatus); | |
8486 if (uscmdp->uscsi_rqlen && uscmdp->uscsi_rqbuf) { | |
8487 bcopy(rqbp->b_un.b_addr, uscmdp->uscsi_rqbuf, | |
8488 rqlen); | |
8489 } | |
8490 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_TRANSERR); | |
8491 scsi_free_consistent_buf(rqbp); | |
8492 } | |
8493 VHCI_DEBUG(4, (CE_NOTE, NULL, "vhci_uscsi_iodone: FLAG_SENSING" | |
8494 "uscsi_rqstatus=0x%x uscsi_rqresid=%d\n", | |
8495 uscmdp->uscsi_rqstatus, uscmdp->uscsi_rqresid)); | |
8496 } else { | |
8497 struct scsi_status *status = | |
8498 (struct scsi_status *)pkt->pkt_scbp; | |
8499 /* | |
8500 * Command completed and we're not getting sense. Check for | |
8501 * errors and decide what to do next. | |
8502 */ | |
8503 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8504 "vhci_uscsi_iodone: command appears complete: reason: %x", | |
8505 pkt->pkt_reason)); | |
8506 if (status->sts_chk) { | |
8507 /* need to manually get the request sense */ | |
8508 if (vhci_uscsi_send_sense(pkt, mp_uscmdp) == 0) { | |
8509 scsi_destroy_pkt(pkt); | |
8510 return; | |
8511 } | |
8512 } else { | |
8513 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8514 "vhci_chk_err: appears complete")); | |
8515 err = 0; | |
8516 mdi_pi_kstat_iosupdate(mp_uscmdp->pip, bp); | |
8517 if (pkt->pkt_resid) { | |
8518 bp->b_resid += pkt->pkt_resid; | |
8519 } | |
8520 } | |
8521 } | |
8522 | |
8523 if (err) { | |
8524 if (bp->b_resid == 0) | |
8525 bp->b_resid = bp->b_bcount; | |
8526 bioerror(bp, err); | |
8527 bp->b_flags |= B_ERROR; | |
8528 } | |
8529 | |
8530 scsi_destroy_pkt(pkt); | |
8531 biodone(bp); | |
8532 | |
8533 VHCI_DEBUG(4, (CE_WARN, NULL, "vhci_uscsi_iodone: exit")); | |
8534 } | |
8535 | |
8536 /* | |
8537 * start routine for the mpapi uscsi command | |
8538 */ | |
8539 int | |
8540 vhci_uscsi_iostart(struct buf *bp) | |
8541 { | |
8542 struct scsi_pkt *pkt; | |
8543 struct uscsi_cmd *uscmdp; | |
8544 mp_uscsi_cmd_t *mp_uscmdp; | |
8545 int stat_size, rval; | |
8546 int retry = 0; | |
8547 | |
8548 ASSERT(bp->b_private != NULL); | |
8549 | |
8550 mp_uscmdp = (mp_uscsi_cmd_t *)bp->b_private; | |
8551 uscmdp = mp_uscmdp->uscmdp; | |
8552 if (uscmdp->uscsi_flags & USCSI_RQENABLE) { | |
8553 stat_size = SENSE_LENGTH; | |
8554 } else { | |
8555 stat_size = 1; | |
8556 } | |
8557 | |
8558 pkt = scsi_init_pkt(mp_uscmdp->ap, NULL, bp, uscmdp->uscsi_cdblen, | |
8559 stat_size, 0, 0, SLEEP_FUNC, NULL); | |
8560 if (pkt == NULL) { | |
8561 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8562 "vhci_uscsi_iostart: rval: EINVAL")); | |
8563 bp->b_resid = bp->b_bcount; | |
8564 uscmdp->uscsi_resid = bp->b_bcount; | |
8565 bioerror(bp, EINVAL); | |
8566 biodone(bp); | |
8567 return (EINVAL); | |
8568 } | |
8569 | |
8570 pkt->pkt_time = uscmdp->uscsi_timeout; | |
8571 bcopy(uscmdp->uscsi_cdb, pkt->pkt_cdbp, (size_t)uscmdp->uscsi_cdblen); | |
8572 pkt->pkt_comp = vhci_uscsi_iodone; | |
8573 pkt->pkt_private = mp_uscmdp; | |
8574 if (uscmdp->uscsi_flags & USCSI_SILENT) | |
8575 pkt->pkt_flags |= FLAG_SILENT; | |
8576 if (uscmdp->uscsi_flags & USCSI_ISOLATE) | |
8577 pkt->pkt_flags |= FLAG_ISOLATE; | |
8578 if (uscmdp->uscsi_flags & USCSI_DIAGNOSE) | |
8579 pkt->pkt_flags |= FLAG_DIAGNOSE; | |
8580 if (uscmdp->uscsi_flags & USCSI_RENEGOT) { | |
8581 pkt->pkt_flags |= FLAG_RENEGOTIATE_WIDE_SYNC; | |
8582 } | |
8583 VHCI_DEBUG(4, (CE_WARN, NULL, | |
8584 "vhci_uscsi_iostart: ap: %p pkt: %p pcdbp: %p uscmdp: %p" | |
8585 " ucdbp: %p pcdblen: %d bp: %p count: %ld pip: %p" | |
8586 " stat_size: %d", | |
8587 (void *)mp_uscmdp->ap, (void *)pkt, (void *)pkt->pkt_cdbp, | |
8588 (void *)uscmdp, (void *)uscmdp->uscsi_cdb, pkt->pkt_cdblen, | |
8589 (void *)bp, bp->b_bcount, (void *)mp_uscmdp->pip, stat_size)); | |
8590 | |
6640
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8591 /* |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8592 * 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
|
8593 * 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
|
8594 */ |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8595 if (scsi_pkt_allocated_correctly(pkt)) |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8596 pkt->pkt_path_instance = 0; |
c92ca9b95b9c
PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2
cth
parents:
6042
diff
changeset
|
8597 |
4851 | 8598 while (((rval = scsi_transport(pkt)) == TRAN_BUSY) && |
8599 retry < vhci_uscsi_retry_count) { | |
8600 delay(drv_usectohz(vhci_uscsi_delay)); | |
8601 retry++; | |
8602 } | |
8603 if (retry >= vhci_uscsi_retry_count) { | |
8604 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8605 "vhci_uscsi_iostart: tran_busy - retry: %d", retry)); | |
8606 } | |
8607 switch (rval) { | |
8608 case TRAN_ACCEPT: | |
8609 rval = 0; | |
8610 break; | |
8611 | |
8612 default: | |
8613 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8614 "vhci_uscsi_iostart: rval: %d count: %ld res: %ld", | |
8615 rval, bp->b_bcount, bp->b_resid)); | |
8616 bp->b_resid = bp->b_bcount; | |
8617 uscmdp->uscsi_resid = bp->b_bcount; | |
8618 bioerror(bp, EIO); | |
8619 scsi_destroy_pkt(pkt); | |
8620 biodone(bp); | |
8621 rval = EIO; | |
8622 MDI_PI_ERRSTAT(mp_uscmdp->pip, MDI_PI_TRANSERR); | |
8623 break; | |
8624 } | |
8625 VHCI_DEBUG(4, (CE_NOTE, NULL, | |
8626 "vhci_uscsi_iostart: exit: rval: %d", rval)); | |
8627 return (rval); | |
8628 } | |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8629 |
9167
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8630 /* ARGSUSED */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8631 static struct scsi_failover_ops * |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8632 vhci_dev_fo(dev_info_t *vdip, struct scsi_device *psd, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8633 void **ctprivp, char **fo_namep) |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8634 { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8635 struct scsi_failover_ops *sfo; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8636 char *sfo_name; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8637 char *override; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8638 struct scsi_failover *sf; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8639 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8640 ASSERT(psd && psd->sd_inq); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8641 if ((psd == NULL) || (psd->sd_inq == NULL)) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8642 VHCI_DEBUG(1, (CE_NOTE, NULL, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8643 "!vhci_dev_fo:return NULL no scsi_device or inquiry")); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8644 return (NULL); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8645 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8646 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8647 /* |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8648 * Determine if device is supported under scsi_vhci, and select |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8649 * failover module. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8650 * |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8651 * See if there is a scsi_vhci.conf file override for this devices's |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8652 * VID/PID. The following values can be returned: |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8653 * |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8654 * NULL If the NULL is returned then there is no scsi_vhci.conf |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8655 * override. For NULL, we determine the failover_ops for |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8656 * this device by checking the sfo_device_probe entry |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8657 * point for each 'fops' module, in order. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8658 * |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8659 * NOTE: Correct operation may depend on module ordering |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8660 * of 'specific' (failover modules that are completely |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8661 * VID/PID table based) to 'generic' (failover modules |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8662 * that based on T10 standards like TPGS). Currently, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8663 * the value of 'ddi-forceload' in scsi_vhci.conf is used |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8664 * to establish the module list and probe order. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8665 * |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8666 * "NONE" If value "NONE" is returned then there is a |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8667 * scsi_vhci.conf VID/PID override to indicate the device |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8668 * should not be supported under scsi_vhci (even if there |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8669 * is an 'fops' module supporting the device). |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8670 * |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8671 * "<other>" If another value is returned then that value is the |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8672 * name of the 'fops' module that should be used. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8673 */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8674 sfo = NULL; /* "NONE" */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8675 override = scsi_get_device_type_string( |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8676 "scsi-vhci-failover-override", vdip, psd); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8677 if (override == NULL) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8678 /* NULL: default: select based on sfo_device_probe results */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8679 for (sf = scsi_failover_table; sf->sf_mod; sf++) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8680 if ((sf->sf_sfo == NULL) || |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8681 sf->sf_sfo->sfo_device_probe(psd, psd->sd_inq, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8682 ctprivp) == SFO_DEVICE_PROBE_PHCI) |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8683 continue; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8684 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8685 /* found failover module, supported under scsi_vhci */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8686 sfo = sf->sf_sfo; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8687 if (fo_namep && (*fo_namep == NULL)) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8688 sfo_name = i_ddi_strdup(sfo->sfo_name, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8689 KM_SLEEP); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8690 *fo_namep = sfo_name; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8691 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8692 break; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8693 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8694 } else if (strcasecmp(override, "NONE")) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8695 /* !"NONE": select based on driver.conf specified name */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8696 for (sf = scsi_failover_table, sfo = NULL; sf->sf_mod; sf++) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8697 if ((sf->sf_sfo == NULL) || |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8698 (sf->sf_sfo->sfo_name == NULL) || |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8699 strcmp(override, sf->sf_sfo->sfo_name)) |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8700 continue; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8701 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8702 /* |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8703 * NOTE: If sfo_device_probe() has side-effects, |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8704 * including setting *ctprivp, these are not going |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8705 * to occur with override config. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8706 */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8707 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8708 /* found failover module, supported under scsi_vhci */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8709 sfo = sf->sf_sfo; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8710 if (fo_namep && (*fo_namep == NULL)) { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8711 sfo_name = kmem_alloc(strlen("conf ") + |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8712 strlen(sfo->sfo_name) + 1, KM_SLEEP); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8713 (void) sprintf(sfo_name, "conf %s", |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8714 sfo->sfo_name); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8715 *fo_namep = sfo_name; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8716 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8717 break; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8718 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8719 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8720 if (override) |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8721 kmem_free(override, strlen(override) + 1); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8722 return (sfo); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8723 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8724 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8725 /* |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8726 * Determine the device described by cinfo should be enumerated under |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8727 * the vHCI or the pHCI - if there is a failover ops then device is |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8728 * supported under vHCI. By agreement with SCSA cinfo is a pointer |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8729 * to a scsi_device structure associated with a decorated pHCI probe node. |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8730 */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8731 /* ARGSUSED */ |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8732 int |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8733 vhci_is_dev_supported(dev_info_t *vdip, dev_info_t *pdip, void *cinfo) |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8734 { |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8735 struct scsi_device *psd = (struct scsi_device *)cinfo; |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8736 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8737 return (vhci_dev_fo(vdip, psd, NULL, NULL) ? MDI_SUCCESS : MDI_FAILURE); |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8738 } |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8739 |
21b904fd060c
PSARC/2009/114 mdi_is_dev_supported
Randall Ralphs <Randall.Ralphs@Sun.COM>
parents:
9106
diff
changeset
|
8740 |
6941
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8741 #ifdef DEBUG |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8742 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
|
8743 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8744 static char * |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8745 vhci_print_scsi_cmd(char cmd) |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8746 { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8747 char tmp[64]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8748 char *cpnt; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8749 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8750 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
|
8751 /* 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
|
8752 if (cpnt == tmp) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8753 cpnt = "Unknown Command"; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8754 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8755 return (cpnt); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8756 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8757 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8758 extern uchar_t scsi_cdb_size[]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8759 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8760 static void |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8761 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
|
8762 { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8763 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
|
8764 char buf[256]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8765 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8766 if (level == CE_NOTE) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8767 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
|
8768 vhci_print_scsi_cmd(*cdb)); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8769 return; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8770 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8771 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8772 (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
|
8773 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
|
8774 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8775 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8776 static void |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8777 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
|
8778 int len) |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8779 { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8780 int i; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8781 int c; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8782 char *format; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8783 char buf[256]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8784 uchar_t byte; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8785 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8786 (void) sprintf(buf, "%s:\n", title); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8787 vhci_log(level, dev, "%s", buf); |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8788 level = CE_CONT; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8789 for (i = 0; i < len; ) { |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8790 buf[0] = 0; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8791 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
|
8792 byte = (uchar_t)data[i]; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8793 if (byte < 0x10) |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8794 format = "0x0%x "; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8795 else |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8796 format = "0x%x "; |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8797 (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
|
8798 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8799 (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
|
8800 |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8801 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
|
8802 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8803 } |
c5d83acec1bc
6459247 scsi_vhci does not return correct value for dma-max property
rralphs
parents:
6777
diff
changeset
|
8804 #endif |
10696
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8805 static void |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8806 vhci_invalidate_mpapi_lu(struct scsi_vhci *vhci, scsi_vhci_lun_t *vlun) |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8807 { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8808 char *svl_wwn; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8809 mpapi_item_list_t *ilist; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8810 mpapi_lu_data_t *ld; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8811 |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8812 if (vlun == NULL) { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8813 return; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8814 } else { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8815 svl_wwn = vlun->svl_lun_wwn; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8816 } |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8817 |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8818 ilist = vhci->mp_priv->obj_hdr_list[MP_OBJECT_TYPE_MULTIPATH_LU]->head; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8819 |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8820 while (ilist != NULL) { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8821 ld = (mpapi_lu_data_t *)(ilist->item->idata); |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8822 if ((ld != NULL) && (strncmp(ld->prop.name, svl_wwn, |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8823 strlen(svl_wwn)) == 0)) { |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8824 ld->valid = 0; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8825 VHCI_DEBUG(6, (CE_WARN, NULL, |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8826 "vhci_invalidate_mpapi_lu: " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8827 "Invalidated LU(%s)", svl_wwn)); |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8828 return; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8829 } |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8830 ilist = ilist->next; |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8831 } |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8832 VHCI_DEBUG(6, (CE_WARN, NULL, "vhci_invalidate_mpapi_lu: " |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8833 "Could not find LU(%s) to invalidate.", svl_wwn)); |
cd0f390dd9e2
PSARC 2008/672 thebe SAS/SATA driver
dh142964 <David.Hollister@Sun.COM>
parents:
10098
diff
changeset
|
8834 } |