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