aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorAndrew Vasquez <andrew.vasquez@qlogic.com>2010-05-04 18:01:25 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-05-16 18:21:44 -0400
commit99b0bec7bbf3350d1a920a7138fa62c456a8ecf1 (patch)
tree89e2265ec02f650e11a3ae8c53bcba295f9b3f76 /drivers/scsi
parent6a03b4cd78f3f2695a2d0e6343d555b3de0e67c1 (diff)
[SCSI] qla2xxx: Further generalization of SRB CTX infrastructure.
Prepare CTX infrastructure for additional asynchronous executions, add generic done() operator, pull CMD definitions. Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com> Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h17
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c43
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c74
3 files changed, 65 insertions, 69 deletions
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index d4a53e5549b..b3cf6099600 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -214,14 +214,21 @@ typedef struct srb {
214/* 214/*
215 * SRB extensions. 215 * SRB extensions.
216 */ 216 */
217struct srb_ctx {
218#define SRB_LOGIN_CMD 1 217#define SRB_LOGIN_CMD 1
219#define SRB_LOGOUT_CMD 2 218#define SRB_LOGOUT_CMD 2
219#define SRB_ELS_CMD_RPT 3
220#define SRB_ELS_CMD_HST 4
221#define SRB_CT_CMD 5
222
223struct srb_ctx {
220 uint16_t type; 224 uint16_t type;
225 char *name;
226
221 struct timer_list timer; 227 struct timer_list timer;
222 228
223 void (*free)(srb_t *sp); 229 void (*done)(srb_t *);
224 void (*timeout)(srb_t *sp); 230 void (*free)(srb_t *);
231 void (*timeout)(srb_t *);
225}; 232};
226 233
227struct srb_logio { 234struct srb_logio {
@@ -231,12 +238,10 @@ struct srb_logio {
231#define SRB_LOGIN_COND_PLOGI BIT_1 238#define SRB_LOGIN_COND_PLOGI BIT_1
232#define SRB_LOGIN_SKIP_PRLI BIT_2 239#define SRB_LOGIN_SKIP_PRLI BIT_2
233 uint16_t flags; 240 uint16_t flags;
241 uint16_t data[2];
234}; 242};
235 243
236struct srb_bsg_ctx { 244struct srb_bsg_ctx {
237#define SRB_ELS_CMD_RPT 3
238#define SRB_ELS_CMD_HST 4
239#define SRB_CT_CMD 5
240 uint16_t type; 245 uint16_t type;
241}; 246};
242 247
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 55540d2d4e3..c3c2c3627a7 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -117,13 +117,22 @@ qla2x00_async_logio_timeout(srb_t *sp)
117 117
118 DEBUG2(printk(KERN_WARNING 118 DEBUG2(printk(KERN_WARNING
119 "scsi(%ld:%x): Async-%s timeout.\n", 119 "scsi(%ld:%x): Async-%s timeout.\n",
120 fcport->vha->host_no, sp->handle, 120 fcport->vha->host_no, sp->handle, lio->ctx.name));
121 lio->ctx.type == SRB_LOGIN_CMD ? "login": "logout"));
122 121
123 if (lio->ctx.type == SRB_LOGIN_CMD) 122 if (lio->ctx.type == SRB_LOGIN_CMD)
124 qla2x00_post_async_logout_work(fcport->vha, fcport, NULL); 123 qla2x00_post_async_logout_work(fcport->vha, fcport, NULL);
125} 124}
126 125
126static void
127qla2x00_async_login_ctx_done(srb_t *sp)
128{
129 struct srb_logio *lio = sp->ctx;
130
131 qla2x00_post_async_login_done_work(sp->fcport->vha, sp->fcport,
132 lio->data);
133 lio->ctx.free(sp);
134}
135
127int 136int
128qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, 137qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
129 uint16_t *data) 138 uint16_t *data)
@@ -141,7 +150,9 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
141 150
142 lio = sp->ctx; 151 lio = sp->ctx;
143 lio->ctx.type = SRB_LOGIN_CMD; 152 lio->ctx.type = SRB_LOGIN_CMD;
153 lio->ctx.name = "login";
144 lio->ctx.timeout = qla2x00_async_logio_timeout; 154 lio->ctx.timeout = qla2x00_async_logio_timeout;
155 lio->ctx.done = qla2x00_async_login_ctx_done;
145 lio->flags |= SRB_LOGIN_COND_PLOGI; 156 lio->flags |= SRB_LOGIN_COND_PLOGI;
146 if (data[1] & QLA_LOGIO_LOGIN_RETRIED) 157 if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
147 lio->flags |= SRB_LOGIN_RETRIED; 158 lio->flags |= SRB_LOGIN_RETRIED;
@@ -163,6 +174,16 @@ done:
163 return rval; 174 return rval;
164} 175}
165 176
177static void
178qla2x00_async_logout_ctx_done(srb_t *sp)
179{
180 struct srb_logio *lio = sp->ctx;
181
182 qla2x00_post_async_logout_done_work(sp->fcport->vha, sp->fcport,
183 lio->data);
184 lio->ctx.free(sp);
185}
186
166int 187int
167qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) 188qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
168{ 189{
@@ -179,7 +200,9 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
179 200
180 lio = sp->ctx; 201 lio = sp->ctx;
181 lio->ctx.type = SRB_LOGOUT_CMD; 202 lio->ctx.type = SRB_LOGOUT_CMD;
203 lio->ctx.name = "logout";
182 lio->ctx.timeout = qla2x00_async_logio_timeout; 204 lio->ctx.timeout = qla2x00_async_logio_timeout;
205 lio->ctx.done = qla2x00_async_logout_ctx_done;
183 rval = qla2x00_start_sp(sp); 206 rval = qla2x00_start_sp(sp);
184 if (rval != QLA_SUCCESS) 207 if (rval != QLA_SUCCESS)
185 goto done_free_sp; 208 goto done_free_sp;
@@ -202,17 +225,17 @@ qla2x00_async_login_done(struct scsi_qla_host *vha, fc_port_t *fcport,
202 uint16_t *data) 225 uint16_t *data)
203{ 226{
204 int rval; 227 int rval;
205 uint8_t opts = 0;
206 228
207 switch (data[0]) { 229 switch (data[0]) {
208 case MBS_COMMAND_COMPLETE: 230 case MBS_COMMAND_COMPLETE:
209 if (fcport->flags & FCF_FCP2_DEVICE) 231 if (fcport->flags & FCF_FCP2_DEVICE) {
210 opts |= BIT_1; 232 rval = qla2x00_get_port_database(vha, fcport, BIT_1);
211 rval = qla2x00_get_port_database(vha, fcport, opts); 233 if (rval != QLA_SUCCESS) {
212 if (rval != QLA_SUCCESS) 234 qla2x00_mark_device_lost(vha, fcport, 1, 0);
213 qla2x00_mark_device_lost(vha, fcport, 1, 0); 235 break;
214 else 236 }
215 qla2x00_update_fcport(vha, fcport); 237 }
238 qla2x00_update_fcport(vha, fcport);
216 break; 239 break;
217 case MBS_COMMAND_ERROR: 240 case MBS_COMMAND_ERROR:
218 if (data[1] & QLA_LOGIO_LOGIN_RETRIED) 241 if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index f1ac62d505d..037bc41eef5 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -895,34 +895,20 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
895{ 895{
896 const char func[] = "MBX-IOCB"; 896 const char func[] = "MBX-IOCB";
897 const char *type; 897 const char *type;
898 struct qla_hw_data *ha = vha->hw;
899 fc_port_t *fcport; 898 fc_port_t *fcport;
900 srb_t *sp; 899 srb_t *sp;
901 struct srb_logio *lio; 900 struct srb_logio *lio;
902 uint16_t data[2]; 901 uint16_t *data;
903 902
904 sp = qla2x00_get_sp_from_handle(vha, func, req, mbx); 903 sp = qla2x00_get_sp_from_handle(vha, func, req, mbx);
905 if (!sp) 904 if (!sp)
906 return; 905 return;
907 906
908 type = NULL;
909 lio = sp->ctx; 907 lio = sp->ctx;
910 switch (lio->ctx.type) {
911 case SRB_LOGIN_CMD:
912 type = "login";
913 break;
914 case SRB_LOGOUT_CMD:
915 type = "logout";
916 break;
917 default:
918 qla_printk(KERN_WARNING, ha,
919 "%s: Unrecognized SRB: (%p) type=%d.\n", func, sp,
920 lio->ctx.type);
921 return;
922 }
923
924 del_timer(&lio->ctx.timer); 908 del_timer(&lio->ctx.timer);
909 type = lio->ctx.name;
925 fcport = sp->fcport; 910 fcport = sp->fcport;
911 data = lio->data;
926 912
927 data[0] = data[1] = 0; 913 data[0] = data[1] = 0;
928 if (mbx->entry_status) { 914 if (mbx->entry_status) {
@@ -938,7 +924,7 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
938 data[0] = MBS_COMMAND_ERROR; 924 data[0] = MBS_COMMAND_ERROR;
939 data[1] = lio->flags & SRB_LOGIN_RETRIED ? 925 data[1] = lio->flags & SRB_LOGIN_RETRIED ?
940 QLA_LOGIO_LOGIN_RETRIED: 0; 926 QLA_LOGIO_LOGIN_RETRIED: 0;
941 goto done_post_logio_done_work; 927 goto logio_done;
942 } 928 }
943 929
944 if (!mbx->status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { 930 if (!mbx->status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) {
@@ -948,10 +934,14 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
948 le16_to_cpu(mbx->mb1))); 934 le16_to_cpu(mbx->mb1)));
949 935
950 data[0] = MBS_COMMAND_COMPLETE; 936 data[0] = MBS_COMMAND_COMPLETE;
951 if (lio->ctx.type == SRB_LOGIN_CMD && le16_to_cpu(mbx->mb1) & BIT_1) 937 if (lio->ctx.type == SRB_LOGIN_CMD)
952 fcport->flags |= FCF_FCP2_DEVICE; 938 fcport->port_type = FCT_TARGET;
939 if (le16_to_cpu(mbx->mb1) & BIT_0)
940 fcport->port_type = FCT_INITIATOR;
941 if (le16_to_cpu(mbx->mb1) & BIT_1)
942 fcport->flags |= FCF_FCP2_DEVICE;
953 943
954 goto done_post_logio_done_work; 944 goto logio_done;
955 } 945 }
956 946
957 data[0] = le16_to_cpu(mbx->mb0); 947 data[0] = le16_to_cpu(mbx->mb0);
@@ -976,12 +966,8 @@ qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
976 le16_to_cpu(mbx->mb2), le16_to_cpu(mbx->mb6), 966 le16_to_cpu(mbx->mb2), le16_to_cpu(mbx->mb6),
977 le16_to_cpu(mbx->mb7))); 967 le16_to_cpu(mbx->mb7)));
978 968
979done_post_logio_done_work: 969logio_done:
980 lio->ctx.type == SRB_LOGIN_CMD ? 970 lio->ctx.done(sp);
981 qla2x00_post_async_login_done_work(fcport->vha, fcport, data):
982 qla2x00_post_async_logout_done_work(fcport->vha, fcport, data);
983
984 lio->ctx.free(sp);
985} 971}
986 972
987static void 973static void
@@ -1084,35 +1070,21 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1084{ 1070{
1085 const char func[] = "LOGIO-IOCB"; 1071 const char func[] = "LOGIO-IOCB";
1086 const char *type; 1072 const char *type;
1087 struct qla_hw_data *ha = vha->hw;
1088 fc_port_t *fcport; 1073 fc_port_t *fcport;
1089 srb_t *sp; 1074 srb_t *sp;
1090 struct srb_logio *lio; 1075 struct srb_logio *lio;
1091 uint16_t data[2]; 1076 uint16_t *data;
1092 uint32_t iop[2]; 1077 uint32_t iop[2];
1093 1078
1094 sp = qla2x00_get_sp_from_handle(vha, func, req, logio); 1079 sp = qla2x00_get_sp_from_handle(vha, func, req, logio);
1095 if (!sp) 1080 if (!sp)
1096 return; 1081 return;
1097 1082
1098 type = NULL;
1099 lio = sp->ctx; 1083 lio = sp->ctx;
1100 switch (lio->ctx.type) {
1101 case SRB_LOGIN_CMD:
1102 type = "login";
1103 break;
1104 case SRB_LOGOUT_CMD:
1105 type = "logout";
1106 break;
1107 default:
1108 qla_printk(KERN_WARNING, ha,
1109 "%s: Unrecognized SRB: (%p) type=%d.\n", func, sp,
1110 lio->ctx.type);
1111 return;
1112 }
1113
1114 del_timer(&lio->ctx.timer); 1084 del_timer(&lio->ctx.timer);
1085 type = lio->ctx.name;
1115 fcport = sp->fcport; 1086 fcport = sp->fcport;
1087 data = lio->data;
1116 1088
1117 data[0] = data[1] = 0; 1089 data[0] = data[1] = 0;
1118 if (logio->entry_status) { 1090 if (logio->entry_status) {
@@ -1125,7 +1097,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1125 data[0] = MBS_COMMAND_ERROR; 1097 data[0] = MBS_COMMAND_ERROR;
1126 data[1] = lio->flags & SRB_LOGIN_RETRIED ? 1098 data[1] = lio->flags & SRB_LOGIN_RETRIED ?
1127 QLA_LOGIO_LOGIN_RETRIED: 0; 1099 QLA_LOGIO_LOGIN_RETRIED: 0;
1128 goto done_post_logio_done_work; 1100 goto logio_done;
1129 } 1101 }
1130 1102
1131 if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) { 1103 if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) {
@@ -1136,7 +1108,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1136 1108
1137 data[0] = MBS_COMMAND_COMPLETE; 1109 data[0] = MBS_COMMAND_COMPLETE;
1138 if (lio->ctx.type == SRB_LOGOUT_CMD) 1110 if (lio->ctx.type == SRB_LOGOUT_CMD)
1139 goto done_post_logio_done_work; 1111 goto logio_done;
1140 1112
1141 iop[0] = le32_to_cpu(logio->io_parameter[0]); 1113 iop[0] = le32_to_cpu(logio->io_parameter[0]);
1142 if (iop[0] & BIT_4) { 1114 if (iop[0] & BIT_4) {
@@ -1151,7 +1123,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1151 if (logio->io_parameter[9] || logio->io_parameter[10]) 1123 if (logio->io_parameter[9] || logio->io_parameter[10])
1152 fcport->supported_classes |= FC_COS_CLASS3; 1124 fcport->supported_classes |= FC_COS_CLASS3;
1153 1125
1154 goto done_post_logio_done_work; 1126 goto logio_done;
1155 } 1127 }
1156 1128
1157 iop[0] = le32_to_cpu(logio->io_parameter[0]); 1129 iop[0] = le32_to_cpu(logio->io_parameter[0]);
@@ -1184,12 +1156,8 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
1184 le32_to_cpu(logio->io_parameter[0]), 1156 le32_to_cpu(logio->io_parameter[0]),
1185 le32_to_cpu(logio->io_parameter[1]))); 1157 le32_to_cpu(logio->io_parameter[1])));
1186 1158
1187done_post_logio_done_work: 1159logio_done:
1188 lio->ctx.type == SRB_LOGIN_CMD ? 1160 lio->ctx.done(sp);
1189 qla2x00_post_async_login_done_work(fcport->vha, fcport, data):
1190 qla2x00_post_async_logout_done_work(fcport->vha, fcport, data);
1191
1192 lio->ctx.free(sp);
1193} 1161}
1194 1162
1195/** 1163/**