1457c8996SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2d188e5dbSJohn Garry 3d188e5dbSJohn Garry #include "sas_internal.h" 4d188e5dbSJohn Garry 5366ca51fSJames Bottomley #include <linux/kernel.h> 609703660SPaul Gortmaker #include <linux/export.h> 7366ca51fSJames Bottomley #include <scsi/sas.h> 8366ca51fSJames Bottomley #include <scsi/libsas.h> 9366ca51fSJames Bottomley 10366ca51fSJames Bottomley /* fill task_status_struct based on SSP response frame */ 11366ca51fSJames Bottomley void sas_ssp_task_response(struct device *dev, struct sas_task *task, 12366ca51fSJames Bottomley struct ssp_response_iu *iu) 13366ca51fSJames Bottomley { 14366ca51fSJames Bottomley struct task_status_struct *tstat = &task->task_status; 15366ca51fSJames Bottomley 16366ca51fSJames Bottomley tstat->resp = SAS_TASK_COMPLETE; 17366ca51fSJames Bottomley 18*1d6049a3SJohn Garry switch (iu->datapres) { 19*1d6049a3SJohn Garry case SAS_DATAPRES_NO_DATA: 20366ca51fSJames Bottomley tstat->stat = iu->status; 21*1d6049a3SJohn Garry break; 22*1d6049a3SJohn Garry case SAS_DATAPRES_RESPONSE_DATA: 23366ca51fSJames Bottomley tstat->stat = iu->resp_data[3]; 24*1d6049a3SJohn Garry break; 25*1d6049a3SJohn Garry case SAS_DATAPRES_SENSE_DATA: 26d377f415SBart Van Assche tstat->stat = SAS_SAM_STAT_CHECK_CONDITION; 27366ca51fSJames Bottomley tstat->buf_valid_size = 28366ca51fSJames Bottomley min_t(int, SAS_STATUS_BUF_SIZE, 29366ca51fSJames Bottomley be32_to_cpu(iu->sense_data_len)); 30366ca51fSJames Bottomley memcpy(tstat->buf, iu->sense_data, tstat->buf_valid_size); 31366ca51fSJames Bottomley 32df64d3caSJames Bottomley if (iu->status != SAM_STAT_CHECK_CONDITION) 33b3e3d4c6SJohn Garry dev_warn(dev, "dev %016llx sent sense data, but stat(0x%x) is not CHECK CONDITION\n", 3415ba7806SJohn Garry SAS_ADDR(task->dev->sas_addr), iu->status); 35*1d6049a3SJohn Garry break; 36*1d6049a3SJohn Garry default: 37366ca51fSJames Bottomley /* when datapres contains corrupt/unknown value... */ 38d377f415SBart Van Assche tstat->stat = SAS_SAM_STAT_CHECK_CONDITION; 39366ca51fSJames Bottomley } 40*1d6049a3SJohn Garry } 41366ca51fSJames Bottomley EXPORT_SYMBOL_GPL(sas_ssp_task_response); 42366ca51fSJames Bottomley 43