Commit 1d6049a3 authored by John Garry's avatar John Garry Committed by Martin K. Petersen

scsi: libsas: Use enum for response frame DATAPRES field

As defined in table 126 of the SAS spec 1.1, use an enum for the DATAPRES
field, which makes reading the code easier.

Also change sas_ssp_task_response() to use a switch statement, which is
more suitable (than if-else), as suggested by Christoph.

Link: https://lore.kernel.org/r/1645112566-115804-3-git-send-email-john.garry@huawei.comSuggested-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Tested-by: default avatarYihang Li <liyihang6@hisilicon.com>
Tested-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: default avatarJack Wang <jinpu.wang@ionos.com>
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 9aacf6fe
...@@ -287,7 +287,7 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb, ...@@ -287,7 +287,7 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb,
fh = edb->vaddr + 16; fh = edb->vaddr + 16;
ru = edb->vaddr + 16 + sizeof(*fh); ru = edb->vaddr + 16 + sizeof(*fh);
res = ru->status; res = ru->status;
if (ru->datapres == 1) /* Response data present */ if (ru->datapres == SAS_DATAPRES_RESPONSE_DATA)
res = ru->resp_data[3]; res = ru->resp_data[3];
#if 0 #if 0
ascb->tag = fh->tag; ascb->tag = fh->tag;
......
...@@ -1047,7 +1047,8 @@ request_started_state_tc_event(struct isci_request *ireq, ...@@ -1047,7 +1047,8 @@ request_started_state_tc_event(struct isci_request *ireq,
resp_iu = &ireq->ssp.rsp; resp_iu = &ireq->ssp.rsp;
datapres = resp_iu->datapres; datapres = resp_iu->datapres;
if (datapres == 1 || datapres == 2) { if (datapres == SAS_DATAPRES_RESPONSE_DATA ||
datapres == SAS_DATAPRES_SENSE_DATA) {
ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE;
ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID;
} else { } else {
...@@ -1730,8 +1731,8 @@ sci_io_request_frame_handler(struct isci_request *ireq, ...@@ -1730,8 +1731,8 @@ sci_io_request_frame_handler(struct isci_request *ireq,
resp_iu = &ireq->ssp.rsp; resp_iu = &ireq->ssp.rsp;
if (resp_iu->datapres == 0x01 || if (resp_iu->datapres == SAS_DATAPRES_RESPONSE_DATA ||
resp_iu->datapres == 0x02) { resp_iu->datapres == SAS_DATAPRES_SENSE_DATA) {
ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE;
ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR;
} else { } else {
......
...@@ -15,11 +15,14 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task, ...@@ -15,11 +15,14 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,
tstat->resp = SAS_TASK_COMPLETE; tstat->resp = SAS_TASK_COMPLETE;
if (iu->datapres == 0) switch (iu->datapres) {
case SAS_DATAPRES_NO_DATA:
tstat->stat = iu->status; tstat->stat = iu->status;
else if (iu->datapres == 1) break;
case SAS_DATAPRES_RESPONSE_DATA:
tstat->stat = iu->resp_data[3]; tstat->stat = iu->resp_data[3];
else if (iu->datapres == 2) { break;
case SAS_DATAPRES_SENSE_DATA:
tstat->stat = SAS_SAM_STAT_CHECK_CONDITION; tstat->stat = SAS_SAM_STAT_CHECK_CONDITION;
tstat->buf_valid_size = tstat->buf_valid_size =
min_t(int, SAS_STATUS_BUF_SIZE, min_t(int, SAS_STATUS_BUF_SIZE,
...@@ -29,10 +32,11 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task, ...@@ -29,10 +32,11 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,
if (iu->status != SAM_STAT_CHECK_CONDITION) if (iu->status != SAM_STAT_CHECK_CONDITION)
dev_warn(dev, "dev %016llx sent sense data, but stat(0x%x) is not CHECK CONDITION\n", dev_warn(dev, "dev %016llx sent sense data, but stat(0x%x) is not CHECK CONDITION\n",
SAS_ADDR(task->dev->sas_addr), iu->status); SAS_ADDR(task->dev->sas_addr), iu->status);
} break;
else default:
/* when datapres contains corrupt/unknown value... */ /* when datapres contains corrupt/unknown value... */
tstat->stat = SAS_SAM_STAT_CHECK_CONDITION; tstat->stat = SAS_SAM_STAT_CHECK_CONDITION;
}
} }
EXPORT_SYMBOL_GPL(sas_ssp_task_response); EXPORT_SYMBOL_GPL(sas_ssp_task_response);
...@@ -1638,7 +1638,7 @@ static void mvs_set_sense(u8 *buffer, int len, int d_sense, ...@@ -1638,7 +1638,7 @@ static void mvs_set_sense(u8 *buffer, int len, int d_sense,
static void mvs_fill_ssp_resp_iu(struct ssp_response_iu *iu, static void mvs_fill_ssp_resp_iu(struct ssp_response_iu *iu,
u8 key, u8 asc, u8 asc_q) u8 key, u8 asc, u8 asc_q)
{ {
iu->datapres = 2; iu->datapres = SAS_DATAPRES_SENSE_DATA;
iu->response_data_len = 0; iu->response_data_len = 0;
iu->sense_data_len = 17; iu->sense_data_len = 17;
iu->status = 02; iu->status = 02;
......
...@@ -191,6 +191,13 @@ enum sas_gpio_reg_type { ...@@ -191,6 +191,13 @@ enum sas_gpio_reg_type {
SAS_GPIO_REG_TX_GP = 4, SAS_GPIO_REG_TX_GP = 4,
}; };
/* Response frame DATAPRES field */
enum {
SAS_DATAPRES_NO_DATA = 0,
SAS_DATAPRES_RESPONSE_DATA = 1,
SAS_DATAPRES_SENSE_DATA = 2,
};
struct dev_to_host_fis { struct dev_to_host_fis {
u8 fis_type; /* 0x34 */ u8 fis_type; /* 0x34 */
u8 flags; u8 flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment