FreeBSD/sys/dev/isci/scil/scic_sds_stp_request.c
/**
 * Copy the data from the buffer for the length specified to the IO reqeust
 * SGL specified data region.
 *
 * @param[in] this_request The request that is used for the SGL processing.
 * @param[in] data_buffer The buffer of data to be copied.
 * @param[in] length  The length of the data transfer.
 *
 * @return SCI_STATUS
 */
Copy the data from the buffer for the length specified to the IO reqeust
SGL specified data region.

@param[in] this_request The request that is used for the SGL processing.
@param[in] data_buffer The buffer of data to be copied.
@param[in] length  The length of the data transfer.


Copy the data from the buffer for the length specified to the IO reqeust SGL specified data region . @param [ in ] this_request The request that is used for the SGL processing . @param [ in ] data_buffer The buffer of data to be copied . @param [ in ] length The length of the data transfer .
static
SCI_STATUS scic_sds_stp_request_pio_data_in_copy_data_buffer(
   SCIC_SDS_STP_REQUEST_T * this_request,
   U8                     * data_buffer,
   U32                      length
)
{
   SCI_STATUS          status;
   SCU_SGL_ELEMENT_T * current_sgl;
   U32                 sgl_offset;
   U32                 data_offset;
   U8                * source_address;
   current_sgl =
      (this_request->type.pio.request_current.sgl_set == SCU_SGL_ELEMENT_PAIR_A) ?
         &(this_request->type.pio.request_current.sgl_pair->A) :
         &(this_request->type.pio.request_current.sgl_pair->B) ;
   sgl_offset = this_request->type.pio.request_current.sgl_offset;
   source_address = data_buffer;
   data_offset = this_request->type.pio.current_transfer_bytes;
   status = SCI_SUCCESS;
   while (
            (length > 0)
         && (status == SCI_SUCCESS)
         )
   {
      if (current_sgl->length == sgl_offset)
      {
         current_sgl = scic_sds_stp_request_pio_get_next_sgl(this_request);
         if (current_sgl == NULL)
            status = SCI_FAILURE;
         else
            sgl_offset = 0;
      }
      else
      {
#ifdef ENABLE_OSSL_COPY_BUFFER
         scic_cb_io_request_copy_buffer(this_request, data_buffer, data_offset, length);
         length = 0;
#else
         U8 * destination_address;
         U32  copy_length;
         destination_address = (U8 *)scic_cb_io_request_get_virtual_address_from_sgl(
            this_request,
            data_offset
         );
         copy_length = MIN(length, current_sgl->length - sgl_offset);
         memcpy(destination_address, source_address, copy_length);
         length -= copy_length;
         sgl_offset += copy_length;
         data_offset += copy_length;
         source_address += copy_length;
#endif
      }
   }
   this_request->type.pio.request_current.sgl_offset = sgl_offset;
   return status;
}
static SCI_STATUS scic_sds_stp_request_pio_data_in_copy_data_buffer ( SCIC_SDS_STP_REQUEST_T * this_request , U8 * data_buffer , U32 length ) { SCI_STATUS status ; SCU_SGL_ELEMENT_T * current_sgl ; U32 sgl_offset ; U32 data_offset ; U8 * source_address ; current_sgl = ( this_request -> type . pio . request_current . sgl_set == SCU_SGL_ELEMENT_PAIR_A ) ? & ( this_request -> type . pio . request_current . sgl_pair -> A ) : & ( this_request -> type . pio . request_current . sgl_pair -> B ) ; sgl_offset = this_request -> type . pio . request_current . sgl_offset ; source_address = data_buffer ; data_offset = this_request -> type . pio . current_transfer_bytes ; status = SCI_SUCCESS ; while ( ( length > 0 ) && ( status == SCI_SUCCESS ) ) { if ( current_sgl -> length == sgl_offset ) { current_sgl = scic_sds_stp_request_pio_get_next_sgl ( this_request ) ; if ( current_sgl == NULL ) status = SCI_FAILURE ; else sgl_offset = 0 ; } else { #ifdef ENABLE_OSSL_COPY_BUFFER scic_cb_io_request_copy_buffer ( this_request , data_buffer , data_offset , length ) ; length = 0 ; #else U8 * destination_address ; U32 copy_length ; destination_address = ( U8 * ) scic_cb_io_request_get_virtual_address_from_sgl ( this_request , data_offset ) ; copy_length = MIN ( length , current_sgl -> length - sgl_offset ) ; memcpy ( destination_address , source_address , copy_length ) ; length -= copy_length ; sgl_offset += copy_length ; data_offset += copy_length ; source_address += copy_length ; #endif } } this_request -> type . pio . request_current . sgl_offset = sgl_offset ; return status ; }
Copy the data from the buffer for the length specified to the IO reqeust
 SGL specified data region.
Copy the data from the buffer for the length specified to the IO reqeust SGL specified data region .
// Initial setup to get the current working SGL and the offset within the buffer // While we are still doing Ok and there is more data to transfer // This SGL has been exauhasted so we need to get the next SGL