Fix to support Indirect Data Buffer Descriptors in SRP.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 20 Jun 2005 22:45:00 +0000 (22:45 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 20 Jun 2005 22:45:00 +0000 (22:45 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@20 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/srp/kernel/ib_srp.inf
ulp/srp/kernel/srp.h
ulp/srp/kernel/srp_cmd.h
ulp/srp/kernel/srp_connection.c
ulp/srp/kernel/srp_connection.h
ulp/srp/kernel/srp_data_path.c
ulp/srp/kernel/srp_data_path.h
ulp/srp/kernel/srp_driver.c

index 3388a6a..197f537 100644 (file)
@@ -7,7 +7,7 @@ Class=SCSIAdapter
 ClassGUID={4D36E97B-E325-11CE-BFC1-08002BE10318}\r
 Provider=%SST%\r
 CatalogFile=ibsrp.cat\r
-DriverVer=05/10/2005,3.0.0031.0\r
+DriverVer=06/20/2005,3.0.0033.0\r
 \r
 \r
 ; ================= Device Install section =====================\r
index cfb5090..d8c74f9 100644 (file)
@@ -49,7 +49,7 @@
 #define SRP_EXTENSION_ID_LENGTH         16      /* Service name extension ID length */\r
 \r
 #define SRP_MIN_IU_SIZE     64\r
-#define SRP_MAX_IU_SIZE     320\r
+#define SRP_MAX_IU_SIZE     340\r
 \r
 #define SRP_MIN_INI_TO_TGT_IU       64      // Minimum initiator message size\r
 #define SRP_MIN_TGT_TO_INI_IU       56      // Minimum target message size\r
@@ -251,6 +251,12 @@ typedef struct _srp_memory_descriptor
        uint32_t    data_length;\r
 } PACK_SUFFIX srp_memory_descriptor_t;\r
 \r
+typedef struct _srp_memory_table_descriptor\r
+{\r
+       srp_memory_descriptor_t descriptor;\r
+       uint32_t    total_length;\r
+} PACK_SUFFIX srp_memory_table_descriptor_t;\r
+\r
 typedef struct _srp_cmd\r
 {\r
        uint8_t     type;\r
index 5dbc82a..3c1e76e 100644 (file)
@@ -491,11 +491,40 @@ uint32_t
 get_srp_command_length(\r
        IN  srp_cmd_t *p_information_unit )\r
 {\r
-       /* do not include additional cdb field in the sizeof the IU. add it's length and data out/in buffer desc counts to the structure size */\r
-       return( ( sizeof( *p_information_unit ) - sizeof( p_information_unit->additional_cdb ) ) +\r
-                       ( get_srp_command_additional_cdb_length( p_information_unit ) * 4 ) +\r
-                       ( get_srp_command_data_out_buffer_desc_count( p_information_unit ) * sizeof( srp_memory_descriptor_t ) ) +\r
-                       ( get_srp_command_data_in_buffer_desc_count( p_information_unit )  * sizeof( srp_memory_descriptor_t ) ) );\r
+       int                     buffer_desc_count;\r
+       uint32_t        srp_cmd_length = ( sizeof( *p_information_unit ) - sizeof( p_information_unit->additional_cdb ) ) +\r
+                                                       ( get_srp_command_additional_cdb_length( p_information_unit ) * 4 );\r
+       \r
+       switch ( get_srp_command_data_out_buffer_desc_fmt ( p_information_unit ))\r
+       {\r
+               case DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR:\r
+                       buffer_desc_count = get_srp_command_data_out_buffer_desc_count( p_information_unit );\r
+                       srp_cmd_length += ( buffer_desc_count == 0)? sizeof(srp_memory_descriptor_t): \r
+                                                                                                                ( buffer_desc_count * sizeof(srp_memory_descriptor_t ));\r
+                       break;\r
+               case DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS:\r
+                       buffer_desc_count = get_srp_command_data_out_buffer_desc_count( p_information_unit );\r
+                       srp_cmd_length += sizeof(srp_memory_table_descriptor_t) + ( buffer_desc_count * sizeof(srp_memory_descriptor_t));\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+\r
+       switch ( get_srp_command_data_in_buffer_desc_fmt ( p_information_unit ))\r
+       {\r
+               case DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR:\r
+                       buffer_desc_count = get_srp_command_data_in_buffer_desc_count( p_information_unit );\r
+                       srp_cmd_length += ( buffer_desc_count == 0)? sizeof(srp_memory_descriptor_t): \r
+                                                                                                                ( buffer_desc_count * sizeof(srp_memory_descriptor_t ));\r
+                       break;\r
+               case DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS:\r
+                       buffer_desc_count = get_srp_command_data_in_buffer_desc_count( p_information_unit );\r
+                       srp_cmd_length += sizeof(srp_memory_table_descriptor_t) + ( buffer_desc_count * sizeof(srp_memory_descriptor_t));\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+       return ( srp_cmd_length );\r
 }\r
 \r
 /* set_srp_command_from_host_to_network */\r
@@ -513,8 +542,8 @@ set_srp_command_from_host_to_network(
        IN OUT  srp_cmd_t   *p_information_unit )\r
 {\r
        srp_memory_descriptor_t *p_memory_descriptor;\r
-       int                     buffer_desc_count = get_srp_command_data_in_buffer_desc_count( p_information_unit ) +\r
-                                                                                               get_srp_command_data_out_buffer_desc_count( p_information_unit );\r
+       srp_memory_table_descriptor_t *p_table_descriptor;\r
+       int                     buffer_desc_count;\r
        int                     i;\r
 \r
        set_srp_information_unit_from_host_to_network( ( srp_information_unit_t* ) p_information_unit );\r
@@ -522,10 +551,80 @@ set_srp_command_from_host_to_network(
 \r
        p_memory_descriptor = get_srp_command_buffer_desc( p_information_unit );\r
 \r
-       for( i = 0; i < buffer_desc_count; i++, p_memory_descriptor++ )\r
+       switch (get_srp_command_data_out_buffer_desc_fmt(p_information_unit) )\r
+       {\r
+       case DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR:\r
+               buffer_desc_count = get_srp_command_data_out_buffer_desc_count( p_information_unit );\r
+               if ( p_memory_descriptor != NULL )\r
+               {\r
+                       for ( i=0; i < buffer_desc_count; i++)\r
+                       {\r
+                               p_memory_descriptor->virtual_address = cl_hton64( p_memory_descriptor->virtual_address );\r
+                               p_memory_descriptor->data_length =  cl_hton32 ( p_memory_descriptor->data_length );\r
+                               p_memory_descriptor++;\r
+                       }\r
+               }\r
+               break;\r
+       case DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS:\r
+               buffer_desc_count = get_srp_command_data_out_buffer_desc_count( p_information_unit );\r
+               if ( p_memory_descriptor != NULL )\r
+               {\r
+                       p_table_descriptor = ( srp_memory_table_descriptor_t *)p_memory_descriptor;\r
+                       p_memory_descriptor = ( srp_memory_descriptor_t *)( p_table_descriptor + 1);\r
+                       \r
+                       p_table_descriptor->descriptor.virtual_address = cl_hton64( p_table_descriptor->descriptor.virtual_address );\r
+                       p_table_descriptor->descriptor.data_length = cl_hton32( p_table_descriptor->descriptor.data_length );\r
+                       p_table_descriptor->total_length =  cl_hton32( p_table_descriptor->total_length );\r
+                       \r
+                       for ( i=0; i < buffer_desc_count; i++)\r
+                       {\r
+                               p_memory_descriptor->virtual_address = cl_hton64( p_memory_descriptor->virtual_address );\r
+                               p_memory_descriptor->data_length =  cl_hton32( p_memory_descriptor->data_length );\r
+                               p_memory_descriptor++;\r
+                       }\r
+               }\r
+               break;\r
+       case DBDF_NO_DATA_BUFFER_DESCRIPTOR_PRESENT:\r
+       default:\r
+               break;\r
+       }\r
+\r
+       switch (get_srp_command_data_in_buffer_desc_fmt(p_information_unit) )\r
        {\r
-               p_memory_descriptor->virtual_address = cl_hton64( p_memory_descriptor->virtual_address );\r
-               p_memory_descriptor->data_length = cl_hton32( p_memory_descriptor->data_length );\r
+       case DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR:\r
+               buffer_desc_count = get_srp_command_data_in_buffer_desc_count( p_information_unit );\r
+               if ( p_memory_descriptor != NULL )\r
+               {\r
+                       for ( i=0; i < buffer_desc_count; i++)\r
+                       {\r
+                               p_memory_descriptor->virtual_address = cl_hton64( p_memory_descriptor->virtual_address );\r
+                               p_memory_descriptor->data_length = cl_hton32 ( p_memory_descriptor->data_length );\r
+                               p_memory_descriptor++;\r
+                       }\r
+               }\r
+               break;\r
+       case DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS:\r
+               buffer_desc_count = get_srp_command_data_in_buffer_desc_count( p_information_unit );\r
+               if ( p_memory_descriptor != NULL )\r
+               {\r
+                       p_table_descriptor = ( srp_memory_table_descriptor_t *)p_memory_descriptor;\r
+                       p_memory_descriptor = ( srp_memory_descriptor_t *)( p_table_descriptor + 1);\r
+                       \r
+                       p_table_descriptor->descriptor.virtual_address = cl_hton64( p_table_descriptor->descriptor.virtual_address );\r
+                       p_table_descriptor->descriptor.data_length = cl_hton32( p_table_descriptor->descriptor.data_length );\r
+                       p_table_descriptor->total_length = cl_hton32( p_table_descriptor->total_length );\r
+                       \r
+                       for ( i=0; i < buffer_desc_count; i++)\r
+                       {\r
+                               p_memory_descriptor->virtual_address = cl_hton64( p_memory_descriptor->virtual_address );\r
+                               p_memory_descriptor->data_length =  cl_hton32( p_memory_descriptor->data_length );\r
+                               p_memory_descriptor++;\r
+                       }\r
+               }\r
+               break;\r
+       case DBDF_NO_DATA_BUFFER_DESCRIPTOR_PRESENT:\r
+       default:\r
+               break;\r
        }\r
 }\r
 \r
index 6e3b75a..821aa93 100644 (file)
@@ -424,6 +424,7 @@ __srp_cm_reply_cb(
        p_connection = &p_srp_session->connection;\r
 \r
        set_srp_login_response_from_network_to_host( p_srp_login_rsp );\r
+       p_connection->descriptor_format = get_srp_login_response_supported_data_buffer_formats( p_srp_login_rsp );\r
 \r
        p_connection->request_limit      =\r
                MIN( get_srp_login_response_request_limit_delta( p_srp_login_rsp ), SRP_DEFAULT_RECV_Q_DEPTH );\r
@@ -433,9 +434,23 @@ __srp_cm_reply_cb(
        p_connection->targ_to_init_iu_sz = get_srp_login_response_max_targ_to_init_iu( p_srp_login_rsp );\r
 \r
        p_connection->signaled_send_completion_count  = p_connection->send_queue_depth / 2;\r
-       p_connection->max_scatter_gather_entries      =\r
-               (p_connection->init_to_targ_iu_sz - offsetof( srp_cmd_t, additional_cdb )) / sizeof( srp_memory_descriptor_t );\r
-\r
+       \r
+       if (( p_connection->descriptor_format & DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS ) == DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS )\r
+       {\r
+               p_connection->max_scatter_gather_entries =\r
+                               ( MAX( SRP_MAX_IU_SIZE, p_connection->init_to_targ_iu_sz ) - offsetof( srp_cmd_t, additional_cdb )- sizeof(srp_memory_table_descriptor_t)) / sizeof( srp_memory_descriptor_t );\r
+       }\r
+       else if (( p_connection->descriptor_format & DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR ) == DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR )\r
+       {\r
+               p_connection->max_scatter_gather_entries = \r
+                               (p_connection->init_to_targ_iu_sz - offsetof( srp_cmd_t, additional_cdb ))/ sizeof( srp_memory_descriptor_t );\r
+       }\r
+       else /* not reported any descriptor format */\r
+       {\r
+               SRP_TRACE( SRP_DBG_DEBUG,(" Target does not support valid descriptor formats\n") );\r
+               p_connection->state = SRP_CONNECT_FAILURE;\r
+               goto exit;\r
+       }\r
        SRP_TRACE( SRP_DBG_DEBUG,\r
                        ("Request Limit = %d, SendQ Depth = %d, RecvQDepth = %d, ItoT size = %d, TtoI size = %d, Max S/G = %d\n",\r
                        p_connection->request_limit,\r
@@ -570,11 +585,25 @@ __srp_cm_rej_cb(
        if( p_srp_login_rej )\r
        {\r
                set_srp_login_reject_from_network_to_host( p_srp_login_rej ); // <-- Is this coming back NULL?\r
+               p_connection->reject_reason = get_srp_login_reject_reason( p_srp_login_rej );\r
 \r
                SRP_TRACE( SRP_DBG_ERROR,\r
                        ("Login Rejected. IBT Code = 0x%x, SRP Code = 0x%x\n",\r
-                       p_cm_reject->rej_status,\r
-                       get_srp_login_reject_reason( p_srp_login_rej ) ) );\r
+                       p_cm_reject->rej_status, p_connection->reject_reason ) );\r
+               switch( p_connection->reject_reason )\r
+               {\r
+                       case LIREJ_INIT_TO_TARG_IU_LENGTH_TOO_LARGE:\r
+                               SRP_TRACE( SRP_DBG_ERROR, ("REQUESTED IU_SIZE %d\n", p_connection->req_max_iu_msg_size ));\r
+                               break;\r
+                       case LIREJ_UNSUPPORTED_DATA_BUFFER_DESCRIPTOR_FORMAT:\r
+                               SRP_TRACE( SRP_DBG_ERROR, ("REQUESTED DESC FORMAT: %#x, SUPPORTED FORMAT %#x\n",\r
+                                       p_connection->descriptor_format, \r
+                                       get_srp_login_reject_supported_data_buffer_formats(p_srp_login_rej) ));\r
+                                       __srp_issue_session_login( p_connection, (srp_hca_t *)&p_srp_session->hca, p_connection->ioc_max_send_msg_depth );\r
+                                       return;\r
+                       default:\r
+                               break;\r
+               }\r
        }\r
        else\r
        {\r
@@ -620,14 +649,30 @@ __srp_issue_session_login(
        cm_req.flags = 0; // event used instead of IB_FLAGS_SYNC\r
        cm_req.max_cm_retries = 8;\r
        cm_req.p_primary_path = p_connection->p_path_rec;\r
-\r
+       \r
+       /*already tried to login before and failed ? */\r
+       if ( !p_connection->reject_reason )\r
+       {\r
+               p_connection->descriptor_format = DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR | DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS;\r
+       }\r
+       else if ( p_connection->reject_reason == LIREJ_UNSUPPORTED_DATA_BUFFER_DESCRIPTOR_FORMAT )\r
+       {\r
+               p_connection->descriptor_format = DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR;\r
+       }\r
+       else\r
+       {\r
+               p_connection->state = SRP_CONNECT_FAILURE;\r
+               status = IB_ERROR;\r
+               goto exit;\r
+       }\r
+       p_connection->req_max_iu_msg_size = ( p_connection->ioc_max_send_msg_size >= SRP_MAX_IU_SIZE )? SRP_MAX_IU_SIZE: p_connection->ioc_max_send_msg_size;\r
        /*\r
           Build SRP Login request\r
         */\r
        setup_srp_login_request( &login_req,\r
                                                         0, /* tag */\r
-                                                        SRP_MAX_IU_SIZE,\r
-                                                        DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR,\r
+                                                        p_connection->req_max_iu_msg_size,\r
+                                                        p_connection->descriptor_format,\r
                                                         MCA_TERMINATE_EXISTING,\r
                                                         &p_connection->init_port_id,\r
                                                         &p_connection->targ_port_id );\r
@@ -745,6 +790,9 @@ srp_connect(
 \r
        p_connection->init_port_id.guid = p_hca->ca_guid;\r
        p_connection->init_port_id.id_extension = initiator_extension;\r
+       p_connection->ioc_max_send_msg_size = cl_ntoh32 (p_session->p_hba->ioc_info.profile.send_msg_size);\r
+       p_connection->ioc_max_send_msg_depth = send_msg_depth;\r
+       p_connection->reject_reason = 0;\r
 \r
        status = __srp_create_cqs( p_connection, p_hca, p_session );\r
        if ( status != IB_SUCCESS )\r
index 9159831..3108fab 100644 (file)
@@ -88,8 +88,12 @@ typedef struct _srp_connection
 \r
        uint32_t                signaled_send_completion_count;\r
        uint32_t                max_scatter_gather_entries;\r
-\r
+       uint32_t                                ioc_max_send_msg_size;\r
+       uint32_t                                req_max_iu_msg_size;\r
        cl_event_t              conn_req_event;\r
+       DATA_BUFFER_DESCRIPTOR_FORMAT  descriptor_format;\r
+       LOGIN_REJECT_CODE               reject_reason;\r
+       uint8_t                                 ioc_max_send_msg_depth;\r
 }   srp_connection_t;\r
 \r
 ib_api_status_t\r
@@ -110,5 +114,11 @@ srp_connect(
 void\r
 srp_free_connection(\r
        IN  srp_connection_t    *p_srp_connection );\r
+static\r
+ib_api_status_t\r
+__srp_issue_session_login(\r
+       IN OUT  srp_connection_t    *p_connection,\r
+       IN      srp_hca_t           *p_hca,\r
+       IN      uint8_t             send_msg_depth );\r
 \r
 #endif  /* _SRP_CONNECTION_H_ */\r
index 5990022..56364d3 100644 (file)
@@ -536,8 +536,11 @@ __srp_build_cmd(
        PSTOR_SCATTER_GATHER_LIST       p_scatter_gather_list = NULL;\r
        uint8_t                         scatter_gather_count = 0;\r
        srp_memory_descriptor_t         *p_memory_descriptor = NULL;\r
+       srp_memory_table_descriptor_t   *p_table_descriptor = NULL;\r
        uint32_t                        i;\r
-\r
+       ULONG                           scsi_direction = p_srb->SrbFlags & ( SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT );\r
+       DATA_BUFFER_DESCRIPTOR_FORMAT   format = p_srp_conn_info->descriptor_format & DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS;\r
+       ULONG                                                   length;\r
        SRP_ENTER( SRP_DBG_FUNC );\r
 \r
        SRP_TRACE( SRP_DBG_VERBOSE,\r
@@ -566,56 +569,84 @@ __srp_build_cmd(
                SRP_TRACE( SRP_DBG_VERBOSE, ("%0.2x", p_srb->Cdb[i]) );\r
        }\r
        SRP_TRACE( SRP_DBG_VERBOSE, ("\n.") );\r
+       \r
+       if ( !format )\r
+       {\r
+               format = DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR;\r
+       }\r
 \r
-       if ( (p_srb->SrbFlags & SRB_FLAGS_DATA_IN) == SRB_FLAGS_DATA_IN )\r
+       if ( scsi_direction )\r
        {\r
                p_scatter_gather_list = StorPortGetScatterGatherList( p_dev_ext, p_srb );\r
                CL_ASSERT( p_scatter_gather_list != NULL );\r
-\r
                scatter_gather_count = (uint8_t)p_scatter_gather_list->NumberOfElements;\r
+               CL_ASSERT( scatter_gather_count <= p_srp_conn_info->max_scatter_gather_entries );\r
+       }\r
 \r
-               set_srp_command_data_in_buffer_desc_fmt( p_srp_cmd, DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR );\r
+       if ( scsi_direction == SRB_FLAGS_DATA_IN )\r
+       {\r
+               set_srp_command_data_in_buffer_desc_fmt( p_srp_cmd, format );\r
                set_srp_command_data_in_buffer_desc_count( p_srp_cmd, scatter_gather_count );\r
                p_memory_descriptor = get_srp_command_data_in_buffer_desc( p_srp_cmd );\r
        }\r
-       else\r
-       {\r
-               if ( (p_srb->SrbFlags & SRB_FLAGS_DATA_OUT) == SRB_FLAGS_DATA_OUT )\r
-               {\r
-                       p_scatter_gather_list = StorPortGetScatterGatherList( p_dev_ext, p_srb );\r
-                       CL_ASSERT( p_scatter_gather_list != NULL );\r
 \r
-                       scatter_gather_count = (uint8_t)p_scatter_gather_list->NumberOfElements;\r
-\r
-                       set_srp_command_data_out_buffer_desc_fmt( p_srp_cmd, DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR );\r
-                       set_srp_command_data_out_buffer_desc_count( p_srp_cmd, scatter_gather_count );\r
-                       p_memory_descriptor = get_srp_command_data_out_buffer_desc( p_srp_cmd );\r
-               }\r
+       else if ( scsi_direction == SRB_FLAGS_DATA_OUT )\r
+       {\r
+               set_srp_command_data_out_buffer_desc_fmt( p_srp_cmd, format );\r
+               set_srp_command_data_out_buffer_desc_count( p_srp_cmd, scatter_gather_count );\r
+               p_memory_descriptor = get_srp_command_data_out_buffer_desc( p_srp_cmd );\r
        }\r
 \r
        if ( p_memory_descriptor != NULL )\r
        {\r
                PSTOR_SCATTER_GATHER_ELEMENT    p_sg_element;\r
-\r
-               CL_ASSERT( scatter_gather_count <= p_srp_conn_info->max_scatter_gather_entries );\r
-\r
-               for ( i = 0, p_sg_element = p_scatter_gather_list->List;\r
-                         i < scatter_gather_count;\r
-                         i++, p_memory_descriptor++, p_sg_element++ )\r
+               uint32_t                                                totalLength;\r
+               uint64_t                                                buf_addr;\r
+               if ( format == DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS )\r
                {\r
-                       p_memory_descriptor->virtual_address = p_srp_conn_info->vaddr + p_sg_element->PhysicalAddress.QuadPart;\r
-                       p_memory_descriptor->memory_handle   = p_srp_conn_info->rkey;\r
-                       p_memory_descriptor->data_length     = p_sg_element->Length;\r
-\r
-                       SRP_TRACE( SRP_DBG_VERBOSE, ("virtual_address[%d] = 0x%"PRIx64".\n", i, p_memory_descriptor->virtual_address) );\r
-                       SRP_TRACE( SRP_DBG_VERBOSE, ("memory_handle[%d]   = 0x%x.\n", i, p_memory_descriptor->memory_handle) );\r
-                       SRP_TRACE( SRP_DBG_VERBOSE, ("data_length[%d]     = %d.\n", i, p_memory_descriptor->data_length) );\r
+                       p_table_descriptor = (srp_memory_table_descriptor_t *)p_memory_descriptor;\r
+                       p_memory_descriptor = ( srp_memory_descriptor_t *)(p_table_descriptor + 1 );\r
+\r
+                       buf_addr = (StorPortGetPhysicalAddress( p_dev_ext,p_srb, p_memory_descriptor, &length)).QuadPart;\r
+\r
+                       /* we don't swap rkey - it is already in network order*/\r
+                       p_table_descriptor->descriptor.virtual_address =  cl_hton64( buf_addr );\r
+                       p_table_descriptor->descriptor.memory_handle = p_srp_conn_info->rkey;\r
+                       p_table_descriptor->descriptor.data_length =  cl_hton32( sizeof(srp_memory_descriptor_t) * scatter_gather_count );\r
+                       \r
+                       for ( i = 0, totalLength = 0, p_sg_element = p_scatter_gather_list->List;\r
+                                 i < scatter_gather_count;     i++, p_memory_descriptor++, p_sg_element++ )\r
+                       {\r
+                               buf_addr =  p_srp_conn_info->vaddr + p_sg_element->PhysicalAddress.QuadPart;\r
+                       \r
+                               p_memory_descriptor->virtual_address = cl_hton64( buf_addr );\r
+                               p_memory_descriptor->memory_handle   = p_srp_conn_info->rkey;\r
+                               p_memory_descriptor->data_length     =  cl_hton32( p_sg_element->Length );\r
+                               totalLength += p_sg_element->Length;\r
+                       }\r
+                       p_table_descriptor->total_length = cl_hton32( totalLength );\r
+               }\r
+               else if ( format == DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR )\r
+               {\r
+                       for ( i = 0, p_sg_element = p_scatter_gather_list->List;\r
+                                 i < scatter_gather_count;     i++, p_memory_descriptor++, p_sg_element++ )\r
+                       {\r
+                               buf_addr =  p_srp_conn_info->vaddr + p_sg_element->PhysicalAddress.QuadPart;\r
+                               p_memory_descriptor->virtual_address = cl_hton64( buf_addr );\r
+                               p_memory_descriptor->memory_handle   = p_srp_conn_info->rkey;\r
+                               p_memory_descriptor->data_length     = cl_hton32( p_sg_element->Length );\r
+\r
+                               SRP_TRACE( SRP_DBG_VERBOSE, ("virtual_address[%d] = 0x%"PRIx64".\n", i, cl_ntoh64(p_memory_descriptor->virtual_address) ) );\r
+                               SRP_TRACE( SRP_DBG_VERBOSE, ("memory_handle[%d]   = 0x%x.\n", i, cl_ntoh32( p_memory_descriptor->memory_handle) ) );\r
+                               SRP_TRACE( SRP_DBG_VERBOSE, ("data_length[%d]     = %d.\n", i, cl_ntoh32( p_memory_descriptor->data_length) ) );\r
+                       }\r
                }\r
-\r
                SRP_TRACE( SRP_DBG_VERBOSE, ("scatter/gather count = %d.\n", scatter_gather_count));\r
        }\r
 \r
-       set_srp_command_from_host_to_network( p_srp_cmd );\r
+       p_srp_cmd->logical_unit_number = cl_hton64( p_srp_cmd->logical_unit_number );\r
+\r
+       //set_srp_command_from_host_to_network( p_srp_cmd );\r
 \r
        SRP_EXIT( SRP_DBG_FUNC );\r
 }\r
@@ -659,7 +690,7 @@ srp_format_io_request(
                srp_conn_info.vaddr = p_srp_session->hca.vaddr;\r
                srp_conn_info.lkey  = p_srp_session->hca.lkey;\r
                srp_conn_info.rkey  = p_srp_session->hca.rkey;\r
-\r
+               srp_conn_info.descriptor_format = p_srp_session->connection.descriptor_format;\r
                srp_conn_info.init_to_targ_iu_sz         = p_srp_session->connection.init_to_targ_iu_sz;\r
                srp_conn_info.max_scatter_gather_entries = p_srp_session->connection.max_scatter_gather_entries;\r
                srp_conn_info.tag                        = cl_atomic_inc( &p_srp_session->connection.tag );\r
index b3385a0..4bdbae1 100644 (file)
@@ -37,6 +37,7 @@
 \r
 #include <iba/ib_al.h>\r
 #include <iba/ioc_ifc.h>\r
+#include "srp.h"\r
 #include "srp_data.h"\r
 \r
 typedef struct _srp_conn_info\r
@@ -48,6 +49,7 @@ typedef struct _srp_conn_info
        uint64_t                tag;\r
        uint32_t                max_scatter_gather_entries;\r
        BOOLEAN                 signal_send_completion;\r
+       DATA_BUFFER_DESCRIPTOR_FORMAT descriptor_format;\r
 } srp_conn_info_t;\r
 \r
 void\r
index 064b83b..448da38 100644 (file)
@@ -408,8 +408,8 @@ srp_find_adapter(
                return SP_RETURN_ERROR;\r
        }\r
 \r
-       p_config->SrbExtensionSize            = p_ext->p_hba->max_srb_ext_sz;\r
-       CL_ASSERT( p_config->SrbExtensionSize >= sizeof( srp_send_descriptor_t ) );\r
+       p_config->SrbExtensionSize            = MAX( p_ext->p_hba->max_srb_ext_sz, sizeof( srp_send_descriptor_t ));\r
+       //CL_ASSERT( p_config->SrbExtensionSize >= sizeof( srp_send_descriptor_t ) );\r
 \r
        p_config->MaximumTransferLength       = SCSI_MAXIMUM_TRANSFER_SIZE;\r
        p_config->AlignmentMask               = 0; /* byte alignment */\r