[IPoIB NDIS 6.0 CM]
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 17 Nov 2009 11:31:39 +0000 (11:31 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 17 Nov 2009 11:31:39 +0000 (11:31 +0000)
Code cleanup
Fixed printouts
Bugfix: p_sgl member of s_buf should be initialized during error flow (mlnx 4995)

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2561 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp

index c336a70..775d106 100644 (file)
@@ -327,26 +327,20 @@ __send_mgr_destroy(
 \r
 static NDIS_STATUS\r
 __send_gen(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN                              ipoib_send_NB_SG *                      s_buf,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
        IN                              INT                                             lso_data_index,\r
-       IN                              NET_BUFFER                                      *p_netbuf,\r
        IN                              UINT                                            lso_header_size OPTIONAL);\r
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_ip(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   eth_hdr_t* const                        p_eth_hdr,\r
        IN                              MDL*                                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
-       IN      OUT                     ipoib_send_NB_SG* const         s_buf,\r
-       IN                              NET_BUFFER                                      *p_netbuf);\r
+       IN      OUT                     ipoib_send_NB_SG* const         s_buf);\r
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_igmp_v2(\r
-       IN                              ipoib_port_t* const                     p_port,\r
+       IN                              ipoib_port_t* const                     p_port,\r
     IN         const   ip_hdr_t* const                         p_ip_hdr,\r
        IN                              size_t                                          iph_options_size,\r
        IN                              MDL*                                            p_mdl,\r
@@ -354,7 +348,6 @@ __send_mgr_filter_igmp_v2(
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_udp(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   ip_hdr_t* const                         p_ip_hdr,\r
        IN                              MDL*                                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
@@ -362,7 +355,6 @@ __send_mgr_filter_udp(
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_dhcp(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   udp_hdr_t* const                        p_udp_hdr,\r
        IN                              MDL*                                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
@@ -370,7 +362,6 @@ __send_mgr_filter_dhcp(
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_arp(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   eth_hdr_t* const                        p_eth_hdr,\r
        IN                              MDL*                                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
@@ -392,12 +383,9 @@ __send_mgr_queue(
 \r
 static NDIS_STATUS\r
 __build_send_desc(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN                              eth_hdr_t* const                        p_eth_hdr,\r
        IN                              MDL* const                                      p_mdl,\r
        IN              const   size_t                                          mdl_len,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
-       IN                              NET_BUFFER                                      *p_netbuf,\r
        IN                              ipoib_send_NB_SG                        *s_buf);\r
 \r
 \r
@@ -418,7 +406,6 @@ static NDIS_STATUS
 __build_lso_desc(\r
        IN                              ipoib_port_t* const                     p_port,\r
        IN                              ULONG                                           mss,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
        IN                              int32_t                                         hdr_idx,\r
        IN PNDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO p_lso_info,\r
        IN                              NET_BUFFER                                      *p_netbuf);\r
@@ -3314,13 +3301,10 @@ __send_mgr_destroy(
 \r
 static NDIS_STATUS\r
 __send_mgr_filter(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   eth_hdr_t* const                        p_eth_hdr,\r
        IN                              MDL* const                                      p_mdl,\r
        IN                              size_t                                          buf_len,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
-       IN      OUT                     ipoib_send_NB_SG                        *s_buf,\r
-       IN                              NET_BUFFER                                      *p_netbuf)\r
+       IN      OUT                     ipoib_send_NB_SG                        *s_buf)\r
 {\r
        NDIS_STATUS             status;\r
 \r
@@ -3334,22 +3318,20 @@ __send_mgr_filter(
         * We already checked the ethernet header length, so we know it's safe\r
         * to decrement the buf_len without underflowing.\r
         */\r
-       ipoib_send_desc_t *p_desc = p_port->p_desc;\r
+       ipoib_send_desc_t *p_desc = s_buf->p_port->p_desc;\r
        buf_len -= sizeof(eth_hdr_t);\r
 \r
        switch( p_eth_hdr->type )\r
        {\r
        case ETH_PROT_TYPE_IP:\r
                cl_perf_start( FilterIp );\r
-               status = __send_mgr_filter_ip(\r
-                       p_port, p_eth_hdr, p_mdl, buf_len, p_sgl, s_buf, p_netbuf);\r
+               status = __send_mgr_filter_ip( p_eth_hdr, p_mdl, buf_len, s_buf );\r
                cl_perf_stop( &p_port->p_adapter->perf, FilterIp );\r
                break;\r
 \r
        case ETH_PROT_TYPE_ARP:\r
                cl_perf_start( FilterArp );\r
-               status = __send_mgr_filter_arp(\r
-                       p_port, p_eth_hdr, p_mdl, buf_len, s_buf );\r
+               status = __send_mgr_filter_arp( p_eth_hdr, p_mdl, buf_len, s_buf );\r
                p_desc->send_dir = SEND_UD_QP;\r
                cl_perf_stop( &p_port->p_adapter->perf, FilterArp );\r
                break;\r
@@ -3362,7 +3344,7 @@ __send_mgr_filter(
 \r
                p_desc->send_dir = SEND_UD_QP;\r
                cl_perf_start( SendGen );\r
-               status = __send_gen( p_port, s_buf, p_sgl, 0, p_netbuf,0 );\r
+               status = __send_gen( s_buf, 0, 0 );\r
                cl_perf_stop( &p_port->p_adapter->perf, SendGen );\r
                break;\r
        }\r
@@ -3822,9 +3804,11 @@ ipoib_process_sg_list_real(
                }\r
                s_buf->p_sgl = NULL;\r
        }\r
-       else\r
+       else //We got this Net Buffer and its SG list directly from NDIS\r
        {\r
                ASSERT(s_buf->p_sgl ==NULL);\r
+               s_buf->p_sgl = p_sgl;\r
+               \r
                cl_perf_start( SendMgrQueue );\r
                if ( ETH_IS_MULTICAST( p_eth_hdr->dst.addr ) && \r
                         p_eth_hdr->type == ETH_PROT_TYPE_IP &&\r
@@ -3887,13 +3871,11 @@ mc_end:
                {\r
                        /* Queue net buffer list. */\r
                        cl_perf_start( QueuePacket );\r
-                       s_buf->p_sgl = p_sgl;\r
 \r
                        cl_qlist_insert_tail( &p_port->send_mgr.pending_list, (cl_list_item_t*)s_buf );\r
-                       //cl_dbg_out("Inserting %x NB first time to the pending list\n", p_netbuf);\r
+                       IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND, ("Inserting %p NB first time to the pending list\n", p_netbuf));\r
                        \r
                        cl_perf_stop( &p_port->p_adapter->perf, QueuePacket );\r
-//                     cl_dbg_out("Fall into pending flow \n");\r
                        ++g_ipoib_send_SG_pending;\r
                        ret = false;\r
                        goto send_end;\r
@@ -3907,7 +3889,6 @@ mc_end:
                         */\r
                         //TODO - check previous comment !\r
                        cl_perf_start( ProcessFailedSends );\r
-\r
                        __send_complete_net_buffer(s_buf, NDIS_STATUS_SUCCESS, complete_flags, TRUE);\r
                        cl_perf_stop( &p_port->p_adapter->perf, ProcessFailedSends );\r
                        //++g_ipoib_send_SG_failed;\r
@@ -3916,7 +3897,7 @@ mc_end:
                }\r
        }\r
        cl_perf_start( BuildSendDesc );\r
-       status = __build_send_desc( p_port, p_eth_hdr, p_mdl, mdl_len, p_sgl, p_netbuf, s_buf );\r
+       status = __build_send_desc( p_eth_hdr, p_mdl, mdl_len, s_buf );\r
        cl_perf_stop( &p_port->p_adapter->perf, BuildSendDesc );\r
 \r
        if( status != NDIS_STATUS_SUCCESS )\r
@@ -3931,11 +3912,8 @@ mc_end:
 \r
        /* Post the WR. */\r
        cl_perf_start( PostSend );\r
-//     cl_dbg_out("sending packet with wr-id =0x%x\n",p_net_buffer_list );\r
+       IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND, ("sending packet with wr-id =0x%p\n",p_net_buffer_list ));\r
        \r
-       // IF this value is NULL, this netbuffer was already sent and when working on its NBL it will be not sent again\r
-       ASSERT(s_buf->p_sgl == NULL);\r
-       s_buf->p_sgl = p_sgl;\r
        ib_status = p_port->p_adapter->p_ifc->post_send( p_port->ib_mgr.h_qp, &(p_port->p_desc->send_wr[0].wr), &p_wr_failed );\r
        ret = true;\r
        cl_perf_stop( &p_port->p_adapter->perf, PostSend );\r
@@ -3992,11 +3970,8 @@ ipoib_process_sg_list(
 \r
 static NDIS_STATUS\r
 __send_gen(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN                              ipoib_send_NB_SG *                      s_buf,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
        IN                              INT                                                     lso_data_index,\r
-       IN                              NET_BUFFER                                      *p_netbuf,\r
        IN                              UINT                                            lso_header_size OPTIONAL)\r
 {\r
        NDIS_STATUS             status;\r
@@ -4008,6 +3983,8 @@ __send_gen(
 \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
+       PSCATTER_GATHER_LIST    p_sgl = s_buf->p_sgl;\r
+\r
        if( !p_sgl )\r
        {\r
                ASSERT( p_sgl );\r
@@ -4015,7 +3992,7 @@ __send_gen(
                        ("Failed to get SGL from packet.\n") );\r
                return NDIS_STATUS_FAILURE;\r
        }\r
-       ipoib_send_desc_t *p_desc = p_port->p_desc;\r
+       ipoib_send_desc_t *p_desc = s_buf->p_port->p_desc;\r
        \r
        /* Remember that one of the DS entries is reserved for the IPoIB header. */\r
        if( ( p_sgl->NumberOfElements >= MAX_SEND_SGE ||\r
@@ -4027,11 +4004,11 @@ __send_gen(
                         Or buffer[0] length %d < Eth header. Copying data.\n",\r
                        p_sgl->NumberOfElements, MAX_SEND_SGE,  p_sgl->Elements[0].Length ) );\r
                status = NDIS_STATUS_RESOURCES;\r
-               if( !p_port->p_adapter->params.cm_enabled )\r
+               if( !s_buf->p_port->p_adapter->params.cm_enabled )\r
                {\r
                        cl_perf_start( SendCopy );\r
-                       status = __send_copy( p_port, s_buf, lso_header_size );\r
-                       cl_perf_stop( &p_port->p_adapter->perf, SendCopy );\r
+                       status = __send_copy( s_buf->p_port, s_buf, lso_header_size );\r
+                       cl_perf_stop( &s_buf->p_port->p_adapter->perf, SendCopy );\r
                }\r
                IPOIB_EXIT( IPOIB_DBG_SEND );\r
                return status;\r
@@ -4042,7 +4019,7 @@ __send_gen(
         * or part of it.\r
         */\r
        i = 0;\r
-       DataOffset= (ULONG)(NET_BUFFER_CURRENT_MDL_OFFSET(p_netbuf)); \r
+       DataOffset= (ULONG)(NET_BUFFER_CURRENT_MDL_OFFSET(s_buf->p_curr_nb)); \r
        \r
        if( lso_data_index )\r
        { /* we have an LSO packet */\r
@@ -4059,7 +4036,7 @@ __send_gen(
                                p_sgl->Elements[0].Address.QuadPart + lso_header_size;\r
                        p_desc->send_wr[0].local_ds[j].length = \r
                                p_sgl->Elements[0].Length - lso_header_size;\r
-                       p_desc->send_wr[0].local_ds[j].lkey = p_port->ib_mgr.lkey;\r
+                       p_desc->send_wr[0].local_ds[j].lkey = s_buf->p_port->ib_mgr.lkey;\r
                        /* Set the number of data segments. */\r
                        p_desc->send_wr[0].wr.num_ds = 1;\r
                        return NDIS_STATUS_SUCCESS;\r
@@ -4077,7 +4054,7 @@ __send_gen(
                                p_sgl->Elements[i].Address.QuadPart + offset + DataOffset;\r
                        p_desc->send_wr[0].local_ds[j].length =\r
                                p_sgl->Elements[i].Length - offset - DataOffset;\r
-                       p_desc->send_wr[0].local_ds[j].lkey = p_port->ib_mgr.lkey;\r
+                       p_desc->send_wr[0].local_ds[j].lkey = s_buf->p_port->ib_mgr.lkey;\r
                        i++;\r
                        j++;\r
                        break;\r
@@ -4088,7 +4065,7 @@ __send_gen(
        {\r
                p_desc->send_wr[0].local_ds[j].vaddr = p_sgl->Elements[i].Address.QuadPart;\r
                p_desc->send_wr[0].local_ds[j].length = p_sgl->Elements[i].Length;\r
-               p_desc->send_wr[0].local_ds[j].lkey = p_port->ib_mgr.lkey;\r
+               p_desc->send_wr[0].local_ds[j].lkey = s_buf->p_port->ib_mgr.lkey;\r
                i++;\r
                j++;\r
        }\r
@@ -4104,13 +4081,10 @@ __send_gen(
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_ip(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   eth_hdr_t* const                        p_eth_hdr,\r
        IN                              MDL*                                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
-       IN                              ipoib_send_NB_SG                        *s_buf,\r
-       IN                              NET_BUFFER                                      *p_netbuf)\r
+       IN                              ipoib_send_NB_SG                        *s_buf )\r
 {\r
        NDIS_STATUS             status;\r
        ip_hdr_t                *p_ip_hdr;\r
@@ -4124,7 +4098,7 @@ __send_mgr_filter_ip(
 \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
-       ipoib_send_desc_t *p_desc = p_port->p_desc;\r
+       ipoib_send_desc_t *p_desc = s_buf->p_port->p_desc;\r
        if( !buf_len )\r
        {\r
                cl_perf_start( QueryIp );\r
@@ -4162,8 +4136,7 @@ __send_mgr_filter_ip(
        case IP_PROT_UDP:\r
 \r
                cl_perf_start( FilterUdp );\r
-               status = __send_mgr_filter_udp(\r
-                       p_port, p_ip_hdr, p_mdl, (buf_len - sizeof(ip_hdr_t)), s_buf );\r
+               status = __send_mgr_filter_udp( p_ip_hdr, p_mdl, (buf_len - sizeof(ip_hdr_t)), s_buf );\r
                cl_perf_stop( &p_port->p_adapter->perf, FilterUdp );\r
                if( status == NDIS_STATUS_PENDING )\r
                {  /* not DHCP packet, keep going */\r
@@ -4195,7 +4168,7 @@ __send_mgr_filter_ip(
                We anyway pass it to __send_mgr_filter_igmp_v2().\r
                */\r
                status =\r
-                       __send_mgr_filter_igmp_v2( p_port, p_ip_hdr, iph_options_size, p_mdl, buf_len );\r
+                       __send_mgr_filter_igmp_v2( s_buf->p_port, p_ip_hdr, iph_options_size, p_mdl, buf_len );\r
                if( status != NDIS_STATUS_SUCCESS )\r
                        return status;\r
 \r
@@ -4205,7 +4178,7 @@ __send_mgr_filter_ip(
                break;\r
        }\r
        \r
-       if( !p_port->p_adapter->params.cm_enabled )\r
+       if( !s_buf->p_port->p_adapter->params.cm_enabled )\r
        {\r
                p_desc->send_dir = SEND_UD_QP;\r
                goto send_gen;\r
@@ -4217,7 +4190,7 @@ __send_mgr_filter_ip(
        if( p_desc->send_dir == SEND_UD_QP )\r
        {\r
                ip_packet_len = cl_ntoh16( p_ip_hdr->length );\r
-               if( ip_packet_len  > p_port->p_adapter->params.payload_mtu )\r
+               if( ip_packet_len  > s_buf->p_port->p_adapter->params.payload_mtu )\r
                {\r
                        //TODO: NDIS60\r
                        #if 0\r
@@ -4231,7 +4204,7 @@ __send_mgr_filter_ip(
 \r
 send_gen:\r
        cl_perf_start( SendTcp );\r
-       status = __send_gen( p_port, s_buf, p_sgl, 0, p_netbuf,0 );\r
+       status = __send_gen(  s_buf, 0, 0 );\r
        cl_perf_stop( &p_port->p_adapter->perf, SendTcp );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_SEND );\r
@@ -4368,7 +4341,6 @@ __send_mgr_filter_igmp_v2(
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_udp(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   ip_hdr_t* const                         p_ip_hdr,\r
        IN                              MDL*                                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
@@ -4398,7 +4370,7 @@ __send_mgr_filter_udp(
                                ("Failed to query UDP header buffer.\n") );\r
                        return NDIS_STATUS_FAILURE;\r
                }\r
-               cl_perf_stop( &p_port->p_adapter->perf, QueryUdp );\r
+               cl_perf_stop( &s_buf->p_port->p_adapter->perf, QueryUdp );\r
        }\r
        else\r
        {\r
@@ -4434,7 +4406,7 @@ __send_mgr_filter_udp(
 \r
        /* Allocate our scratch buffer. */\r
        s_buf->p_send_buf = (send_buf_t*)\r
-               ExAllocateFromNPagedLookasideList( &p_port->buf_mgr.send_buf_list );\r
+               ExAllocateFromNPagedLookasideList( &s_buf->p_port->buf_mgr.send_buf_list );\r
        if( !s_buf->p_send_buf )\r
        {\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
@@ -4447,8 +4419,7 @@ __send_mgr_filter_udp(
                &s_buf->p_send_buf->ip.prot.udp.hdr, p_udp_hdr, sizeof(udp_hdr_t) );\r
 \r
        cl_perf_start( FilterDhcp );\r
-       status = __send_mgr_filter_dhcp(\r
-               p_port, p_udp_hdr, p_mdl, buf_len, s_buf );\r
+       status = __send_mgr_filter_dhcp( p_udp_hdr, p_mdl, buf_len, s_buf );\r
        cl_perf_stop( &p_port->p_adapter->perf, FilterDhcp );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_SEND );\r
@@ -4470,7 +4441,6 @@ unsigned short ipchksum(unsigned short *ip, int len)
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_dhcp(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   udp_hdr_t* const                        p_udp_hdr,\r
        IN                              NDIS_BUFFER*                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
@@ -4485,7 +4455,7 @@ __send_mgr_filter_dhcp(
 \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
-       ipoib_send_desc_t *p_desc = p_port->p_desc;\r
+       ipoib_send_desc_t *p_desc = s_buf->p_port->p_desc;\r
        \r
        if( !buf_len )\r
        {\r
@@ -4562,7 +4532,7 @@ __send_mgr_filter_dhcp(
                {\r
                        /* do we need to replace it ?  len eq ETH MAC sz 'and' MAC is mine */\r
                        if( p_cid[1] == HW_ADDR_LEN+1 && !cl_memcmp( &p_cid[3],\r
-                               &p_port->p_adapter->params.conf_mac.addr, HW_ADDR_LEN ) )\r
+                               &s_buf->p_port->p_adapter->params.conf_mac.addr, HW_ADDR_LEN ) )\r
                        {\r
                                /* Make sure there's room to extend it.  23 is the size of\r
                                 * the CID option for IPoIB.\r
@@ -4611,9 +4581,9 @@ __send_mgr_filter_dhcp(
 \r
                CL_ASSERT( p_cid[1] == 21 );\r
                p_cid[23]= DHCP_OPT_END;\r
-               ib_gid_set_default( &gid, p_port->p_adapter->guids.port_guid.guid );\r
+               ib_gid_set_default( &gid, s_buf->p_port->p_adapter->guids.port_guid.guid );\r
                cl_memcpy( &p_cid[7], &gid, sizeof(ib_gid_t) );\r
-               cl_memcpy( &p_cid[3], &p_port->ib_mgr.qpn, sizeof(p_port->ib_mgr.qpn) );                \r
+               cl_memcpy( &p_cid[3], &s_buf->p_port->ib_mgr.qpn, sizeof(s_buf->p_port->ib_mgr.qpn) );          \r
                p_ib_dhcp->htype = DHCP_HW_TYPE_IB;\r
 \r
                /* update lengths to include any change we made */\r
@@ -4644,7 +4614,7 @@ __send_mgr_filter_dhcp(
        s_buf->p_send_buf->ip.prot.udp.hdr.chksum = 0;\r
        p_desc->send_wr[0].local_ds[1].vaddr = cl_get_physaddr( s_buf->p_send_buf );\r
        p_desc->send_wr[0].local_ds[1].length = sizeof(ip_hdr_t) +      sizeof(udp_hdr_t) + sizeof(dhcp_pkt_t);\r
-       p_desc->send_wr[0].local_ds[1].lkey = p_port->ib_mgr.lkey;\r
+       p_desc->send_wr[0].local_ds[1].lkey = s_buf->p_port->ib_mgr.lkey;\r
        p_desc->send_wr[0].wr.num_ds = 2;\r
        p_desc->send_dir = SEND_UD_QP;\r
        IPOIB_EXIT( IPOIB_DBG_SEND );\r
@@ -4654,7 +4624,6 @@ __send_mgr_filter_dhcp(
 \r
 static NDIS_STATUS\r
 __send_mgr_filter_arp(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN              const   eth_hdr_t* const                        p_eth_hdr,\r
        IN                              MDL*                                            p_mdl,\r
        IN                              size_t                                          buf_len,\r
@@ -4667,7 +4636,7 @@ __send_mgr_filter_arp(
 \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
-       ipoib_send_desc_t *p_desc = p_port->p_desc;\r
+       ipoib_send_desc_t *p_desc = s_buf->p_port->p_desc;\r
        \r
        if( !buf_len )\r
        {\r
@@ -4709,7 +4678,7 @@ __send_mgr_filter_arp(
        /* Allocate our scratch buffer. */\r
        ASSERT(s_buf->p_send_buf == NULL);\r
        s_buf->p_send_buf = (send_buf_t*)\r
-               NdisAllocateFromNPagedLookasideList( &p_port->buf_mgr.send_buf_list );\r
+               NdisAllocateFromNPagedLookasideList( &s_buf->p_port->buf_mgr.send_buf_list );\r
        if( !s_buf->p_send_buf )\r
        {\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
@@ -4725,7 +4694,7 @@ __send_mgr_filter_arp(
        p_ib_arp->prot_size = p_arp->prot_size;\r
        p_ib_arp->op = p_arp->op;\r
        \r
-       ipoib_addr_set_qpn( &p_ib_arp->src_hw, p_port->ib_mgr.qpn );\r
+       ipoib_addr_set_qpn( &p_ib_arp->src_hw, s_buf->p_port->ib_mgr.qpn );\r
 #if 0\r
 \r
        if( p_port->p_adapter->params.cm_enabled )\r
@@ -4735,13 +4704,13 @@ __send_mgr_filter_arp(
 #endif\r
 \r
        ib_gid_set_default( &p_ib_arp->src_hw.gid,\r
-               p_port->p_adapter->guids.port_guid.guid );\r
+               s_buf->p_port->p_adapter->guids.port_guid.guid );\r
        p_ib_arp->src_ip = p_arp->src_ip;\r
        if( cl_memcmp( &p_arp->dst_hw, &null_hw, sizeof(mac_addr_t) ) )\r
        {\r
                /* Get the endpoint referenced by the dst_hw address. */\r
                net32_t qpn = 0;\r
-               status = __endpt_mgr_get_gid_qpn( p_port, p_arp->dst_hw,\r
+               status = __endpt_mgr_get_gid_qpn( s_buf->p_port, p_arp->dst_hw,\r
                        &p_ib_arp->dst_hw.gid, &qpn );\r
                if( status != NDIS_STATUS_SUCCESS )\r
                {\r
@@ -4819,7 +4788,7 @@ __send_mgr_filter_arp(
 \r
        p_desc->send_wr[0].local_ds[1].vaddr = cl_get_physaddr( p_ib_arp );\r
        p_desc->send_wr[0].local_ds[1].length = sizeof(ipoib_arp_pkt_t);\r
-       p_desc->send_wr[0].local_ds[1].lkey = p_port->ib_mgr.lkey;\r
+       p_desc->send_wr[0].local_ds[1].lkey = s_buf->p_port->ib_mgr.lkey;\r
        p_desc->send_wr[0].wr.num_ds = 2;\r
        p_desc->send_wr[0].wr.p_next = NULL;\r
 \r
@@ -4888,12 +4857,9 @@ __send_mgr_queue(
 \r
 static NDIS_STATUS\r
 __build_send_desc(\r
-       IN                              ipoib_port_t* const                     p_port,\r
        IN                              eth_hdr_t* const                        p_eth_hdr,\r
        IN                              MDL* const                                      p_mdl,\r
        IN              const   size_t                                          mdl_len,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
-       IN                              NET_BUFFER                                      *p_netbuf,\r
        IN                              ipoib_send_NB_SG                        *s_buf)\r
 {\r
        NDIS_STATUS                     status;\r
@@ -4906,14 +4872,14 @@ __build_send_desc(
        \r
        IPOIB_ENTER( IPOIB_DBG_SEND );\r
 \r
-       ipoib_send_desc_t *p_desc = p_port->p_desc;\r
+       ipoib_send_desc_t *p_desc = s_buf->p_port->p_desc;\r
 \r
        /* Format the send descriptor. */\r
        PVOID* ppTemp           = &NET_BUFFER_LIST_INFO(s_buf->p_nbl, TcpIpChecksumNetBufferListInfo);\r
     p_checksum_list_info = \r
                         (PNDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO) ((PULONG)ppTemp); \r
        // Calculate LSO\r
-       if( p_port->p_adapter->params.lso ) {\r
+       if( s_buf->p_port->p_adapter->params.lso ) {\r
 \r
                p_lso_info =\r
                        (PNDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO) (PULONG) &NET_BUFFER_LIST_INFO(s_buf->p_nbl, TcpLargeSendNetBufferListInfo);\r
@@ -4921,7 +4887,7 @@ __build_send_desc(
        ULONG LsoType = p_lso_info->Transmit.Type;\r
 \r
            mss = p_lso_info->LsoV1Transmit.MSS;\r
-               ULONG PacketLength = NET_BUFFER_DATA_LENGTH(p_netbuf);\r
+               ULONG PacketLength = NET_BUFFER_DATA_LENGTH(s_buf->p_curr_nb);\r
                if  (PacketLength < mss) {\r
                        ASSERT(FALSE);\r
                        return NDIS_STATUS_INVALID_PACKET;\r
@@ -4936,18 +4902,18 @@ __build_send_desc(
        }\r
                        \r
        /* Format the send descriptor. */\r
-       hdr_idx = cl_atomic_inc( &p_port->hdr_idx );\r
-       hdr_idx &= (p_port->p_adapter->params.sq_depth - 1);\r
-       ASSERT( hdr_idx < p_port->p_adapter->params.sq_depth );\r
-       p_port->hdr[hdr_idx].type = p_eth_hdr->type;\r
-       p_port->hdr[hdr_idx].resv = 0;\r
+       hdr_idx = cl_atomic_inc( &s_buf->p_port->hdr_idx );\r
+       hdr_idx &= (s_buf->p_port->p_adapter->params.sq_depth - 1);\r
+       ASSERT( hdr_idx < s_buf->p_port->p_adapter->params.sq_depth );\r
+       s_buf->p_port->hdr[hdr_idx].type = p_eth_hdr->type;\r
+       s_buf->p_port->hdr[hdr_idx].resv = 0;\r
 \r
        //TODO why we enter this block for LSO ???\r
-       p_desc->send_wr[0].local_ds[0].vaddr = cl_get_physaddr( &p_port->hdr[hdr_idx] );\r
+       p_desc->send_wr[0].local_ds[0].vaddr = cl_get_physaddr( &s_buf->p_port->hdr[hdr_idx] );\r
        p_desc->send_wr[0].local_ds[0].length = sizeof(ipoib_hdr_t);\r
-       p_desc->send_wr[0].local_ds[0].lkey = p_port->ib_mgr.lkey;\r
+       p_desc->send_wr[0].local_ds[0].lkey = s_buf->p_port->ib_mgr.lkey;\r
        p_desc->send_wr[0].wr.send_opt = 0;\r
-       //Set this value to 0\r
+       //Init send buffer to 0\r
        s_buf->p_send_buf = NULL;\r
 \r
        \r
@@ -4956,7 +4922,7 @@ __build_send_desc(
                \r
                ASSERT( mss == (p_lso_info->LsoV1Transmit.MSS & p_lso_info->LsoV2Transmit.MSS));\r
                //ASSERT ( (mss & (1<<20)) == mss);\r
-               status = __build_lso_desc( p_port, mss, p_sgl, hdr_idx, p_lso_info, p_netbuf);\r
+               status = __build_lso_desc( s_buf->p_port, mss, hdr_idx, p_lso_info, s_buf->p_curr_nb);\r
                if( status != NDIS_STATUS_SUCCESS )\r
                {\r
                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
@@ -4969,8 +4935,7 @@ __build_send_desc(
        {\r
                uint32_t        i;\r
                cl_perf_start( SendMgrFilter );\r
-               status = __send_mgr_filter(\r
-               p_port, p_eth_hdr, p_mdl, mdl_len,p_sgl, s_buf, p_netbuf );\r
+               status = __send_mgr_filter( p_eth_hdr, p_mdl, mdl_len, s_buf );\r
                cl_perf_stop( &p_port->p_adapter->perf, SendMgrFilter );\r
                if( status != NDIS_STATUS_SUCCESS )\r
                {\r
@@ -4981,17 +4946,17 @@ __build_send_desc(
 \r
                if( p_desc->send_dir == SEND_UD_QP )\r
                {\r
-                       p_desc->send_qp = p_port->ib_mgr.h_qp; // UD QP\r
+                       p_desc->send_qp = s_buf->p_port->ib_mgr.h_qp; // UD QP\r
                        for( i = 0; i < p_desc->num_wrs; i++ )\r
                        {\r
                                p_desc->send_wr[i].wr.dgrm.ud.remote_qp = p_desc->p_endpt->qpn;\r
-                               p_desc->send_wr[i].wr.dgrm.ud.remote_qkey = p_port->ib_mgr.bcast_rec.qkey;\r
+                               p_desc->send_wr[i].wr.dgrm.ud.remote_qkey = s_buf->p_port->ib_mgr.bcast_rec.qkey;\r
                                p_desc->send_wr[i].wr.dgrm.ud.h_av = p_desc->p_endpt->h_av;\r
-                               p_desc->send_wr[i].wr.dgrm.ud.pkey_index = p_port->pkey_index;\r
+                               p_desc->send_wr[i].wr.dgrm.ud.pkey_index = s_buf->p_port->pkey_index;\r
                                p_desc->send_wr[i].wr.dgrm.ud.rsvd = NULL;\r
                                p_desc->send_wr[i].wr.send_opt = 0;\r
 \r
-                               if( p_port->p_adapter->params.send_chksum_offload       &&\r
+                               if( s_buf->p_port->p_adapter->params.send_chksum_offload        &&\r
                                        p_checksum_list_info                                                    &&\r
                                        ( p_checksum_list_info->Transmit.IsIPv4  || \r
                                        p_checksum_list_info->Transmit.IsIPv6  ))\r
@@ -5032,7 +4997,7 @@ __build_send_desc(
 \r
        /* Store context in our reserved area of the packet. */\r
 \r
-       ASSERT(s_buf == (ipoib_send_NB_SG *) IPOIB_INFO_FROM_NB(p_netbuf));\r
+       ASSERT(s_buf == (ipoib_send_NB_SG *) IPOIB_INFO_FROM_NB(s_buf->p_curr_nb));\r
        s_buf->p_endpt = p_desc->p_endpt;\r
        //TODO IMPORTANT: Send buffer should not be allocated within global struct !!!\r
        // Otherwise, the next send may override its content\r
@@ -5046,7 +5011,6 @@ static NDIS_STATUS
 __build_lso_desc(\r
        IN                              ipoib_port_t* const                     p_port,\r
        IN                              ULONG                                           mss,\r
-       IN                              SCATTER_GATHER_LIST                     *p_sgl,\r
        IN                              int32_t                                         hdr_idx, \r
        IN PNDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO p_lso_info,\r
        IN                              NET_BUFFER                                      *p_netbuf)\r
@@ -5115,7 +5079,7 @@ __build_lso_desc(
        p_desc->send_wr[0].wr.p_next = NULL;\r
        p_desc->send_qp = p_port->ib_mgr.h_qp;\r
        p_desc->send_dir = SEND_UD_QP;\r
-       status = __send_gen(p_port, s_buf, p_sgl, IndexOfData, p_netbuf, TheLsoData.LsoHeaderSize);\r
+       status = __send_gen( s_buf, IndexOfData, TheLsoData.LsoHeaderSize );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_SEND );\r
        return status;\r
@@ -5166,7 +5130,7 @@ CreateFragList(
     UNREFERENCED_PARAMETER(PacketLength);\r
 \r
 \r
-//    ETH_PRINT(TRACE_LEVEL_VERBOSE, ETH_SND, "CreateFragList: NetBuff %p, Length =0x%x\n", NetBuff, buf_len);\r
+    IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND, ("CreateFragList: NetBuff %p, Length =0x%x\n", NetBuff, buf_len));\r
 \r
     while ( (pMdl != NULL) && (buf_len != 0) )\r
     {\r
@@ -5185,7 +5149,7 @@ CreateFragList(
 \r
         ASSERT( (buf_len > 0) && (MdlBytesCount > 0) );\r
  \r
-//        ETH_PRINT(TRACE_LEVEL_VERBOSE, ETH_SND, "CreateFragList: pMdl=%p, MdlBytesCount=x%x, MdlBufCount=0x%x\n", pMdl, MdlBytesCount, MdlBufCount);\r
+               IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND, ("CreateFragList: pMdl=%p, MdlBytesCount=x%x, MdlBufCount=0x%x\n", pMdl, MdlBytesCount, MdlBufCount));\r
 \r
         if (MdlBytesCount > 0)\r
         {\r
@@ -5230,7 +5194,7 @@ CreateFragList(
                         MdlBytesCount = 0;\r
                     }\r
 \r
-//                    ETH_PRINT(TRACE_LEVEL_VERBOSE, ETH_SND, "CreateFragList: j == 0, MdlBytesCount=x%x, i = %d, element.length=0x%x \n",  MdlBytesCount, i, pFragList->Elements[i].Length);                    \r
+                   IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND, ( "CreateFragList: j == 0, MdlBytesCount=x%x, i = %d, element.length=0x%x \n",  MdlBytesCount, i, pFragList->Elements[i].Length));                    \r
                 } \r
                 else \r
                 {\r
@@ -5253,7 +5217,7 @@ CreateFragList(
                         MdlBytesCount -= pFragList->Elements[i].Length;\r
                     }\r
 \r
-//                    ETH_PRINT(TRACE_LEVEL_VERBOSE, ETH_SND, "CreateFragList: j != 0, MdlBytesCount=x%x, i = %d, element.length=0x%x \n",  MdlBytesCount, i, pFragList->Elements[i].Length);                    \r
+                    IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND, ( "CreateFragList: j != 0, MdlBytesCount=x%x, i = %d, element.length=0x%x \n",  MdlBytesCount, i, pFragList->Elements[i].Length));                    \r
                 }                \r
                 i++;\r
                 ASSERT(i <= MAX_PHYS_BUF_FRAG_ELEMENTS);\r
@@ -5271,7 +5235,7 @@ CreateFragList(
         //\r
         ASSERT(i > 0); // To prevent array underflow\r
         pFragList->Elements[i-1].Length += buf_len;\r
-//        ETH_PRINT(TRACE_LEVEL_ERROR, ETH_SND, "CreateFragList: buf_len != 0, i = %d, element.length=0x%x \n",  i -1, pFragList->Elements[i-1].Length);                    \r
+        IPOIB_PRINT( TRACE_LEVEL_VERBOSE, IPOIB_DBG_SEND, ( "CreateFragList: buf_len != 0, i = %d, element.length=0x%x \n",  i -1, pFragList->Elements[i-1].Length));                    \r
     }\r
 \r
     ASSERT(i <= PhysBufCount);\r
@@ -7721,7 +7685,7 @@ __mcast_cb(
        \r
        /* Try to send all pending sends. */\r
        cl_spinlock_acquire( &p_port->send_lock );\r
-       //cl_dbg_out("Calling ipoib_port_resume from mcast_cb\n");\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_MCAST, ("Calling ipoib_port_resume from mcast_cb\n"));\r
        ipoib_port_resume(p_port , FALSE);\r
        cl_spinlock_release( &p_port->send_lock );\r
 \r