patch-2.3.41 linux/drivers/fc4/fc.c
Next file: linux/drivers/fc4/fcp_impl.h
Previous file: linux/drivers/char/wdt.c
Back to the patch index
Back to the overall index
- Lines: 254
- Date:
Thu Jan 27 08:58:15 2000
- Orig file:
v2.3.40/linux/drivers/fc4/fc.c
- Orig date:
Wed Dec 29 13:13:15 1999
diff -u --recursive --new-file v2.3.40/linux/drivers/fc4/fc.c linux/drivers/fc4/fc.c
@@ -54,32 +54,19 @@
#endif
#ifdef __sparc__
-static inline void *fc_dma_alloc(long size, dma_handle *dma, fc_channel *fc)
-{
- return sbus_alloc_consistant(fc->dev, size, dma);
-}
-
-static inline dma_handle fc_sync_dma_entry(void *buf, long len, fc_channel *fc)
-{
- return sbus_map_single(fc->dev, buf, len);
-}
-
-static inline void fc_sync_dma_exit(dma_handle dmh, long size, fc_channel *fc)
-{
- sbus_unmap_single(fc->dev, dmh, size);
-}
-
-static inline void fc_sync_dma_entry_sg(struct scatterlist *list, int count, fc_channel *fc)
-{
- sbus_map_sg(fc->dev, list, count);
-}
-
-static inline void fc_sync_dma_exit_sg(struct scatterlist *list, int count, fc_channel *fc)
-{
- sbus_unmap_sg(fc->dev, list, count);
-}
+#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)
#else
-#error Port this
+#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)
#endif
#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp))
@@ -176,7 +163,7 @@
fc->state = FC_STATE_FPORT_OK;
fcmd = l->fcmds + i;
plogi = l->logi + 3 * i;
- fc_sync_dma_exit (fcmd->cmd, 3 * sizeof(logi), fc);
+ dma_unmap_single (fc->dev, fcmd->cmd, 3 * sizeof(logi));
plogi->code = LS_PLOGI;
memcpy (&plogi->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn));
memcpy (&plogi->node_wwn, &fc->wwn_node, sizeof(fc_wwn));
@@ -196,7 +183,7 @@
printk ("\n");
}
#endif
- fcmd->cmd = fc_sync_dma_entry (plogi, 3 * sizeof(logi), fc);
+ fcmd->cmd = dma_map_single (fc->dev, plogi, 3 * sizeof(logi));
fcmd->rsp = fcmd->cmd + 2 * sizeof(logi);
if (fc->hw_enque (fc, fcmd))
printk ("FC: Cannot enque PLOGI packet on %s\n", fc->name);
@@ -219,7 +206,7 @@
switch (status) {
case FC_STATUS_OK:
plogi = l->logi + 3 * i;
- fc_sync_dma_exit (l->fcmds[i].cmd, 3 * sizeof(logi), fc);
+ dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
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))
@@ -237,7 +224,7 @@
break;
case FC_STATUS_ERR_OFFLINE:
fc->state = FC_STATE_OFFLINE;
- fc_sync_dma_exit (l->fcmds[i].cmd, 3 * sizeof(logi), fc);
+ dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
printk ("%s: FC is offline\n", fc->name);
if (atomic_dec_and_test (&l->todo))
up(&l->sem);
@@ -261,7 +248,7 @@
FCD(("Report map done %d %d\n", i, status))
switch (status) {
case FC_STATUS_OK: /* Ok, let's have a fun on a loop */
- fc_sync_dma_exit (l->fcmds[i].cmd, 3 * sizeof(logi), fc);
+ dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
p = (fc_al_posmap *)(l->logi + 3 * i);
#ifdef FCDEBUG
{
@@ -310,7 +297,7 @@
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;
- fc_sync_dma_exit(fcmd->cmd, 3 * sizeof(logi), fc);
+ dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi));
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);
@@ -320,11 +307,11 @@
FILL_FCHDR_OXRX(fch, 0xffff, 0xffff);
fch->param = 0;
l->logi [3 * i].code = LS_FLOGI;
- fcmd->cmd = fc_sync_dma_entry (l->logi + 3 * i, 3 * sizeof(logi), fc);
+ fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi));
fcmd->rsp = fcmd->cmd + sizeof(logi);
fcmd->cmdlen = sizeof(logi);
fcmd->rsplen = sizeof(logi);
- fcmd->data = (dma_handle)NULL;
+ fcmd->data = (dma_addr_t)NULL;
fcmd->class = FC_CLASS_SIMPLE;
fcmd->proto = TYPE_EXTENDED_LS;
if (fc->hw_enque (fc, fcmd))
@@ -350,9 +337,10 @@
if (type == TYPE_SCSI_FCP) {
if (!unregister) {
- fc->scsi_cmd_pool =
- (fcp_cmd *) fc_dma_alloc (slots * (sizeof (fcp_cmd) + fc->rsp_size),
- &fc->dma_scsi_cmd, fc);
+ fc->scsi_cmd_pool = (fcp_cmd *)
+ dma_alloc_consistent (fc->dev,
+ slots * (sizeof (fcp_cmd) + fc->rsp_size),
+ &fc->dma_scsi_cmd);
fc->scsi_rsp_pool = (char *)(fc->scsi_cmd_pool + slots);
fc->dma_scsi_rsp = fc->dma_scsi_cmd + slots * sizeof (fcp_cmd);
fc->scsi_bitmap_end = (slots + 63) & ~63;
@@ -436,9 +424,9 @@
if (fcmd->data) {
if (SCpnt->use_sg)
- fc_sync_dma_exit_sg((struct scatterlist *)SCpnt->buffer, SCpnt->use_sg, fc);
+ dma_unmap_sg(fc->dev, (struct scatterlist *)SCpnt->buffer, SCpnt->use_sg);
else
- fc_sync_dma_exit(fcmd->data, SCpnt->request_bufflen, fc);
+ dma_unmap_single(fc->dev, fcmd->data, SCpnt->request_bufflen);
}
break;
default:
@@ -577,7 +565,7 @@
fc->login = fcmd;
fc->ls = (void *)l;
/* Assumes sizeof(fc_al_posmap) < 3 * sizeof(logi), which is true */
- fcmd->cmd = fc_sync_dma_entry (l->logi + 3 * i, 3 * sizeof(logi), fc);
+ fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi));
fcmd->proto = PROTO_REPORT_AL_MAP;
fcmd->token = i;
fcmd->fc = fc;
@@ -596,7 +584,7 @@
} else {
fc->state = FC_STATE_OFFLINE;
enable_irq(fc->irq);
- fc_sync_dma_exit (l->fcmds[i].cmd, 3 * sizeof(logi), fc);
+ dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
if (atomic_dec_and_test (&l->todo))
goto all_done;
}
@@ -613,7 +601,7 @@
FCD(("SID %d DID %d\n", fc->sid, fc->did))
fcmd = l->fcmds + i;
- fc_sync_dma_exit(fcmd->cmd, 3 * sizeof(logi), fc);
+ dma_unmap_single(fc->dev, fcmd->cmd, 3 * sizeof(logi));
fch = &fcmd->fch;
FILL_FCHDR_RCTL_DID(fch, R_CTL_ELS_REQ, FS_FABRIC_F_PORT);
FILL_FCHDR_SID(fch, 0);
@@ -622,11 +610,11 @@
FILL_FCHDR_OXRX(fch, 0xffff, 0xffff);
fch->param = 0;
l->logi [3 * i].code = LS_FLOGI;
- fcmd->cmd = fc_sync_dma_entry (l->logi + 3 * i, 3 * sizeof(logi), fc);
+ fcmd->cmd = dma_map_single (fc->dev, l->logi + 3 * i, 3 * sizeof(logi));
fcmd->rsp = fcmd->cmd + sizeof(logi);
fcmd->cmdlen = sizeof(logi);
fcmd->rsplen = sizeof(logi);
- fcmd->data = (dma_handle)NULL;
+ fcmd->data = (dma_addr_t)NULL;
fcmd->class = FC_CLASS_SIMPLE;
fcmd->proto = TYPE_EXTENDED_LS;
} else
@@ -650,7 +638,7 @@
switch (fc->state) {
case FC_STATE_ONLINE: break;
case FC_STATE_OFFLINE: break;
- default: fc_sync_dma_exit (l->fcmds[i].cmd, 3 * sizeof(logi), fc);
+ default: dma_unmap_single (fc->dev, l->fcmds[i].cmd, 3 * sizeof(logi));
break;
}
}
@@ -800,7 +788,7 @@
fcp_cntl = FCP_CNTL_QTYPE_UNTAGGED;
if (!SCpnt->request_bufflen && !SCpnt->use_sg) {
cmd->fcp_cntl = fcp_cntl;
- fcmd->data = (dma_handle)NULL;
+ fcmd->data = (dma_addr_t)NULL;
} else {
switch (SCpnt->cmnd[0]) {
case WRITE_6:
@@ -812,16 +800,17 @@
}
if (!SCpnt->use_sg) {
cmd->fcp_data_len = SCpnt->request_bufflen;
- fcmd->data = fc_sync_dma_entry ((char *)SCpnt->request_buffer,
- SCpnt->request_bufflen, fc);
+ fcmd->data = dma_map_single (fc->dev, (char *)SCpnt->request_buffer,
+ SCpnt->request_bufflen);
} else {
struct scatterlist *sg = (struct scatterlist *)SCpnt->buffer;
+ int nents;
FCD(("XXX: Use_sg %d %d\n", SCpnt->use_sg, sg->length))
- if (SCpnt->use_sg > 1) printk ("%s: SG for use_sg > 1 not handled yet\n", fc->name);
- fc_sync_dma_entry_sg (sg, SCpnt->use_sg, fc);
- fcmd->data = sg->dvma_address;
- cmd->fcp_data_len = sg->dvma_length;
+ nents = dma_map_sg (fc->dev, sg, SCpnt->use_sg);
+ 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);
}
}
memcpy (cmd->fcp_cdb, SCpnt->cmnd, SCpnt->cmd_len);
@@ -954,7 +943,7 @@
fc->cmd_slots[0] = fcmd;
cmd->fcp_cntl = FCP_CNTL_QTYPE_ORDERED | FCP_CNTL_RESET;
- fcmd->data = (dma_handle)NULL;
+ fcmd->data = (dma_addr_t)NULL;
fcmd->proto = TYPE_SCSI_FCP;
memcpy (cmd->fcp_cdb, SCpnt->cmnd, SCpnt->cmd_len);
@@ -1059,11 +1048,11 @@
FILL_FCHDR_SEQ_DF_SEQ(fch, 0, 0, 0);
FILL_FCHDR_OXRX(fch, 0xffff, 0xffff);
fch->param = 0;
- fcmd->cmd = fc_sync_dma_entry (data, 2 * len, fc);
+ fcmd->cmd = dma_map_single (fc->dev, data, 2 * len);
fcmd->rsp = fcmd->cmd + len;
fcmd->cmdlen = len;
fcmd->rsplen = len;
- fcmd->data = (dma_handle)NULL;
+ fcmd->data = (dma_addr_t)NULL;
fcmd->fc = fc;
fcmd->class = FC_CLASS_SIMPLE;
fcmd->proto = TYPE_EXTENDED_LS;
@@ -1094,7 +1083,7 @@
clear_bit(fcmd->token, fc->scsi_bitmap);
fc->scsi_free++;
- fc_sync_dma_exit (fcmd->cmd, 2 * len, fc);
+ dma_unmap_single (fc->dev, fcmd->cmd, 2 * len);
return l.status;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)