diff usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c @ 6640:c92ca9b95b9c

PSARC/2007/522 Disk enumeration for Sun Fire X4200 and X4200 M2 PSARC/2008/077 Multiplexed I/O Enhancements to Support FMA 5039931 glm fails to use DDI-compliant interface for scsi_pkt(9S) allocation 5039932 mpt fails to use DDI-compliant interface for scsi_pkt(9S) allocation 5039935 esp fails to use DDI-compliant interface for scsi_pkt(9S) allocation 5039936 fas fails to use DDI-compliant interface for scsi_pkt(9S) allocation 5039937 ifp fails to use DDI-compliant interface for scsi_pkt(9S) allocation 5039938 isp fails to use DDI-compliant interface for scsi_pkt(9S) allocation 5039941 sf fails to use DDI-compliant interface for scsi_pkt(9S) allocation 6276696 USCSI should support a path selection mechanism in conjunction with scsi_vhci 6284426 di_path_addr should have its second argument removed. 6425326 prtconf pathinfo output should show path's pHCI unit-address (di_path_addr) 6657250 devid should be available at interrupt time 6657251 libtopo: disk enumeration needs to be shared by multiple enumeration strategies 6657252 libtopo: xmlgen files should use consistent format 6657253 fmdump: add support for filtering on nvpair (and value) 6657254 eversholt: support devid-based mapping to topology 6657255 eversholt: define property indicating ereport may not map to topology 6657256 SCSA should detect scsi_pkt allocation violations 6657257 Multiplexed I/O Enhancements to Support FMA 6657258 libnvpair: need nvlist_lookup_nvpair peer that supports embeded nvlist 6695221 scsa1394 fails to use DDI-compliant interface for scsi_pkt(9S) allocation 6695222 ata has dependency on scsi_device(9S) size 6695223 ncrs fails to use DDI-compliant interface for scsi_pkt(9S) allocation 6695224 st fails to use DDI-compliant interface for scsi_pkt(9S) allocation
author cth
date Wed, 14 May 2008 04:05:43 -0700
parents b578f00bc056
children cc437863808b
line wrap: on
line diff
--- a/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c	Tue May 13 17:13:13 2008 -0700
+++ b/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c	Wed May 14 04:05:43 2008 -0700
@@ -68,7 +68,7 @@
 /*
  * Version Macros
  */
-#define	VHCI_NAME_VERSION	"SCSI VHCI Driver 1.68"
+#define	VHCI_NAME_VERSION	"SCSI VHCI Driver %I%"
 char		vhci_version_name[] = VHCI_NAME_VERSION;
 
 int		vhci_first_time = 0;
@@ -1347,6 +1347,17 @@
 	 * If this changes it needs to be handled for the polled scenario.
 	 */
 	flags = vpkt->vpkt_hba_pkt->pkt_flags;
+
+	/*
+	 * Set the path_instance *before* sending the scsi_pkt down the path
+	 * to mpxio's pHCI so that additional path abstractions at a pHCI
+	 * level (like maybe iSCSI at some point in the future) can update
+	 * the path_instance.
+	 */
+	if (scsi_pkt_allocated_correctly(vpkt->vpkt_hba_pkt))
+		vpkt->vpkt_hba_pkt->pkt_path_instance =
+		    mdi_pi_get_path_instance(vpkt->vpkt_path);
+
 	rval = scsi_transport(vpkt->vpkt_hba_pkt);
 	if (rval == TRAN_ACCEPT) {
 		if (flags & FLAG_NOINTR) {
@@ -2101,6 +2112,7 @@
 	int			mps_flag = MDI_SELECT_ONLINE_PATH;
 	struct scsi_vhci_lun	*vlun;
 	time_t			tnow;
+	int			path_instance;
 
 	vlun = ADDR2VLUN(ap);
 	ASSERT(vlun != 0);
@@ -2171,6 +2183,17 @@
 	}
 
 	/*
+	 * Get path_instance. Non-zero indicates that mdi_select_path should
+	 * be called to select a specific instance.
+	 *
+	 * NB: Condition pkt_path_instance reference on proper allocation.
+	 */
+	if (scsi_pkt_allocated_correctly(vpkt->vpkt_tgt_pkt))
+		path_instance = vpkt->vpkt_tgt_pkt->pkt_path_instance;
+	else
+		path_instance = 0;
+
+	/*
 	 * If reservation is active bind the transport directly to the pip
 	 * with the reservation.
 	 */
@@ -2190,8 +2213,9 @@
 			}
 		}
 try_again:
