18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* QLogic FCoE Offload Driver 38c2ecf20Sopenharmony_ci * Copyright (c) 2016-2018 Cavium Inc. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci#include "drv_scsi_fw_funcs.h" 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#define SCSI_NUM_SGES_IN_CACHE 0x4 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cibool scsi_is_slow_sgl(u16 num_sges, bool small_mid_sge) 108c2ecf20Sopenharmony_ci{ 118c2ecf20Sopenharmony_ci return (num_sges > SCSI_NUM_SGES_SLOW_SGL_THR && small_mid_sge); 128c2ecf20Sopenharmony_ci} 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_civoid init_scsi_sgl_context(struct scsi_sgl_params *ctx_sgl_params, 158c2ecf20Sopenharmony_ci struct scsi_cached_sges *ctx_data_desc, 168c2ecf20Sopenharmony_ci struct scsi_sgl_task_params *sgl_task_params) 178c2ecf20Sopenharmony_ci{ 188c2ecf20Sopenharmony_ci /* no need to check for sgl_task_params->sgl validity */ 198c2ecf20Sopenharmony_ci u8 num_sges_to_init = sgl_task_params->num_sges > 208c2ecf20Sopenharmony_ci SCSI_NUM_SGES_IN_CACHE ? SCSI_NUM_SGES_IN_CACHE : 218c2ecf20Sopenharmony_ci sgl_task_params->num_sges; 228c2ecf20Sopenharmony_ci u8 sge_index; 238c2ecf20Sopenharmony_ci u32 val; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci val = cpu_to_le32(sgl_task_params->sgl_phys_addr.lo); 268c2ecf20Sopenharmony_ci ctx_sgl_params->sgl_addr.lo = val; 278c2ecf20Sopenharmony_ci val = cpu_to_le32(sgl_task_params->sgl_phys_addr.hi); 288c2ecf20Sopenharmony_ci ctx_sgl_params->sgl_addr.hi = val; 298c2ecf20Sopenharmony_ci val = cpu_to_le32(sgl_task_params->total_buffer_size); 308c2ecf20Sopenharmony_ci ctx_sgl_params->sgl_total_length = val; 318c2ecf20Sopenharmony_ci ctx_sgl_params->sgl_num_sges = cpu_to_le16(sgl_task_params->num_sges); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci for (sge_index = 0; sge_index < num_sges_to_init; sge_index++) { 348c2ecf20Sopenharmony_ci val = cpu_to_le32(sgl_task_params->sgl[sge_index].sge_addr.lo); 358c2ecf20Sopenharmony_ci ctx_data_desc->sge[sge_index].sge_addr.lo = val; 368c2ecf20Sopenharmony_ci val = cpu_to_le32(sgl_task_params->sgl[sge_index].sge_addr.hi); 378c2ecf20Sopenharmony_ci ctx_data_desc->sge[sge_index].sge_addr.hi = val; 388c2ecf20Sopenharmony_ci val = cpu_to_le32(sgl_task_params->sgl[sge_index].sge_len); 398c2ecf20Sopenharmony_ci ctx_data_desc->sge[sge_index].sge_len = val; 408c2ecf20Sopenharmony_ci } 418c2ecf20Sopenharmony_ci} 42