]> Pileus Git - ~andy/linux/commitdiff
ixgbe: add support to FCoE DDP in target mode
authorYi Zou <yi.zou@intel.com>
Tue, 1 Feb 2011 07:22:16 +0000 (07:22 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tue, 8 Mar 2011 02:04:35 +0000 (18:04 -0800)
Add support to the ndo_fcoe_ddp_target() to allow the Intel 82599 device to
also provide DDP offload capability when the upper FCoE protocol stack is
operating as a target.

Signed-off-by: Yi Zou <yi.zou@intel.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ixgbe/ixgbe.h
drivers/net/ixgbe/ixgbe_fcoe.c
drivers/net/ixgbe/ixgbe_fcoe.h
drivers/net/ixgbe/ixgbe_main.c

index b60b81bc2b1551f17e005184edd46c4311deb614..1e546fc127d06a83126bc2857d7da2abe51790e1 100644 (file)
@@ -552,6 +552,8 @@ extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
                           struct sk_buff *skb);
 extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
                               struct scatterlist *sgl, unsigned int sgc);
+extern int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
+                                struct scatterlist *sgl, unsigned int sgc);
 extern int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
 extern int ixgbe_fcoe_enable(struct net_device *netdev);
 extern int ixgbe_fcoe_disable(struct net_device *netdev);
index 27203c87ea147cfc180883e308c45568eecb5050..00af15a9cdc66ade900df22eaa3f717dd77884e6 100644 (file)
@@ -135,22 +135,19 @@ out_ddp_put:
        return len;
 }
 
+
 /**
- * ixgbe_fcoe_ddp_get - called to set up ddp context
+ * ixgbe_fcoe_ddp_setup - called to set up ddp context
  * @netdev: the corresponding net_device
  * @xid: the exchange id requesting ddp
  * @sgl: the scatter-gather list for this request
  * @sgc: the number of scatter-gather items
  *
- * This is the implementation of net_device_ops.ndo_fcoe_ddp_setup
- * and is expected to be called from ULD, e.g., FCP layer of libfc
- * to set up ddp for the corresponding xid of the given sglist for
- * the corresponding I/O.
- *
  * Returns : 1 for success and 0 for no ddp
  */
-int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
-                      struct scatterlist *sgl, unsigned int sgc)
+static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
+                               struct scatterlist *sgl, unsigned int sgc,
+                               int target_mode)
 {
        struct ixgbe_adapter *adapter;
        struct ixgbe_hw *hw;
@@ -164,7 +161,7 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
        unsigned int lastsize;
        unsigned int thisoff = 0;
        unsigned int thislen = 0;
-       u32 fcbuff, fcdmarw, fcfltrw;
+       u32 fcbuff, fcdmarw, fcfltrw, fcrxctl;
        dma_addr_t addr = 0;
 
        if (!netdev || !sgl)
@@ -275,6 +272,9 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
        fcbuff = (IXGBE_FCBUFF_4KB << IXGBE_FCBUFF_BUFFSIZE_SHIFT);
        fcbuff |= ((j & 0xff) << IXGBE_FCBUFF_BUFFCNT_SHIFT);
        fcbuff |= (firstoff << IXGBE_FCBUFF_OFFSET_SHIFT);
+       /* Set WRCONTX bit to allow DDP for target */
+       if (target_mode)
+               fcbuff |= (IXGBE_FCBUFF_WRCONTX);
        fcbuff |= (IXGBE_FCBUFF_VALID);
 
        fcdmarw = xid;
@@ -287,6 +287,16 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
        /* program DMA context */
        hw = &adapter->hw;
        spin_lock_bh(&fcoe->lock);
+
+       /* turn on last frame indication for target mode as FCP_RSPtarget is
+        * supposed to send FCP_RSP when it is done. */
+       if (target_mode && !test_bit(__IXGBE_FCOE_TARGET, &fcoe->mode)) {
+               set_bit(__IXGBE_FCOE_TARGET, &fcoe->mode);
+               fcrxctl = IXGBE_READ_REG(hw, IXGBE_FCRXCTRL);
+               fcrxctl |= IXGBE_FCRXCTRL_LASTSEQH;
+               IXGBE_WRITE_REG(hw, IXGBE_FCRXCTRL, fcrxctl);
+       }
+
        IXGBE_WRITE_REG(hw, IXGBE_FCPTRL, ddp->udp & DMA_BIT_MASK(32));
        IXGBE_WRITE_REG(hw, IXGBE_FCPTRH, (u64)ddp->udp >> 32);
        IXGBE_WRITE_REG(hw, IXGBE_FCBUFF, fcbuff);
@@ -295,6 +305,7 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
        IXGBE_WRITE_REG(hw, IXGBE_FCPARAM, 0);
        IXGBE_WRITE_REG(hw, IXGBE_FCFLT, IXGBE_FCFLT_VALID);
        IXGBE_WRITE_REG(hw, IXGBE_FCFLTRW, fcfltrw);
+
        spin_unlock_bh(&fcoe->lock);
 
        return 1;
@@ -308,6 +319,47 @@ out_noddp_unmap:
        return 0;
 }
 
