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 :
16 5 : NsRecoveryLite::NsRecoveryLite()
17 5 : {}
18 :
19 2 : void NsRecoveryLite::Init(const std::shared_ptr<HDCommunicate>& kfcControlTransferH2D,
20 : const std::shared_ptr<HDCommunicate>& kfcStatusTransferD2H)
21 : {
22 2 : hdcHandler_ = std::make_unique<HcclAicpuHdcHandler>(kfcControlTransferH2D, kfcStatusTransferD2H);
23 2 : }
24 :
25 1 : Hccl::KfcCommand NsRecoveryLite::BackGroundGetCmd()
26 : {
27 1 : std::unique_lock<std::mutex> lock(hdcShmLock_);
28 1 : Hccl::KfcCommand cmd{Hccl::KfcCommand::NONE};
29 1 : auto ret = hdcHandler_->GetKfcCommand(cmd);
30 1 : if (ret != HCCL_SUCCESS) {
31 1 : HCCL_ERROR("BackGroundGetCmd failed, ret = 0x%016llx, cmd = %s", HCCL_ERROR_CODE(ret), cmd.Describe().c_str());
32 : }
33 1 : return cmd;
34 1 : }
35 :
36 1 : void NsRecoveryLite::BackGroundSetStatus(Hccl::KfcStatus status, Hccl::KfcErrType errorCode)
37 : {
38 1 : std::unique_lock<std::mutex> lock(hdcShmLock_);
39 1 : hdcHandler_->SetKfcExecStatus(status, errorCode);
40 1 : }
41 :
42 3 : void NsRecoveryLite::SetNeedClean(bool flag)
43 : {
44 3 : needClean_ = flag;
45 3 : }
46 4 : bool NsRecoveryLite::IsNeedClean() const
47 : {
48 4 : return needClean_;
49 : }
50 :
51 : }
|