patch-2.3.47 linux/drivers/fc4/fc.c

Next file: linux/drivers/ieee1394/hosts.c
Previous file: linux/drivers/char/vt.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.46/linux/drivers/fc4/fc.c linux/drivers/fc4/fc.c
@@ -56,17 +56,21 @@
 #ifdef __sparc__
 #define dma_alloc_consistent(d,s,p) sbus_alloc_consistent(d,s,p)
 #define dma_free_consistent(d,s,v,h) sbus_free_consistent(d,s,v,h)
-#define dma_map_single(d,v,s) sbus_map_single(d,v,s)
-#define dma_unmap_single(d,h,s) sbus_unmap_single(d,h,s)
-#define dma_map_sg(d,s,n) sbus_map_sg(d,s,n)
-#define dma_unmap_sg(d,s,n) sbus_unmap_sg(d,s,n)
+#define dma_map_single(d,v,s,dir) sbus_map_single(d,v,s,dir)
+#define dma_unmap_single(d,h,s,dir) sbus_unmap_single(d,h,s,dir)
+#define dma_map_sg(d,s,n,dir) sbus_map_sg(d,s,n,dir)
+#define dma_unmap_sg(d,s,n,dir) sbus_unmap_sg(d,s,n,dir)
+#define scsi_to_fc_dma_dir(dir)	scsi_to_sbus_dma_dir(dir)
+#define FC_DMA_BIDIRECTIONAL	SBUS_DMA_BIDIRECTIONAL
 #else
 #define dma_alloc_consistent(d,s,p) pci_alloc_consistent(d,s,p)
 #define dma_free_consistent(d,s,v,h) pci_free_consistent(d,s,v,h)
-#define dma_map_single(d,v,s) pci_map_single(d,v,s)
-#define dma_unmap_single(d,h,s) pci_unmap_single(d,h,s)
-#define dma_map_sg(d,s,n) pci_map_sg(d,s,n)
-#define dma_unmap_sg(d,s,n) pci_unmap_sg(d,s,n)
+#define dma_map_single(d,v,s,dir) pci_map_single(d,v,s,dir)
+#define dma_unmap_single(d,h,s,dir) pci_unmap_single(d,h,s,dir)
+#define dma_map_sg(d,s,n,dir) pci_map_sg(d,s,n,dir)
+#define dma_unmap_sg(d,s,n,dir) pci_unmap_sg(d,s,n,dir)
+#define scsi_to_fc_dma_dir(dir)	scsi_to_pci_dma_dir(dir)
+#define FC_DMA_BIDIRECTIONAL	PCI_DMA_BIDIRECTIONAL
 #endif							       
 
 #define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp))
@@ -163,7 +167,8 @@
 			fc->state = FC_STATE_FPORT_OK;
 			fcmd = l->fcmds + i;
 			plogi = l->logi + 3 * i;
-			dma_unmap_single (fc->dev, fcmd->cmd, 3 * sizeof(logi));
+			dma_unmap_single (fc->dev, fcmd->cmd, 3 * sizeof(logi),
+					  FC_DMA_BIDIRECTIONAL);
 			plogi->code = LS_PLOGI;
 			memcpy (&plogi->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn));
 			memcpy (&plogi->node_wwn, &fc->wwn_node, sizeof(fc_wwn));
@@ -183,7 +188,8 @@
 				printk ("\n");
 			}
 #endif			
-			fcmd->cmd = dma_map_single (fc->dev, plogi, 3 * sizeof(logi));
+			fcmd->cmd = dma_map_single (fc->dev, plogi, 3 * sizeof(logi),
+						    FC_DMA_BIDIRECTIONAL);
 			fcmd->rsp = fcmd->cmd + 2 * sizeof(logi);
 			if (fc->hw_enque (fc, fcmd))
 				printk ("FC: Cannot enque PLOGI packet on %s\n", fc->name);
@@ -206,7 +212,8 @@
 		switch (status) {
 		case FC_STATUS_OK:
 			plogi = l->logi + 3 * i;
-			dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
+			dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi),
+					  FC_DMA_BIDIRECTIONAL);
 			if (!fc->wwn_dest.lo && !fc->wwn_dest.hi) {
 				memcpy (&fc->wwn_dest, &plogi[1].node_wwn, sizeof(fc_wwn)); 
 				FCD(("Dest WWN %08x%08x\n", *(u32 *)&fc->wwn_dest, fc->wwn_dest.lo))
@@ -224,7 +231,8 @@
 			break;
 		case FC_STATUS_ERR_OFFLINE:
 			fc->state = FC_STATE_OFFLINE;
-			dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
+			dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi),
+					  FC_DMA_BIDIRECTIONAL);
 			printk ("%s: FC is offline\n", fc->name);
 			if (atomic_dec_and_test (&l->todo))
 				up(&l->sem);
@@ -248,7 +256,8 @@
 	FCD(("Report map done %d %d\n", i, status))
 	switch (status) {
 	case FC_STATUS_OK: /* Ok, let's have a fun on a loop */
-		dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
+		dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi),
+				  FC_DMA_BIDIRECTIONAL);
 		p = (fc_al_posmap *)(l->logi + 3 * i);
 #ifdef FCDEBUG
 		{
@@ -297,7 +306,8 @@
 	case FC_STATUS_POINTTOPOINT: /* We're Point-to-Point, no AL... */
 		FCD(("SID %d DID %d\n", fc->sid, fc->did))
 		fcmd = l->fcmds + i;
-		dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi));
+		dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi),
+				 FC_DMA_BIDIRECTIONAL);
 		fch = &fcmd->fch;
 		memset(l->logi + 3 * i, 0, 3 * sizeof(logi));
 		FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, FS_FABRIC_F_PORT);
@@ -307,7 +317,8 @@
 		FILL_FCHDR_OXRX(fch, 0xffff, 0xffff);
 		fch->param = 0;
 		l->logi [3 * i].code = LS_FLOGI;
-		fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi));
+		fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi),
+					    FC_DMA_BIDIRECTIONAL);
 		fcmd->rsp = fcmd->cmd + sizeof(logi);
 		fcmd->cmdlen = sizeof(logi);
 		fcmd->rsplen = sizeof(logi);
@@ -424,9 +435,11 @@
 		
 		if (fcmd->data) {
 			if (SCpnt->use_sg)
-				dma_unmap_sg(fc->dev, (struct scatterlist *)SCpnt->buffer, SCpnt->use_sg);
+				dma_unmap_sg(fc->dev, (struct scatterlist *)SCpnt->buffer, SCpnt->use_sg,
+					     scsi_to_fc_dma_dir(SCpnt->sc_data_direction));
 			else
-				dma_unmap_single(fc->dev, fcmd->data, SCpnt->request_bufflen);
+				dma_unmap_single(fc->dev, fcmd->data, SCpnt->request_bufflen,
+						 scsi_to_fc_dma_dir(SCpnt->sc_data_direction));
 		}
 		break;
 	default:
@@ -565,7 +578,8 @@
 		fc->login = fcmd;
 		fc->ls = (void *)l;
 		/* Assumes sizeof(fc_al_posmap) < 3 * sizeof(logi), which is true */
-		fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi));
+		fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi),
+					    FC_DMA_BIDIRECTIONAL);
 		fcmd->proto = PROTO_REPORT_AL_MAP;
 		fcmd->token = i;
 		fcmd->fc = fc;
@@ -584,7 +598,7 @@
 				} else {
 					fc->state = FC_STATE_OFFLINE;
 					enable_irq(fc->irq);
-					dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
+					dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), FC_DMA_BIDIRECTIONAL);
 					if (atomic_dec_and_test (&l->todo))
 						goto all_done;
 				}
@@ -601,7 +615,7 @@
 
 				FCD(("SID %d DID %d\n", fc->sid, fc->did))
 				fcmd = l->fcmds + i;
-				dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi));
+				dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi), FC_DMA_BIDIRECTIONAL);
 				fch = &fcmd->fch;
 				FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, FS_FABRIC_F_PORT);
 				FILL_FCHDR_SID(fch, 0);
@@ -610,7 +624,7 @@
 				FILL_FCHDR_OXRX(fch, 0xffff, 0xffff);
 				fch->param = 0;
 				l->logi [3 * i].code = LS_FLOGI;
-				fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi));
+				fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi), FC_DMA_BIDIRECTIONAL);
 				fcmd->rsp = fcmd->cmd + sizeof(logi);
 				fcmd->cmdlen = sizeof(logi);
 				fcmd->rsplen = sizeof(logi);
@@ -638,7 +652,7 @@
 		switch (fc->state) {
 		case FC_STATE_ONLINE: break;
 		case FC_STATE_OFFLINE: break;
-		default: dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
+		default: dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi), FC_DMA_BIDIRECTIONAL);
 			break;
 		}
 	}
@@ -801,13 +815,15 @@
 			if (!SCpnt->use_sg) {
 				cmd->fcp_data_len = SCpnt->request_bufflen;
 				fcmd->data = dma_map_single (fc->dev, (char *)SCpnt->request_buffer,
-							     SCpnt->request_bufflen);
+							     SCpnt->request_bufflen,
+							     scsi_to_fc_dma_dir(SCpnt->sc_data_direction));
 			} else {
 				struct scatterlist *sg = (struct scatterlist *)SCpnt->buffer;
 				int nents;
 
 				FCD(("XXX: Use_sg %d %d\n", SCpnt->use_sg, sg->length))
-				nents = dma_map_sg (fc->dev, sg, SCpnt->use_sg);
+				nents = dma_map_sg (fc->dev, sg, SCpnt->use_sg,
+						    scsi_to_fc_dma_dir(SCpnt->sc_data_direction));
 				if (nents > 1) printk ("%s: SG for nents %d (use_sg %d) not handled yet\n", fc->name, nents, SCpnt->use_sg);
 				fcmd->data = sg_dma_address(sg);
 				cmd->fcp_data_len = sg_dma_len(sg);
@@ -1048,7 +1064,7 @@
 	FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0);
 	FILL_FCHDR_OXRX(fch, 0xffff, 0xffff);
 	fch->param = 0;
-	fcmd->cmd = dma_map_single (fc->dev, data, 2 * len);
+	fcmd->cmd = dma_map_single (fc->dev, data, 2 * len, FC_DMA_BIDIRECTIONAL);
 	fcmd->rsp = fcmd->cmd + len;
 	fcmd->cmdlen = len;
 	fcmd->rsplen = len;
@@ -1083,7 +1099,7 @@
 	
 	clear_bit(fcmd->token, fc->scsi_bitmap);
 	fc->scsi_free++;
-	dma_unmap_single (fc->dev, fcmd->cmd, 2 * len);
+	dma_unmap_single (fc->dev, fcmd->cmd, 2 * len, FC_DMA_BIDIRECTIONAL);
 	return l.status;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)