[SRP] add SCSI errors to the logs
[mirror/winof/.git] / ulp / srp / kernel / srp_descriptors.c
index d6def78..e10802a 100644 (file)
 #include "srp_cmd.h"\r
 #include "srp_data_path.h"\r
 #include "srp_descriptors.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "srp_descriptors.tmh"\r
+#endif\r
 #include "srp_rsp.h"\r
 #include "srp_session.h"\r
 #include "srp_tsk_mgmt.h"\r
@@ -68,7 +74,7 @@ __srp_create_recv_descriptors(
                (srp_recv_descriptor_t *)cl_zalloc( p_descriptors->recv_descriptor_count * sizeof(srp_recv_descriptor_t) );\r
        if ( p_descriptors->p_recv_descriptors_array == NULL )\r
        {\r
-               SRP_TRACE( SRP_DBG_ERROR,\r
+               SRP_PRINT( TRACE_LEVEL_ERROR, SRP_DBG_ERROR,\r
                        ("Failed to allocate %d recv descriptors.\n",  p_descriptors->recv_descriptor_count) );\r
                status = IB_INSUFFICIENT_MEMORY;\r
                goto exit;\r
@@ -79,7 +85,7 @@ __srp_create_recv_descriptors(
                cl_zalloc( p_descriptors->recv_descriptor_count * p_descriptors->recv_data_segment_size );\r
        if ( p_descriptors->p_recv_data_segments_array == NULL )\r
        {\r
-               SRP_TRACE( SRP_DBG_ERROR,\r
+               SRP_PRINT( TRACE_LEVEL_ERROR, SRP_DBG_ERROR,\r
                        ("Failed to allocate %d recv data segments of %d length.\n",\r
                        p_descriptors->recv_descriptor_count,\r
                        p_descriptors->recv_data_segment_size) );\r
@@ -102,7 +108,7 @@ __srp_create_recv_descriptors(
                                                 &p_descriptors->h_recv_mr );\r
        if ( status != IB_SUCCESS )\r
        {\r
-               SRP_TRACE( SRP_DBG_ERROR,\r
+               SRP_PRINT( TRACE_LEVEL_ERROR, SRP_DBG_ERROR,\r
                        ("Failed to register recv data segments. Status = %d.\n", status) );\r
 \r
                cl_free( p_descriptors->p_recv_data_segments_array );\r
@@ -133,8 +139,8 @@ __srp_create_recv_descriptors(
                status = p_ifc->post_recv( h_qp, &p_descriptor->wr, NULL );\r
                if ( status != IB_SUCCESS )\r
                {\r
-                       SRP_TRACE( SRP_DBG_ERROR,\r
-                               ("Failed to post send descriptor. Status = %d.\n", status) );\r
+                       SRP_PRINT( TRACE_LEVEL_ERROR, SRP_DBG_ERROR,\r
+                               ("Failed to post recv descriptor. Status = %d.\n", status) );\r
                        goto exit;\r
                }\r
 \r
@@ -247,7 +253,7 @@ srp_add_send_descriptor(
        IN  srp_descriptors_t       *p_descriptors,\r
        IN  srp_send_descriptor_t   *p_descriptor )\r
 {\r
-       SRP_ENTER( SRP_DBG_FUNC );\r
+       SRP_ENTER( SRP_DBG_DATA );\r
 \r
        cl_spinlock_acquire ( &p_descriptors->sent_list_lock );\r
 \r
@@ -256,7 +262,7 @@ srp_add_send_descriptor(
 \r
        cl_spinlock_release ( &p_descriptors->sent_list_lock );\r
 \r
-       SRP_EXIT( SRP_DBG_FUNC );\r
+       SRP_EXIT( SRP_DBG_DATA );\r
 }\r
 \r
 /* srp_remove_send_descriptor */\r
@@ -274,7 +280,7 @@ srp_remove_send_descriptor(
        IN  srp_descriptors_t       *p_descriptors,\r
        IN  srp_send_descriptor_t   *p_descriptor )\r
 {\r
-       SRP_ENTER( SRP_DBG_FUNC );\r
+       SRP_ENTER( SRP_DBG_DATA );\r
 \r
        cl_spinlock_acquire ( &p_descriptors->sent_list_lock );\r
 \r
@@ -283,7 +289,7 @@ srp_remove_send_descriptor(
 \r
        cl_spinlock_release ( &p_descriptors->sent_list_lock );\r
 \r
-       SRP_EXIT( SRP_DBG_FUNC );\r
+       SRP_EXIT( SRP_DBG_DATA );\r
 }\r
 \r
 /* srp_remove_lun_head_send_descriptor */\r
@@ -302,7 +308,7 @@ srp_remove_lun_head_send_descriptor(
 {\r
        srp_send_descriptor_t   *p_descriptor;\r
 \r
-       SRP_ENTER( SRP_DBG_FUNC );\r
+       SRP_ENTER( SRP_DBG_DATA );\r
 \r
        cl_spinlock_acquire ( &p_descriptors->sent_list_lock );\r
 \r
@@ -329,7 +335,7 @@ srp_remove_lun_head_send_descriptor(
 \r
        cl_spinlock_release ( &p_descriptors->sent_list_lock );\r
 \r
-       SRP_EXIT( SRP_DBG_FUNC );\r
+       SRP_EXIT( SRP_DBG_DATA );\r
 \r
        return ( p_descriptor );\r
 }\r
@@ -355,20 +361,25 @@ srp_post_send_descriptor(
        srp_connection_t        *p_connection;\r
        ib_al_ifc_t                     *p_ifc;\r
 \r
-       SRP_ENTER( SRP_DBG_FUNC );\r
+       SRP_ENTER( SRP_DBG_DATA );\r
 \r
        p_connection = &p_session->connection;\r
        p_ifc = &p_session->hca.p_hba->ifc;\r
 \r
        if ( p_connection->state == SRP_CONNECTED )\r
        {\r
-               SRP_TRACE( SRP_DBG_VERBOSE, ("wr_id    = 0x%"PRIx64".\n", p_descriptor->wr.wr_id) );\r
-               SRP_TRACE( SRP_DBG_VERBOSE, ("wr_type  = 0x%x.\n", p_descriptor->wr.wr_type) );\r
-               SRP_TRACE( SRP_DBG_VERBOSE, ("send_opt = 0x%x.\n", p_descriptor->wr.send_opt) );\r
-               SRP_TRACE( SRP_DBG_VERBOSE, ("num_ds   = 0x%x.\n", p_descriptor->wr.num_ds) );\r
-\r
-               SRP_TRACE( SRP_DBG_VERBOSE,\r
-                                  ("Posting  I/O for Function = %s(0x%x), Path = 0x%x, Target = 0x%x, Lun = 0x%x, tag 0x%"PRIx64"\n",\r
+               SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+                       ("wr_id    = 0x%I64x.\n", p_descriptor->wr.wr_id) );\r
+               SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+                       ("wr_type  = 0x%x.\n", p_descriptor->wr.wr_type) );\r
+               SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+                       ("send_opt = 0x%x.\n", p_descriptor->wr.send_opt) );\r
+               SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+                       ("num_ds   = 0x%x.\n", p_descriptor->wr.num_ds) );\r
+\r
+               SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+                                  ("Posting  I/O for Function = %s(0x%x), Path = 0x%x, "\r
+                                  "Target = 0x%x, Lun = 0x%x, tag 0x%I64x\n",\r
                                   g_srb_function_name[p_descriptor->p_srb->Function],\r
                                   p_descriptor->p_srb->Function,\r
                                   p_descriptor->p_srb->PathId,\r
@@ -385,6 +396,8 @@ srp_post_send_descriptor(
                        p_descriptor->ds[0].length = get_srp_tsk_mgmt_length( (srp_tsk_mgmt_t *)p_descriptor->data_segment );\r
                }\r
 \r
+               ASSERT( p_descriptor->ds[0].length <= p_connection->init_to_targ_iu_sz );\r
+\r
                srp_add_send_descriptor( p_descriptors, p_descriptor );\r
 \r
                status = p_ifc->post_send(\r
@@ -393,19 +406,20 @@ srp_post_send_descriptor(
                {\r
                        /* Remove From Sent List */\r
                        srp_remove_send_descriptor( p_descriptors, p_descriptor );\r
-                       SRP_TRACE( SRP_DBG_ERROR,\r
-                                               ("Failed to post send descriptor. ib_post_send status = 0x%x tag = 0x%"PRIx64"\n",\r
+                       SRP_PRINT( TRACE_LEVEL_ERROR, SRP_DBG_ERROR,\r
+                                               ("Failed to post send descriptor. "\r
+                                               "ib_post_send status = 0x%x tag = 0x%I64x\n",\r
                                                status,\r
                                                get_srp_command_tag( (srp_cmd_t *)p_descriptor->data_segment )) );\r
                }\r
        }\r
        else\r
        {\r
-               SRP_TRACE( SRP_DBG_ERROR,\r
+               SRP_PRINT( TRACE_LEVEL_ERROR, SRP_DBG_ERROR,\r
                        ("Attempting to post to an unconnected session.\n") );\r
        }\r
 \r
-       SRP_EXIT( SRP_DBG_FUNC );\r
+       SRP_EXIT( SRP_DBG_DATA );\r
 \r
        return ( status );\r
 }\r
@@ -428,18 +442,19 @@ srp_find_matching_send_descriptor(
 {\r
        srp_send_descriptor_t   *p_send_descriptor;\r
 \r
-       SRP_ENTER( SRP_DBG_FUNC );\r
+       SRP_ENTER( SRP_DBG_DATA );\r
 \r
        cl_spinlock_acquire( &p_descriptors->sent_list_lock );\r
 \r
        p_send_descriptor = (srp_send_descriptor_t *)cl_qlist_head( &p_descriptors->sent_descriptors );\r
        CL_ASSERT( &p_descriptors->sent_descriptors == p_send_descriptor->list_item.p_list );\r
 \r
-       SRP_TRACE( SRP_DBG_VERBOSE, ("rsp tag = 0x%"PRIx64".\n", tag) );\r
+       SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+               ("rsp tag = 0x%I64x.\n", tag) );\r
 \r
        while ( p_send_descriptor != (srp_send_descriptor_t *)cl_qlist_end( &p_descriptors->sent_descriptors ) )\r
        {\r
-               SRP_TRACE( SRP_DBG_VERBOSE, ("cmd tag = 0x%"PRIx64".\n",\r
+               SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA, ("cmd tag = 0x%I64x.\n",\r
                        get_srp_command_tag( (srp_cmd_t *)p_send_descriptor->data_segment )) );\r
 \r
                if ( get_srp_command_tag( (srp_cmd_t *)p_send_descriptor->data_segment ) == tag )\r
@@ -458,7 +473,7 @@ srp_find_matching_send_descriptor(
 exit:\r
        cl_spinlock_release( &p_descriptors->sent_list_lock );\r
 \r
-       SRP_EXIT( SRP_DBG_FUNC );\r
+       SRP_EXIT( SRP_DBG_DATA );\r
 \r
        return ( p_send_descriptor );\r
 }\r
@@ -483,7 +498,7 @@ srp_build_send_descriptor(
        STOR_PHYSICAL_ADDRESS   physical_address;\r
        ULONG                   length;\r
 \r
-       SRP_ENTER( SRP_DBG_FUNC );\r
+       SRP_ENTER( SRP_DBG_DATA );\r
 \r
        cl_memclr( p_send_descriptor, (sizeof ( srp_send_descriptor_t ) - SRP_MAX_IU_SIZE) );\r
 \r
@@ -500,11 +515,16 @@ srp_build_send_descriptor(
        p_send_descriptor->ds[0].length =  p_srp_conn_info->init_to_targ_iu_sz;\r
        p_send_descriptor->ds[0].lkey =   p_srp_conn_info->lkey;\r
 \r
-       SRP_TRACE( SRP_DBG_VERBOSE, ("hca vaddr        = 0x%"PRIx64".\n", p_srp_conn_info->vaddr));\r
-       SRP_TRACE( SRP_DBG_VERBOSE, ("physical_address = 0x%"PRIx64".\n", physical_address.QuadPart));\r
-       SRP_TRACE( SRP_DBG_VERBOSE, ("IU  vaddr        = 0x%"PRIx64".\n", p_send_descriptor->ds[0].vaddr));\r
-       SRP_TRACE( SRP_DBG_VERBOSE, ("length           = %d.\n",          p_send_descriptor->ds[0].length));\r
-       SRP_TRACE( SRP_DBG_VERBOSE, ("lkey             = 0x%x.\n",        p_send_descriptor->ds[0].lkey));\r
-\r
-       SRP_EXIT( SRP_DBG_FUNC );\r
+       SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+               ("hca vaddr        = 0x%I64x.\n", p_srp_conn_info->vaddr));\r
+       SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+               ("physical_address = 0x%I64x.\n", physical_address.QuadPart));\r
+       SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+               ("IU  vaddr        = 0x%I64x.\n", p_send_descriptor->ds[0].vaddr));\r
+       SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+               ("length           = %d.\n",          p_send_descriptor->ds[0].length));\r
+       SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,\r
+               ("lkey             = 0x%x.\n",        p_send_descriptor->ds[0].lkey));\r
+\r
+       SRP_EXIT( SRP_DBG_DATA );\r
 }\r