sas_task.c 1.1 KB

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