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