scsi: lpfc: Rework misleading nvme not supported in firmware message
[linux-2.6-microblaze.git] / drivers / scsi / libsas / sas_task.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include "sas_internal.h"
3
4 #include <linux/kernel.h>
5 #include <linux/export.h>
6 #include <scsi/sas.h>
7 #include <scsi/libsas.h>
8
9 /* fill task_status_struct based on SSP response frame */
10 void sas_ssp_task_response(struct device *dev, struct sas_task *task,
11                            struct ssp_response_iu *iu)
12 {
13         struct task_status_struct *tstat = &task->task_status;
14
15         tstat->resp = SAS_TASK_COMPLETE;
16
17         if (iu->datapres == 0)
18                 tstat->stat = iu->status;
19         else if (iu->datapres == 1)
20                 tstat->stat = iu->resp_data[3];
21         else if (iu->datapres == 2) {
22                 tstat->stat = SAM_STAT_CHECK_CONDITION;
23                 tstat->buf_valid_size =
24                         min_t(int, SAS_STATUS_BUF_SIZE,
25                               be32_to_cpu(iu->sense_data_len));
26                 memcpy(tstat->buf, iu->sense_data, tstat->buf_valid_size);
27
28                 if (iu->status != SAM_STAT_CHECK_CONDITION)
29                         dev_warn(dev, "dev %llx sent sense data, but stat(%x) is not CHECK CONDITION\n",
30                                  SAS_ADDR(task->dev->sas_addr), iu->status);
31         }
32         else
33                 /* when datapres contains corrupt/unknown value... */
34                 tstat->stat = SAM_STAT_CHECK_CONDITION;
35 }
36 EXPORT_SYMBOL_GPL(sas_ssp_task_response);
37