Here is a patch for the old open-fcoe target.  I'm still attempting to
get the target to work reliably, and this patch is a solution for one
of the issues I have encountered.

The problem is that the data direction field is not set properly, when
converting from an OpenFC structure to the corresponding SCST
structure.  This patch fixes this issue, by mapping the data direction
field to an allowed value and copying it in.

The symptom is that the connection between the initiator and target
will fail, and there will be logging messages on the target
complaining about expected data direction mismatch.  This can be
observed in Wireshark.

This patch should be applied in the "openfctgt" directory of the old
archive open-fcoe-target tree.

Hope this helps the people who are working on the open-fcoe target.

Josh Lehan


diff -urN openfctgt-OLD/openfc_scst.c openfctgt-NEW/openfc_scst.c
--- openfctgt-OLD/openfc_scst.c 2008-08-12 13:26:51.000000000 -0700
+++ openfctgt-NEW/openfc_scst.c 2008-08-12 13:52:58.000000000 -0700
@@ -294,6 +294,26 @@
        fc_seq_send_last(sp, fp, FC_RCTL_DD_CMD_STATUS, FC_TYPE_FCP);
 }

+/* Map data direction constants from OpenFC to SCST */
+static scst_data_direction flags_to_datadir(net8_t flags)
+{
+       /* Use only lowest 2 bits (data direction), ignore length */
+       switch(flags & ~FCP_CFL_LEN_MASK)
+       {
+               case FCP_CFL_RDDATA:
+                       return SCST_DATA_READ;
+               case FCP_CFL_WRDATA:
+                       return SCST_DATA_WRITE;
+               case 0:
+                       return SCST_DATA_NONE;
+               default:
+                       break;
+       }
+       
+       printk(KERN_WARNING "openfctgt: bidirection not supported\n");
+       return SCST_DATA_UNKNOWN;
+}
+
 void openfct_rcv_cmd(struct fc_seq *sp, struct fc_frame *fp, void *arg)
 {
        struct openfchba_softc *hba;
@@ -323,6 +343,7 @@
                __memcpy(pkt->lunp, fcmd->fc_lun, 8);
                __memcpy(pkt->cdb, fcmd->fc_cdb, 16);
                fc_seq_set_recv(sp, openfct_rcv_data, (void *)pkt);
+               pkt->data_direction = flags_to_datadir(fcmd->fc_flags);
                openfct_process_scsi_cmd(hba, pkt);
                break;
        default:
_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel

Reply via email to