aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/phy.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-05-12 07:17:51 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:48 -0400
commitc4441abc25a33ab259f01dce4b4d63721013f86d (patch)
tree85ea42e94f9d993963d6c815f009914c53f865f5 /drivers/scsi/isci/phy.c
parent35b317bec511b4a5f87a637bf78b6d1d635c617d (diff)
isci: unify phy frame handlers
Unify the implementations in scic_sds_phy_frame_handler(), and kill the state handler Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/phy.c')
-rw-r--r--drivers/scsi/isci/phy.c267
1 files changed, 93 insertions, 174 deletions
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 8beea40697d..433ea605f70 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -519,18 +519,100 @@ enum sci_status scic_sds_phy_event_handler(
519 return sci_phy->state_handlers->event_handler(sci_phy, event_code); 519 return sci_phy->state_handlers->event_handler(sci_phy, event_code);
520} 520}
521 521
522/** 522enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
523 * This method will process the frame index received. 523 u32 frame_index)
524 * @sci_phy:
525 * @frame_index:
526 *
527 * enum sci_status
528 */
529enum sci_status scic_sds_phy_frame_handler(
530 struct scic_sds_phy *sci_phy,
531 u32 frame_index)
532{ 524{
533 return sci_phy->state_handlers->frame_handler(sci_phy, frame_index); 525 enum scic_sds_phy_states state = sci_phy->state_machine.current_state_id;
526 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
527 enum sci_status result;
528
529 switch (state) {
530 case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF: {
531 u32 *frame_words;
532 struct sas_identify_frame iaf;
533 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
534
535 result = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
536 frame_index,
537 (void **)&frame_words);
538
539 if (result != SCI_SUCCESS)
540 return result;
541
542 sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32));
543 if (iaf.frame_type == 0) {
544 u32 state;
545
546 memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf));
547 if (iaf.smp_tport) {
548 /* We got the IAF for an expander PHY go to the final
549 * state since there are no power requirements for
550 * expander phys.
551 */
552 state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL;
553 } else {
554 /* We got the IAF we can now go to the await spinup
555 * semaphore state
556 */
557 state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER;
558 }
559 sci_base_state_machine_change_state(&sci_phy->state_machine,
560 state);
561 result = SCI_SUCCESS;
562 } else
563 dev_warn(sciphy_to_dev(sci_phy),
564 "%s: PHY starting substate machine received "
565 "unexpected frame id %x\n",
566 __func__, frame_index);
567
568 scic_sds_controller_release_frame(scic, frame_index);
569 return result;
570 }
571 case SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF: {
572 struct dev_to_host_fis *frame_header;
573 u32 *fis_frame_data;
574 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
575
576 result = scic_sds_unsolicited_frame_control_get_header(
577 &(scic_sds_phy_get_controller(sci_phy)->uf_control),
578 frame_index,
579 (void **)&frame_header);
580
581 if (result != SCI_SUCCESS)
582 return result;
583
584 if ((frame_header->fis_type == FIS_REGD2H) &&
585 !(frame_header->status & ATA_BUSY)) {
586 scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control,
587 frame_index,
588 (void **)&fis_frame_data);
589
590 scic_sds_controller_copy_sata_response(&iphy->frame_rcvd.fis,
591 frame_header,
592 fis_frame_data);
593
594 /* got IAF we can now go to the await spinup semaphore state */
595 sci_base_state_machine_change_state(&sci_phy->state_machine,
596 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
597
598 result = SCI_SUCCESS;
599 } else
600 dev_warn(sciphy_to_dev(sci_phy),
601 "%s: PHY starting substate machine received "
602 "unexpected frame id %x\n",
603 __func__, frame_index);
604
605 /* Regardless of the result we are done with this frame with it */
606 scic_sds_controller_release_frame(scic, frame_index);
607
608 return result;
609 }
610 default:
611 dev_dbg(sciphy_to_dev(sci_phy),
612 "%s: in wrong state: %d\n", __func__, state);
613 return SCI_FAILURE_INVALID_STATE;
614 }
615
534} 616}
535 617
536/** 618/**
@@ -1069,141 +1151,6 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handle
1069 return result; 1151 return result;
1070} 1152}
1071 1153
1072
1073/*
1074 * *****************************************************************************
1075 * * SCIC SDS PHY FRAME_HANDLERS
1076 * ***************************************************************************** */
1077
1078/**
1079 *
1080 * @phy: This is struct scic_sds_phy object which is being requested to decode the
1081 * frame data.
1082 * @frame_index: This is the index of the unsolicited frame which was received
1083 * for this phy.
1084 *
1085 * This method decodes the unsolicited frame when the struct scic_sds_phy is in the
1086 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Get the UF Header - If the UF
1087 * is an IAF - Copy IAF data to local phy object IAF data buffer. - Change
1088 * starting substate to wait power. - else - log warning message of unexpected
1089 * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS
1090 */
1091static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler(
1092 struct scic_sds_phy *sci_phy, u32 frame_index)
1093{
1094 enum sci_status result;
1095 u32 *frame_words;
1096 struct sas_identify_frame iaf;
1097 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
1098
1099 result = scic_sds_unsolicited_frame_control_get_header(
1100 &(scic_sds_phy_get_controller(sci_phy)->uf_control),
1101 frame_index,
1102 (void **)&frame_words);
1103
1104 if (result != SCI_SUCCESS)
1105 return result;
1106
1107 sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32));
1108 if (iaf.frame_type == 0) {
1109 u32 state;
1110
1111 memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf));
1112 if (iaf.smp_tport) {
1113 /* We got the IAF for an expander PHY go to the final
1114 * state since there are no power requirements for
1115 * expander phys.
1116 */
1117 state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL;
1118 } else {
1119 /* We got the IAF we can now go to the await spinup
1120 * semaphore state
1121 */
1122 state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER;
1123 }
1124 sci_base_state_machine_change_state(
1125 &sci_phy->state_machine,
1126 state);
1127 result = SCI_SUCCESS;
1128 } else
1129 dev_warn(sciphy_to_dev(sci_phy),
1130 "%s: PHY starting substate machine received "
1131 "unexpected frame id %x\n",
1132 __func__,
1133 frame_index);
1134
1135 scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
1136 frame_index);
1137
1138 return result;
1139}
1140
1141/**
1142 *
1143 * @phy: This is struct scic_sds_phy object which is being requested to decode the
1144 * frame data.
1145 * @frame_index: This is the index of the unsolicited frame which was received
1146 * for this phy.
1147 *
1148 * This method decodes the unsolicited frame when the struct scic_sds_phy is in the
1149 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Get the UF Header - If
1150 * the UF is an SIGNATURE FIS - Copy IAF data to local phy object SIGNATURE FIS
1151 * data buffer. - else - log warning message of unexpected unsolicted frame -
1152 * release frame buffer enum sci_status SCI_SUCCESS Must decode the SIGNATURE FIS
1153 * data
1154 */
1155static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler(
1156 struct scic_sds_phy *sci_phy,
1157 u32 frame_index)
1158{
1159 enum sci_status result;
1160 struct dev_to_host_fis *frame_header;
1161 u32 *fis_frame_data;
1162 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
1163
1164 result = scic_sds_unsolicited_frame_control_get_header(
1165 &(scic_sds_phy_get_controller(sci_phy)->uf_control),
1166 frame_index,
1167 (void **)&frame_header);
1168
1169 if (result != SCI_SUCCESS)
1170 return result;
1171
1172 if ((frame_header->fis_type == FIS_REGD2H) &&
1173 !(frame_header->status & ATA_BUSY)) {
1174 scic_sds_unsolicited_frame_control_get_buffer(
1175 &(scic_sds_phy_get_controller(sci_phy)->uf_control),
1176 frame_index,
1177 (void **)&fis_frame_data);
1178
1179 scic_sds_controller_copy_sata_response(&iphy->frame_rcvd.fis,
1180 frame_header,
1181 fis_frame_data);
1182
1183 /* got IAF we can now go to the await spinup semaphore state */
1184 sci_base_state_machine_change_state(&sci_phy->state_machine,
1185 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
1186
1187 result = SCI_SUCCESS;
1188 } else
1189 dev_warn(sciphy_to_dev(sci_phy),
1190 "%s: PHY starting substate machine received "
1191 "unexpected frame id %x\n",
1192 __func__,
1193 frame_index);
1194
1195 /* Regardless of the result we are done with this frame with it */
1196 scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
1197 frame_index);
1198
1199 return result;
1200}
1201
1202/*
1203 * *****************************************************************************
1204 * * SCIC SDS PHY POWER_HANDLERS
1205 * ***************************************************************************** */
1206
1207/* 1154/*
1208 * This method is called by the struct scic_sds_controller when the phy object is 1155 * This method is called by the struct scic_sds_controller when the phy object is
1209 * granted power. - The notify enable spinups are turned on for this phy object 1156 * granted power. - The notify enable spinups are turned on for this phy object
@@ -1268,18 +1215,6 @@ static enum sci_status default_phy_handler(struct scic_sds_phy *sci_phy,
1268} 1215}
1269 1216
1270static enum sci_status 1217static enum sci_status
1271scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy,
1272 u32 frame_index)
1273{
1274 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
1275
1276 default_phy_handler(sci_phy, __func__);
1277 scic_sds_controller_release_frame(scic, frame_index);
1278
1279 return SCI_FAILURE_INVALID_STATE;
1280}
1281
1282static enum sci_status
1283scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy, 1218scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy,
1284 u32 event_code) 1219 u32 event_code)
1285{ 1220{
@@ -1367,82 +1302,66 @@ static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sd
1367 1302
1368static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = { 1303static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = {
1369 [SCI_BASE_PHY_STATE_INITIAL] = { 1304 [SCI_BASE_PHY_STATE_INITIAL] = {
1370 .frame_handler = scic_sds_phy_default_frame_handler,
1371 .event_handler = scic_sds_phy_default_event_handler, 1305 .event_handler = scic_sds_phy_default_event_handler,
1372 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1306 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1373 }, 1307 },
1374 [SCI_BASE_PHY_STATE_STOPPED] = { 1308 [SCI_BASE_PHY_STATE_STOPPED] = {
1375 .frame_handler = scic_sds_phy_default_frame_handler,
1376 .event_handler = scic_sds_phy_default_event_handler, 1309 .event_handler = scic_sds_phy_default_event_handler,
1377 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1310 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1378 }, 1311 },
1379 [SCI_BASE_PHY_STATE_STARTING] = { 1312 [SCI_BASE_PHY_STATE_STARTING] = {
1380 .frame_handler = scic_sds_phy_default_frame_handler,
1381 .event_handler = scic_sds_phy_default_event_handler, 1313 .event_handler = scic_sds_phy_default_event_handler,
1382 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1314 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1383 }, 1315 },
1384 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { 1316 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
1385 .frame_handler = scic_sds_phy_default_frame_handler,
1386 .event_handler = scic_sds_phy_default_event_handler, 1317 .event_handler = scic_sds_phy_default_event_handler,
1387 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1318 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1388 }, 1319 },
1389 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { 1320 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
1390 .frame_handler = scic_sds_phy_default_frame_handler,
1391 .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler, 1321 .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler,
1392 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1322 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1393 }, 1323 },
1394 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { 1324 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
1395 .frame_handler = scic_sds_phy_default_frame_handler,
1396 .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler, 1325 .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler,
1397 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1326 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1398 }, 1327 },
1399 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { 1328 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
1400 .frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler,
1401 .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler, 1329 .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler,
1402 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1330 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1403 }, 1331 },
1404 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { 1332 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
1405 .frame_handler = scic_sds_phy_default_frame_handler,
1406 .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler, 1333 .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler,
1407 .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler 1334 .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
1408 }, 1335 },
1409 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { 1336 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
1410 .frame_handler = scic_sds_phy_default_frame_handler,
1411 .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler, 1337 .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler,
1412 .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler 1338 .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
1413 }, 1339 },
1414 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { 1340 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
1415 .frame_handler = scic_sds_phy_default_frame_handler,
1416 .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler, 1341 .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler,
1417 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1342 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1418 }, 1343 },
1419 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { 1344 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
1420 .frame_handler = scic_sds_phy_default_frame_handler,
1421 .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler, 1345 .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler,
1422 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1346 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1423 }, 1347 },
1424 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { 1348 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
1425 .frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler,
1426 .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler, 1349 .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler,
1427 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1350 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1428 }, 1351 },
1429 [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { 1352 [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
1430 .frame_handler = scic_sds_phy_default_frame_handler,
1431 .event_handler = scic_sds_phy_default_event_handler, 1353 .event_handler = scic_sds_phy_default_event_handler,
1432 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1354 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1433 }, 1355 },
1434 [SCI_BASE_PHY_STATE_READY] = { 1356 [SCI_BASE_PHY_STATE_READY] = {
1435 .frame_handler = scic_sds_phy_default_frame_handler,
1436 .event_handler = scic_sds_phy_ready_state_event_handler, 1357 .event_handler = scic_sds_phy_ready_state_event_handler,
1437 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1358 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1438 }, 1359 },
1439 [SCI_BASE_PHY_STATE_RESETTING] = { 1360 [SCI_BASE_PHY_STATE_RESETTING] = {
1440 .frame_handler = scic_sds_phy_default_frame_handler,
1441 .event_handler = scic_sds_phy_resetting_state_event_handler, 1361 .event_handler = scic_sds_phy_resetting_state_event_handler,
1442 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1362 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1443 }, 1363 },
1444 [SCI_BASE_PHY_STATE_FINAL] = { 1364 [SCI_BASE_PHY_STATE_FINAL] = {
1445 .frame_handler = scic_sds_phy_default_frame_handler,
1446 .event_handler = scic_sds_phy_default_event_handler, 1365 .event_handler = scic_sds_phy_default_event_handler,
1447 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1366 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1448 } 1367 }