Lines Matching +full:sync +full:- +full:update +full:- +full:mask
1 /*-
4 * SPDX-License-Identifier: BSD-3-Clause
36 /*-
41 * Support from LSI-Logic has also gone a great deal toward making this a
75 (((MSG_RAID_ACTION_REQUEST *)(req->req_vbuf)) + 1))
77 #define REQ_IOCSTATUS(req) ((req)->IOCStatus & MPI_IOCSTATUS_MASK)
139 switch (vol->config_page->VolumeType) { in mpt_vol_type()
141 return ("RAID-0"); in mpt_vol_type()
143 return ("RAID-1E"); in mpt_vol_type()
145 return ("RAID-1"); in mpt_vol_type()
154 switch (vol->config_page->VolumeStatus.State) { in mpt_vol_state()
169 switch (disk->config_page.PhysDiskStatus.State) { in mpt_disk_state()
197 printf("%s:vol%d(%s:%d:%d): ", device_get_nameunit(mpt->dev), in mpt_vol_prt()
198 (u_int)(vol - mpt->raid_volumes), device_get_nameunit(mpt->dev), in mpt_vol_prt()
199 vol->config_page->VolumeBus, vol->config_page->VolumeID); in mpt_vol_prt()
211 if (disk->volume != NULL) { in mpt_disk_prt()
213 device_get_nameunit(mpt->dev), in mpt_disk_prt()
214 disk->volume->config_page->VolumeID, in mpt_disk_prt()
215 disk->member_number); in mpt_disk_prt()
217 printf("(%s:%d:%d): ", device_get_nameunit(mpt->dev), in mpt_disk_prt()
218 disk->config_page.PhysDiskBus, in mpt_disk_prt()
219 disk->config_page.PhysDiskID); in mpt_disk_prt()
245 cgd->ccb_h.target_id); in mpt_raid_async()
248 if ((mpt_vol->flags & MPT_RVF_ACTIVE) == 0) in mpt_raid_async()
251 if (mpt_vol->config_page->VolumeID in mpt_raid_async()
252 == cgd->ccb_h.target_id) { in mpt_raid_async()
267 if (mpt->ioc_page2 == NULL || mpt->ioc_page2->MaxPhysDisks == 0) { in mpt_raid_probe()
280 mpt_callout_init(mpt, &mpt->raid_timer); in mpt_raid_attach()
298 xpt_setup_ccb(&csa.ccb_h, mpt->path, 5); in mpt_raid_attach()
331 mpt_callout_drain(mpt, &mpt->raid_timer); in mpt_raid_detach()
339 xpt_setup_ccb(&csa.ccb_h, mpt->path, /*priority*/5); in mpt_raid_detach()
382 if (msg->Event != MPI_EVENT_INTEGRATED_RAID) { in mpt_raid_event()
386 raid_event = (EVENT_DATA_RAID *)&msg->Data; in mpt_raid_event()
390 if (mpt->raid_volumes != NULL && mpt->ioc_page2 != NULL) { in mpt_raid_event()
391 for (i = 0; i < mpt->ioc_page2->MaxVolumes; i++) { in mpt_raid_event()
392 mpt_vol = &mpt->raid_volumes[i]; in mpt_raid_event()
393 vol_pg = mpt_vol->config_page; in mpt_raid_event()
395 if ((mpt_vol->flags & MPT_RVF_ACTIVE) == 0) in mpt_raid_event()
398 if (vol_pg->VolumeID == raid_event->VolumeID in mpt_raid_event()
399 && vol_pg->VolumeBus == raid_event->VolumeBus) in mpt_raid_event()
402 if (i >= mpt->ioc_page2->MaxVolumes) { in mpt_raid_event()
409 if (raid_event->PhysDiskNum != 0xFF && mpt->raid_disks != NULL) { in mpt_raid_event()
410 mpt_disk = mpt->raid_disks + raid_event->PhysDiskNum; in mpt_raid_event()
411 if ((mpt_disk->flags & MPT_RDF_ACTIVE) == 0) { in mpt_raid_event()
417 switch(raid_event->ReasonCode) { in mpt_raid_event()
423 if ((mpt_vol->flags & MPT_RVF_UP2DATE) != 0) { in mpt_raid_event()
424 mpt_vol->flags &= ~MPT_RVF_UP2DATE; in mpt_raid_event()
438 mpt->raid_rescan++; in mpt_raid_event()
440 mpt_vol->flags &= ~(MPT_RVF_UP2DATE|MPT_RVF_ANNOUNCED); in mpt_raid_event()
445 mpt->raid_rescan++; in mpt_raid_event()
449 mpt->raid_rescan++; in mpt_raid_event()
451 mpt_disk->flags &= ~MPT_RDF_UP2DATE; in mpt_raid_event()
455 mpt->raid_rescan++; in mpt_raid_event()
468 mpt_prt(mpt, "Volume(%d:%d", raid_event->VolumeBus, in mpt_raid_event()
469 raid_event->VolumeID); in mpt_raid_event()
471 if (raid_event->PhysDiskNum != 0xFF) in mpt_raid_event()
473 raid_event->PhysDiskNum); in mpt_raid_event()
478 if (raid_event->ReasonCode >= NUM_ELEMENTS(raid_event_txt)) in mpt_raid_event()
480 raid_event->ReasonCode); in mpt_raid_event()
483 raid_event_txt[raid_event->ReasonCode]); in mpt_raid_event()
486 if (raid_event->ReasonCode == MPI_EVENT_RAID_RC_SMART_DATA) { in mpt_raid_event()
492 raid_event->VolumeBus, raid_event->VolumeID, in mpt_raid_event()
493 raid_event->PhysDiskNum); in mpt_raid_event()
495 raid_event->ASC, raid_event->ASCQ); in mpt_raid_event()
507 if (mpt->raid_mwce_setting != MPT_RAID_MWCE_REBUILD_ONLY) { in mpt_raid_shutdown()
511 mpt->raid_mwce_setting = MPT_RAID_MWCE_OFF; in mpt_raid_shutdown()
530 else if (req->ccb != NULL) { in mpt_raid_reply_handler()
535 req->state &= ~REQ_STATE_QUEUED; in mpt_raid_reply_handler()
536 req->state |= REQ_STATE_DONE; in mpt_raid_reply_handler()
537 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_raid_reply_handler()
539 if ((req->state & REQ_STATE_NEED_WAKEUP) != 0) { in mpt_raid_reply_handler()
561 req->IOCStatus = le16toh(reply->IOCStatus); in mpt_raid_reply_frame_handler()
562 rap = (MSG_RAID_ACTION_REQUEST *)req->req_vbuf; in mpt_raid_reply_frame_handler()
564 switch (rap->Action) { in mpt_raid_reply_frame_handler()
575 memcpy(&action_result->action_data, &reply->ActionData, in mpt_raid_reply_frame_handler()
576 sizeof(action_result->action_data)); in mpt_raid_reply_frame_handler()
577 action_result->action_status = le16toh(reply->ActionStatus); in mpt_raid_reply_frame_handler()
593 rap = req->req_vbuf; in mpt_issue_raid_req()
595 rap->Action = Action; in mpt_issue_raid_req()
596 rap->ActionDataWord = htole32(ActionDataWord); in mpt_issue_raid_req()
597 rap->Function = MPI_FUNCTION_RAID_ACTION; in mpt_issue_raid_req()
598 rap->VolumeID = vol->config_page->VolumeID; in mpt_issue_raid_req()
599 rap->VolumeBus = vol->config_page->VolumeBus; in mpt_issue_raid_req()
601 rap->PhysDiskNum = disk->config_page.PhysDiskNum; in mpt_issue_raid_req()
603 rap->PhysDiskNum = 0xFF; in mpt_issue_raid_req()
604 se = (SGE_SIMPLE32 *)&rap->ActionDataSGE; in mpt_issue_raid_req()
605 se->Address = htole32(addr); in mpt_issue_raid_req()
611 se->FlagsLength = htole32(se->FlagsLength); in mpt_issue_raid_req()
612 rap->MsgContext = htole32(req->index | raid_handler_id); in mpt_issue_raid_req()
633 * is able to run at least once. We need to update in mpt_spawn_raid_thread()
639 xpt_freeze_simq(mpt->phydisk_sim, 1); in mpt_spawn_raid_thread()
642 &mpt->raid_thread, /*flags*/0, /*altstack*/0, in mpt_spawn_raid_thread()
643 "mpt_raid%d", mpt->unit); in mpt_spawn_raid_thread()
646 xpt_release_simq(mpt->phydisk_sim, /*run_queue*/FALSE); in mpt_spawn_raid_thread()
656 if (mpt->raid_thread == NULL) { in mpt_terminate_raid_thread()
659 mpt->shutdwn_raid = 1; in mpt_terminate_raid_thread()
660 wakeup(&mpt->raid_volumes); in mpt_terminate_raid_thread()
665 mpt_sleep(mpt, &mpt->raid_thread, PUSER, "thtrm", 0); in mpt_terminate_raid_thread()
677 while (mpt->shutdwn_raid == 0) { in mpt_raid_thread()
678 if (mpt->raid_wakeup == 0) { in mpt_raid_thread()
679 mpt_sleep(mpt, &mpt->raid_volumes, PUSER, "idle", 0); in mpt_raid_thread()
683 mpt->raid_wakeup = 0; in mpt_raid_thread()
696 xpt_release_simq(mpt->phydisk_sim, TRUE); in mpt_raid_thread()
699 if (mpt->raid_rescan != 0) { in mpt_raid_thread()
703 mpt->raid_rescan = 0; in mpt_raid_thread()
709 error = xpt_create_path(&ccb->ccb_h.path, NULL, in mpt_raid_thread()
710 cam_sim_path(mpt->phydisk_sim), in mpt_raid_thread()
720 mpt->raid_thread = NULL; in mpt_raid_thread()
721 wakeup(&mpt->raid_thread); in mpt_raid_thread()
742 ccb = req->ccb;
743 if ((mpt_disk->flags & MPT_RDF_QUIESCED) != 0)
746 if ((mpt_disk->flags & MPT_RDF_QUIESCING) == 0) {
749 mpt_disk->flags |= MPT_RDF_QUIESCING;
750 xpt_freeze_devq(ccb->ccb_h.path, 1);
752 rv = mpt_issue_raid_req(mpt, mpt_disk->volume, mpt_disk, req,
764 "Quiece Timed-out\n");
765 xpt_release_devq(ccb->ccb_h.path, 1, /*run*/0);
772 || (ar->action_status != MPI_RAID_ACTION_ASTATUS_SUCCESS)) {
774 "%d:%x:%x\n", rv, req->IOCStatus,
775 ar->action_status);
776 xpt_release_devq(ccb->ccb_h.path, 1, /*run*/0);
792 mpt_disk = mpt->raid_disks + ccb->ccb_h.target_id; in mpt_map_physdisk()
793 if (ccb->ccb_h.target_id < mpt->raid_max_disks in mpt_map_physdisk()
794 && (mpt_disk->flags & MPT_RDF_ACTIVE) != 0) { in mpt_map_physdisk()
795 *tgt = mpt_disk->config_page.PhysDiskID; in mpt_map_physdisk()
798 mpt_lprt(mpt, MPT_PRT_DEBUG1, "mpt_map_physdisk(%d) - Not Active\n", in mpt_map_physdisk()
799 ccb->ccb_h.target_id); in mpt_map_physdisk()
800 return (-1); in mpt_map_physdisk()
810 if (mpt->ioc_page2 == NULL || mpt->ioc_page2->MaxPhysDisks == 0) in mpt_is_raid_member()
812 for (i = 0; i < mpt->ioc_page2->MaxPhysDisks; i++) { in mpt_is_raid_member()
813 mpt_disk = &mpt->raid_disks[i]; in mpt_is_raid_member()
814 if ((mpt_disk->flags & MPT_RDF_ACTIVE) != 0 && in mpt_is_raid_member()
815 mpt_disk->config_page.PhysDiskID == tgt) in mpt_is_raid_member()
829 if (mpt->ioc_page2 == NULL || mpt->ioc_page2->MaxPhysDisks == 0) { in mpt_is_raid_volume()
832 ioc_vol = mpt->ioc_page2->RaidVolume; in mpt_is_raid_volume()
833 ioc_last_vol = ioc_vol + mpt->ioc_page2->NumActiveVolumes; in mpt_is_raid_volume()
835 if (ioc_vol->VolumeID == tgt) { in mpt_is_raid_volume()
853 vol_pg = mpt_vol->config_page;
854 enabled = vol_pg->VolumeStatus.Flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED;
878 "%s Volume Timed-out\n",
885 || (ar->action_status != MPI_RAID_ACTION_ASTATUS_SUCCESS)) {
888 rv, req->IOCStatus, ar->action_status);
906 vol_pg = mpt_vol->config_page; in mpt_verify_mwce()
907 resyncing = vol_pg->VolumeStatus.Flags in mpt_verify_mwce()
909 mwce = vol_pg->VolumeSettings.Settings in mpt_verify_mwce()
916 switch (mpt->raid_mwce_setting) { in mpt_verify_mwce()
921 mpt_vol->flags ^= MPT_RVF_WCE_CHANGED; in mpt_verify_mwce()
922 if ((mpt_vol->flags & MPT_RVF_WCE_CHANGED) == 0) { in mpt_verify_mwce()
924 * Wait one more status update to see if in mpt_verify_mwce()
950 vol_pg->VolumeSettings.Settings ^= in mpt_verify_mwce()
952 memcpy(&data, &vol_pg->VolumeSettings, sizeof(data)); in mpt_verify_mwce()
953 vol_pg->VolumeSettings.Settings ^= in mpt_verify_mwce()
961 "Write Cache Enable Timed-out\n"); in mpt_verify_mwce()
967 || (ar->action_status != MPI_RAID_ACTION_ASTATUS_SUCCESS)) { in mpt_verify_mwce()
969 "%d:%x:%x\n", rv, req->IOCStatus, in mpt_verify_mwce()
970 ar->action_status); in mpt_verify_mwce()
972 vol_pg->VolumeSettings.Settings ^= in mpt_verify_mwce()
987 vol_pg = mpt_vol->config_page; in mpt_verify_resync_rate()
989 if (mpt->raid_resync_rate == MPT_RAID_RESYNC_RATE_NC) in mpt_verify_resync_rate()
994 * match our configured rate, update it. in mpt_verify_resync_rate()
996 prio = vol_pg->VolumeSettings.Settings in mpt_verify_resync_rate()
998 if (vol_pg->ResyncRate != 0 in mpt_verify_resync_rate()
999 && vol_pg->ResyncRate != mpt->raid_resync_rate) { in mpt_verify_resync_rate()
1009 mpt->raid_resync_rate, /*addr*/0, in mpt_verify_resync_rate()
1013 "Resync Rate Setting Timed-out\n"); in mpt_verify_resync_rate()
1020 || (ar->action_status != MPI_RAID_ACTION_ASTATUS_SUCCESS)) { in mpt_verify_resync_rate()
1022 "%d:%x:%x\n", rv, req->IOCStatus, in mpt_verify_resync_rate()
1023 ar->action_status); in mpt_verify_resync_rate()
1025 vol_pg->ResyncRate = mpt->raid_resync_rate; in mpt_verify_resync_rate()
1027 } else if ((prio && mpt->raid_resync_rate < 128) in mpt_verify_resync_rate()
1028 || (!prio && mpt->raid_resync_rate >= 128)) { in mpt_verify_resync_rate()
1038 vol_pg->VolumeSettings.Settings ^= in mpt_verify_resync_rate()
1040 memcpy(&data, &vol_pg->VolumeSettings, sizeof(data)); in mpt_verify_resync_rate()
1041 vol_pg->VolumeSettings.Settings ^= in mpt_verify_resync_rate()
1049 "Resync Rate Setting Timed-out\n"); in mpt_verify_resync_rate()
1055 || (ar->action_status != MPI_RAID_ACTION_ASTATUS_SUCCESS)) { in mpt_verify_resync_rate()
1057 "%d:%x:%x\n", rv, req->IOCStatus, in mpt_verify_resync_rate()
1058 ar->action_status); in mpt_verify_resync_rate()
1060 vol_pg->VolumeSettings.Settings ^= in mpt_verify_resync_rate()
1079 crs.openings = mpt->raid_queue_depth; in mpt_adjust_queue_depth()
1092 vol_pg = mpt_vol->config_page; in mpt_announce_vol()
1095 switch (vol_pg->VolumeSettings.Settings & i) { in mpt_announce_vol()
1097 mpt_prtc(mpt, " Member-WCE"); in mpt_announce_vol()
1100 mpt_prtc(mpt, " Offline-On-SMART-Err"); in mpt_announce_vol()
1103 mpt_prtc(mpt, " Hot-Plug-Spares"); in mpt_announce_vol()
1106 mpt_prtc(mpt, " High-Priority-ReSync"); in mpt_announce_vol()
1113 if (vol_pg->VolumeSettings.HotSparePool != 0) { in mpt_announce_vol()
1115 powerof2(vol_pg->VolumeSettings.HotSparePool) in mpt_announce_vol()
1118 u_int mask; in mpt_announce_vol() local
1120 mask = 0x1 << i; in mpt_announce_vol()
1121 if ((vol_pg->VolumeSettings.HotSparePool & mask) == 0) in mpt_announce_vol()
1127 mpt_vol_prt(mpt, mpt_vol, "%d Members:\n", vol_pg->NumPhysDisks); in mpt_announce_vol()
1128 for (i = 0; i < vol_pg->NumPhysDisks; i++){ in mpt_announce_vol()
1131 int pt_bus = cam_sim_bus(mpt->phydisk_sim); in mpt_announce_vol()
1134 mpt_disk = mpt->raid_disks + vol_pg->PhysDisk[i].PhysDiskNum; in mpt_announce_vol()
1135 disk_pg = &mpt_disk->config_page; in mpt_announce_vol()
1137 mpt_prtc(mpt, "(%s:%d:%d:0): ", device_get_nameunit(mpt->dev), in mpt_announce_vol()
1138 pt_bus, disk_pg->PhysDiskID); in mpt_announce_vol()
1139 if (vol_pg->VolumeType == MPI_RAID_VOL_TYPE_IM) { in mpt_announce_vol()
1140 mpt_prtc(mpt, "%s", mpt_disk->member_number == 0? in mpt_announce_vol()
1144 mpt_disk->member_number); in mpt_announce_vol()
1146 f = disk_pg->PhysDiskStatus.Flags; in mpt_announce_vol()
1147 s = disk_pg->PhysDiskStatus.State; in mpt_announce_vol()
1149 mpt_prtc(mpt, " Out of Sync"); in mpt_announce_vol()
1161 mpt_prtc(mpt, " Was Non-Optimal"); in mpt_announce_vol()
1198 int rd_bus = cam_sim_bus(mpt->sim); in mpt_announce_disk()
1199 int pt_bus = cam_sim_bus(mpt->phydisk_sim); in mpt_announce_disk()
1202 disk_pg = &mpt_disk->config_page; in mpt_announce_disk()
1204 "Physical (%s:%d:%d:0), Pass-thru (%s:%d:%d:0)\n", in mpt_announce_disk()
1205 device_get_nameunit(mpt->dev), rd_bus, in mpt_announce_disk()
1206 disk_pg->PhysDiskID, device_get_nameunit(mpt->dev), in mpt_announce_disk()
1207 pt_bus, mpt_disk - mpt->raid_disks); in mpt_announce_disk()
1208 if (disk_pg->PhysDiskSettings.HotSparePool == 0) in mpt_announce_disk()
1211 powerof2(disk_pg->PhysDiskSettings.HotSparePool) in mpt_announce_disk()
1214 u_int mask; in mpt_announce_disk() local
1216 mask = 0x1 << i; in mpt_announce_disk()
1217 if ((disk_pg->PhysDiskSettings.HotSparePool & mask) == 0) in mpt_announce_disk()
1231 /*PageNumber*/0, ioc_disk->PhysDiskNum, in mpt_refresh_raid_disk()
1232 &mpt_disk->config_page.Header, in mpt_refresh_raid_disk()
1237 ioc_disk->PhysDiskNum); in mpt_refresh_raid_disk()
1240 rv = mpt_read_cur_cfg_page(mpt, ioc_disk->PhysDiskNum, in mpt_refresh_raid_disk()
1241 &mpt_disk->config_page.Header, in mpt_refresh_raid_disk()
1242 sizeof(mpt_disk->config_page), in mpt_refresh_raid_disk()
1247 ioc_disk->PhysDiskNum); in mpt_refresh_raid_disk()
1248 mpt2host_config_page_raid_phys_disk_0(&mpt_disk->config_page); in mpt_refresh_raid_disk()
1261 vol_pg = mpt_vol->config_page; in mpt_refresh_raid_vol()
1262 mpt_vol->flags &= ~MPT_RVF_UP2DATE; in mpt_refresh_raid_vol()
1265 ioc_vol->VolumePageNumber, &vol_pg->Header, TRUE, 5000); in mpt_refresh_raid_vol()
1269 ioc_vol->VolumePageNumber); in mpt_refresh_raid_vol()
1273 rv = mpt_read_cur_cfg_page(mpt, ioc_vol->VolumePageNumber, in mpt_refresh_raid_vol()
1274 &vol_pg->Header, mpt->raid_page0_len, TRUE, 5000); in mpt_refresh_raid_vol()
1278 ioc_vol->VolumePageNumber); in mpt_refresh_raid_vol()
1283 mpt_vol->flags |= MPT_RVF_ACTIVE; in mpt_refresh_raid_vol()
1285 /* Update disk entry array data. */ in mpt_refresh_raid_vol()
1286 for (i = 0; i < vol_pg->NumPhysDisks; i++) { in mpt_refresh_raid_vol()
1288 mpt_disk = mpt->raid_disks + vol_pg->PhysDisk[i].PhysDiskNum; in mpt_refresh_raid_vol()
1289 mpt_disk->volume = mpt_vol; in mpt_refresh_raid_vol()
1290 mpt_disk->member_number = vol_pg->PhysDisk[i].PhysDiskMap; in mpt_refresh_raid_vol()
1291 if (vol_pg->VolumeType == MPI_RAID_VOL_TYPE_IM) { in mpt_refresh_raid_vol()
1292 mpt_disk->member_number--; in mpt_refresh_raid_vol()
1296 if ((vol_pg->VolumeStatus.Flags in mpt_refresh_raid_vol()
1317 && ar->action_status == MPI_RAID_ACTION_ASTATUS_SUCCESS in mpt_refresh_raid_vol()
1319 memcpy(&mpt_vol->sync_progress, in mpt_refresh_raid_vol()
1320 &ar->action_data.indicator_struct, in mpt_refresh_raid_vol()
1321 sizeof(mpt_vol->sync_progress)); in mpt_refresh_raid_vol()
1322 mpt2host_mpi_raid_vol_indicator(&mpt_vol->sync_progress); in mpt_refresh_raid_vol()
1331 * Update in-core information about RAID support. We update any entries
1349 if (mpt->ioc_page2 == NULL || mpt->ioc_page3 == NULL) { in mpt_refresh_raid_data()
1358 for (i = 0; i < mpt->ioc_page2->MaxPhysDisks; i++) { in mpt_refresh_raid_data()
1359 mpt->raid_disks[i].flags &= ~MPT_RDF_REFERENCED; in mpt_refresh_raid_data()
1361 for (i = 0; i < mpt->ioc_page2->MaxVolumes; i++) { in mpt_refresh_raid_data()
1362 mpt->raid_volumes[i].flags &= ~MPT_RVF_REFERENCED; in mpt_refresh_raid_data()
1368 len = mpt->ioc_page3->Header.PageLength * sizeof(uint32_t); in mpt_refresh_raid_data()
1370 &mpt->ioc_page3->Header, len, in mpt_refresh_raid_data()
1375 return (-1); in mpt_refresh_raid_data()
1377 mpt2host_config_page_ioc3(mpt->ioc_page3); in mpt_refresh_raid_data()
1379 ioc_disk = mpt->ioc_page3->PhysDisk; in mpt_refresh_raid_data()
1380 ioc_last_disk = ioc_disk + mpt->ioc_page3->NumPhysDisks; in mpt_refresh_raid_data()
1384 mpt_disk = mpt->raid_disks + ioc_disk->PhysDiskNum; in mpt_refresh_raid_data()
1385 mpt_disk->flags |= MPT_RDF_REFERENCED; in mpt_refresh_raid_data()
1386 if ((mpt_disk->flags & (MPT_RDF_ACTIVE|MPT_RDF_UP2DATE)) in mpt_refresh_raid_data()
1390 mpt_disk->flags |= MPT_RDF_ACTIVE; in mpt_refresh_raid_data()
1391 mpt->raid_rescan++; in mpt_refresh_raid_data()
1397 len = mpt->ioc_page2->Header.PageLength * sizeof(uint32_t); in mpt_refresh_raid_data()
1399 &mpt->ioc_page2->Header, len, in mpt_refresh_raid_data()
1404 return (-1); in mpt_refresh_raid_data()
1406 mpt2host_config_page_ioc2(mpt->ioc_page2); in mpt_refresh_raid_data()
1408 ioc_vol = mpt->ioc_page2->RaidVolume; in mpt_refresh_raid_data()
1409 ioc_last_vol = ioc_vol + mpt->ioc_page2->NumActiveVolumes; in mpt_refresh_raid_data()
1413 mpt_vol = mpt->raid_volumes + ioc_vol->VolumePageNumber; in mpt_refresh_raid_data()
1414 mpt_vol->flags |= MPT_RVF_REFERENCED; in mpt_refresh_raid_data()
1415 vol_pg = mpt_vol->config_page; in mpt_refresh_raid_data()
1418 if (((mpt_vol->flags & (MPT_RVF_ACTIVE|MPT_RVF_UP2DATE)) in mpt_refresh_raid_data()
1420 || (vol_pg->VolumeStatus.Flags in mpt_refresh_raid_data()
1424 mpt_vol->flags |= MPT_RVF_ACTIVE; in mpt_refresh_raid_data()
1428 for (i = 0; i < mpt->ioc_page2->MaxVolumes; i++) { in mpt_refresh_raid_data()
1435 mpt_vol = &mpt->raid_volumes[i]; in mpt_refresh_raid_data()
1437 if ((mpt_vol->flags & MPT_RVF_ACTIVE) == 0) { in mpt_refresh_raid_data()
1441 vol_pg = mpt_vol->config_page; in mpt_refresh_raid_data()
1442 if ((mpt_vol->flags & (MPT_RVF_REFERENCED|MPT_RVF_ANNOUNCED)) in mpt_refresh_raid_data()
1445 mpt_vol->flags = 0; in mpt_refresh_raid_data()
1449 if ((mpt_vol->flags & MPT_RVF_ANNOUNCED) == 0) { in mpt_refresh_raid_data()
1451 mpt_vol->flags |= MPT_RVF_ANNOUNCED; in mpt_refresh_raid_data()
1454 if (vol_pg->VolumeStatus.State != in mpt_refresh_raid_data()
1458 if ((mpt_vol->flags & MPT_RVF_UP2DATE) != 0) in mpt_refresh_raid_data()
1461 mpt_vol->flags |= MPT_RVF_UP2DATE; in mpt_refresh_raid_data()
1462 mpt_vol_prt(mpt, mpt_vol, "%s - %s\n", in mpt_refresh_raid_data()
1466 if (vol_pg->VolumeStatus.Flags == 0) { in mpt_refresh_raid_data()
1472 switch (vol_pg->VolumeStatus.Flags & m) { in mpt_refresh_raid_data()
1480 mpt_prtc(mpt, " Re-Syncing"); in mpt_refresh_raid_data()
1491 if ((vol_pg->VolumeStatus.Flags in mpt_refresh_raid_data()
1497 left = MPT_U64_2_SCALAR(mpt_vol->sync_progress.BlocksRemaining); in mpt_refresh_raid_data()
1498 total = MPT_U64_2_SCALAR(mpt_vol->sync_progress.TotalBlocks); in mpt_refresh_raid_data()
1499 if (vol_pg->ResyncRate != 0) { in mpt_refresh_raid_data()
1500 prio = ((u_int)vol_pg->ResyncRate * 100000) / 0xFF; in mpt_refresh_raid_data()
1504 prio = vol_pg->VolumeSettings.Settings in mpt_refresh_raid_data()
1506 mpt_vol_prt(mpt, mpt_vol, "%s Priority Re-Sync\n", in mpt_refresh_raid_data()
1513 /* Periodically report on sync progress. */ in mpt_refresh_raid_data()
1517 for (i = 0; i < mpt->ioc_page2->MaxPhysDisks; i++) { in mpt_refresh_raid_data()
1522 mpt_disk = &mpt->raid_disks[i]; in mpt_refresh_raid_data()
1523 disk_pg = &mpt_disk->config_page; in mpt_refresh_raid_data()
1525 if ((mpt_disk->flags & MPT_RDF_ACTIVE) == 0) in mpt_refresh_raid_data()
1528 if ((mpt_disk->flags & (MPT_RDF_REFERENCED|MPT_RDF_ANNOUNCED)) in mpt_refresh_raid_data()
1531 mpt_disk->flags = 0; in mpt_refresh_raid_data()
1532 mpt->raid_rescan++; in mpt_refresh_raid_data()
1536 if ((mpt_disk->flags & MPT_RDF_ANNOUNCED) == 0) { in mpt_refresh_raid_data()
1538 mpt_disk->flags |= MPT_RVF_ANNOUNCED; in mpt_refresh_raid_data()
1541 if ((mpt_disk->flags & MPT_RDF_UP2DATE) != 0) in mpt_refresh_raid_data()
1544 mpt_disk->flags |= MPT_RDF_UP2DATE; in mpt_refresh_raid_data()
1546 if (disk_pg->PhysDiskStatus.Flags == 0) in mpt_refresh_raid_data()
1551 switch (disk_pg->PhysDiskStatus.Flags & m) { in mpt_refresh_raid_data()
1553 mpt_prtc(mpt, " Out-Of-Sync"); in mpt_refresh_raid_data()
1565 mpt->raid_nonopt_volumes = nonopt_volumes; in mpt_refresh_raid_data()
1583 callout_reset(&mpt->raid_timer, MPT_RAID_SYNC_REPORT_INTERVAL, in mpt_schedule_raid_refresh()
1591 if (mpt->raid_volumes) { in mpt_raid_free_mem()
1594 for (i = 0; i < mpt->raid_max_volumes; i++) { in mpt_raid_free_mem()
1595 mpt_raid = &mpt->raid_volumes[i]; in mpt_raid_free_mem()
1596 if (mpt_raid->config_page) { in mpt_raid_free_mem()
1597 free(mpt_raid->config_page, M_DEVBUF); in mpt_raid_free_mem()
1598 mpt_raid->config_page = NULL; in mpt_raid_free_mem()
1601 free(mpt->raid_volumes, M_DEVBUF); in mpt_raid_free_mem()
1602 mpt->raid_volumes = NULL; in mpt_raid_free_mem()
1604 if (mpt->raid_disks) { in mpt_raid_free_mem()
1605 free(mpt->raid_disks, M_DEVBUF); in mpt_raid_free_mem()
1606 mpt->raid_disks = NULL; in mpt_raid_free_mem()
1608 if (mpt->ioc_page2) { in mpt_raid_free_mem()
1609 free(mpt->ioc_page2, M_DEVBUF); in mpt_raid_free_mem()
1610 mpt->ioc_page2 = NULL; in mpt_raid_free_mem()
1612 if (mpt->ioc_page3) { in mpt_raid_free_mem()
1613 free(mpt->ioc_page3, M_DEVBUF); in mpt_raid_free_mem()
1614 mpt->ioc_page3 = NULL; in mpt_raid_free_mem()
1616 mpt->raid_max_volumes = 0; in mpt_raid_free_mem()
1617 mpt->raid_max_disks = 0; in mpt_raid_free_mem()
1631 mpt->raid_resync_rate = rate; in mpt_raid_set_vol_resync_rate()
1633 if ((mpt_vol->flags & MPT_RVF_ACTIVE) == 0) { in mpt_raid_set_vol_resync_rate()
1651 mpt->raid_queue_depth = vol_queue_depth; in mpt_raid_set_vol_queue_depth()
1656 if ((mpt_vol->flags & MPT_RVF_ACTIVE) == 0) in mpt_raid_set_vol_queue_depth()
1659 mpt->raid_rescan = 0; in mpt_raid_set_vol_queue_depth()
1662 cam_sim_path(mpt->sim), in mpt_raid_set_vol_queue_depth()
1663 mpt_vol->config_page->VolumeID, in mpt_raid_set_vol_queue_depth()
1683 if (mwce == mpt->raid_mwce_setting) { in mpt_raid_set_vol_mwce()
1695 if (mpt->raid_mwce_set == 0 in mpt_raid_set_vol_mwce()
1696 && mpt->raid_mwce_setting == MPT_RAID_MWCE_NC in mpt_raid_set_vol_mwce()
1700 mpt->raid_mwce_setting = mwce; in mpt_raid_set_vol_mwce()
1706 if ((mpt_vol->flags & MPT_RVF_ACTIVE) == 0) in mpt_raid_set_vol_mwce()
1709 vol_pg = mpt_vol->config_page; in mpt_raid_set_vol_mwce()
1710 resyncing = vol_pg->VolumeStatus.Flags in mpt_raid_set_vol_mwce()
1712 mwce = vol_pg->VolumeSettings.Settings in mpt_raid_set_vol_mwce()
1720 mpt_vol_prt(mpt, mpt_vol, "WARNING - Unsafe shutdown " in mpt_raid_set_vol_mwce()
1725 mpt->raid_mwce_set = 1; in mpt_raid_set_vol_mwce()
1734 "On-During-Rebuild",
1749 str = mpt_vol_mwce_strs[mpt->raid_mwce_setting]; in mpt_raid_sysctl_vol_member_wce()
1751 if (error || !req->newptr) { in mpt_raid_sysctl_vol_member_wce()
1755 size = req->newlen - req->newidx; in mpt_raid_sysctl_vol_member_wce()
1781 raid_resync_rate = mpt->raid_resync_rate; in mpt_raid_sysctl_vol_resync_rate()
1784 if (error || !req->newptr) { in mpt_raid_sysctl_vol_resync_rate()
1799 raid_queue_depth = mpt->raid_queue_depth; in mpt_raid_sysctl_vol_queue_depth()
1802 if (error || !req->newptr) { in mpt_raid_sysctl_vol_queue_depth()
1812 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(mpt->dev); in mpt_raid_sysctl_attach()
1813 struct sysctl_oid *tree = device_get_sysctl_tree(mpt->dev); in mpt_raid_sysctl_attach()
1818 "volume member WCE(On,Off,On-During-Rebuild,NC)"); in mpt_raid_sysctl_attach()
1828 "volume resync priority (0 == NC, 1 - 255)"); in mpt_raid_sysctl_attach()
1831 &mpt->raid_nonopt_volumes, 0, in mpt_raid_sysctl_attach()