From: Mike Christie <[EMAIL PROTECTED]>

Just support the current format, so remove older fcoe header code.

Signed-off-by: Mike Christie <[EMAIL PROTECTED]>
---
 usr/fcoe/fc_fcoe.h  |   50 ------------------------------------
 usr/fcoe/fcoe_dev.c |   70 +++++++++++++++++++-------------------------------
 usr/fcoe/fcoe_if.c  |    1 -
 3 files changed, 27 insertions(+), 94 deletions(-)

diff --git a/usr/fcoe/fc_fcoe.h b/usr/fcoe/fc_fcoe.h
index 6c883b6..27b5dbe 100644
--- a/usr/fcoe/fc_fcoe.h
+++ b/usr/fcoe/fc_fcoe.h
@@ -54,54 +54,6 @@
 #define        FC_FCOE_ENCAPS_ID(n)    (((u_int64_t) FC_FCOE_OUI << 24) | (n))
 #define        FC_FCOE_DECAPS_ID(n)    ((n) >> 24)
 
-#ifndef FCOE_T11_AUG07                         /* old version */
-
-/*
- * Start of frame values.
- * For FCOE the SOF value is encoded in 4 bits by simply trimming the
- * standard RFC 3643 encapsulation values.  See fc/encaps.h.
- *
- * The following macros work for class 3 and class F traffic.
- * It is still required to use net access functions to do the byte swapping.
- *
- * SOF code    Normal   FCOE
- *  SOFf       0x28        8
- *  SOFi3      0x2e        e
- *  SOFn3      0x36        6
- */
-#define        FC_FCOE_ENCAPS_LEN_SOF(len, sof) \
-               ((FC_FCOE_VER << 14) | (((len) & 0x3ff) << 4) | ((sof) & 0xf))
-#define        FC_FCOE_DECAPS_VER(n)   ((n) >> 14)
-#define        FC_FCOE_DECAPS_LEN(n)   (((n) >> 4) & 0x3ff)
-#define        FC_FCOE_DECAPS_SOF(n) \
-               (((n) & 0x8) ? (((n) & 0xf) + 0x20) : (((n) & 0xf) + 0x30))
-
-/*
- * FCoE frame header
- *
- * NB: This is the old version, defined before August 2007.
- *
- * This follows the VLAN header, which includes the ethertype.
- * The version is the MS 2 bits, followed by the 10-bit length (in 32b words),
- * followed by the 4-bit encoded SOF as the LSBs.
- */
-struct fcoe_hdr {
-       net16_t         fcoe_plen;      /* fc frame len and SOF */
-};
-
-/*
- * FCoE CRC & EOF
- * NB: This is the old version, defined before August 2007.
- */
-struct fcoe_crc_eof {
-       u_int32_t       fcoe_crc32;     /* CRC for FC packet */
-       net8_t          fcoe_eof;       /* EOF from RFC 3643 */
-} __attribute__((packed));
-
-#define        FCOE_CRC_LEN    4       /* byte length of the FC CRC */
-
-#else /* FCOE_T11_AUG07 */
-
 /*
  * FCoE frame header - 14 bytes
  *
@@ -126,8 +78,6 @@ struct fcoe_crc_eof {
        net8_t          fcoe_resvd[3];  /* reserved - send zero and ignore */
 } __attribute__((packed));
 
-#endif /* FCOE_T11_AUG07 */
-
 /*
  * Store OUI + DID into MAC address field.
  */
diff --git a/usr/fcoe/fcoe_dev.c b/usr/fcoe/fcoe_dev.c
index 96d2cdb..0027e79 100644
--- a/usr/fcoe/fcoe_dev.c
+++ b/usr/fcoe/fcoe_dev.c
@@ -36,7 +36,6 @@
 #include "fc_types.h"
 #include "fc_frame.h"
 #include "fc_encaps.h"
-#define        FCOE_T11_AUG07          /* use new FCoE version */
 #include "fc_fcoe.h"
 #include "fc_fcoe_old.h"
 #include "fcdev.h"
@@ -127,6 +126,7 @@ int fcoe_xmit(struct fcdev *fdev, struct fc_frame *fp)
        struct fcoe_crc_eof *cp;
        int wlen, ret, total;
        struct ethhdr *eh;
+       struct fcoe_hdr *hp;
 
        dprintf("op %x\n", fc_frame_payload_op(fp));
 
@@ -164,8 +164,6 @@ int fcoe_xmit(struct fcdev *fdev, struct fc_frame *fp)
         */
        hlen = fc->fcoe_hlen;
        tlen = sizeof(struct fcoe_crc_eof);
-       if (hlen == sizeof(struct fcoe_hdr_old))
-               tlen = sizeof(struct fcoe_crc_eof_old);
 
        cp = (struct fcoe_crc_eof *)((char *)fh + fp->fr_len);
 
@@ -192,20 +190,11 @@ int fcoe_xmit(struct fcdev *fdev, struct fc_frame *fp)
 
        eh->h_proto = htons(ETH_P_FCOE);
 
