[ofw] [Patch][IPoIB_NDIS6_CM] ETH header was copied twice when falling into __send_copy flow.

Alex Naslednikov xalex at mellanox.co.il
Tue Nov 16 07:16:31 PST 2010


Applied at 2994

From: Alex Naslednikov
Sent: Monday, November 15, 2010 3:44 PM
To: ofw at lists.openfabrics.org
Subject: [ofw][Patch][IPoIB_NDIS6_CM] ETH header was copied twice when falling into __send_copy flow.

ETH header was copied twice when falling into __send_copy flow
Signed off by:
Tzachi Dar (tzachid at mellanox.co.il), Alexander Naslednikov (xalex at mellanox.co.il)

Index: ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp
===================================================================
--- ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp                (revision 2988)
+++ ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp             (working copy)
@@ -3702,7 +3702,10 @@
                IN                                                           ipoib_send_NB_SG *                                     s_buf,
                IN                                                           UINT                                                                                      lso_header_size)
 {
-              ULONG                                                                 tot_len = 0;
+             ULONG                                 tot_len = 0;
+             uint32_t                               offset =
+                                                                                             (lso_header_size ? EthIPoIBHeaderOffset : EthHeaderOffset );
+             int seg_index = lso_header_size ? 0 : 1;

                IPOIB_ENTER( IPOIB_DBG_SEND );

@@ -3722,13 +3725,11 @@
                                ASSERT(tot_len > lso_header_size);
                                return NDIS_STATUS_FAILURE;
                }
-              //TODO Do not copy the ETH header
+
                /* Setup the work request. */
-              int seg_index = lso_header_size ? 0 : 1;
-
                p_desc->send_wr[0].local_ds[seg_index].vaddr = cl_get_physaddr(
-                              ((uint8_t*)s_buf->p_send_buf) + lso_header_size );
-              p_desc->send_wr[0].local_ds[seg_index].length = tot_len - lso_header_size;
+                             ((uint8_t*)s_buf->p_send_buf) + lso_header_size + offset );
+             p_desc->send_wr[0].local_ds[seg_index].length = tot_len - lso_header_size - offset;
                p_desc->send_wr[0].local_ds[seg_index].lkey = p_port->ib_mgr.lkey;
                p_desc->send_wr[0].wr.num_ds = seg_index+1;

@@ -4265,9 +4266,7 @@
                NDIS_STATUS                    status;
                uint32_t                               i, j                           = 1;
                ULONG                                                 DataOffset          = 0;
-              uint32_t                               EthHeaderOffset                             = sizeof(eth_hdr_t);
-              static const         EthIPoIBHeaderOffset   = EthHeaderOffset - sizeof(ipoib_hdr_t);
-
+             uint32_t                               offset                    = EthHeaderOffset;
                PERF_DECLARE( SendCopy );

                IPOIB_ENTER( IPOIB_DBG_SEND );
@@ -4282,7 +4281,6 @@
                                return NDIS_STATUS_FAILURE;
                }
                ipoib_send_desc_t *p_desc = s_buf->p_port->p_desc;
-
                /* TODO: Copy only essential data
                   That is, copy only 2 chunks of ETH header if it contained in several
                   first SG elements.
@@ -4340,18 +4338,18 @@
                                                return NDIS_STATUS_SUCCESS;
                                }
                }
-              else while( EthHeaderOffset )
+             else while( offset )
                {
-                              if( p_sgl->Elements[i].Length <= EthHeaderOffset )
+                             if( p_sgl->Elements[i].Length <= offset )
                                {
-                                              EthHeaderOffset -= p_sgl->Elements[i++].Length;
+                                             offset -= p_sgl->Elements[i++].Length;
                                }
                                else
                                {
                                                p_desc->send_wr[0].local_ds[j].vaddr =
-                                                              p_sgl->Elements[i].Address.QuadPart + EthHeaderOffset + DataOffset;
+                                                             p_sgl->Elements[i].Address.QuadPart + offset + DataOffset;
                                                p_desc->send_wr[0].local_ds[j].length =
-                                                              p_sgl->Elements[i].Length - EthHeaderOffset - DataOffset;
+                                                             p_sgl->Elements[i].Length - offset - DataOffset;
                                                p_desc->send_wr[0].local_ds[j].lkey = s_buf->p_port->ib_mgr.lkey;
                                                if( p_desc->send_wr[0].local_ds[j].length > 0 )
                                                {
Index: ulp/ipoib_NDIS6_CM/kernel/ipoib_port.h
===================================================================
--- ulp/ipoib_NDIS6_CM/kernel/ipoib_port.h     (revision 2988)
+++ ulp/ipoib_NDIS6_CM/kernel/ipoib_port.h  (working copy)
@@ -168,7 +168,12 @@
 *            resv
 *                            Reserved portion of IPoIB header.
 *********/
+static const uint32_t     EthHeaderOffset                             = sizeof(eth_hdr_t);

+//We reuse eth header to put there IPoIB header for LSO Net Buffers.
+// Thus, when copying such NB one need to jump over the appropriate offset
+static const uint32_t     EthIPoIBHeaderOffset   = EthHeaderOffset - sizeof(ipoib_hdr_t);
+
 typedef struct _ipoib_arp_pkt
 {
                net16_t                                                hw_type;
@@ -184,6 +189,7 @@
 }             PACK_SUFFIX ipoib_arp_pkt_t;


+
 /****s* IPoIB Driver/ipoib_pkt_t
 * NAME
 *            ipoib_pkt_t

Alexander (XaleX) Naslednikov
SW Networking Team
Mellanox Technologies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20101116/87e1b2a8/attachment.html>


More information about the ofw mailing list