-		rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp, 0, NULL,
-		    &pip);
+		rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp,
+		    path_instance ? MDI_SELECT_PATH_INSTANCE : 0,
+		    (void *)(intptr_t)path_instance, &pip);
 		if (rval == MDI_BUSY) {
 			if (pgr_sema_held) {
 				sema_v(&vlun->svl_pgr_sema);
@@ -2352,6 +2376,10 @@
 		address = &pkt->pkt_address;
 	}
 
+	/* Verify match of specified path_instance and selected path_instance */
+	ASSERT((path_instance == 0) ||
+	    (path_instance == mdi_pi_get_path_instance(vpkt->vpkt_path)));
+
 	/*
 	 * For PKT_PARTIAL_DMA case, call pHCI's scsi_init_pkt whenever
 	 * target driver calls vhci_scsi_init_pkt.
@@ -2988,6 +3016,21 @@
 	tpkt->pkt_statistics = pkt->pkt_statistics;
 	tpkt->pkt_reason = pkt->pkt_reason;
 
+	/* Return path_instance information back to the target driver. */
+	if (scsi_pkt_allocated_correctly(tpkt)) {
+		if (scsi_pkt_allocated_correctly(pkt)) {
+			/*
+			 * If both packets were correctly allocated,
+			 * return path returned by pHCI.
+			 */
+			tpkt->pkt_path_instance = pkt->pkt_path_instance;
+		} else {
+			/* Otherwise return path of pHCI we used */
+			tpkt->pkt_path_instance =
+			    mdi_pi_get_path_instance(lpath);
+		}
+	}
+
 	if (pkt->pkt_cdbp[0] == SCMD_PROUT &&
 	    ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_REGISTER) ||
 	    ((pkt->pkt_cdbp[1] & 0x1f) == VHCI_PROUT_R_AND_IGNORE)) {
@@ -3699,6 +3742,9 @@
 					    SCMD_READ, 1, 1, 0);
 					pkt->pkt_time = 3*30;
 					pkt->pkt_flags = FLAG_NOINTR;
+					pkt->pkt_path_instance =
+					    mdi_pi_get_path_instance(pip);
+
 					if ((scsi_transport(pkt) ==
 					    TRAN_ACCEPT) && (pkt->pkt_reason
 					    == CMD_CMPLT) && (SCBP_C(pkt) ==
@@ -6741,7 +6787,9 @@
 			    pkt->pkt_cdbp, SCMD_READ, 1, 1, 0);
 			pkt->pkt_flags = FLAG_NOINTR;
 check_path_again:
+			pkt->pkt_path_instance = mdi_pi_get_path_instance(npip);
 			pkt->pkt_time = 3*30;
+
 			if (scsi_transport(pkt) == TRAN_ACCEPT) {
 				switch (pkt->pkt_reason) {
 				case CMD_CMPLT:
@@ -7110,7 +7158,6 @@
 	}
 	dvlp->svl_lun_wwn = NULL;
 
-
 	if (dvlp->svl_fops_name) {
 		kmem_free(dvlp->svl_fops_name, strlen(dvlp->svl_fops_name)+1);
 	}
@@ -8115,6 +8162,13 @@
 	rqpkt->pkt_comp = vhci_uscsi_iodone;
 	rqpkt->pkt_private = mp_uscmdp;
 
+	/*
+	 * NOTE: This code path is related to MPAPI uscsi(7I), so path
+	 * selection is not based on path_instance.
+	 */
+	if (scsi_pkt_allocated_correctly(rqpkt))
+		rqpkt->pkt_path_instance = 0;
+
 	/* get her done */
 	switch (scsi_transport(rqpkt)) {
 	case TRAN_ACCEPT:
@@ -8340,6 +8394,13 @@
 	    (void *)uscmdp, (void *)uscmdp->uscsi_cdb, pkt->pkt_cdblen,
 	    (void *)bp, bp->b_bcount, (void *)mp_uscmdp->pip, stat_size));
 
+	/*
+	 * NOTE: This code path is related to MPAPI uscsi(7I), so path
+	 * selection is not based on path_instance.
+	 */
+	if (scsi_pkt_allocated_correctly(pkt))
+		pkt->pkt_path_instance = 0;
+
 	while (((rval = scsi_transport(pkt)) == TRAN_BUSY) &&
 	    retry < vhci_uscsi_retry_count) {
 		delay(drv_usectohz(vhci_uscsi_delay));