summaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorXiaofei Tan <tanxiaofei@huawei.com>2018-05-21 06:09:21 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2018-05-28 22:40:32 -0400
commit78bd2b4f6e7c0522cc8bc8ad651f20813ae06f6c (patch)
treec8918e2aae3253e46c8dc1426c4f4d94ed0fe180 /drivers/scsi
parenta865ae14ff62797f14b760b2063b90c81d27d178 (diff)
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: Xiaofei Tan <tanxiaofei@huawei.com> Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas.h14
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_main.c15
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v1_hw.c12
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v2_hw.c10
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v3_hw.c10
5 files changed, 30 insertions, 31 deletions
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h
index 8ce6abb48867..60bd652534fe 100644
--- a/drivers/scsi/hisi_sas/hisi_sas.h
+++ b/drivers/scsi/hisi_sas/hisi_sas.h
@@ -179,6 +179,11 @@ struct hisi_sas_device {
179 u8 dev_status; 179 u8 dev_status;
180}; 180};
181 181
182struct hisi_sas_tmf_task {
183 u8 tmf;
184 u16 tag_of_task_to_be_managed;
185};
186
182struct hisi_sas_slot { 187struct hisi_sas_slot {
183 struct list_head entry; 188 struct list_head entry;
184 struct list_head delivery; 189 struct list_head delivery;
@@ -199,11 +204,7 @@ struct hisi_sas_slot {
199 struct work_struct abort_slot; 204 struct work_struct abort_slot;
200 struct timer_list internal_abort_timer; 205 struct timer_list internal_abort_timer;
201 bool is_internal; 206 bool is_internal;
202}; 207 struct hisi_sas_tmf_task *tmf;
203
204struct hisi_sas_tmf_task {
205 u8 tmf;
206 u16 tag_of_task_to_be_managed;
207}; 208};
208 209
209struct hisi_sas_hw { 210struct hisi_sas_hw {
@@ -217,8 +218,7 @@ struct hisi_sas_hw {
217 int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq); 218 int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq);
218 void (*start_delivery)(struct hisi_sas_dq *dq); 219 void (*start_delivery)(struct hisi_sas_dq *dq);
219 void (*prep_ssp)(struct hisi_hba *hisi_hba, 220 void (*prep_ssp)(struct hisi_hba *hisi_hba,
220 struct hisi_sas_slot *slot, int is_tmf, 221 struct hisi_sas_slot *slot);
221 struct hisi_sas_tmf_task *tmf);
222 void (*prep_smp)(struct hisi_hba *hisi_hba, 222 void (*prep_smp)(struct hisi_hba *hisi_hba,
223 struct hisi_sas_slot *slot); 223 struct hisi_sas_slot *slot);
224 void (*prep_stp)(struct hisi_hba *hisi_hba, 224 void (*prep_stp)(struct hisi_hba *hisi_hba,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 5bc522c35690..4e8046ecf477 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -266,10 +266,9 @@ static void hisi_sas_task_prep_smp(struct hisi_hba *hisi_hba,
266} 266}
267 267
268static void hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba, 268static void hisi_sas_task_prep_ssp(struct hisi_hba *hisi_hba,
269 struct hisi_sas_slot *slot, int is_tmf, 269 struct hisi_sas_slot *slot)
270 struct hisi_sas_tmf_task *tmf)
271{ 270{
272 hisi_hba->hw->prep_ssp(hisi_hba, slot, is_tmf, tmf); 271 hisi_hba->hw->prep_ssp(hisi_hba, slot);
273} 272}
274 273
275static void hisi_sas_task_prep_ata(struct hisi_hba *hisi_hba, 274static void hisi_sas_task_prep_ata(struct hisi_hba *hisi_hba,
@@ -322,7 +321,7 @@ out:
322 321
323static int hisi_sas_task_prep(struct sas_task *task, 322static int hisi_sas_task_prep(struct sas_task *task,
324 struct hisi_sas_dq **dq_pointer, 323 struct hisi_sas_dq **dq_pointer,
325 int is_tmf, struct hisi_sas_tmf_task *tmf, 324 bool is_tmf, struct hisi_sas_tmf_task *tmf,
326 int *pass) 325 int *pass)
327{ 326{
328 struct domain_device *device = task->dev; 327 struct domain_device *device = task->dev;
@@ -461,8 +460,8 @@ static int hisi_sas_task_prep(struct sas_task *task,
461 slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot]; 460 slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot];
462 slot->task = task; 461 slot->task = task;
463 slot->port = port; 462 slot->port = port;
464 if (is_tmf) 463 slot->tmf = tmf;
465 slot->is_internal = true; 464 slot->is_internal = is_tmf;
466 task->lldd_task = slot; 465 task->lldd_task = slot;
467 INIT_WORK(&slot->abort_slot, hisi_sas_slot_abort); 466 INIT_WORK(&slot->abort_slot, hisi_sas_slot_abort);
468 467
@@ -475,7 +474,7 @@ static int hisi_sas_task_prep(struct sas_task *task,
475 hisi_sas_task_prep_smp(hisi_hba, slot); 474 hisi_sas_task_prep_smp(hisi_hba, slot);
476 break; 475 break;
477 case SAS_PROTOCOL_SSP: 476 case SAS_PROTOCOL_SSP:
478 hisi_sas_task_prep_ssp(hisi_hba, slot, is_tmf, tmf); 477 hisi_sas_task_prep_ssp(hisi_hba, slot);
479 break; 478 break;
480 case SAS_PROTOCOL_SATA: 479 case SAS_PROTOCOL_SATA:
481 case SAS_PROTOCOL_STP: 480 case SAS_PROTOCOL_STP:
@@ -527,7 +526,7 @@ prep_out:
527} 526}
528 527
529static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, 528static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags,
530 int is_tmf, struct hisi_sas_tmf_task *tmf) 529 bool is_tmf, struct hisi_sas_tmf_task *tmf)
531{ 530{
532 u32 rc; 531 u32 rc;
533 u32 pass = 0; 532 u32 pass = 0;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 8d5d8575d939..05609ac1b31d 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -986,8 +986,7 @@ static void prep_smp_v1_hw(struct hisi_hba *hisi_hba,
986} 986}
987 987
988static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba, 988static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
989 struct hisi_sas_slot *slot, int is_tmf, 989 struct hisi_sas_slot *slot)
990 struct hisi_sas_tmf_task *tmf)
991{ 990{
992 struct sas_task *task = slot->task; 991 struct sas_task *task = slot->task;
993 struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; 992 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 struct hisi_sas_port *port = slot->port; 995 struct hisi_sas_port *port = slot->port;
997 struct sas_ssp_task *ssp_task = &task->ssp_task; 996 struct sas_ssp_task *ssp_task = &task->ssp_task;
998 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; 997 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
999 int has_data = 0, priority = is_tmf; 998 struct hisi_sas_tmf_task *tmf = slot->tmf;
999 int has_data = 0, priority = !!tmf;
1000 u8 *buf_cmd, fburst = 0; 1000 u8 *buf_cmd, fburst = 0;
1001 u32 dw1, dw2; 1001 u32 dw1, dw2;
1002 1002
@@ -1010,7 +1010,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
1010 1010
1011 dw1 = 1 << CMD_HDR_VERIFY_DTL_OFF; 1011 dw1 = 1 << CMD_HDR_VERIFY_DTL_OFF;
1012 1012
1013 if (is_tmf) { 1013 if (tmf) {
1014 dw1 |= 3 << CMD_HDR_SSP_FRAME_TYPE_OFF; 1014 dw1 |= 3 << CMD_HDR_SSP_FRAME_TYPE_OFF;
1015 } else { 1015 } else {
1016 switch (scsi_cmnd->sc_data_direction) { 1016 switch (scsi_cmnd->sc_data_direction) {
@@ -1031,7 +1031,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
1031 dw1 |= sas_dev->device_id << CMD_HDR_DEVICE_ID_OFF; 1031 dw1 |= sas_dev->device_id << CMD_HDR_DEVICE_ID_OFF;
1032 hdr->dw1 = cpu_to_le32(dw1); 1032 hdr->dw1 = cpu_to_le32(dw1);
1033 1033
1034 if (is_tmf) { 1034 if (tmf) {
1035 dw2 = ((sizeof(struct ssp_tmf_iu) + 1035 dw2 = ((sizeof(struct ssp_tmf_iu) +
1036 sizeof(struct ssp_frame_hdr)+3)/4) << 1036 sizeof(struct ssp_frame_hdr)+3)/4) <<
1037 CMD_HDR_CFL_OFF; 1037 CMD_HDR_CFL_OFF;
@@ -1062,7 +1062,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
1062 hdr->dw2 = cpu_to_le32(dw2); 1062 hdr->dw2 = cpu_to_le32(dw2);
1063 1063
1064 memcpy(buf_cmd, &task->ssp_task.LUN, 8); 1064 memcpy(buf_cmd, &task->ssp_task.LUN, 8);
1065 if (!is_tmf) { 1065 if (!tmf) {
1066 buf_cmd[9] = fburst | task->ssp_task.task_attr | 1066 buf_cmd[9] = fburst | task->ssp_task.task_attr |
1067 (task->ssp_task.task_prio << 3); 1067 (task->ssp_task.task_prio << 3);
1068 memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd, 1068 memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 18dbaffc9988..fafb3f1835be 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1745,8 +1745,7 @@ static void prep_smp_v2_hw(struct hisi_hba *hisi_hba,
1745} 1745}
1746 1746
1747static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba, 1747static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
1748 struct hisi_sas_slot *slot, int is_tmf, 1748 struct hisi_sas_slot *slot)
1749 struct hisi_sas_tmf_task *tmf)
1750{ 1749{
1751 struct sas_task *task = slot->task; 1750 struct sas_task *task = slot->task;
1752 struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; 1751 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 struct hisi_sas_port *port = slot->port; 1754 struct hisi_sas_port *port = slot->port;
1756 struct sas_ssp_task *ssp_task = &task->ssp_task; 1755 struct sas_ssp_task *ssp_task = &task->ssp_task;
1757 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; 1756 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
1758 int has_data = 0, priority = is_tmf; 1757 struct hisi_sas_tmf_task *tmf = slot->tmf;
1758 int has_data = 0, priority = !!tmf;
1759 u8 *buf_cmd; 1759 u8 *buf_cmd;
1760 u32 dw1 = 0, dw2 = 0; 1760 u32 dw1 = 0, dw2 = 0;
1761 1761
@@ -1766,7 +1766,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
1766 (1 << CMD_HDR_CMD_OFF)); /* ssp */ 1766 (1 << CMD_HDR_CMD_OFF)); /* ssp */
1767 1767
1768 dw1 = 1 << CMD_HDR_VDTL_OFF; 1768 dw1 = 1 << CMD_HDR_VDTL_OFF;
1769 if (is_tmf) { 1769 if (tmf) {
1770 dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF; 1770 dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF;
1771 dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF; 1771 dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF;
1772 } else { 1772 } else {
@@ -1809,7 +1809,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
1809 sizeof(struct ssp_frame_hdr); 1809 sizeof(struct ssp_frame_hdr);
1810 1810
1811 memcpy(buf_cmd, &task->ssp_task.LUN, 8); 1811 memcpy(buf_cmd, &task->ssp_task.LUN, 8);
1812 if (!is_tmf) { 1812 if (!tmf) {
1813 buf_cmd[9] = task->ssp_task.task_attr | 1813 buf_cmd[9] = task->ssp_task.task_attr |
1814 (task->ssp_task.task_prio << 3); 1814 (task->ssp_task.task_prio << 3);
1815 memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd, 1815 memcpy(buf_cmd + 12, task->ssp_task.cmd->cmnd,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index dd5f542bbc45..8c996aa42528 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -911,8 +911,7 @@ static void prep_prd_sge_v3_hw(struct hisi_hba *hisi_hba,
911} 911}
912 912
913static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba, 913static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
914 struct hisi_sas_slot *slot, int is_tmf, 914 struct hisi_sas_slot *slot)
915 struct hisi_sas_tmf_task *tmf)
916{ 915{
917 struct sas_task *task = slot->task; 916 struct sas_task *task = slot->task;
918 struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; 917 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 struct hisi_sas_port *port = slot->port; 920 struct hisi_sas_port *port = slot->port;
922 struct sas_ssp_task *ssp_task = &task->ssp_task; 921 struct sas_ssp_task *ssp_task = &task->ssp_task;
923 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; 922 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
924 int has_data = 0, priority = is_tmf; 923 struct hisi_sas_tmf_task *tmf = slot->tmf;
924 int has_data = 0, priority = !!tmf;
925 u8 *buf_cmd; 925 u8 *buf_cmd;
926 u32 dw1 = 0, dw2 = 0; 926 u32 dw1 = 0, dw2 = 0;
927 927
@@ -932,7 +932,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
932 (1 << CMD_HDR_CMD_OFF)); /* ssp */ 932 (1 << CMD_HDR_CMD_OFF)); /* ssp */
933 933
934 dw1 = 1 << CMD_HDR_VDTL_OFF; 934 dw1 = 1 << CMD_HDR_VDTL_OFF;
935 if (is_tmf) { 935 if (tmf) {
936 dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF; 936 dw1 |= 2 << CMD_HDR_FRAME_TYPE_OFF;
937 dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF; 937 dw1 |= DIR_NO_DATA << CMD_HDR_DIR_OFF;
938 } else { 938 } else {
@@ -974,7 +974,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
974 sizeof(struct ssp_frame_hdr); 974 sizeof(struct ssp_frame_hdr);
975 975
976 memcpy(buf_cmd, &task->ssp_task.LUN, 8); 976 memcpy(buf_cmd, &task->ssp_task.LUN, 8);
977 if (!is_tmf) { 977 if (!tmf) {
978 buf_cmd[9] = ssp_task->task_attr | (ssp_task->task_prio << 3); 978 buf_cmd[9] = ssp_task->task_attr | (ssp_task->task_prio << 3);
979 memcpy(buf_cmd + 12, scsi_cmnd->cmnd, scsi_cmnd->cmd_len); 979 memcpy(buf_cmd + 12, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
980 } else { 980 } else {