[SRP] Properly format and cap the number of memory descriptors in
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 17 Oct 2005 04:07:31 +0000 (04:07 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 17 Oct 2005 04:07:31 +0000 (04:07 +0000)
IDBD information units.

Signed-off-by: Fab Tillier (ftillier@silverstorm.com)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@118 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/srp/kernel/srp_connection.c
ulp/srp/kernel/srp_data_path.c
ulp/srp/kernel/srp_descriptors.c
ulp/srp/kernel/srp_hba.c

index 821aa93..f8f2c11 100644 (file)
@@ -438,7 +438,7 @@ __srp_cm_reply_cb(
        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
+                               ( MIN( 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
index 56364d3..aca2b49 100644 (file)
@@ -580,7 +580,13 @@ __srp_build_cmd(
                p_scatter_gather_list = StorPortGetScatterGatherList( p_dev_ext, p_srb );\r
                CL_ASSERT( p_scatter_gather_list != NULL );\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
+       /* Cap the length of the inline descriptors to the maximum IU size. */\r
+       if( p_srp_conn_info->max_scatter_gather_entries < scatter_gather_count )\r
+       {\r
+               scatter_gather_count =\r
+                       (uint8_t)p_srp_conn_info->max_scatter_gather_entries;\r
        }\r
 \r
        if ( scsi_direction == SRB_FLAGS_DATA_IN )\r
@@ -612,10 +618,14 @@ __srp_build_cmd(
                        /* 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
+                       p_table_descriptor->descriptor.data_length =\r
+                               cl_hton32( sizeof(srp_memory_descriptor_t) *\r
+                               p_scatter_gather_list->NumberOfElements );\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
+                                 i < p_scatter_gather_list->NumberOfElements;\r
+                                 i++, p_memory_descriptor++, p_sg_element++ )\r
                        {\r
                                buf_addr =  p_srp_conn_info->vaddr + p_sg_element->PhysicalAddress.QuadPart;\r
                        \r
@@ -628,6 +638,8 @@ __srp_build_cmd(
                }\r
                else if ( format == DBDF_DIRECT_DATA_BUFFER_DESCRIPTOR )\r
                {\r
+                       CL_ASSERT( scatter_gather_count ==\r
+                               p_scatter_gather_list->NumberOfElements );\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
index d6def78..81cb0e9 100644 (file)
@@ -385,6 +385,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
index eec6c0b..ba8949d 100644 (file)
@@ -683,7 +683,10 @@ __srp_connect_sessions(
                        {\r
                                any_ioc_connected = TRUE;\r
 \r
-                               if ( p_hba->max_sg > p_session->connection.max_scatter_gather_entries )\r
+                               if ( (p_hba->max_sg >\r
+                                       p_session->connection.max_scatter_gather_entries)\r
+                                       && !(p_session->connection.descriptor_format &\r
+                                       DBDF_INDIRECT_DATA_BUFFER_DESCRIPTORS) )\r
                                {\r
                                        p_hba->max_sg = p_session->connection.max_scatter_gather_entries;\r
                                }\r