-       if (hlen == sizeof(struct fcoe_hdr)) {
-               struct fcoe_hdr *hp;
-
-               hp = (struct fcoe_hdr *)(eh + 1);
-               memset(hp, 0, sizeof(*hp));
-               if (FC_FCOE_VER)
-                       FC_FCOE_ENCAPS_VER(hp, FC_FCOE_VER);
-               hp->fcoe_sof = sof;
-       } else {
-               struct fcoe_hdr_old *ohp;
-
-               ohp = (struct fcoe_hdr_old *)(eh + 1);
-               net16_put(&ohp->fcoe_plen, FC_FCOE_ENCAPS_LEN_SOF(wlen, sof));
-       }
+       hp = (struct fcoe_hdr *)(eh + 1);
+       memset(hp, 0, sizeof(*hp));
+       if (FC_FCOE_VER)
+               FC_FCOE_ENCAPS_VER(hp, FC_FCOE_VER);
+       hp->fcoe_sof = sof;
 
        total = fp->fr_len + tlen + sizeof(*eh) + hlen;
        ret = write(fdev->fd, eh, total);
@@ -223,11 +212,11 @@ int fcoe_rcv(struct fcdev *fdev)
        struct fcoe_softc *fc;
        struct ethhdr *eh;
        uint64_t mac = 0;
-       enum fc_sof sof;
        int ret;
        struct fcoe_dev_stats *stats;
        struct fcoe_crc_eof *cp;
        struct fc_frame *fp;
+       struct fcoe_hdr *hp;
 
        fc = fdev->drv_priv;
 
@@ -254,31 +243,26 @@ int fcoe_rcv(struct fcdev *fdev)
                mac = net48_get((net48_t *)eh->h_source);
 
        hlen = fc->fcoe_hlen;
-       if (hlen == sizeof(struct fcoe_hdr)) {
-               struct fcoe_hdr *hp = (struct fcoe_hdr *)(eh + 1);
-
-               if (FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER) {
-                       eprintf("unknown FCoE version %x\n",
-                               FC_FCOE_DECAPS_VER(hp));
-                       stats->ErrorFrames++;
-                       free(buf);
-                       goto out;
-               }
-               sof = hp->fcoe_sof;
-               fr_len = ret -(sizeof(*eh) +
-                              sizeof(*hp) + sizeof(struct fcoe_crc_eof));
-               tlen = sizeof(struct fcoe_crc_eof);
-       } else {
-               struct fcoe_hdr_old *fchp = (struct fcoe_hdr_old *)(eh + 1);
-               u_int len;
-
-               len = net16_get(&fchp->fcoe_plen);
-               fr_len = FC_FCOE_DECAPS_LEN(len);
-               fr_len = fr_len * FCOE_WORD_TO_BYTE;
-               sof = FC_FCOE_DECAPS_SOF(len);
-               fr_len -= sizeof(cp->fcoe_crc32);
-               tlen = sizeof(struct fcoe_crc_eof_old);
+       if (hlen != sizeof(struct fcoe_hdr)) {
+               eprintf("Wrong fcoe header size. Got %u, but should "
+                       "be %u. Make sure you are using a initiator that "
+                       "is using the current header format\n",
+                       hlen, sizeof(struct fcoe_hdr));
+               stats->ErrorFrames++;
+               goto out;
+       }
+
+       hp = (struct fcoe_hdr *)(eh + 1);
+       if (FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER) {
+               eprintf("unknown FCoE version %x\n",
+                       FC_FCOE_DECAPS_VER(hp));
+               stats->ErrorFrames++;
+               free(buf);
+               goto out;
        }
+       fr_len = ret -(sizeof(*eh) +
+                      sizeof(*hp) + sizeof(struct fcoe_crc_eof));
+       tlen = sizeof(struct fcoe_crc_eof);
 
        if (fr_len + tlen > ret) {
                eprintf("short frame fr_len %x len %x\n",
@@ -296,7 +280,7 @@ int fcoe_rcv(struct fcdev *fdev)
        fp->fr_len = fr_len;
        cp = (struct fcoe_crc_eof *)((char *)fp->fr_hdr + fr_len);
        fp->fr_eof = cp->fcoe_eof;
-       fp->fr_sof = sof;
+       fp->fr_sof = hp->fcoe_sof;
 
        /*
         * Check the CRC here, unless it's solicited data for SCSI.
diff --git a/usr/fcoe/fcoe_if.c b/usr/fcoe/fcoe_if.c
index 68be336..9470f70 100644
--- a/usr/fcoe/fcoe_if.c
+++ b/usr/fcoe/fcoe_if.c
@@ -38,7 +38,6 @@
 #include "fc_types.h"
 #include "fc_frame.h"
 #include "fc_encaps.h"
-#define FCOE_T11_AUG07         /* use new FCoE version */
 #include "fc_fcoe.h"
 #include "fc_fcoe_old.h"
 #include "fc_fs.h"
-- 
1.5.5.1

_______________________________________________
Stgt-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/stgt-devel

Reply via email to