[ipoib] Using ib_local_mad instead of SM. (mlnx: 3342)
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 22 Oct 2008 14:05:31 +0000 (14:05 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 22 Oct 2008 14:05:31 +0000 (14:05 +0000)
signed off by: slavas@voltaire.com

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

ulp/ipoib/kernel/ipoib_port.c
ulp/ipoib/kernel/ipoib_port.h

index f0551cd..4996c8e 100644 (file)
@@ -450,9 +450,6 @@ static ib_api_status_t
 __port_create_bcast(\r
        IN                              ipoib_port_t* const                     p_port );\r
 \r
-static void\r
-__port_info_cb(\r
-       IN                              ib_query_rec_t                          *p_query_rec );\r
 \r
 \r
 static void\r
@@ -5177,10 +5174,10 @@ ipoib_port_up(
        IN                              ipoib_port_t* const                     p_port,\r
        IN              const   ib_pnp_port_rec_t* const        p_pnp_rec )\r
 {\r
-       ib_api_status_t                 status;\r
-       ib_query_req_t                  query;\r
-       ib_user_query_t                 info;\r
-       ib_portinfo_record_t    port_rec;\r
+       ib_port_info_t          *p_port_info;\r
+       ib_mad_t                        *mad_in = NULL;\r
+       ib_mad_t                        *mad_out = NULL;\r
+       ib_api_status_t         status = IB_INSUFFICIENT_MEMORY;\r
 \r
        IPOIB_ENTER( IPOIB_DBG_INIT );\r
 \r
@@ -5193,41 +5190,72 @@ ipoib_port_up(
        KeResetEvent( &p_port->sa_event );\r
        cl_obj_unlock( &p_port->obj );\r
 \r
-       info.method = IB_MAD_METHOD_GETTABLE;\r
-       info.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;\r
-       info.attr_size = sizeof(ib_portinfo_record_t);\r
-       info.comp_mask = IB_PIR_COMPMASK_BASELID;\r
-       info.p_attr = &port_rec;\r
-\r
-       /* Query requires only the base LID. */\r
-       cl_memclr( &port_rec, sizeof(ib_portinfo_record_t) );\r
-       port_rec.port_info.base_lid = p_pnp_rec->p_port_attr->lid;\r
-\r
-       cl_memclr( &query, sizeof(ib_query_req_t) );\r
-       query.query_type = IB_QUERY_USER_DEFINED;\r
-       query.p_query_input = &info;\r
-       query.port_guid = p_port->p_adapter->guids.port_guid.guid;\r
-       query.timeout_ms = p_port->p_adapter->params.sa_timeout;\r
-       query.retry_cnt = p_port->p_adapter->params.sa_retry_cnt;\r
-       query.query_context = p_port;\r
-       query.pfn_query_cb = __port_info_cb;\r
+       mad_out = (ib_mad_t*)cl_zalloc(256);\r
+       if(! mad_out)\r
+       {\r
+               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                       ("failed to allocate mad mad_out\n")); \r
+               goto up_done;\r
+       }\r
+       mad_in = (ib_mad_t*)cl_zalloc(256);\r
+       if(! mad_in)\r
+       {\r
+               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                       ("failed to allocate mad mad_in\n")); \r
+               goto up_done;\r
+       }\r
 \r
-       /* reference the object for the multicast query. */\r
-       ipoib_port_ref( p_port, ref_port_up );\r
+       mad_in->attr_id = IB_MAD_ATTR_PORT_INFO;\r
+       mad_in->method = IB_MAD_METHOD_GET;\r
+       mad_in->base_ver = 1;\r
+       mad_in->class_ver =1;\r
+       mad_in->mgmt_class = IB_MCLASS_SUBN_LID;\r
+       \r
+       status = p_port->p_adapter->p_ifc->local_mad(\r
+               p_port->ib_mgr.h_ca ,p_port->port_num ,mad_in ,mad_out);\r
 \r
-       status = p_port->p_adapter->p_ifc->query(\r
-               p_port->p_adapter->h_al, &query, &p_port->ib_mgr.h_query );\r
        if( status != IB_SUCCESS )\r
        {\r
-               KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
                ipoib_set_inactive( p_port->p_adapter );\r
-               ipoib_port_deref( p_port, ref_port_up );\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                       ("ib_query returned %s\n", \r
+                       ("ib_local_mad returned %s\n", \r
                        p_port->p_adapter->p_ifc->get_err_str( status )) );\r
-               return;\r
+               goto up_done;\r
+       }\r
+\r
+       p_port_info = (ib_port_info_t*)(((ib_smp_t*)mad_out)->data);\r
+       p_port->base_lid = p_pnp_rec->p_port_attr->lid;\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
+                       ("Received port info: link width = %d.\n",\r
+                       p_port_info->link_width_active) );\r
+       p_port->ib_mgr.rate =\r
+               ib_port_info_compute_rate( p_port_info );\r
+       \r
+       ipoib_set_rate( p_port->p_adapter,\r
+               p_port_info->link_width_active,\r
+       ib_port_info_get_link_speed_active( p_port_info ) );\r
+\r
+       status = __port_get_bcast( p_port );\r
+       if (status != IB_SUCCESS)\r
+               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+               (" __port_get_bcast returned %s\n",p_port->p_adapter->p_ifc->get_err_str( status )));\r
+\r
+up_done:\r
+       if( status != IB_SUCCESS )\r
+       {\r
+               if( status != IB_CANCELED )\r
+               {\r
+                       ipoib_set_inactive( p_port->p_adapter );\r
+                       __endpt_mgr_reset_all( p_port );\r
+               }\r
+               KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
        }\r
 \r
