[ofw] [PATCH] remove unused CM code 3 of 3

Alex Naslednikov xalex at mellanox.co.il
Sun Jan 9 08:54:06 PST 2011


Please, commit.
I inserted "#if 0" just to make future CM patches clear,
but I saw a lot of changes on CM branch. So it will be good idea to apply the CM patches
directly on UD code without "#if 0".

-----Original Message-----
From: Smith, Stan [mailto:stan.smith at intel.com]
Sent: Friday, January 07, 2011 10:39 PM
To: Alex Naslednikov
Cc: ofw at lists.openfabrics.org
Subject: [PATCH] remove unused CM code 3 of 3


In order to make IPoIB-CM patches clear, remove #if 0 unused CM code.

signed-off-by: stan smith <stan.smith at intel.com>

--- A/ulp/ipoib_NDIS6_CM/kernel/ipoib_endpoint.cpp      Fri Jan 07 12:01:19 2011
+++ B/ulp/ipoib_NDIS6_CM/kernel/ipoib_endpoint.cpp      Fri Jan 07 10:48:53 2011
@@ -75,74 +75,8 @@
 __endpt_resolve(
        IN                              ipoib_endpt_t* const            p_endpt );

-static void
-__endpt_cm_send_cb(
-       IN              const   ib_cq_handle_t                  h_cq,
-       IN                              void                                    *cq_context );
-static void
-__endpt_cm_recv_cb(
-       IN              const   ib_cq_handle_t                  h_cq,
-       IN                              void                                    *cq_context );
-
-static void
-__endpt_cm_buf_mgr_construct(
-       IN              endpt_buf_mgr_t * const         p_buf_mgr );
-static void
-__conn_reply_cb(
-       IN              ib_cm_rep_rec_t                 *p_cm_rep );
-
-static void
-__conn_mra_cb(
-       IN              ib_cm_mra_rec_t                 *p_mra_rec );
-
-static void
-__conn_rej_cb(
-       IN              ib_cm_rej_rec_t                 *p_rej_rec );
-
-static void
-__conn_dreq_cb(
-        IN     ib_cm_dreq_rec_t                        *p_dreq_rec );
-
-#if 0 //CM
-static cl_status_t
-__cm_recv_desc_ctor(
-       IN              void* const                                     p_object,
-       IN              void*                                           context,
-       OUT             cl_pool_item_t** const          pp_pool_item );
-
-static void
-__cm_recv_desc_dtor(
-       IN              const   cl_pool_item_t* const           p_pool_item,
-       IN                              void                                            *context );
-
-static NDIS_PACKET*
-__endpt_cm_get_ndis_pkt(
-       IN              ipoib_port_t* const                     p_port,
-       IN              ipoib_cm_desc_t* const          p_desc );
-
-static inline ipoib_cm_desc_t*
-__endpt_cm_buf_mgr_get_recv(
-       IN              endpt_buf_mgr_t * const         p_buf_mgr );
-
-static boolean_t
-__cm_recv_is_dhcp(
-       IN              const ipoib_pkt_t* const        p_ipoib );

-static ib_api_status_t
-__endpt_cm_recv_arp(
-       IN              ipoib_port_t* const                     p_port,
-       IN              const   ipoib_pkt_t* const      p_ipoib,
-       OUT             eth_pkt_t* const                        p_eth,
-       IN              ipoib_endpt_t* const            p_src_endpt );

-static ib_api_status_t
-__endpt_cm_recv_udp(
-       IN              ipoib_port_t* const                     p_port,
-       IN              ib_wc_t* const                          p_wc,
-       IN              const   ipoib_pkt_t* const      p_ipoib,
-       OUT             eth_pkt_t* const                        p_eth,
-       IN              ipoib_endpt_t* const            p_src_endpt );
-#endif

 ipoib_endpt_t*
 ipoib_endpt_create(
@@ -296,13 +230,6 @@
                p_port->p_adapter->p_ifc->leave_mcast( p_endpt->h_mcast,
                                                                                           ipoib_leave_mcast_cb );
        }
-#if 0
-       else if( p_port->p_adapter->params.cm_enabled )
-       {
-               p_endpt->cm_flag = 0;
-               CL_ASSERT( endpt_cm_get_state( p_endpt ) == IPOIB_CM_DISCONNECTED );
-       }
-#endif

        cl_obj_unlock( p_obj );

