Line data Source code
1 : /**
2 : * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "ns_recovery_lite.h"
12 :
13 : namespace hccl {
14 :
15 6 : NsRecoveryLite::NsRecoveryLite() {}
16 :
17 3 : void NsRecoveryLite::Init(
18 : const std::shared_ptr<HDCommunicate>& kfcControlTransferH2D,
19 : const std::shared_ptr<HDCommunicate>& kfcStatusTransferD2H)
20 : {
21 3 : hdcHandler_ = std::make_unique<HcclAicpuHdcHandler>(kfcControlTransferH2D, kfcStatusTransferD2H);
22 3 : }
23 :
24 1 : Hccl::KfcCommand NsRecoveryLite::BackGroundGetCmd()
25 : {
26 1 : std::unique_lock<std::mutex> lock(hdcShmLock_);
27 1 : Hccl::KfcCommand cmd{Hccl::KfcCommand::NONE};
28 1 : auto ret = hdcHandler_->GetKfcCommand(cmd);
29 1 : if (ret != HCCL_SUCCESS) {
30 1 : HCCL_ERROR("BackGroundGetCmd failed, ret = 0x%016llx, cmd = %s", HCCL_ERROR_CODE(ret), cmd.Describe().c_str());
31 : }
32 1 : return cmd;
33 1 : }
34 :
35 1 : void NsRecoveryLite::BackGroundSetStatus(Hccl::KfcStatus status, Hccl::KfcErrType errorCode)
36 : {
37 1 : std::unique_lock<std::mutex> lock(hdcShmLock_);
38 1 : hdcHandler_->SetKfcExecStatus(status, errorCode);
39 1 : }
40 :
41 3 : void NsRecoveryLite::SetNeedClean(bool flag) { needClean_ = flag; }
42 4 : bool NsRecoveryLite::IsNeedClean() const { return needClean_; }
43 :
44 : } // namespace hccl
|