+       if(mad_out)\r
+               cl_free(mad_out);\r
+       if(mad_in)\r
+               cl_free(mad_in);\r
+\r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
 \r
@@ -5261,7 +5289,7 @@ __endpt_mgr_add_local(
        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ENDPT,\r
                ("<__endpt_mgr_add_local>:  av_attr.dlid = p_port_info->base_lid = %d\n",p_port_info->base_lid));\r
        av_attr.dlid = p_port_info->base_lid;\r
-       av_attr.static_rate = ib_port_info_compute_rate( p_port_info );\r
+       av_attr.static_rate = p_port->ib_mgr.rate;\r
        av_attr.path_bits = 0;\r
        status = p_port->p_adapter->p_ifc->create_av(\r
                p_port->ib_mgr.h_pd, &av_attr, &p_endpt->h_av );\r
@@ -5293,109 +5321,6 @@ __endpt_mgr_add_local(
 }\r
 \r
 \r
-static void\r
-__port_info_cb(\r
-       IN                              ib_query_rec_t                          *p_query_rec )\r
-{\r
-       ib_api_status_t                 status;\r
-       ipoib_port_t                    *p_port;\r
-       ib_portinfo_record_t    *p_port_rec;\r
-\r
-       IPOIB_ENTER( IPOIB_DBG_INIT );\r
-\r
-       p_port = (ipoib_port_t*)p_query_rec->query_context;\r
-\r
-       cl_obj_lock( &p_port->obj );\r
-       p_port->ib_mgr.h_query = NULL;\r
-\r
-       if( p_port->state != IB_QPS_INIT )\r
-       {\r
-               status = IB_CANCELED;\r
-               goto done;\r
-       }\r
-\r
-       status = p_query_rec->status;\r
-\r
-       switch( status )\r
-       {\r
-       case IB_SUCCESS:\r
-               /* Note that the we report the rate from the port info. */\r
-               p_port_rec = (ib_portinfo_record_t*)\r
-                       ib_get_query_result( p_query_rec->p_result_mad, 0 );\r
-\r
-               status = __endpt_mgr_add_local( p_port, &p_port_rec->port_info );\r
-               if( status == IB_SUCCESS )\r
-               {\r
-                       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
-                               ("Received port info: link width = %d.\n",\r
-                               p_port_rec->port_info.link_width_active) );\r
-\r
-                       p_port->ib_mgr.rate =\r
-                               ib_port_info_compute_rate( &p_port_rec->port_info );\r
-\r
-                       ipoib_set_rate( p_port->p_adapter,\r
-                               p_port_rec->port_info.link_width_active,\r
-                               ib_port_info_get_link_speed_active( &p_port_rec->port_info ) );\r
-\r
-                       status = __port_get_bcast( p_port );\r
-               }\r
-               else\r
-               {\r
-                       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                               ("__endpt_mgr_add_local returned %s\n",\r
-                               p_port->p_adapter->p_ifc->get_err_str( status )) );\r
-               }\r
-               break;\r
-\r
-       case IB_CANCELED:\r
-               IPOIB_PRINT(TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
-                       ("Instance destroying - Aborting.\n") );\r
-               break;\r
-\r
-       case IB_TIMEOUT:\r
-               NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,\r
-                       EVENT_IPOIB_PORT_INFO_TIMEOUT, 0 );\r
-               IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
-                       ("Port info query timed out.\n") );\r
-               break;\r
-\r
-       case IB_REMOTE_ERROR:\r
-               NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,\r
-                       EVENT_IPOIB_PORT_INFO_REJECT, 0 );\r
-               IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
-                       ("Port info query rejected by SA.\n") );\r
-               break;\r
-\r
-       default:\r
-               NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,\r
-                       EVENT_IPOIB_QUERY_PORT_INFO, 1, p_query_rec->status );\r
-               /* Hopefully we'll get an SM change event that will restart things. */\r
-               IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
-                       ("Port info query failed.\n") );\r
-       }\r
-\r
-done:\r
-       cl_obj_unlock( &p_port->obj );\r
-\r
-       if( status != IB_SUCCESS )\r
-       {\r
-               if( status != IB_CANCELED )\r
-               {\r
-                       ipoib_set_inactive( p_port->p_adapter );\r
-                       __endpt_mgr_reset_all( p_port );\r
-               }\r
-               KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
-       }\r
-\r
-       /* Return the response MAD to AL. */\r
-       if( p_query_rec->p_result_mad )\r
-               p_port->p_adapter->p_ifc->put_mad( p_query_rec->p_result_mad );\r
-\r
-       /* Release the reference taken when issuing the port info query. */\r
-       ipoib_port_deref( p_port, ref_port_info_cb );\r
-\r
-       IPOIB_EXIT( IPOIB_DBG_INIT );\r
-}\r
 \r
 \r
 static ib_api_status_t\r
