Commit 78bd2b4f authored by Xiaofei Tan's avatar Xiaofei Tan Committed by Martin K. Petersen

scsi: hisi_sas: Include TMF elements in struct hisi_sas_slot

In future scenarios we will want to use the TMF struct for more task types
than SSP.

As such, we can add struct hisi_sas_tmf_task directly into struct
hisi_sas_slot, and this will mean we can remove the TMF parameters from the
task prep functions.
Signed-off-by: default avatarXiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent a865ae14
...@@ -179,6 +179,11 @@ struct hisi_sas_device { ...@@ -179,6 +179,11 @@ struct hisi_sas_device {
u8 dev_status; u8 dev_status;
}; };
struct hisi_sas_tmf_task {
u8 tmf;
u16 tag_of_task_to_be_managed;
};
struct hisi_sas_slot { struct hisi_sas_slot {
struct list_head entry; struct list_head entry;
struct list_head delivery; struct list_head delivery;
...@@ -199,11 +204,7 @@ struct hisi_sas_slot { ...@@ -199,11 +204,7 @@ struct hisi_sas_slot {
struct work_struct abort_slot; struct work_struct abort_slot;
struct timer_list internal_abort_timer; struct timer_list internal_abort_timer;
bool is_internal; bool is_internal;
}; struct hisi_sas_tmf_task *tmf;
struct hisi_sas_tmf_task {
u8 tmf;
u16 tag_of_task_to_be_managed;
}; };
struct hisi_sas_hw { struct hisi_sas_hw {
...@@ -217,8 +218,7 @@ struct hisi_sas_hw { ...@@ -217,8 +218,7 @@ struct hisi_sas_hw {
int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq); int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq);
void (*start_delivery)(struct hisi_sas_dq *dq); void (*start_delivery)(struct hisi_sas_dq *dq);
void (*prep_ssp)(struct hisi_hba *hisi_hba, void (*prep_ssp)(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot);
struct hisi_sas_tmf_task *tmf);
void (*prep_smp)(struct hisi_hba *hisi_hba, void (*prep_smp)(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot); struct hisi_sas_slot *slot);
void (*prep_stp)(struct hisi_hba *hisi_hba, void (*prep_stp)(struct hisi_hba *hisi_hba,
......
...@@ -266,10 +266,9 @@ static void hisi_sas_task_prep_smp(struct hisi_hba *hisi_hba, ...@@ -266,10 +266,9 @@ static void hisi_sas_task_prep_smp(struct hisi_hba *hisi_hba,
} }
static void hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba, static void hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot)
struct hisi_sas_tmf_task *tmf)
{ {
hisi_hba->hw->prep_ssp(hisi_hba, slot, is_tmf, tmf); hisi_hba->hw->prep_ssp(hisi_hba, slot);
} }
static void hisi_sas_task_prep_ata(struct hisi_hba *hisi_hba, static void hisi_sas_task_prep_ata(struct hisi_hba *hisi_hba,
...@@ -322,7 +321,7 @@ static void hisi_sas_slot_abort(struct work_struct *work) ...@@ -322,7 +321,7 @@ static void hisi_sas_slot_abort(struct work_struct *work)
static int hisi_sas_task_prep(struct sas_task *task, static int hisi_sas_task_prep(struct sas_task *task,
struct hisi_sas_dq **dq_pointer, struct hisi_sas_dq **dq_pointer,
int is_tmf, struct hisi_sas_tmf_task *tmf, bool is_tmf, struct hisi_sas_tmf_task *tmf,
int *pass) int *pass)
{ {
struct domain_device *device = task->dev; struct domain_device *device = task->dev;
...@@ -461,8 +460,8 @@ static int hisi_sas_task_prep(struct sas_task *task, ...@@ -461,8 +460,8 @@ static int hisi_sas_task_prep(struct sas_task *task,
slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot]; slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot];
slot->task = task; slot->task = task;
slot->port = port; slot->port = port;
if (is_tmf) slot->tmf = tmf;
slot->is_internal = true; slot->is_internal = is_tmf;
task->lldd_task = slot; task->lldd_task = slot;
INIT_WORK(&slot->abort_slot, hisi_sas_slot_abort); INIT_WORK(&slot->abort_slot, hisi_sas_slot_abort);
...@@ -475,7 +474,7 @@ static int hisi_sas_task_prep(struct sas_task *task, ...@@ -475,7 +474,7 @@ static int hisi_sas_task_prep(struct sas_task *task,
hisi_sas_task_prep_smp(hisi_hba, slot); hisi_sas_task_prep_smp(hisi_hba, slot);
break; break;
case SAS_PROTOCOL_SSP: case SAS_PROTOCOL_SSP:
hisi_sas_task_prep_ssp(hisi_hba, slot, is_tmf, tmf); hisi_sas_task_prep_ssp(hisi_hba, slot);
break; break;
case SAS_PROTOCOL_SATA: case SAS_PROTOCOL_SATA:
case SAS_PROTOCOL_STP: case SAS_PROTOCOL_STP:
...@@ -527,7 +526,7 @@ static int hisi_sas_task_prep(struct sas_task *task, ...@@ -527,7 +526,7 @@ static int hisi_sas_task_prep(struct sas_task *task,
} }
static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags,
int is_tmf, struct hisi_sas_tmf_task *tmf) bool is_tmf, struct hisi_sas_tmf_task *tmf)
{ {
u32 rc; u32 rc;
u32 pass = 0; u32 pass = 0;
......
...@@ -986,8 +986,7 @@ static void prep_smp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -986,8 +986,7 @@ static void prep_smp_v1_hw(struct hisi_hba *hisi_hba,
} }
static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba, static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot)
struct hisi_sas_tmf_task *tmf)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;
...@@ -996,7 +995,8 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -996,7 +995,8 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_port *port = slot->port; struct hisi_sas_port *port = slot->port;
struct sas_ssp_task *ssp_task = &task->ssp_task; struct sas_ssp_task *ssp_task = &task->ssp_task;
struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
int has_data = 0, priority = is_tmf; struct hisi_sas_tmf_task *tmf = slot->tmf;
int has_data = 0, priority = !!tmf;
u8 *buf_cmd, fburst = 0; u8 *buf_cmd, fburst = 0;
u32 dw1, dw2; u32 dw1, dw2;
...@@ -1010,7 +1010,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1010,7 +1010,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
dw1 = 1 << CMD_HDR_VERIFY_DTL_OFF; dw1 = 1 << CMD_HDR_VERIFY_DTL_OFF;
if (is_tmf) { if (tmf) {
dw1 |= 3 << CMD_HDR_SSP_FRAME_TYPE_OFF; dw1 |= 3 << CMD_HDR_SSP_FRAME_TYPE_OFF;
} else { } else {
switch (scsi_cmnd->sc_data_direction) { switch (scsi_cmnd->sc_data_direction) {
...@@ -1031,7 +1031,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1031,7 +1031,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
dw1 |= sas_dev->device_id << CMD_HDR_DEVICE_ID_OFF; dw1 |= sas_dev->device_id << CMD_HDR_DEVICE_ID_OFF;
hdr->dw1 = cpu_to_le32(dw1); hdr->dw1 = cpu_to_le32(dw1);
if (is_tmf) { if (tmf) {
dw2 = ((sizeof(struct ssp_tmf_iu) + dw2 = ((sizeof(struct ssp_tmf_iu) +
sizeof(struct ssp_frame_hdr)+3)/4) << sizeof(struct ssp_frame_hdr)+3)/4) <<
CMD_HDR_CFL_OFF; CMD_HDR_CFL_OFF;
...@@ -1062,7 +1062,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba, ...@@ -1062,7 +1062,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
hdr->dw2 = cpu_to_le32(dw2); hdr->dw2 = cpu_to_le32(dw2);
memcpy(buf_cmd, &task->ssp_task.LUN, 8); memcpy(buf_cmd, &task->ssp_task.LUN, 8);
if (!is_tmf) { if (!tmf) {
buf_cmd[9] = fburst | task->ssp_task.task_attr | buf_cmd[9] = fburst | task->ssp_task.task_attr |
(task->ssp_task.task_prio << 3); (task->ssp_task.task_prio << 3);
memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd, memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd,
......
...@@ -1745,8 +1745,7 @@ static void prep_smp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1745,8 +1745,7 @@ static void prep_smp_v2_hw(struct hisi_hba *hisi_hba,
} }
static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba, static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot)
struct hisi_sas_tmf_task *tmf)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;
...@@ -1755,7 +1754,8 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1755,7 +1754,8 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_port *port = slot->port; struct hisi_sas_port *port = slot->port;
struct sas_ssp_task *ssp_task = &task->ssp_task; struct sas_ssp_task *ssp_task = &task->ssp_task;
struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
int has_data = 0, priority = is_tmf; struct hisi_sas_tmf_task *tmf = slot->tmf;
int has_data = 0, priority = !!tmf;
u8 *buf_cmd; u8 *buf_cmd;
u32 dw1 = 0, dw2 = 0; u32 dw1 = 0, dw2 = 0;
...@@ -1766,7 +1766,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1766,7 +1766,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
(1 << CMD_HDR_CMD_OFF)); /* ssp */ (1 << CMD_HDR_CMD_OFF)); /* ssp */
dw1 = 1 << CMD_HDR_VDTL_OFF; dw1 = 1 << CMD_HDR_VDTL_OFF;
if (is_tmf) { if (tmf) {
dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF; dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF;
dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF; dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF;
} else { } else {
...@@ -1809,7 +1809,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba, ...@@ -1809,7 +1809,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
sizeof(struct ssp_frame_hdr); sizeof(struct ssp_frame_hdr);
memcpy(buf_cmd, &task->ssp_task.LUN, 8); memcpy(buf_cmd, &task->ssp_task.LUN, 8);
if (!is_tmf) { if (!tmf) {
buf_cmd[9] = task->ssp_task.task_attr | buf_cmd[9] = task->ssp_task.task_attr |
(task->ssp_task.task_prio << 3); (task->ssp_task.task_prio << 3);
memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd, memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd,
......
...@@ -911,8 +911,7 @@ static void prep_prd_sge_v3_hw(struct hisi_hba *hisi_hba, ...@@ -911,8 +911,7 @@ static void prep_prd_sge_v3_hw(struct hisi_hba *hisi_hba,
} }
static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_slot *slot, int is_tmf, struct hisi_sas_slot *slot)
struct hisi_sas_tmf_task *tmf)
{ {
struct sas_task *task = slot->task; struct sas_task *task = slot->task;
struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;
...@@ -921,7 +920,8 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, ...@@ -921,7 +920,8 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
struct hisi_sas_port *port = slot->port; struct hisi_sas_port *port = slot->port;
struct sas_ssp_task *ssp_task = &task->ssp_task; struct sas_ssp_task *ssp_task = &task->ssp_task;
struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
int has_data = 0, priority = is_tmf; struct hisi_sas_tmf_task *tmf = slot->tmf;
int has_data = 0, priority = !!tmf;
u8 *buf_cmd; u8 *buf_cmd;
u32 dw1 = 0, dw2 = 0; u32 dw1 = 0, dw2 = 0;
...@@ -932,7 +932,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, ...@@ -932,7 +932,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
(1 << CMD_HDR_CMD_OFF)); /* ssp */ (1 << CMD_HDR_CMD_OFF)); /* ssp */
dw1 = 1 << CMD_HDR_VDTL_OFF; dw1 = 1 << CMD_HDR_VDTL_OFF;
if (is_tmf) { if (tmf) {
dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF; dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF;
dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF; dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF;
} else { } else {
...@@ -974,7 +974,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, ...@@ -974,7 +974,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
sizeof(struct ssp_frame_hdr); sizeof(struct ssp_frame_hdr);
memcpy(buf_cmd, &task->ssp_task.LUN, 8); memcpy(buf_cmd, &task->ssp_task.LUN, 8);
if (!is_tmf) { if (!tmf) {
buf_cmd[9] = ssp_task->task_attr | (ssp_task->task_prio << 3); buf_cmd[9] = ssp_task->task_attr | (ssp_task->task_prio << 3);
memcpy(buf_cmd + 12, scsi_cmnd->cmnd, scsi_cmnd->cmd_len); memcpy(buf_cmd + 12, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
} else { } else {
......
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