@@ -449,735 +376,3 @@
        IPOIB_EXIT( IPOIB_DBG_ENDPT );
        return NDIS_STATUS_SUCCESS;
 }
-
-#if 0
-
-static void
-__endpt_cm_buf_mgr_construct(
-       IN              endpt_buf_mgr_t * const         p_buf_mgr )
-{
-       IPOIB_ENTER( IPOIB_DBG_INIT );
-
-       cl_qpool_construct( &p_buf_mgr->recv_pool );
-
-       p_buf_mgr->h_packet_pool = NULL;
-       p_buf_mgr->h_buffer_pool = NULL;
-
-       IPOIB_EXIT( IPOIB_DBG_INIT );
-}
-
-ib_api_status_t
-endpt_cm_buf_mgr_init(
-       IN                              ipoib_port_t* const                             p_port )
-{
-       cl_status_t             cl_status;
-       NDIS_STATUS             ndis_status;
-       ib_api_status_t ib_status = IB_SUCCESS;
-
-       IPOIB_ENTER( IPOIB_DBG_INIT );
-
-       if( p_port->cm_buf_mgr.pool_init )
-               return ib_status;
-
-       cl_qlist_init( &p_port->cm_buf_mgr.posted_list );
-
-       __endpt_cm_buf_mgr_construct( &p_port->cm_buf_mgr );
-       p_port->cm_recv_mgr.rq_depth =
-               min( (uint32_t)p_port->p_adapter->params.rq_depth * 8,
-                               p_port->p_ca_attrs->max_srq_wrs/2 );
-       p_port->cm_recv_mgr.depth = 0;
-       /* Allocate the receive descriptors pool */
-       cl_status = cl_qpool_init( &p_port->cm_buf_mgr.recv_pool,
-               p_port->cm_recv_mgr.rq_depth ,
-               0,
-               0,
-               sizeof( ipoib_cm_desc_t ),
-               __cm_recv_desc_ctor,
-               __cm_recv_desc_dtor,
-               p_port );
-
-       if( cl_status != CL_SUCCESS )
-       {
-               NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,
-                       EVENT_IPOIB_RECV_POOL, 1, cl_status );
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("cl_qpool_init(cm_buf_mgr.recv_pool) returned %#x\n", cl_status) );
-               return IB_INSUFFICIENT_MEMORY;
-       }
-
-       /* Allocate the NDIS buffer and packet pools for receive indication. */
-       NdisAllocatePacketPool( &ndis_status,
-                                                       &p_port->cm_buf_mgr.h_packet_pool,
-                                                       p_port->cm_recv_mgr.rq_depth,
-                                                       PROTOCOL_RESERVED_SIZE_IN_PACKET );
-       if( ndis_status != NDIS_STATUS_SUCCESS )
-       {
-               NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,
-                       EVENT_IPOIB_RECV_PKT_POOL, 1, ndis_status );
-
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("NdisAllocatePacketPool returned %08X\n", ndis_status) );
-
-               ib_status = IB_INSUFFICIENT_RESOURCES;
-               goto pkt_pool_failed;
-       }
-
-       NdisAllocateBufferPool( &ndis_status,
-                                                       &p_port->cm_buf_mgr.h_buffer_pool,
-                                                       p_port->cm_recv_mgr.rq_depth );
-       if( ndis_status != NDIS_STATUS_SUCCESS )
-       {
-               NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,
-                       EVENT_IPOIB_RECV_BUF_POOL, 1, ndis_status );
-
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("NdisAllocateBufferPool returned %08X\n", ndis_status) );
-
-               ib_status = IB_INSUFFICIENT_RESOURCES;
-               goto buf_pool_failed;
-       }
-       //NDIS60
-       //p_port->cm_recv_mgr.recv_pkt_array =
-               //cl_zalloc( sizeof(NDIS_PACKET*) * p_port->cm_recv_mgr.rq_depth );
-       p_port->cm_recv_mgr.recv_lst_array =
-               cl_zalloc( sizeof(NET_BUFFER_LIST*) * p_port->cm_recv_mgr.rq_depth );
-
-
-
-       if( !p_port->cm_recv_mgr.recv_NBL_array )
-       {
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("cl_zalloc for cm_recv_mgr NET_BUFFER_LIST array failed.\n") );
-
-               ib_status = IB_INSUFFICIENT_MEMORY;
-               goto pkt_array_failed;
-       }
-
-       p_port->cm_buf_mgr.pool_init = TRUE;
-       return IB_SUCCESS;
-
-
-pkt_array_failed:
-       if( p_port->cm_buf_mgr.h_buffer_pool )
-               NdisFreeBufferPool( p_port->cm_buf_mgr.h_buffer_pool );
-buf_pool_failed:
-       if( p_port->cm_buf_mgr.h_packet_pool )
-               NdisFreePacketPool( p_port->cm_buf_mgr.h_packet_pool );
-pkt_pool_failed:
-               cl_qpool_destroy( &p_port->cm_buf_mgr.recv_pool );
-
-       IPOIB_EXIT( IPOIB_DBG_INIT );
-       return ib_status;
-}
-
-
-void
-endpt_cm_buf_mgr_reset(
-       IN              ipoib_port_t* const             p_port )
-{
-       cl_list_item_t          *p_item;
-
-       if( !p_port->cm_buf_mgr.pool_init )
-               return;
-
-       if( cl_qlist_count( &p_port->cm_buf_mgr.posted_list ) )
-       {
-               for( p_item = cl_qlist_remove_head( &p_port->cm_buf_mgr.posted_list );
-                       p_item != cl_qlist_end( &p_port->cm_buf_mgr.posted_list );
-                       p_item =  cl_qlist_remove_head( &p_port->cm_buf_mgr.posted_list ) )
-               {
-                       cl_qpool_put( &p_port->cm_buf_mgr.recv_pool,
-                               &( PARENT_STRUCT( p_item, ipoib_cm_desc_t, list_item ))->item );
-               }
-       }
-}
-
-void
-endpt_cm_buf_mgr_destroy(
-       IN              ipoib_port_t* const             p_port )
-{
-
-       IPOIB_ENTER(IPOIB_DBG_INIT );
-
-       CL_ASSERT( p_port );
-
-       /* Free the receive descriptors. */
-       if( !p_port->cm_buf_mgr.pool_init )
-               return;
-
-       endpt_cm_buf_mgr_reset( p_port );
-
-       p_port->cm_buf_mgr.pool_init = FALSE;
-
-       if( p_port->cm_recv_mgr.recv_NBL_array )
-       {
-               cl_free( p_port->cm_recv_mgr.recv_NBL_array );
-       }
-
-       /* Destroy the receive packet and buffer pools. */
-       if( p_port->cm_buf_mgr.h_buffer_pool )
-               NdisFreeBufferPool( p_port->cm_buf_mgr.h_buffer_pool );
-       if( p_port->cm_buf_mgr.h_packet_pool )
-               NdisFreePacketPool( p_port->cm_buf_mgr.h_packet_pool );
-
-       cl_qpool_destroy( &p_port->cm_buf_mgr.recv_pool );
-
-       IPOIB_EXIT(  IPOIB_DBG_INIT );
-}
-
-static cl_status_t
-__cm_recv_desc_ctor(
-       IN                              void* const                                     p_object,
-       IN                              void*                                           context,
-               OUT                     cl_pool_item_t** const          pp_pool_item )
-{
-       ipoib_cm_desc_t*        p_desc;
-       ipoib_port_t*           p_port;
-       ib_mr_create_t          create_mr;
-       net32_t                         rkey;
-
-       CL_ASSERT( p_object );
-       CL_ASSERT( context );
-
-       p_desc = (ipoib_cm_desc_t*)p_object;
-       p_port = (ipoib_port_t*)context;
-
-#define BUF_ALIGN              (16)
-
-       p_desc->alloc_buf_size =
-               ROUNDUP( p_port->p_adapter->params.cm_xfer_block_size, BUF_ALIGN );
-
-       p_desc->p_alloc_buf = (uint8_t *)ExAllocatePoolWithTag(
-               NonPagedPool, p_desc->alloc_buf_size, 'DOMC' );
-
-       if( p_desc->p_alloc_buf == NULL )
-       {
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("Failed to allocate CM recv buffer size %d bytes.\n",
-                       p_desc->alloc_buf_size ) );
-               return CL_INSUFFICIENT_MEMORY;
-       }
-
-       create_mr.vaddr  = p_desc->p_alloc_buf;
-       create_mr.length  = p_desc->alloc_buf_size;
-       create_mr.access_ctrl = IB_AC_LOCAL_WRITE;
-
-       if( p_port->p_adapter->p_ifc->reg_mem( p_port->ib_mgr.h_pd,
-                                                                                  &create_mr,
-                                                                                  &p_desc->lkey,
-                                                                                  &rkey,
-                                                                                  &p_desc->h_mr ) != IB_SUCCESS )
-       {
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("Failed to create Memory Region size %d bytes.\n",
-                       p_desc->alloc_buf_size ) );
-               goto ctor_failed;
-       }
-       p_desc->p_buf = p_desc->p_alloc_buf + (BUF_ALIGN - sizeof( ipoib_hdr_t));
-       p_desc->buf_size = p_desc->alloc_buf_size - (BUF_ALIGN - sizeof( ipoib_hdr_t));
-
-       /* Setup the local data segment. */
-       p_desc->local_ds[0].vaddr = (uint64_t)(uintn_t)p_desc->p_buf;
-       p_desc->local_ds[0].length = p_desc->buf_size;
-       p_desc->local_ds[0].lkey = p_desc->lkey;
-
-       /* Setup the work request. */
-       p_desc->wr.wr_id = (uintn_t)p_desc;
-       p_desc->wr.ds_array = p_desc->local_ds;
-       p_desc->wr.num_ds = 1;
-
-       p_desc->type = PKT_TYPE_CM_UCAST;
-
-       *pp_pool_item = &p_desc->item;
-
-       return CL_SUCCESS;
-
-ctor_failed:
-       ExFreePoolWithTag( p_desc->p_alloc_buf, 'DOMC' );
-       return CL_INSUFFICIENT_MEMORY;
-}
-
-static void
-__cm_recv_desc_dtor(
-       IN              const   cl_pool_item_t* const           p_pool_item,
-       IN                              void                                            *context )
-{
-       ipoib_cm_desc_t *p_desc;
-       ipoib_port_t*   p_port;
-
-       if( p_pool_item == NULL || context == NULL )
-               return;
-
-       p_port = (ipoib_port_t*)context;
-       p_desc = PARENT_STRUCT( p_pool_item, ipoib_cm_desc_t, item );
-
-       if( p_desc->h_mr )
-               p_port->p_adapter->p_ifc->dereg_mr( p_desc->h_mr );
-
-       if( p_desc->p_alloc_buf )
-               ExFreePoolWithTag( p_desc->p_alloc_buf, 'DOMC' );
-}
-
-
-static NDIS_PACKET*
-__endpt_cm_get_ndis_pkt(
-       IN              ipoib_port_t* const                     p_port,
-       IN              ipoib_cm_desc_t* const  p_desc )
-{
-       NDIS_STATUS                             status;
-       NDIS_PACKET                             *p_packet;
-       NDIS_BUFFER                             *p_buffer;
-
-       IPOIB_ENTER(  IPOIB_DBG_RECV );
-
-       NdisDprAllocatePacketNonInterlocked( &status, &p_packet,
-                       p_port->cm_buf_mgr.h_packet_pool );
-       if( status != NDIS_STATUS_SUCCESS )
-       {
-               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("Failed to allocate NDIS_PACKET: %08x\n", status) );
-               return NULL;
-       }
-
-       IPOIB_PORT_FROM_PACKET( p_packet ) = p_port;
-       IPOIB_RECV_FROM_PACKET( p_packet ) = p_desc;
-
-       NdisAllocateBuffer(
-                       &status,
-                       &p_buffer,
-                       p_port->cm_buf_mgr.h_buffer_pool,
-                       (void *)(p_desc->p_buf - DATA_OFFSET),
-                       p_desc->len + DATA_OFFSET );
-
-       if( status != NDIS_STATUS_SUCCESS )
-       {
-               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("Failed to allocate NDIS_BUFFER: %08x\n", status) );
-               NdisDprFreePacketNonInterlocked( p_packet );
-               return NULL;
-       }
-
-       NdisChainBufferAtFront( p_packet, p_buffer );
-       NDIS_SET_PACKET_HEADER_SIZE( p_packet, sizeof(eth_hdr_t) );
-
-       IPOIB_EXIT(  IPOIB_DBG_RECV );
-       return p_packet;
-}
-
-static inline ipoib_cm_desc_t*
-__endpt_cm_buf_mgr_get_recv(
-       IN              endpt_buf_mgr_t * const         p_buf_mgr )
-{
-       ipoib_cm_desc_t *p_desc;
-
-       p_desc = (ipoib_cm_desc_t*)cl_qpool_get( &p_buf_mgr->recv_pool );
-       if( p_desc )
-               cl_qlist_insert_tail( &p_buf_mgr->posted_list, &p_desc->list_item );
-
-       return p_desc;
-}
-
-void
-endpt_cm_buf_mgr_put_recv(
-       IN              endpt_buf_mgr_t * const         p_buf_mgr,
-       IN              ipoib_cm_desc_t* const  p_desc )
-{
-
-       IPOIB_ENTER(IPOIB_DBG_RECV );
-
-       /* Return the descriptor to it's pool. */
-       cl_qlist_remove_item( &p_buf_mgr->posted_list, &p_desc->list_item );
-       cl_qpool_put( &p_buf_mgr->recv_pool, &p_desc->item );
-
-       IPOIB_EXIT(  IPOIB_DBG_RECV );
-}
-
-void
-endpt_cm_buf_mgr_put_recv_list(
-       IN              endpt_buf_mgr_t * const         p_buf_mgr,
-       IN              cl_qlist_t* const                       p_list )
-{
-       cl_qpool_put_list( &p_buf_mgr->recv_pool, p_list );
-}
-
-uint32_t
-endpt_cm_recv_mgr_build_pkt_array(
-       IN                      ipoib_port_t* const                     p_port,
-       IN                      ipoib_endpt_t* const            p_endpt,
-       IN                      cl_qlist_t* const                       p_done_list,
-       IN OUT          uint32_t*                                       p_bytes_recv )
-{
-       cl_list_item_t                  *p_item;
-       ipoib_cm_desc_t         *p_desc;
-       uint32_t                                i = 0;
-       NDIS_PACKET                             *p_packet;
-       NDIS_TCP_IP_CHECKSUM_PACKET_INFO        chksum;
-
-       IPOIB_ENTER( IPOIB_DBG_RECV );
-       UNUSED_PARAM( p_endpt );
-
-       p_item = cl_qlist_remove_head( p_done_list );
-
-       *p_bytes_recv = 0;
-
-       for( p_item; p_item != cl_qlist_end( p_done_list );
-               p_item = cl_qlist_remove_head( p_done_list ) )
-       {
-               p_desc = (ipoib_cm_desc_t*)p_item;
-
-               p_packet = __endpt_cm_get_ndis_pkt( p_port, p_desc );
-               if( !p_packet )
-               {
-                       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                               ("Failed to get Packet from descriptor\n" ) );
-                       endpt_cm_buf_mgr_put_recv( &p_port->cm_buf_mgr, p_desc );
-                       p_port->cm_recv_mgr.depth--;
-                       continue;
-               }
-               chksum.Value = 0;
-               switch( p_port->p_adapter->params.recv_chksum_offload )
-               {
-               default:
-                       CL_ASSERT( FALSE );
-               case CSUM_DISABLED:
-               case CSUM_ENABLED:
-               NDIS_PER_PACKET_INFO_FROM_PACKET( p_packet, TcpIpChecksumPacketInfo ) =
-                               (void*)(uintn_t)chksum.Value;
-                       break;
-               case CSUM_BYPASS:
-                       /* Flag the checksums as having been calculated. */
-                       chksum.Receive.NdisPacketTcpChecksumSucceeded = TRUE;
-                       chksum.Receive.NdisPacketUdpChecksumSucceeded = TRUE;
-                       chksum.Receive.NdisPacketIpChecksumSucceeded = TRUE;
-                       NDIS_PER_PACKET_INFO_FROM_PACKET( p_packet, TcpIpChecksumPacketInfo ) =
-                               (void*)(uintn_t)chksum.Value;
-                       break;
-               }
-
-               NDIS_SET_PACKET_STATUS( p_packet, NDIS_STATUS_SUCCESS );
-               p_port->cm_recv_mgr.recv_NBL_array[i] = p_packet;
-               i++;
-               *p_bytes_recv += p_desc->len;
-       }
-
-       IPOIB_EXIT( IPOIB_DBG_RECV );
-       return i;
-}
-void
-endpt_cm_flush_recv(
-       IN                              ipoib_port_t* const             p_port,
-       IN                              ipoib_endpt_t* const    p_endpt )
-{
-       ib_api_status_t         ib_status = IB_SUCCESS;
-       ib_qp_mod_t                     mod_attr;
-       ib_wc_t                         wc[MAX_RECV_WC];
-       ib_wc_t                         *p_free_wc;
-       ib_wc_t                         *p_done_wc;
-       ib_wc_t                         *p_wc;
-       ipoib_cm_desc_t         *p_desc;
-
-       IPOIB_ENTER( IPOIB_DBG_RECV );
-
-       CL_ASSERT( p_endpt );
-
-       if( p_endpt->conn.h_recv_qp )
-       {
-               memset( &mod_attr, 0, sizeof( mod_attr ) );
-               mod_attr.req_state = IB_QPS_ERROR;
-               p_port->p_adapter->p_ifc->modify_qp( p_endpt->conn.h_send_qp, &mod_attr );
-               p_port->p_adapter->p_ifc->modify_qp( p_endpt->conn.h_recv_qp, &mod_attr );
-
-               for( p_free_wc=wc; p_free_wc < &wc[MAX_RECV_WC - 1]; p_free_wc++ )
-                       p_free_wc->p_next = p_free_wc + 1;
-               p_free_wc->p_next = NULL;
-
-               do
-               {
-                       p_free_wc = wc;
-                       ib_status =
-                               p_port->p_adapter->p_ifc->poll_cq( p_endpt->conn.h_recv_cq,
-                               &p_free_wc, &p_done_wc );
-                       if( ib_status != IB_SUCCESS &&
-                               ib_status != IB_NOT_FOUND )
-                       {
-                               /* connection CQ failed */
-                               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                                       ("Poll Recv CQ failed status %#x\n", ib_status ) );
-                               break;
-                       }
-                       cl_spinlock_acquire( &p_port->recv_lock );
-                       for( p_wc = p_done_wc; p_wc; p_wc = p_wc->p_next )
-                       {
-                               p_desc = (ipoib_cm_desc_t *)(uintn_t)p_wc->wr_id;
-                               endpt_cm_buf_mgr_put_recv( &p_port->cm_buf_mgr, p_desc );
-                               p_port->cm_recv_mgr.depth--;
-                       }
-                       cl_spinlock_release( &p_port->recv_lock );
-               } while( !p_free_wc );
-
-               ib_status = p_port->p_adapter->p_ifc->destroy_qp( p_endpt->conn.h_recv_qp, NULL );
-               if( ib_status != IB_SUCCESS )
-               {
-                       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                               ("Destroy Recv QP failed status %#x\n", ib_status ) );
-               }
-               p_endpt->conn.h_recv_qp = NULL;
-       }
-
-       if( p_endpt->conn.h_send_qp )
-       {
-               ib_status = p_port->p_adapter->p_ifc->destroy_qp( p_endpt->conn.h_send_qp, NULL );
-               if( ib_status != IB_SUCCESS )
-               {
-                       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                               ("Destroy Send QP failed status %#x\n", ib_status ) );
-               }
-               p_endpt->conn.h_send_qp = NULL;
-       }
-
-       IPOIB_EXIT( IPOIB_DBG_RECV );
-}
-
-int32_t
-endpt_cm_recv_mgr_filter(
-       IN              ipoib_endpt_t* const            p_endpt,
-       IN              ib_wc_t* const                          p_done_wc_list,
-       OUT             cl_qlist_t* const                       p_done_list,
-       OUT             cl_qlist_t* const                       p_bad_list )
-{
-       ib_api_status_t                 ib_status;
-       ipoib_cm_desc_t                 *p_desc;
-       ib_wc_t                                 *p_wc;
-       ipoib_pkt_t                             *p_ipoib;
-       eth_pkt_t                               *p_eth;
-       ipoib_port_t*                   p_port;
-       int32_t                                 recv_cnt;
-
-       IPOIB_ENTER( IPOIB_DBG_RECV );
-
-       p_port = ipoib_endpt_parent( p_endpt );
-
-       for( p_wc = p_done_wc_list, recv_cnt = 0; p_wc; p_wc = p_wc->p_next )
-       {
-               p_desc = (ipoib_cm_desc_t *)(uintn_t)p_wc->wr_id;
-               recv_cnt++;
-               if(  p_wc->status != IB_WCS_SUCCESS )
-               {
-                       if( p_wc->status != IB_WCS_WR_FLUSHED_ERR )
-                       {
-
-                               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                                       ("Failed completion %s  (vendor specific %#x)\n",
-                                       p_port->p_adapter->p_ifc->get_wc_status_str( p_wc->status ),
-                                       (int)p_wc->vendor_specific) );
-                       }
-                       else
-                       {
-                               IPOIB_PRINT(TRACE_LEVEL_INFORMATION, IPOIB_DBG_RECV,
-                                       ("Flushed completion %s\n",
-                                       p_port->p_adapter->p_ifc->get_wc_status_str( p_wc->status )) );
-                       }
-
-                       ipoib_inc_recv_stat( p_port->p_adapter, IP_STAT_ERROR, 0, 0 );
-
-                       cl_qlist_remove_item( &p_port->cm_buf_mgr.posted_list, &p_desc->list_item );
-                       cl_qlist_insert_tail( p_bad_list, &p_desc->item.list_item );
-                       continue;
-               }
-
-               /* Successful completion
-                Setup the ethernet/ip/arp header and queue descriptor for report. */
-               ib_status = IB_SUCCESS;
-               p_ipoib = (ipoib_pkt_t *)((uint8_t*)p_desc->p_buf );
-               p_eth = (eth_pkt_t *)((uint8_t*)p_desc->p_buf - DATA_OFFSET );
-
-               switch( p_ipoib->hdr.type )
-               {
-               case ETH_PROT_TYPE_ARP:
-                       if( p_wc->length < (sizeof(ipoib_hdr_t) + sizeof(ipoib_arp_pkt_t)) )
-                       {
-                               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                               ("Received ARP packet too short (wc_len %d)\n", p_wc->length) );
-                               ib_status = IB_ERROR;
-                               break;
-                       }
-                       ib_status = __endpt_cm_recv_arp( p_port, p_ipoib, p_eth, p_endpt );
-                       break;
-
-               case ETH_PROT_TYPE_IP:
-                       if( p_wc->length < (sizeof(ipoib_hdr_t) + sizeof(ip_hdr_t)) )
-                       {
-                               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                                       ("Received IP packet too short (wc_len %d)\n", p_wc->length) );
-                               ib_status = IB_ERROR;
-                               break;
-                       }
-                       if( p_ipoib->type.ip.hdr.prot == IP_PROT_UDP )
-                       {
-                               ib_status = __endpt_cm_recv_udp( p_port,
-                                                                                                p_wc,
-                                                                                                p_ipoib,
-                                                                                                p_eth,
-                                                                                                p_endpt );
-                       }
-
-                       break;
-               }
-
-               if( ib_status != IB_SUCCESS )
-               {
-                       ipoib_inc_recv_stat( p_port->p_adapter, IP_STAT_ERROR, 0, 0 );
-                       cl_qlist_insert_tail( p_bad_list, &p_desc->item.list_item );
-                       continue;
-               }
-
-               p_eth->hdr.type = p_ipoib->hdr.type;
-               p_eth->hdr.src = p_endpt->mac;
-               p_eth->hdr.dst = p_port->p_adapter->mac;
-
-               /* save payload length */
-               p_desc->len = p_wc->length;
-
-               cl_qlist_insert_tail( p_done_list, &p_desc->item.list_item );
-       }
-
-       IPOIB_EXIT( IPOIB_DBG_RECV );
-       return recv_cnt;
-}
-
-ib_api_status_t
-endpt_cm_post_recv(
-       IN              ipoib_port_t* const                     p_port )
-{
-       ib_api_status_t         ib_status = IB_SUCCESS;
-       ipoib_cm_desc_t         *p_head_desc = NULL;
-       ipoib_cm_desc_t         *p_tail_desc = NULL;
-       ipoib_cm_desc_t         *p_next_desc;
-       ib_recv_wr_t            *p_failed_wc = NULL;
-
-       IPOIB_ENTER( IPOIB_DBG_RECV );
-
-       while( cl_qpool_count( &p_port->cm_buf_mgr.recv_pool )  > 1  )
-       {
-                       /* Pull receives out of the pool and chain them up. */
-               p_next_desc = __endpt_cm_buf_mgr_get_recv(
-                                                                       &p_port->cm_buf_mgr );
-               if( !p_next_desc )
-               {
-                       IPOIB_PRINT(TRACE_LEVEL_INFORMATION, IPOIB_DBG_RECV,
-                               ("Out of receive descriptors! Endpt recv queue depth 0x%x\n",
-                               p_port->cm_recv_mgr.depth ) );
-                       break;
-               }
-
-               if( !p_tail_desc )
-               {
-                       p_tail_desc = p_next_desc;
-                       p_next_desc->wr.p_next = NULL;
-               }
-               else
-               {
-                       p_next_desc->wr.p_next = &p_head_desc->wr;
-               }
-
-               p_head_desc = p_next_desc;
-
-               p_port->cm_recv_mgr.depth++;
-       }
-
-       if( p_head_desc )
-       {
-               ib_status = p_port->p_adapter->p_ifc->post_srq_recv(
-                       p_port->ib_mgr.h_srq, &p_head_desc->wr, &p_failed_wc );
-
-               if( ib_status != IB_SUCCESS )
-               {
-                       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                               ("ip_post_recv returned %s\n",
-                               p_port->p_adapter->p_ifc->get_err_str( ib_status )) );
-
-                       /* put descriptors back to the pool */
-                       while( p_failed_wc )
-                       {
-                               p_head_desc = PARENT_STRUCT( p_failed_wc, ipoib_cm_desc_t, wr );
-                               p_failed_wc = p_failed_wc->p_next;
-                               endpt_cm_buf_mgr_put_recv( &p_port->cm_buf_mgr, p_head_desc );
-                               p_port->cm_recv_mgr.depth--;
-                       }
-               }
-       }
-
-
-       IPOIB_EXIT( IPOIB_DBG_RECV );
-       return( ib_status );
-}
-
-static ib_api_status_t
-__endpt_cm_recv_arp(
-       IN              ipoib_port_t* const                             p_port,
-       IN              const   ipoib_pkt_t* const              p_ipoib,
-       OUT             eth_pkt_t* const                                p_eth,
-       IN              ipoib_endpt_t* const                    p_src_endpt )
-{
-       const ipoib_arp_pkt_t   *p_ib_arp;
-       arp_pkt_t                               *p_arp;
-
-       p_ib_arp = &p_ipoib->type.arp;
-       p_arp = &p_eth->type.arp;
-
-       if( p_ib_arp->hw_type != ARP_HW_TYPE_IB ||
-               p_ib_arp->hw_size != sizeof(ipoib_hw_addr_t) ||
-               p_ib_arp->prot_type != ETH_PROT_TYPE_IP )
-       {
-               return IB_ERROR;
-       }
-
-       p_arp->hw_type = ARP_HW_TYPE_ETH;
-       p_arp->hw_size = sizeof(mac_addr_t);
-       p_arp->src_hw = p_src_endpt->mac;
-       p_arp->src_ip = p_ib_arp->src_ip;
-       p_arp->dst_hw = p_port->p_local_endpt->mac;
-       p_arp->dst_ip = p_ib_arp->dst_ip;
-
-       return IB_SUCCESS;
-}
-
-static ib_api_status_t
-__endpt_cm_recv_udp(
-       IN      ipoib_port_t* const     p_port,
-       IN                      ib_wc_t* const                          p_wc,
-       IN              const   ipoib_pkt_t* const              p_ipoib,
-       OUT                     eth_pkt_t* const                        p_eth,
-       IN                      ipoib_endpt_t* const            p_src_endpt )
-{
-       ib_api_status_t                 ib_status = IB_SUCCESS;
-
-       if( p_wc->length <
-               (sizeof(ipoib_hdr_t) + sizeof(ip_hdr_t) + sizeof(udp_hdr_t)) )
-       {
-               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
-                       ("Received UDP packet too short\n") );
-               return IB_ERROR;
-       }
-       if( __cm_recv_is_dhcp( p_ipoib ) )
-       {
-               ib_status = ipoib_recv_dhcp( p_port,
-                                                                        p_ipoib,
-                                                                        p_eth,
-                                                                        p_src_endpt,
-                                                                        p_port->p_local_endpt );
-       }
-
-       return ib_status;
-}
-
-static boolean_t
-__cm_recv_is_dhcp(
-       IN      const ipoib_pkt_t* const        p_ipoib )
-{
-       return( (p_ipoib->type.ip.prot.udp.hdr.dst_port == DHCP_PORT_SERVER &&
-                               p_ipoib->type.ip.prot.udp.hdr.src_port == DHCP_PORT_CLIENT) ||
-                               (p_ipoib->type.ip.prot.udp.hdr.dst_port == DHCP_PORT_CLIENT &&
-                               p_ipoib->type.ip.prot.udp.hdr.src_port == DHCP_PORT_SERVER) );
-}
-#endif



More information about the ofw mailing list