+/**
+ * ixgbe_fcoe_ddp_get - called to set up ddp context in initiator mode
+ * @netdev: the corresponding net_device
+ * @xid: the exchange id requesting ddp
+ * @sgl: the scatter-gather list for this request
+ * @sgc: the number of scatter-gather items
+ *
+ * This is the implementation of net_device_ops.ndo_fcoe_ddp_setup
+ * and is expected to be called from ULD, e.g., FCP layer of libfc
+ * to set up ddp for the corresponding xid of the given sglist for
+ * the corresponding I/O.
+ *
+ * Returns : 1 for success and 0 for no ddp
+ */
+int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
+                      struct scatterlist *sgl, unsigned int sgc)
+{
+       return ixgbe_fcoe_ddp_setup(netdev, xid, sgl, sgc, 0);
+}
+
+/**
+ * ixgbe_fcoe_ddp_target - called to set up ddp context in target mode
+ * @netdev: the corresponding net_device
+ * @xid: the exchange id requesting ddp
+ * @sgl: the scatter-gather list for this request
+ * @sgc: the number of scatter-gather items
+ *
+ * This is the implementation of net_device_ops.ndo_fcoe_ddp_target
+ * and is expected to be called from ULD, e.g., FCP layer of libfc
+ * to set up ddp for the corresponding xid of the given sglist for
+ * the corresponding I/O. The DDP in target mode is a write I/O request
+ * from the initiator.
+ *
+ * Returns : 1 for success and 0 for no ddp
+ */
+int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
+                           struct scatterlist *sgl, unsigned int sgc)
+{
+       return ixgbe_fcoe_ddp_setup(netdev, xid, sgl, sgc, 1);
+}
+
 /**
  * ixgbe_fcoe_ddp - check ddp status and mark it done
  * @adapter: ixgbe adapter
@@ -331,6 +383,7 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
        struct ixgbe_fcoe *fcoe;
        struct ixgbe_fcoe_ddp *ddp;
        struct fc_frame_header *fh;
+       struct fcoe_crc_eof *crc;
 
        if (!ixgbe_rx_is_fcoe(rx_desc))
                goto ddp_out;
@@ -384,7 +437,18 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
                else if (ddp->len)
                        rc = ddp->len;
        }
-
+       /* In target mode, check the last data frame of the sequence.
+        * For DDP in target mode, data is already DDPed but the header
+        * indication of the last data frame ould allow is to tell if we
+        * got all the data and the ULP can send FCP_RSP back, as this is
+        * not a full fcoe frame, we fill the trailer here so it won't be
+        * dropped by the ULP stack.
+        */
+       if ((fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA) &&
+           (fctl & FC_FC_END_SEQ)) {
+               crc = (struct fcoe_crc_eof *)skb_put(skb, sizeof(*crc));
+               crc->fcoe_eof = FC_EOF_T;
+       }
 ddp_out:
        return rc;
 }
@@ -840,5 +904,3 @@ int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type)
        }
        return rc;
 }
-
-
index 02a00d2415d9f7ac6674780436234b806f51de09..5a650a4ace66ef2e8575872ee5814b521fb58d5a 100644 (file)
@@ -52,6 +52,9 @@
 /* fcerr */
 #define IXGBE_FCERR_BADCRC       0x00100000
 
+/* FCoE DDP for target mode */
+#define __IXGBE_FCOE_TARGET    1
+
 struct ixgbe_fcoe_ddp {
        int len;
        u32 err;
@@ -66,6 +69,7 @@ struct ixgbe_fcoe {
        u8 tc;
        u8 up;
 #endif
+       unsigned long mode;
        atomic_t refcnt;
        spinlock_t lock;
        struct pci_pool *pool;
index 32231ffe0717d484496f1d63b0ca23aad3051c8c..5e8c39decca1a052ef85856aa0aae5f8bad58ebe 100644 (file)
@@ -7019,6 +7019,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {
 #endif
 #ifdef IXGBE_FCOE
        .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get,
+       .ndo_fcoe_ddp_target = ixgbe_fcoe_ddp_target,
        .ndo_fcoe_ddp_done = ixgbe_fcoe_ddp_put,
        .ndo_fcoe_enable = ixgbe_fcoe_enable,
        .ndo_fcoe_disable = ixgbe_fcoe_disable,