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 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_SCSI_ADAPTERS_SCSI_VHCI_H 27 #define _SYS_SCSI_ADAPTERS_SCSI_VHCI_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 /* 32 * Multiplexed I/O SCSI vHCI global include 33 */ 34 #include <sys/note.h> 35 #include <sys/taskq.h> 36 #include <sys/mhd.h> 37 #include <sys/sunmdi.h> 38 #include <sys/mdi_impldefs.h> 39 #include <sys/scsi/adapters/mpapi_impl.h> 40 #include <sys/scsi/adapters/mpapi_scsi_vhci.h> 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL) 47 #error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined 48 #endif /* _BIT_FIELDS_LTOH */ 49 50 #ifdef _KERNEL 51 52 #ifdef UNDEFINED 53 #undef UNDEFINED 54 #endif 55 #define UNDEFINED -1 56 57 #define VHCI_STATE_OPEN 0x00000001 58 59 60 #define VH_SLEEP 0x0 61 #define VH_NOSLEEP 0x1 62 63 /* 64 * HBA interface macros 65 */ 66 67 #define TRAN2HBAPRIVATE(tran) ((struct scsi_vhci *)(tran)->tran_hba_private) 68 #define VHCI_INIT_WAIT_TIMEOUT 60000000 69 #define VHCI_FOWATCH_INTERVAL 1000000 /* in usecs */ 70 #define VHCI_EXTFO_TIMEOUT 3*60 /* 3 minutes */ 71 72 #define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & STATUS_MASK) 73 74 int vhci_do_scsi_cmd(struct scsi_pkt *); 75 /*PRINTFLIKE3*/ 76 void vhci_log(int, dev_info_t *, const char *, ...); 77 78 /* 79 * debugging stuff 80 */ 81 82 #ifdef DEBUG 83 84 #ifndef VHCI_DEBUG_DEFAULT_VAL 85 #define VHCI_DEBUG_DEFAULT_VAL 0 86 #endif /* VHCI_DEBUG_DEFAULT_VAL */ 87 88 extern int vhci_debug; 89 90 #include <sys/debug.h> 91 92 #define VHCI_DEBUG(level, stmnt) \ 93 if (vhci_debug >= (level)) vhci_log stmnt 94 95 #else /* !DEBUG */ 96 97 #define VHCI_DEBUG(level, stmnt) 98 99 #endif /* !DEBUG */ 100 101 102 103 #define VHCI_PKT_PRIV_SIZE 2 104 105 #define ADDR2VHCI(ap) (struct scsi_vhci *)((ap)->a_hba_tran->tran_hba_private) 106 #define ADDR2VLUN(ap) (scsi_vhci_lun_t *)((ap)->a_hba_tran->tran_tgt_private) 107 #define ADDR2DIP(ap) (dev_info_t *)((ap)->a_hba_tran->tran_sd->sd_dev) 108 #define HBAPKT2VHCIPKT(pkt) (pkt->pkt_private) 109 #define TGTPKT2VHCIPKT(pkt) (pkt->pkt_ha_private) 110 #define VHCIPKT2HBAPKT(pkt) (pkt->pkt_hba_pkt) 111 #define VHCIPKT2TGTPKT(pkt) (pkt->pkt_tgt_pkt) 112 113 #define VHCI_DECR_PATH_CMDCOUNT(svp) mutex_enter(&(svp)->svp_mutex); \ 114 (svp)->svp_cmds--; \ 115 if ((svp)->svp_cmds == 0) \ 116 cv_broadcast(&(svp)->svp_cv); \ 117 mutex_exit(&(svp)->svp_mutex); 118 119 #define VHCI_INCR_PATH_CMDCOUNT(svp) mutex_enter(&(svp)->svp_mutex); \ 120 (svp)->svp_cmds++; \ 121 mutex_exit(&(svp)->svp_mutex); 122 123 /* 124 * When a LUN is HELD it results in new IOs being returned to the target 125 * driver layer with TRAN_BUSY. Should be used while performing 126 * operations that require prevention of any new IOs to the LUN and 127 * the LUN should be HELD for the duration of such operations. 128 * f can be VH_SLEEP or VH_NOSLEEP. 129 * h is set to 1 to indicate LUN was successfully HELD. 130 * h is set to 0 when f is VH_NOSLEEP and LUN is already HELD. 131 * 132 * Application examples: 133 * 134 * 1) SCSI-II RESERVE: HOLD LUN until it is quiesced and the load balancing 135 * policy is switched to NONE before proceeding with RESERVE handling. 136 * 137 * 2) Failover: HOLD LUN before initiating failover. 138 * 139 * 3) When an externally initiated failover is detected, HOLD LUN until all 140 * path states have been refreshed to reflect the new value. 141 * 142 */ 143 #define VHCI_HOLD_LUN(vlun, f, h) { \ 144 int sleep = (f); \ 145 mutex_enter(&(vlun)->svl_mutex); \ 146 if ((vlun)->svl_transient == 1) { \ 147 if (sleep == VH_SLEEP) { \ 148 while ((vlun)->svl_transient == 1) \ 149 cv_wait(&(vlun)->svl_cv, &(vlun)->svl_mutex); \ 150 (vlun)->svl_transient = 1; \ 151 (h) = 1; \ 152 } else { \ 153 (h) = 0; \ 154 } \ 155 } else { \ 156 (vlun)->svl_transient = 1; \ 157 (h) = 1; \ 158 } \ 159 sleep = (h); \ 160 mutex_exit(&(vlun)->svl_mutex); \ 161 } 162 163 #define VHCI_RELEASE_LUN(vlun) { \ 164 mutex_enter(&(vlun)->svl_mutex); \ 165 (vlun)->svl_transient = 0; \ 166 cv_broadcast(&(vlun)->svl_cv); \ 167 mutex_exit(&(vlun)->svl_mutex); \ 168 } 169 170 #define VHCI_LUN_IS_HELD(vlun) ((vlun)->svl_transient == 1) 171 172 /* 173 * vhci_pkt states 174 */ 175 #define VHCI_PKT_IDLE 0x01 176 #define VHCI_PKT_ISSUED 0x02 177 #define VHCI_PKT_ABORTING 0x04 178 #define VHCI_PKT_STALE_BINDING 0x08 179 /* 180 * Set the first time taskq is dispatched from scsi_start for 181 * a packet. To ensure vhci_scsi_start recognizes that the scsi_pkt 182 * is being issued from the taskq and not target driver. 183 */ 184 #define VHCI_PKT_THRU_TASKQ 0x20 185 186 #define VHCI_PKT_TIMEOUT 30 /* seconds */ 187 #define VHCI_PKT_RETRY_CNT 2 188 #define VHCI_POLL_TIMEOUT 60 /* seconds */ 189 190 /* 191 * define extended scsi cmd pkt 192 */ 193 #define EXTCMDS_STATUS_SIZE (sizeof (struct scsi_arq_status)) 194 195 #define CFLAG_NOWAIT 0x1000 /* don't sleep */ 196 #define CFLAG_DMA_PARTIAL 0x2000 /* Support Partial DMA */ 197 198 /* 199 * Maximum size of SCSI cdb in SCSI command 200 */ 201 #define VHCI_SCSI_CDB_SIZE 16 202 #define VHCI_SCSI_SCB_SIZE (sizeof (struct scsi_arq_status)) 203 204 /* 205 * flag to determine failover support 206 */ 207 #define SCSI_NO_FAILOVER 0x0 208 #define SCSI_IMPLICIT_FAILOVER 0x1 209 #define SCSI_EXPLICIT_FAILOVER 0x2 210 #define SCSI_BOTH_FAILOVER \ 211 (SCSI_IMPLICIT_FAILOVER | SCSI_EXPLICIT_FAILOVER) 212 213 struct scsi_vhci_swarg; 214 215 typedef struct vhci_prin_readkeys { 216 uint32_t generation; 217 uint32_t length; 218 mhioc_resv_key_t keylist[MHIOC_RESV_KEY_SIZE]; 219 } vhci_prin_readkeys_t; 220 221 #define VHCI_PROUT_SIZE \ 222 ((sizeof (vhci_prout_t) - 2 * (MHIOC_RESV_KEY_SIZE) * sizeof (char))) 223 224 typedef struct vhci_prout { 225 /* PGR register parameters start */ 226 uchar_t res_key[MHIOC_RESV_KEY_SIZE]; 227 uchar_t service_key[MHIOC_RESV_KEY_SIZE]; 228 uint32_t scope_address; 229 230 #if defined(_BIT_FIELDS_LTOH) 231 uchar_t aptpl:1, 232 reserved:7; 233 #else 234 uchar_t reserved:7, 235 aptpl:1; 236 #endif /* _BIT_FIELDS_LTOH */ 237 238 uchar_t reserved_1; 239 uint16_t ext_len; 240 /* PGR register parameters end */ 241 242 /* Update VHCI_PROUT_SIZE if new fields are added here */ 243 244 uchar_t active_res_key[MHIOC_RESV_KEY_SIZE]; 245 uchar_t active_service_key[MHIOC_RESV_KEY_SIZE]; 246 } vhci_prout_t; 247 248 #define VHCI_PROUT_REGISTER 0x0 249 #define VHCI_PROUT_RESERVE 0x1 250 #define VHCI_PROUT_RELEASE 0x2 251 #define VHCI_PROUT_CLEAR 0x3 252 #define VHCI_PROUT_PREEMPT 0x4 253 #define VHCI_PROUT_P_AND_A 0x5 254 #define VHCI_PROUT_R_AND_IGNORE 0x6 255 256 struct vhci_pkt { 257 struct scsi_pkt *vpkt_tgt_pkt; 258 mdi_pathinfo_t *vpkt_path; /* path pkt bound to */ 259 260 /* 261 * pHCI packet that does the actual work. 262 */ 263 struct scsi_pkt *vpkt_hba_pkt; 264 265 uint_t vpkt_state; 266 uint_t vpkt_flags; 267 268 /* 269 * copy of vhci_scsi_init_pkt args. Used when we invoke 270 * scsi_init_pkt() of the pHCI corresponding to the path that we 271 * bind to 272 */ 273 int vpkt_tgt_init_cdblen; 274 int vpkt_tgt_init_scblen; 275 int vpkt_tgt_init_pkt_flags; 276 struct buf *vpkt_tgt_init_bp; 277 278 /* 279 * Pointer to original struct vhci_pkt for cmd send by ssd. 280 * Saved when the command is being retried internally. 281 */ 282 struct vhci_pkt *vpkt_org_vpkt; 283 }; 284 285 typedef struct scsi_vhci_lun { 286 kmutex_t svl_mutex; 287 kcondvar_t svl_cv; 288 289 /* 290 * following three fields are under svl_mutex protection 291 */ 292 int svl_transient; 293 294 /* 295 * to prevent unnecessary failover when a device is 296 * is discovered across a passive path and active path 297 * is still comng up 298 */ 299 int svl_waiting_for_activepath; 300 time_t svl_wfa_time; 301 302 /* 303 * for RESERVE/RELEASE support 304 */ 305 client_lb_t svl_lb_policy_save; 306 307 /* 308 * Failover ops and ops name selected for the lun. 309 */ 310 struct scsi_failover_ops *svl_fops; 311 char *svl_fops_name; 312 313 void *svl_fops_ctpriv; 314 315 struct scsi_vhci_lun *svl_hash_next; 316 char *svl_lun_wwn; 317 318 /* 319 * currently active pathclass 320 */ 321 char *svl_active_pclass; 322 323 dev_info_t *svl_dip; 324 uint32_t svl_flags; /* protected by svl_mutex */ 325 326 /* 327 * When SCSI-II reservations are active we set the following pip 328 * to point to the path holding the reservation. As long as 329 * the reservation is active this svl_resrv_pip is bound for the 330 * transport directly. We bypass calling mdi_select_path to return 331 * a pip. 332 * The following pip is only valid when VLUN_RESERVE_ACTIVE_FLG 333 * is set. This pip should not be accessed if this flag is reset. 334 */ 335 mdi_pathinfo_t *svl_resrv_pip; 336 337 /* 338 * following fields are for PGR support 339 */ 340 taskq_t *svl_taskq; 341 ksema_t svl_pgr_sema; /* PGR serialization */ 342 vhci_prin_readkeys_t svl_prin; /* PGR in data */ 343 vhci_prout_t svl_prout; /* PGR out data */ 344 uchar_t svl_cdb[CDB_GROUP4]; 345 int svl_time; /* pkt_time */ 346 uint32_t svl_bcount; /* amount of data */ 347 int svl_pgr_active; /* registrations active */ 348 mdi_pathinfo_t *svl_first_path; 349 350 /* external failover */ 351 int svl_efo_update_path; 352 struct scsi_vhci_swarg *svl_swarg; 353 354 uint32_t svl_support_lun_reset; /* Lun reset support */ 355 int svl_not_supported; 356 int svl_xlf_capable; /* XLF implementation */ 357 int svl_sector_size; 358 int svl_setcap_done; 359 uint16_t svl_fo_support; /* failover mode */ 360 } scsi_vhci_lun_t; 361 362 #define VLUN_TASK_D_ALIVE_FLG 0x01 363 364 /* 365 * This flag is used to monitor the state of SCSI-II RESERVATION on the 366 * lun. A SCSI-II RESERVE cmd may be accepted by the target on the inactive 367 * path. This would then cause a subsequent IO to cause the paths to be 368 * updated and be returned with a reservation conflict. By monitoring this 369 * flag, and sending a reset to the target when needed to clear the reservation, 370 * one can avoid this conflict. 371 */ 372 #define VLUN_RESERVE_ACTIVE_FLG 0x04 373 374 /* 375 * This flag is set when a SCSI-II RESERVE cmd is received by scsi_vhci 376 * and cleared when the pkt completes in vhci_intr. It ensures that the 377 * lun remains quiesced for the duration of this pkt. This is different 378 * from VHCI_HOLD_LUN as this pertains to IOs only. 379 */ 380 #define VLUN_QUIESCED_FLG 0x08 381 382 /* 383 * This flag is set to tell vhci_update_pathstates to call back 384 * into vhci_mpapi_update_tpg_acc_state. 385 */ 386 #define VLUN_UPDATE_TPG 0x10 387 388 /* 389 * Various reset recovery depth. 390 */ 391 392 #define VHCI_DEPTH_ALL 3 393 #define VHCI_DEPTH_TARGET 2 394 #define VHCI_DEPTH_LUN 1 /* For the sake completeness */ 395 #define TRUE (1) 396 #define FALSE (0) 397 398 /* 399 * this is stashed away in the client private area of 400 * pathinfo 401 */ 402 typedef struct scsi_vhci_priv { 403 kmutex_t svp_mutex; 404 kcondvar_t svp_cv; 405 struct scsi_vhci_lun *svp_svl; 406 407 /* 408 * scsi device associated with this 409 * pathinfo 410 */ 411 struct scsi_device *svp_psd; 412 413 /* 414 * number of outstanding commands on this 415 * path. Protected by svp_mutex 416 */ 417 int svp_cmds; 418 419 /* 420 * following is used to prevent packets completing with the 421 * same error reason from flooding the screen 422 */ 423 uchar_t svp_last_pkt_reason; 424 425 /* external failover scsi_watch token */ 426 opaque_t svp_sw_token; 427 428 /* any cleanup operations for a newly found path. */ 429 int svp_new_path; 430 } scsi_vhci_priv_t; 431 432 /* 433 * argument to scsi_watch callback. Used for processing 434 * externally initiated failovers 435 */ 436 typedef struct scsi_vhci_swarg { 437 scsi_vhci_priv_t *svs_svp; 438 time_t svs_tos; /* time of submission */ 439 mdi_pathinfo_t *svs_pi; /* pathinfo being "watched" */ 440 int svs_release_lun; 441 int svs_done; 442 } scsi_vhci_swarg_t; 443 444 /* 445 * scsi_vhci softstate 446 * 447 * vhci_mutex protects 448 * vhci_state 449 * and vhci_reset_notify list 450 */ 451 struct scsi_vhci { 452 kmutex_t vhci_mutex; 453 dev_info_t *vhci_dip; 454 struct scsi_hba_tran *vhci_tran; 455 uint32_t vhci_state; 456 uint32_t vhci_instance; 457 kstat_t vhci_kstat; 458 /* 459 * This taskq is for general vhci operations like reservations, 460 * auto-failback, etc. 461 */ 462 taskq_t *vhci_taskq; 463 /* Dedicate taskq to handle external failovers */ 464 taskq_t *vhci_update_pathstates_taskq; 465 struct scsi_reset_notify_entry *vhci_reset_notify_listf; 466 uint16_t vhci_conf_flags; 467 mpapi_priv_t *mp_priv; 468 }; 469 470 /* 471 * vHCI flags for configuration settings, defined in scsi_vhci.conf 472 */ 473 #define VHCI_CONF_FLAGS_AUTO_FAILBACK 0x0001 /* Enables auto failback */ 474 475 typedef enum { 476 SCSI_PATH_INACTIVE, 477 SCSI_PATH_ACTIVE, 478 SCSI_PATH_ACTIVE_NONOPT 479 } scsi_path_state_t; 480 481 #define SCSI_MAXPCLASSLEN 25 482 483 #define OPINFO_REV 1 484 485 /* 486 * structure describing operational characteristics of 487 * path 488 */ 489 struct scsi_path_opinfo { 490 int opinfo_rev; 491 492 /* 493 * name of pathclass. Eg. "primary", "secondary" 494 */ 495 char opinfo_path_attr[SCSI_MAXPCLASSLEN]; 496 497 /* 498 * path state: ACTIVE/PASSIVE 499 */ 500 scsi_path_state_t opinfo_path_state; 501 502 /* 503 * the best and worst case time estimates for 504 * failover operation to complete 505 */ 506 uint_t opinfo_pswtch_best; 507 uint_t opinfo_pswtch_worst; 508 509 /* XLF implementation */ 510 int opinfo_xlf_capable; 511 uint16_t opinfo_preferred; 512 uint16_t opinfo_mode; 513 514 }; 515 516 517 #define SFO_REV 1 518 519 /* 520 * vectors for device specific failover related operations 521 */ 522 struct scsi_failover_ops { 523 int sfo_rev; 524 525 /* 526 * failover module name, begins with "f_" 527 */ 528 char *sfo_name; 529 530 /* 531 * devices supported by failover module 532 * 533 * NOTE: this is an aproximation, sfo_device_probe has the final say. 534 */ 535 char **sfo_devices; 536 537 /* 538 * initialize the failover module 539 */ 540 void (*sfo_init)(); 541 542 /* 543 * identify device 544 */ 545 int (*sfo_device_probe)( 546 struct scsi_device *sd, 547 struct scsi_inquiry *stdinq, 548 void **ctpriv); 549 550 /* 551 * housekeeping (free memory etc alloc'ed during probe 552 */ 553 void (*sfo_device_unprobe)( 554 struct scsi_device *sd, 555 void *ctpriv); 556 557 /* 558 * bring a path ONLINE (ie make it ACTIVE) 559 */ 560 int (*sfo_path_activate)( 561 struct scsi_device *sd, 562 char *pathclass, 563 void *ctpriv); 564 565 /* 566 * inverse of above 567 */ 568 int (*sfo_path_deactivate)( 569 struct scsi_device *sd, 570 char *pathclass, 571 void *ctpriv); 572 573 /* 574 * returns operational characteristics of path 575 */ 576 int (*sfo_path_get_opinfo)( 577 struct scsi_device *sd, 578 struct scsi_path_opinfo *opinfo, 579 void *ctpriv); 580 581 /* 582 * verify path is operational 583 */ 584 int (*sfo_path_ping)( 585 struct scsi_device *sd, 586 void *ctpriv); 587 588 /* 589 * analyze SENSE data to detect externally initiated 590 * failovers 591 */ 592 int (*sfo_analyze_sense)( 593 struct scsi_device *sd, 594 struct scsi_extended_sense *sense, 595 void *ctpriv); 596 597 /* 598 * return the next pathclass in order of preference 599 * eg. "secondary" comes after "primary" 600 */ 601 int (*sfo_pathclass_next)( 602 char *cur, 603 char **nxt, 604 void *ctpriv); 605 }; 606 607 /* 608 * Names of (too) 'well-known' failover ops. 609 * NOTE: consumers of these names should look for a better way... 610 */ 611 #define SFO_NAME_SYM "f_sym" 612 #define SFO_NAME_TPGS "f_tpgs" 613 #define SCSI_FAILOVER_IS_SYM(sfo) \ 614 ((sfo) ? (strcmp((sfo)->sfo_name, SFO_NAME_SYM) == 0) : 0) 615 #define SCSI_FAILOVER_IS_TPGS(sfo) \ 616 ((sfo) ? (strcmp((sfo)->sfo_name, SFO_NAME_TPGS) == 0) : 0) 617 618 /* 619 * Macro to provide plumbing for basic failover module 620 */ 621 #define _SCSI_FAILOVER_OP(sfo_name, local_name, ops_name, vers) \ 622 static struct modlmisc modlmisc = { \ 623 &mod_miscops, sfo_name " " vers \ 624 }; \ 625 static struct modlinkage modlinkage = { \ 626 MODREV_1, (void *)&modlmisc, NULL \ 627 }; \ 628 int _init() \ 629 { \ 630 return (mod_install(&modlinkage)); \ 631 } \ 632 int _fini() \ 633 { \ 634 return (mod_remove(&modlinkage)); \ 635 } \ 636 int _info(struct modinfo *modinfop) \ 637 { \ 638 return (mod_info(&modlinkage, modinfop)); \ 639 } \ 640 static int local_name##_device_probe( \ 641 struct scsi_device *, \ 642 struct scsi_inquiry *, void **); \ 643 static void local_name##_device_unprobe( \ 644 struct scsi_device *, void *); \ 645 static int local_name##_path_activate( \ 646 struct scsi_device *, char *, void *); \ 647 static int local_name##_path_deactivate( \ 648 struct scsi_device *, char *, void *); \ 649 static int local_name##_path_get_opinfo( \ 650 struct scsi_device *, \ 651 struct scsi_path_opinfo *, void *); \ 652 static int local_name##_path_ping( \ 653 struct scsi_device *, void *); \ 654 static int local_name##_analyze_sense( \ 655 struct scsi_device *, \ 656 struct scsi_extended_sense *, void *); \ 657 static int local_name##_pathclass_next( \ 658 char *, char **, void *); \ 659 struct scsi_failover_ops ops_name##_failover_ops = { \ 660 SFO_REV, \ 661 sfo_name, \ 662 local_name##_dev_table, \ 663 NULL, \ 664 local_name##_device_probe, \ 665 local_name##_device_unprobe, \ 666 local_name##_path_activate, \ 667 local_name##_path_deactivate, \ 668 local_name##_path_get_opinfo, \ 669 local_name##_path_ping, \ 670 local_name##_analyze_sense, \ 671 local_name##_pathclass_next \ 672 } 673 674 #ifdef lint 675 #define SCSI_FAILOVER_OP(sfo_name, local_name, vers) \ 676 _SCSI_FAILOVER_OP(sfo_name, local_name, local_name, vers) 677 #else /* lint */ 678 #define SCSI_FAILOVER_OP(sfo_name, local_name, vers) \ 679 _SCSI_FAILOVER_OP(sfo_name, local_name, scsi_vhci, vers) 680 #endif /* lint */ 681 682 /* 683 * Return values for sfo_device_probe 684 */ 685 #define SFO_DEVICE_PROBE_VHCI 1 /* supported under scsi_vhci */ 686 #define SFO_DEVICE_PROBE_PHCI 0 /* not supported under scsi_vhci */ 687 688 /* return values for sfo_analyze_sense() */ 689 #define SCSI_SENSE_NOFAILOVER 0 690 #define SCSI_SENSE_FAILOVER_INPROG 1 691 #define SCSI_SENSE_ACT2INACT 2 692 #define SCSI_SENSE_INACT2ACT 3 693 #define SCSI_SENSE_INACTIVE 4 694 #define SCSI_SENSE_UNKNOWN 5 695 #define SCSI_SENSE_STATE_CHANGED 6 696 #define SCSI_SENSE_NOT_READY 7 697 698 /* vhci_intr action codes */ 699 #define JUST_RETURN 0 700 #define BUSY_RETURN 1 701 #define PKT_RETURN 2 702 703 #if defined(_SYSCALL32) 704 /* 705 * 32 bit variants of sv_path_info_prop_t and sv_path_info_t; 706 * To be used only in the driver and NOT applications 707 */ 708 typedef struct sv_path_info_prop32 { 709 uint32_t buf_size; /* user buffer size */ 710 caddr32_t ret_buf_size; /* actual buffer needed */ 711 caddr32_t buf; /* user space buffer */ 712 } sv_path_info_prop32_t; 713 714 typedef struct sv_path_info32 { 715 union { 716 char ret_ct[MAXPATHLEN]; /* client device */ 717 char ret_phci[MAXPATHLEN]; /* pHCI device */ 718 } device; 719 720 char ret_addr[MAXNAMELEN]; /* device address */ 721 mdi_pathinfo_state_t ret_state; /* state information */ 722 uint32_t ret_ext_state; /* Extended State */ 723 sv_path_info_prop32_t ret_prop; /* path attributes */ 724 } sv_path_info32_t; 725 726 typedef struct sv_iocdata32 { 727 caddr32_t client; /* client dev devfs path name */ 728 caddr32_t phci; /* pHCI dev devfs path name */ 729 caddr32_t addr; /* device address */ 730 uint32_t buf_elem; /* number of path_info elems */ 731 caddr32_t ret_buf; /* addr of array of sv_path_info */ 732 caddr32_t ret_elem; /* count of above sv_path_info */ 733 } sv_iocdata32_t; 734 735 typedef struct sv_switch_to_cntlr_iocdata32 { 736 caddr32_t client; /* client device devfs path name */ 737 caddr32_t class; /* desired path class to be made active */ 738 } sv_switch_to_cntlr_iocdata32_t; 739 740 #endif /* _SYSCALL32 */ 741 742 #endif /* _KERNEL */ 743 744 /* 745 * Userland (Non Kernel) definitions start here. 746 * Multiplexed I/O SCSI vHCI IOCTL Definitions 747 */ 748 749 /* 750 * IOCTL structure for path properties 751 */ 752 typedef struct sv_path_info_prop { 753 uint_t buf_size; /* user buffer size */ 754 uint_t *ret_buf_size; /* actual buffer needed */ 755 caddr_t buf; /* user space buffer */ 756 } sv_path_info_prop_t; 757 758 /* 759 * Max buffer size of getting path properties 760 */ 761 #define SV_PROP_MAX_BUF_SIZE 4096 762 763 /* 764 * String values for "path-class" property 765 */ 766 #define PCLASS_PRIMARY "primary" 767 #define PCLASS_SECONDARY "secondary" 768 769 #define PCLASS_PREFERRED 1 770 #define PCLASS_NONPREFERRED 0 771 772 /* 773 * IOCTL structure for path information 774 */ 775 typedef struct sv_path_info { 776 union { 777 char ret_ct[MAXPATHLEN]; /* client device */ 778 char ret_phci[MAXPATHLEN]; /* pHCI device */ 779 } device; 780 781 char ret_addr[MAXNAMELEN]; /* device address */ 782 mdi_pathinfo_state_t ret_state; /* state information */ 783 uint32_t ret_ext_state; /* Extended State */ 784 sv_path_info_prop_t ret_prop; /* path attributes */ 785 } sv_path_info_t; 786 787 /* 788 * IOCTL argument structure 789 */ 790 typedef struct sv_iocdata { 791 caddr_t client; /* client dev devfs path name */ 792 caddr_t phci; /* pHCI dev devfs path name */ 793 caddr_t addr; /* device address */ 794 uint_t buf_elem; /* number of path_info elems */ 795 sv_path_info_t *ret_buf; /* array of sv_path_info */ 796 uint_t *ret_elem; /* count of sv_path_info */ 797 } sv_iocdata_t; 798 799 /* 800 * IOCTL argument structure for switching controllers 801 */ 802 typedef struct sv_switch_to_cntlr_iocdata { 803 caddr_t client; /* client device devfs path name */ 804 caddr_t class; /* desired path class to be made active */ 805 } sv_switch_to_cntlr_iocdata_t; 806 807 808 /* 809 * IOCTL definitions 810 */ 811 #define SCSI_VHCI_CTL ('X' << 8) 812 #define SCSI_VHCI_CTL_CMD (SCSI_VHCI_CTL | ('S' << 8) | 'P') 813 #define SCSI_VHCI_CTL_SUB_CMD ('x' << 8) 814 815 #define SCSI_VHCI_GET_CLIENT_MULTIPATH_INFO (SCSI_VHCI_CTL_SUB_CMD + 0x01) 816 #define SCSI_VHCI_GET_PHCI_MULTIPATH_INFO (SCSI_VHCI_CTL_SUB_CMD + 0x02) 817 #define SCSI_VHCI_GET_CLIENT_NAME (SCSI_VHCI_CTL_SUB_CMD + 0x03) 818 #define SCSI_VHCI_PATH_ONLINE (SCSI_VHCI_CTL_SUB_CMD + 0x04) 819 #define SCSI_VHCI_PATH_OFFLINE (SCSI_VHCI_CTL_SUB_CMD + 0x05) 820 #define SCSI_VHCI_PATH_STANDBY (SCSI_VHCI_CTL_SUB_CMD + 0x06) 821 #define SCSI_VHCI_PATH_TEST (SCSI_VHCI_CTL_SUB_CMD + 0x07) 822 #define SCSI_VHCI_SWITCH_TO_CNTLR (SCSI_VHCI_CTL_SUB_CMD + 0x08) 823 824 #ifdef DEBUG 825 #define SCSI_VHCI_GET_PHCI_LIST (SCSI_VHCI_CTL_SUB_CMD + 0x09) 826 #define SCSI_VHCI_CONFIGURE_PHCI (SCSI_VHCI_CTL_SUB_CMD + 0x0A) 827 #define SCSI_VHCI_UNCONFIGURE_PHCI (SCSI_VHCI_CTL_SUB_CMD + 0x0B) 828 #endif 829 830 #define SCSI_VHCI_PATH_DISABLE (SCSI_VHCI_CTL_SUB_CMD + 0x0C) 831 #define SCSI_VHCI_PATH_ENABLE (SCSI_VHCI_CTL_SUB_CMD + 0x0D) 832 #define SCSI_VHCI_MPAPI (SCSI_VHCI_CTL_SUB_CMD + 0x0E) 833 834 #define SCSI_VHCI_GET_TARGET_LONGNAME (SCSI_VHCI_CTL_SUB_CMD + 0x0F) 835 836 #ifdef __cplusplus 837 } 838 #endif 839 840 #endif /* _SYS_SCSI_ADAPTERS_SCSI_VHCI_H */ 841