Line data Source code
1 : /**
2 : * Copyright (c) 2025 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 : #ifndef INNER_INC_PROCESS_MODE_MANAGER_H
12 : #define INNER_INC_PROCESS_MODE_MANAGER_H
13 :
14 : #include "inc/client_manager.h"
15 : #include "inc/process_shared_context.h"
16 : #include "inc/response_msg_dispatcher.h"
17 : #include "inc/sub_process_controller.h"
18 : #include "inc/tsd_process_controller.h"
19 : #include "capability_manager.h"
20 : #include "package_manager.h"
21 : #include "device_comm.h"
22 : #include "device_comm_agent.h"
23 : #include "driver/ascend_hal.h"
24 : #include "proto/tsd_message.pb.h"
25 :
26 : namespace tsd {
27 : class ProcessModeManager : public ClientManager {
28 : public:
29 : explicit ProcessModeManager(const uint32_t deviceId, const uint32_t deviceMode);
30 :
31 : TSD_StatusT Open(const uint32_t rankSize) override;
32 :
33 : TSD_StatusT OpenAicpuSd() override;
34 :
35 : TSD_StatusT Close(const uint32_t flag) override;
36 :
37 : TSD_StatusT GetHdcConctStatus(int32_t& hdcSessStat) override;
38 :
39 : TSD_StatusT UpdateProfilingConf(const uint32_t& flag) override;
40 :
41 : TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo) override;
42 :
43 : TSD_StatusT CapabilityGet(const int32_t type, const uint64_t ptr) override;
44 :
45 : static void ServerToClientMsgProc(const uint32_t sessionID, const HDCMessage& msg);
46 :
47 : static void CapabilityResMsgProc(const uint32_t sessionID, const HDCMessage& msg);
48 :
49 : static void PackageInfoMsgProc(const uint32_t sessionID, const HDCMessage& msg);
50 :
51 : void Destroy() override;
52 :
53 : virtual ~ProcessModeManager() override;
54 :
55 : TSD_StatusT LoadFileToDevice(
56 : const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName,
57 : const uint64_t fileNameLen) override;
58 :
59 : TSD_StatusT ProcessOpenSubProc(ProcOpenArgs* openArgs) override;
60 :
61 : TSD_StatusT ProcessCloseSubProc(const pid_t closePid) override;
62 :
63 : TSD_StatusT GetSubProcStatus(ProcStatusInfo* pidInfo, const uint32_t arrayLen) override;
64 :
65 : TSD_StatusT RemoveFileOnDevice(const char_t* const filePath, const uint64_t pathLen) override;
66 :
67 : TSD_StatusT ProcessCloseSubProcList(const ProcStatusParam* closeList, const uint32_t listSize) override;
68 :
69 : TSD_StatusT GetSubProcListStatus(ProcStatusParam* pidInfo, const uint32_t arrayLen) override;
70 :
71 : TSD_StatusT OpenNetService(const NetServiceOpenArgs* args) override;
72 :
73 : TSD_StatusT CloseNetService() override;
74 :
75 255 : PackageManager& GetPackageManager() { return packageMgr_; }
76 :
77 92 : ResponseMsgDispatcher& GetDispatcher() { return rspDispatcher_; }
78 :
79 6 : SubProcessController& GetSubProcessController() { return subProcCtrl_; }
80 :
81 13 : TsdProcessController& GetTsdController() { return tsdCtrl_; }
82 :
83 10 : void DeviceMsgProcess(const HDCMessage& msg) { rspDispatcher_.DeviceMsgProcess(msg); }
84 :
85 : private:
86 : void GetLogLevel();
87 : void SyncSharedCtxLogLevels();
88 : void ParseModuleLogLevelByKey(const std::string& keyStr, const std::string& valStr);
89 :
90 : void ParseModuleLogLevel(const std::string& envModuleLogLevel);
91 :
92 : std::string logLevel_;
93 : DeviceCommAgent commAgent_;
94 : ProcessSharedContext sharedCtx_;
95 : CapabilityManager capabilityMgr_;
96 : PackageManager packageMgr_;
97 : ResponseMsgDispatcher rspDispatcher_;
98 : TsdProcessController tsdCtrl_;
99 : SubProcessController subProcCtrl_;
100 : std::string ccecpuLogLevel_;
101 : std::string aicpuLogLevel_;
102 : };
103 :
104 : } // namespace tsd
105 : #endif // INNER_INC_PROCESS_MODE_MANAGER_H
|