From 42146502c61e06f765f6855903b7df1a3ba50c91 Mon Sep 17 00:00:00 2001 From: tzachid Date: Wed, 22 Oct 2008 14:05:31 +0000 Subject: [PATCH] [ipoib] Using ib_local_mad instead of SM. (mlnx: 3342) signed off by: slavas@voltaire.com git-svn-id: svn://openib.tc.cornell.edu/gen1@1679 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/ipoib/kernel/ipoib_port.c | 213 ++++++++++------------------ trunk/ulp/ipoib/kernel/ipoib_port.h | 1 + 2 files changed, 77 insertions(+), 137 deletions(-) diff --git a/trunk/ulp/ipoib/kernel/ipoib_port.c b/trunk/ulp/ipoib/kernel/ipoib_port.c index f0551cd8..4996c8ec 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_port.c +++ b/trunk/ulp/ipoib/kernel/ipoib_port.c @@ -450,9 +450,6 @@ static ib_api_status_t __port_create_bcast( IN ipoib_port_t* const p_port ); -static void -__port_info_cb( - IN ib_query_rec_t *p_query_rec ); static void @@ -5177,10 +5174,10 @@ ipoib_port_up( IN ipoib_port_t* const p_port, IN const ib_pnp_port_rec_t* const p_pnp_rec ) { - ib_api_status_t status; - ib_query_req_t query; - ib_user_query_t info; - ib_portinfo_record_t port_rec; + ib_port_info_t *p_port_info; + ib_mad_t *mad_in = NULL; + ib_mad_t *mad_out = NULL; + ib_api_status_t status = IB_INSUFFICIENT_MEMORY; IPOIB_ENTER( IPOIB_DBG_INIT ); @@ -5193,41 +5190,72 @@ ipoib_port_up( KeResetEvent( &p_port->sa_event ); cl_obj_unlock( &p_port->obj ); - info.method = IB_MAD_METHOD_GETTABLE; - info.attr_id = IB_MAD_ATTR_PORTINFO_RECORD; - info.attr_size = sizeof(ib_portinfo_record_t); - info.comp_mask = IB_PIR_COMPMASK_BASELID; - info.p_attr = &port_rec; - - /* Query requires only the base LID. */ - cl_memclr( &port_rec, sizeof(ib_portinfo_record_t) ); - port_rec.port_info.base_lid = p_pnp_rec->p_port_attr->lid; - - cl_memclr( &query, sizeof(ib_query_req_t) ); - query.query_type = IB_QUERY_USER_DEFINED; - query.p_query_input = &info; - query.port_guid = p_port->p_adapter->guids.port_guid.guid; - query.timeout_ms = p_port->p_adapter->params.sa_timeout; - query.retry_cnt = p_port->p_adapter->params.sa_retry_cnt; - query.query_context = p_port; - query.pfn_query_cb = __port_info_cb; + mad_out = (ib_mad_t*)cl_zalloc(256); + if(! mad_out) + { + IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, + ("failed to allocate mad mad_out\n")); + goto up_done; + } + mad_in = (ib_mad_t*)cl_zalloc(256); + if(! mad_in) + { + IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, + ("failed to allocate mad mad_in\n")); + goto up_done; + } - /* reference the object for the multicast query. */ - ipoib_port_ref( p_port, ref_port_up ); + mad_in->attr_id = IB_MAD_ATTR_PORT_INFO; + mad_in->method = IB_MAD_METHOD_GET; + mad_in->base_ver = 1; + mad_in->class_ver =1; + mad_in->mgmt_class = IB_MCLASS_SUBN_LID; + + status = p_port->p_adapter->p_ifc->local_mad( + p_port->ib_mgr.h_ca ,p_port->port_num ,mad_in ,mad_out); - status = p_port->p_adapter->p_ifc->query( - p_port->p_adapter->h_al, &query, &p_port->ib_mgr.h_query ); if( status != IB_SUCCESS ) { - KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE ); ipoib_set_inactive( p_port->p_adapter ); - ipoib_port_deref( p_port, ref_port_up ); IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, - ("ib_query returned %s\n", + ("ib_local_mad returned %s\n", p_port->p_adapter->p_ifc->get_err_str( status )) ); - return; + goto up_done; + } + + p_port_info = (ib_port_info_t*)(((ib_smp_t*)mad_out)->data); + p_port->base_lid = p_pnp_rec->p_port_attr->lid; + IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, + ("Received port info: link width = %d.\n", + p_port_info->link_width_active) ); + p_port->ib_mgr.rate = + ib_port_info_compute_rate( p_port_info ); + + ipoib_set_rate( p_port->p_adapter, + p_port_info->link_width_active, + ib_port_info_get_link_speed_active( p_port_info ) ); + + status = __port_get_bcast( p_port ); + if (status != IB_SUCCESS) + IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, + (" __port_get_bcast returned %s\n",p_port->p_adapter->p_ifc->get_err_str( status ))); + +up_done: + if( status != IB_SUCCESS ) + { + if( status != IB_CANCELED ) + { + ipoib_set_inactive( p_port->p_adapter ); + __endpt_mgr_reset_all( p_port ); + } + KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE ); } + if(mad_out) + cl_free(mad_out); + if(mad_in) + cl_free(mad_in); + IPOIB_EXIT( IPOIB_DBG_INIT ); } @@ -5261,7 +5289,7 @@ __endpt_mgr_add_local( IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ENDPT, ("<__endpt_mgr_add_local>: av_attr.dlid = p_port_info->base_lid = %d\n",p_port_info->base_lid)); av_attr.dlid = p_port_info->base_lid; - av_attr.static_rate = ib_port_info_compute_rate( p_port_info ); + av_attr.static_rate = p_port->ib_mgr.rate; av_attr.path_bits = 0; status = p_port->p_adapter->p_ifc->create_av( p_port->ib_mgr.h_pd, &av_attr, &p_endpt->h_av ); @@ -5293,109 +5321,6 @@ __endpt_mgr_add_local( } -static void -__port_info_cb( - IN ib_query_rec_t *p_query_rec ) -{ - ib_api_status_t status; - ipoib_port_t *p_port; - ib_portinfo_record_t *p_port_rec; - - IPOIB_ENTER( IPOIB_DBG_INIT ); - - p_port = (ipoib_port_t*)p_query_rec->query_context; - - cl_obj_lock( &p_port->obj ); - p_port->ib_mgr.h_query = NULL; - - if( p_port->state != IB_QPS_INIT ) - { - status = IB_CANCELED; - goto done; - } - - status = p_query_rec->status; - - switch( status ) - { - case IB_SUCCESS: - /* Note that the we report the rate from the port info. */ - p_port_rec = (ib_portinfo_record_t*) - ib_get_query_result( p_query_rec->p_result_mad, 0 ); - - status = __endpt_mgr_add_local( p_port, &p_port_rec->port_info ); - if( status == IB_SUCCESS ) - { - IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, - ("Received port info: link width = %d.\n", - p_port_rec->port_info.link_width_active) ); - - p_port->ib_mgr.rate = - ib_port_info_compute_rate( &p_port_rec->port_info ); - - ipoib_set_rate( p_port->p_adapter, - p_port_rec->port_info.link_width_active, - ib_port_info_get_link_speed_active( &p_port_rec->port_info ) ); - - status = __port_get_bcast( p_port ); - } - else - { - IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, - ("__endpt_mgr_add_local returned %s\n", - p_port->p_adapter->p_ifc->get_err_str( status )) ); - } - break; - - case IB_CANCELED: - IPOIB_PRINT(TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, - ("Instance destroying - Aborting.\n") ); - break; - - case IB_TIMEOUT: - NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter, - EVENT_IPOIB_PORT_INFO_TIMEOUT, 0 ); - IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, - ("Port info query timed out.\n") ); - break; - - case IB_REMOTE_ERROR: - NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter, - EVENT_IPOIB_PORT_INFO_REJECT, 0 ); - IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, - ("Port info query rejected by SA.\n") ); - break; - - default: - NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter, - EVENT_IPOIB_QUERY_PORT_INFO, 1, p_query_rec->status ); - /* Hopefully we'll get an SM change event that will restart things. */ - IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT, - ("Port info query failed.\n") ); - } - -done: - cl_obj_unlock( &p_port->obj ); - - if( status != IB_SUCCESS ) - { - if( status != IB_CANCELED ) - { - ipoib_set_inactive( p_port->p_adapter ); - __endpt_mgr_reset_all( p_port ); - } - KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE ); - } - - /* Return the response MAD to AL. */ - if( p_query_rec->p_result_mad ) - p_port->p_adapter->p_ifc->put_mad( p_query_rec->p_result_mad ); - - /* Release the reference taken when issuing the port info query. */ - ipoib_port_deref( p_port, ref_port_info_cb ); - - IPOIB_EXIT( IPOIB_DBG_INIT ); -} static ib_api_status_t @@ -5812,6 +5737,20 @@ __bcast_cb( } cl_obj_unlock( &p_port->obj ); p_port->bc_join_retry_cnt = 0; + if(! p_port->p_local_endpt) + { + ib_port_info_t port_info; + cl_memclr(&port_info, sizeof(port_info)); + port_info.base_lid = p_port->base_lid; + status = __endpt_mgr_add_local( p_port, &port_info ); + if( status != IB_SUCCESS ) + { + IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR, + ("__endpt_mgr_add_local returned %s\n", + p_port->p_adapter->p_ifc->get_err_str( status )) ); + goto err; + } + } status = __endpt_mgr_add_bcast( p_port, p_mcast_rec ); if( status != IB_SUCCESS ) { diff --git a/trunk/ulp/ipoib/kernel/ipoib_port.h b/trunk/ulp/ipoib/kernel/ipoib_port.h index 6462469d..ae3eeaac 100644 --- a/trunk/ulp/ipoib/kernel/ipoib_port.h +++ b/trunk/ulp/ipoib/kernel/ipoib_port.h @@ -517,6 +517,7 @@ typedef struct _ipoib_port KDPC gc_dpc; KTIMER gc_timer; uint32_t bc_join_retry_cnt; + ib_net16_t base_lid; ipoib_hdr_t hdr[1]; /* Must be last! */ } ipoib_port_t; -- 2.46.0