@@ -5812,6 +5737,20 @@ __bcast_cb(
        }\r
        cl_obj_unlock( &p_port->obj );\r
        p_port->bc_join_retry_cnt = 0;\r
+       if(! p_port->p_local_endpt)\r
+       {\r
+               ib_port_info_t  port_info;\r
+               cl_memclr(&port_info, sizeof(port_info));\r
+               port_info.base_lid = p_port->base_lid;\r
+               status = __endpt_mgr_add_local( p_port, &port_info );\r
+               if( status != IB_SUCCESS )\r
+               {\r
+                       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                               ("__endpt_mgr_add_local returned %s\n",\r
+                               p_port->p_adapter->p_ifc->get_err_str( status )) );\r
+                       goto err;\r
+               }\r
+       }\r
        status = __endpt_mgr_add_bcast( p_port, p_mcast_rec );\r
        if( status != IB_SUCCESS )\r
        {\r
index 6462469..ae3eeaa 100644 (file)
@@ -517,6 +517,7 @@ typedef struct _ipoib_port
        KDPC                                    gc_dpc;\r
        KTIMER                                  gc_timer;\r
        uint32_t                                bc_join_retry_cnt;\r
+       ib_net16_t                              base_lid;\r
        ipoib_hdr_t                             hdr[1]; /* Must be last! */\r
 \r
 }      ipoib_port_t;\r