已合并
refactor: PackageManager 消除循环依赖与反向分层依赖(#787) #3970
DevLeev创建于 7月30日
refactor: PackageManager 消除循环依赖与反向分层依赖(#787) #3970
已合并
共 31 个文件变更+729-846
| @@ -13,7 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | - | ||
| 17 | 16 | ||
| 18 | 17 | ||
| 19 | 18 | ||
| @@ -298,7 +298,7 @@ TSD_StatusT HdcMessageBuilder::BuildNormalCheckCode(HDCMessage& msg, const Messa | |||
| 298 | } | 298 | } |
| 299 | pkgHostInfo->set_package_name(ctx.packageName); | 299 | pkgHostInfo->set_package_name(ctx.packageName); |
| 300 | pkgHostInfo->set_hash_code(ctx.hashCode); | 300 | pkgHostInfo->set_hash_code(ctx.hashCode); |
| 301 | - if (!ctx.hostPluginVersion.Empty()) { | 301 | + if (!HostPluginVersionEmpty(ctx.hostPluginVersion)) { |
| 302 | PluginPackageVersionInfo* const info = msg.add_host_plugin_versions(); | 302 | PluginPackageVersionInfo* const info = msg.add_host_plugin_versions(); |
| 303 | if (info == nullptr) { | 303 | if (info == nullptr) { |
| 304 | TSD_ERROR("add host plugin versions error"); | 304 | TSD_ERROR("add host plugin versions error"); |
| @@ -86,10 +86,9 @@ struct MessageContext { | |||
| 86 | 86 | ||
| 87 | // ---- Normal check-code with plugin version (per-call, TSD_GET_DEVICE_PACKAGE_CHECKCODE_NORMAL) ---- | 87 | // ---- Normal check-code with plugin version (per-call, TSD_GET_DEVICE_PACKAGE_CHECKCODE_NORMAL) ---- |
| 88 | // Optional: when version is non-empty, a host_plugin_versions entry is appended. | 88 | // Optional: when version is non-empty, a host_plugin_versions entry is appended. |
| 89 | - struct { | 89 | + struct HostPluginVersion { |
| 90 | std::string version; | 90 | std::string version; |
| 91 | std::string timestamp; | 91 | std::string timestamp; |
| 92 | - bool Empty() const { return version.empty() && timestamp.empty(); } | ||
| 93 | } hostPluginVersion; | 92 | } hostPluginVersion; |
| 94 | 93 | ||
| 95 | // ---- Capability query (per-call) ---- | 94 | // ---- Capability query (per-call) ---- |
| @@ -120,6 +119,11 @@ struct MessageContext { | |||
| 120 | std::vector<std::string> subProcExtParamList; | 119 | std::vector<std::string> subProcExtParamList; |
| 121 | }; | 120 | }; |
| 122 | 121 | ||
| 122 | +inline bool HostPluginVersionEmpty(const MessageContext::HostPluginVersion& v) | ||
| 123 | +{ | ||
| 124 | + return v.version.empty() && v.timestamp.empty(); | ||
| 125 | +} | ||
| 126 | + | ||
| 123 | // Pure HDC message assembler. | 127 | // Pure HDC message assembler. |
| 124 | // Responsibility scope: given an immutable MessageContext + per-call inputs, | 128 | // Responsibility scope: given an immutable MessageContext + per-call inputs, |
| 125 | // populate the HDCMessage proto. Methods are static, side-effect free w.r.t. | 129 | // populate the HDCMessage proto. Methods are static, side-effect free w.r.t. |
| @@ -15,23 +15,20 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | - | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | namespace tsd { | 25 | namespace tsd { |
| 26 | 26 | ||
| 27 | -class PackageManager; | ||
| 28 | - | ||
| 29 | class PackageCheckCodeService { | 27 | class PackageCheckCodeService { |
| 30 | public: | 28 | public: |
| 31 | PackageCheckCodeService( | 29 | PackageCheckCodeService( |
| 32 | - PackageManager& mgr, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, | 30 | + DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, |
| 33 | - PackageHashStore& hashStore, ResponseCode& pkgRspCode, bool& getCheckCodeRetrySupport, | 31 | + PackageHashStore& hashStore, PackageContext& ctx); |
| 34 | - std::string& loadPackageErrorMsg); | ||
| 35 | ~PackageCheckCodeService() = default; | 32 | ~PackageCheckCodeService() = default; |
| 36 | 33 | ||
| 37 | TSD_StatusT InitTsdClient(); | 34 | TSD_StatusT InitTsdClient(); |
| @@ -49,22 +46,21 @@ public: | |||
| 49 | void HandleNormalPackageCheckCodeRsp(const HDCMessage& msg); | 46 | void HandleNormalPackageCheckCodeRsp(const HDCMessage& msg); |
| 50 | void HandleCannHsCheckCodeRsp(const HDCMessage& msg); | 47 | void HandleCannHsCheckCodeRsp(const HDCMessage& msg); |
| 51 | void SaveDeviceCheckCode(const HDCMessage& msg); | 48 | void SaveDeviceCheckCode(const HDCMessage& msg); |
| 52 | - uint32_t GetHostCheckCode(TsdLoadPackageType type) const { return hostCheckCode_[static_cast<uint32_t>(type)]; } | 49 | + uint32_t GetHostCheckCode(TsdLoadPackageType type) const { return ctx_.hostCheckCode[static_cast<uint32_t>(type)]; } |
| 53 | - | 50 | + uint32_t GetPeerCheckCode(uint32_t type) const { return ctx_.peerCheckCode[type]; } |
| 54 | - uint32_t peerCheckCode_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | 51 | + void SetPeerCheckCode(uint32_t type, uint32_t code) { ctx_.peerCheckCode[type] = code; } |
| 55 | - uint32_t hostCheckCode_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | 52 | + void SetHostCheckCodeByIndex(uint32_t type, uint32_t code) { ctx_.hostCheckCode[type] = code; } |
| 56 | - ResponseCode& pkgRspCode_; | 53 | + ResponseCode& GetPkgRspCode() { return ctx_.pkgRspCode; } |
| 54 | + const ResponseCode& GetPkgRspCode() const { return ctx_.pkgRspCode; } | ||
| 57 | 55 | ||
| 58 | private: | 56 | private: |
| 59 | void SetHostCheckCode(HDCMessage& msg, TsdLoadPackageType type); | 57 | void SetHostCheckCode(HDCMessage& msg, TsdLoadPackageType type); |
| 60 | 58 | ||
| 61 | - PackageManager& mgr_; | ||
| 62 | DeviceCommAgent& commAgent_; | 59 | DeviceCommAgent& commAgent_; |
| 63 | CapabilityManager& capabilityMgr_; | 60 | CapabilityManager& capabilityMgr_; |
| 64 | PackageEnvInfo& envInfo_; | 61 | PackageEnvInfo& envInfo_; |
| 65 | PackageHashStore& hashStore_; | 62 | PackageHashStore& hashStore_; |
| 66 | - bool& getCheckCodeRetrySupport_; | 63 | + PackageContext& ctx_; |
| 67 | - std::string& loadPackageErrorMsg_; | ||
| 68 | }; | 64 | }; |
| 69 | 65 | ||
| 70 | } // namespace tsd | 66 | } // namespace tsd |
| @@ -0,0 +1,37 @@ | |||
| 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 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +namespace tsd { | ||
| 21 | + | ||
| 22 | +class PackageContext { | ||
| 23 | +public: | ||
| 24 | + PackageContext() = default; | ||
| 25 | + | ||
| 26 | + ResponseCode pkgRspCode = ResponseCode::FAIL; | ||
| 27 | + bool deviceIdle = false; | ||
| 28 | + bool getCheckCodeRetrySupport = false; | ||
| 29 | + std::string loadPackageErrorMsg; | ||
| 30 | + bool aicpuPackageExistInDevice = false; | ||
| 31 | + std::array<uint32_t, static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)> peerCheckCode{}; | ||
| 32 | + std::array<uint32_t, static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)> hostCheckCode{}; | ||
| 33 | +}; | ||
| 34 | + | ||
| 35 | +} // namespace tsd | ||
| 36 | + | ||
| 37 | + | ||
| @@ -49,7 +49,33 @@ public: | |||
| 49 | std::string GetTrustedBasePath(bool useV2) const; | 49 | std::string GetTrustedBasePath(bool useV2) const; |
| 50 | TSD_StatusT GetTrustedBasePathFromDevice(int32_t& peerNode, std::string& dstDirPreFix) const; | 50 | TSD_StatusT GetTrustedBasePathFromDevice(int32_t& peerNode, std::string& dstDirPreFix) const; |
| 51 | 51 | ||
| 52 | - // 状态(public 供 Facade 引用别名访问) | 52 | + const std::string& GetHostSoPath() const { return hostSoPath_; } |
| 53 | + void SetHostSoPath(const std::string& path) { hostSoPath_ = path; } | ||
| 54 | + std::string& GetPackageNameRef(uint32_t type) { return packageName_[type]; } | ||
| 55 | + const std::string& GetPackageNameRef(uint32_t type) const { return packageName_[type]; } | ||
| 56 | + std::string& GetPackagePathRef(uint32_t type) { return packagePath_[type]; } | ||
| 57 | + const std::string& GetPackagePathRef(uint32_t type) const { return packagePath_[type]; } | ||
| 58 | + std::string& GetPackagePatternRef(uint32_t type) { return packagePattern_[type]; } | ||
| 59 | + const std::string& GetPackagePatternRef(uint32_t type) const { return packagePattern_[type]; } | ||
| 60 | + // 供 ClientManager 引用成员绑定(Facade 模式遗留) | ||
| 61 | + std::string (&GetPackageNameArr())[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)] | ||
| 62 | + { | ||
| 63 | + return packageName_; | ||
| 64 | + } | ||
| 65 | + std::string (&GetPackagePathArr())[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)] | ||
| 66 | + { | ||
| 67 | + return packagePath_; | ||
| 68 | + } | ||
| 69 | + std::string (&GetPackagePatternArr())[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)] | ||
| 70 | + { | ||
| 71 | + return packagePattern_; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + bool CheckPackageExistsOnce(const uint32_t packageType); | ||
| 75 | + bool GetPackagePath(std::string& packagePath, const uint32_t packageType) const; | ||
| 76 | + std::vector<std::string> ScanAndMatchPackages(const std::string& pkgPath, const uint32_t packageType) const; | ||
| 77 | + | ||
| 78 | +private: | ||
| 53 | uint32_t platInfoMode_; | 79 | uint32_t platInfoMode_; |
| 54 | bool isAdcEnv_; | 80 | bool isAdcEnv_; |
| 55 | uint32_t chipType_; | 81 | uint32_t chipType_; |
| @@ -57,12 +83,6 @@ public: | |||
| 57 | std::string packageName_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | 83 | std::string packageName_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; |
| 58 | std::string packagePath_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | 84 | std::string packagePath_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; |
| 59 | std::string packagePattern_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | 85 | std::string packagePattern_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; |
| 60 | - | ||
| 61 | - bool CheckPackageExistsOnce(const uint32_t packageType); | ||
| 62 | - bool GetPackagePath(std::string& packagePath, const uint32_t packageType) const; | ||
| 63 | - std::vector<std::string> ScanAndMatchPackages(const std::string& pkgPath, const uint32_t packageType) const; | ||
| 64 | - | ||
| 65 | -private: | ||
| 66 | uint32_t logicDeviceId_; | 86 | uint32_t logicDeviceId_; |
| 67 | }; | 87 | }; |
| 68 | 88 | ||
| @@ -32,6 +32,12 @@ public: | |||
| 32 | void StoreAllPkgHashValue(const HDCMessage& msg); | 32 | void StoreAllPkgHashValue(const HDCMessage& msg); |
| 33 | void Clear(); | 33 | void Clear(); |
| 34 | 34 | ||
| 35 | + std::map<std::string, std::string>& GetPkgHostHashValue() { return pkgHostHashValue_; } | ||
| 36 | + const std::map<std::string, std::string>& GetPkgHostHashValue() const { return pkgHostHashValue_; } | ||
| 37 | + std::map<std::string, std::string>& GetPkgDeviceHashValue() { return pkgDeviceHashValue_; } | ||
| 38 | + const std::map<std::string, std::string>& GetPkgDeviceHashValue() const { return pkgDeviceHashValue_; } | ||
| 39 | + | ||
| 40 | +private: | ||
| 35 | std::map<std::string, std::string> pkgHostHashValue_; | 41 | std::map<std::string, std::string> pkgHostHashValue_; |
| 36 | std::map<std::string, std::string> pkgDeviceHashValue_; | 42 | std::map<std::string, std::string> pkgDeviceHashValue_; |
| 37 | }; | 43 | }; |
| @@ -15,23 +15,26 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | - | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | namespace tsd { | 26 | namespace tsd { |
| 27 | 27 | ||
| 28 | -class PackageManager; | 28 | +class PackageSender; |
| 29 | +class PackageCheckCodeService; | ||
| 30 | +class PluginVersionManager; | ||
| 29 | 31 | ||
| 30 | class PackageLoader { | 32 | class PackageLoader { |
| 31 | public: | 33 | public: |
| 32 | PackageLoader( | 34 | PackageLoader( |
| 33 | - PackageManager& mgr, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, | 35 | + DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, |
| 34 | - PackageHashStore& hashStore, ResponseCode& pkgRspCode, std::string& loadPackageErrorMsg); | 36 | + PackageHashStore& hashStore, PackageContext& ctx, PackageSender& sender, PackageCheckCodeService& checkCodeSvc, |
| 37 | + PluginVersionManager& pluginVersion); | ||
| 35 | ~PackageLoader() = default; | 38 | ~PackageLoader() = default; |
| 36 | 39 | ||
| 37 | TSD_StatusT LoadSysOpKernel(); | 40 | TSD_StatusT LoadSysOpKernel(); |
| @@ -58,7 +61,8 @@ public: | |||
| 58 | 61 | ||
| 59 | void Reset(); | 62 | void Reset(); |
| 60 | 63 | ||
| 61 | - bool aicpuPackageExistInDevice_ = false; | 64 | + bool IsAicpuPackageExistInDevice() const { return ctx_.aicpuPackageExistInDevice; } |
| 65 | + void SetAicpuPackageExistInDevice(bool v) { ctx_.aicpuPackageExistInDevice = v; } | ||
| 62 | 66 | ||
| 63 | private: | 67 | private: |
| 64 | TSD_StatusT LoadHsPkgToDevice( | 68 | TSD_StatusT LoadHsPkgToDevice( |
| @@ -68,13 +72,14 @@ private: | |||
| 68 | TSD_StatusT SendAllPackagesToPeer(); | 72 | TSD_StatusT SendAllPackagesToPeer(); |
| 69 | bool hasSendConfigFile_ = false; | 73 | bool hasSendConfigFile_ = false; |
| 70 | 74 | ||
| 71 | - PackageManager& mgr_; | ||
| 72 | DeviceCommAgent& commAgent_; | 75 | DeviceCommAgent& commAgent_; |
| 73 | CapabilityManager& capabilityMgr_; | 76 | CapabilityManager& capabilityMgr_; |
| 74 | PackageEnvInfo& envInfo_; | 77 | PackageEnvInfo& envInfo_; |
| 75 | PackageHashStore& hashStore_; | 78 | PackageHashStore& hashStore_; |
| 76 | - ResponseCode& pkgRspCode_; | 79 | + PackageContext& ctx_; |
| 77 | - std::string& loadPackageErrorMsg_; | 80 | + PackageSender& sender_; |
| 81 | + PackageCheckCodeService& checkCodeSvc_; | ||
| 82 | + PluginVersionManager& pluginVersion_; | ||
| 78 | }; | 83 | }; |
| 79 | 84 | ||
| 80 | } // namespace tsd | 85 | } // namespace tsd |
| @@ -8,8 +8,8 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | -#ifndef INNER_INC_PACKAGE_MANAGER_H | 11 | +#ifndef TSD_PACKAGE_MANAGER_H |
| 12 | -#define INNER_INC_PACKAGE_MANAGER_H | 12 | +#define TSD_PACKAGE_MANAGER_H |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 21 | 22 | ||
| 22 | 23 | ||
| 23 | 24 | ||
| @@ -26,9 +27,7 @@ | |||
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | 29 | ||
| 29 | - | ||
| 30 | 30 | ||
| 31 | - | ||
| 32 | 31 | ||
| 33 | namespace tsd { | 32 | namespace tsd { |
| 34 | 33 | ||
| @@ -37,7 +36,7 @@ public: | |||
| 37 | PackageManager( | 36 | PackageManager( |
| 38 | uint32_t logicDeviceId, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, uint32_t platInfoMode, | 37 | uint32_t logicDeviceId, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, uint32_t platInfoMode, |
| 39 | bool isAdcEnv, uint32_t chipType); | 38 | bool isAdcEnv, uint32_t chipType); |
| 40 | - ~PackageManager(); | 39 | + ~PackageManager() = default; |
| 41 | 40 | ||
| 42 | // === Open 流程入口 === | 41 | // === Open 流程入口 === |
| 43 | TSD_StatusT LoadPackageConfigInfoToDevice(const bool hasPluginVersion) | 42 | TSD_StatusT LoadPackageConfigInfoToDevice(const bool hasPluginVersion) |
| @@ -60,210 +59,26 @@ public: | |||
| 60 | 59 | ||
| 61 | // === 状态管理 === | 60 | // === 状态管理 === |
| 62 | void ResetOnClose(); | 61 | void ResetOnClose(); |
| 63 | - bool IsAicpuPackageExistInDevice() const { return loader_.aicpuPackageExistInDevice_; } | ||
| 64 | - void SetAicpuPackageExistInDevice(bool val) { loader_.aicpuPackageExistInDevice_ = val; } | ||
| 65 | uint32_t GetHostCheckCode(TsdLoadPackageType type) const { return checkCodeSvc_.GetHostCheckCode(type); } | 62 | uint32_t GetHostCheckCode(TsdLoadPackageType type) const { return checkCodeSvc_.GetHostCheckCode(type); } |
| 66 | void GetAscendLatestIntallPath(std::string& pkgBasePath) const { envInfo_.GetAscendLatestIntallPath(pkgBasePath); } | 63 | void GetAscendLatestIntallPath(std::string& pkgBasePath) const { envInfo_.GetAscendLatestIntallPath(pkgBasePath); } |
| 67 | - | ||
| 68 | - // === 包扫描 === | ||
| 69 | - bool CheckPackageExists(const bool loadAicpuKernelFlag = true) | ||
| 70 | - { | ||
| 71 | - return envInfo_.CheckPackageExists(loadAicpuKernelFlag); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - bool GetPackageTitle(std::string& packageTitle) const { return envInfo_.GetPackageTitle(packageTitle); } | ||
| 75 | - | ||
| 76 | - const std::string& GetPackageName(uint32_t type) const { return envInfo_.GetPackageName(type); } | ||
| 77 | - | ||
| 78 | - const std::string& GetPackagePath(uint32_t type) const { return envInfo_.GetPackagePath(type); } | ||
| 79 | - | ||
| 80 | - uint32_t GetPlatInfoMode() const { return envInfo_.GetPlatInfoMode(); } | ||
| 81 | - | ||
| 82 | - void SetPlatInfoMode(uint32_t mode) { envInfo_.SetPlatInfoMode(mode); } | ||
| 83 | - bool IsAdcEnv() const { return envInfo_.IsAdcEnv(); } | ||
| 84 | - uint32_t GetPlatInfoChipType() const { return envInfo_.GetPlatInfoChipType(); } | ||
| 85 | - void SetPlatInfoChipType(uint32_t chipType) { envInfo_.SetPlatInfoChipType(chipType); } | ||
| 86 | - | ||
| 87 | - TSD_StatusT InitTsdClient() { return checkCodeSvc_.InitTsdClient(); } | ||
| 88 | - TSD_StatusT WaitPkgRsp(const uint32_t timeout, const bool ignoreRecvErr = false) | ||
| 89 | - { | ||
| 90 | - return checkCodeSvc_.WaitPkgRsp(timeout, ignoreRecvErr); | ||
| 91 | - } | ||
| 92 | - TSD_StatusT SendAICPUPackage(const int32_t peerNode, const std::string& path) | ||
| 93 | - { | ||
| 94 | - return sender_.SendAICPUPackage(peerNode, path); | ||
| 95 | - } | ||
| 96 | - TSD_StatusT SendAICPUPackageSimple( | ||
| 97 | - const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, bool useCannPath) | ||
| 98 | - { | ||
| 99 | - return sender_.SendAICPUPackageSimple(peerNode, orgFile, dstFile, useCannPath); | ||
| 100 | - } | ||
| 101 | - TSD_StatusT SendHostPackageComplex( | ||
| 102 | - const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, HDCMessage& msg, | ||
| 103 | - const std::function<bool(void)>& compareCallBack, bool useCannPath) | ||
| 104 | - | ||
| 105 | - { | ||
| 106 | - return sender_.SendHostPackageComplex(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); | ||
| 107 | - } | ||
| 108 | - TSD_StatusT SendMsgAndHostPackage( | ||
| 109 | - const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, HDCMessage& msg, | ||
| 110 | - const std::function<bool(void)>& compareCallBack, bool useCannPath) | ||
| 111 | - | ||
| 112 | - { | ||
| 113 | - return sender_.SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); | ||
| 114 | - } | ||
| 115 | - TSD_StatusT SendCommonPackage(const int32_t peerNode, const std::string& path, const uint32_t packageType) | ||
| 116 | - | ||
| 117 | - { | ||
| 118 | - return sender_.SendCommonPackage(peerNode, path, packageType); | ||
| 119 | - } | ||
| 120 | - TSD_StatusT SendFileToDevice( | ||
| 121 | - const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, | ||
| 122 | - const bool addPreFix = false) | ||
| 123 | - | ||
| 124 | - { | ||
| 125 | - return sender_.SendFileToDevice(filePath, pathLen, fileName, fileNameLen, addPreFix); | ||
| 126 | - } | ||
| 127 | - TSD_StatusT CompareAndSendCommonSinkPkg( | ||
| 128 | - const std::string& pkgPureName, const std::string& hostPkgHash, const int32_t peerNode, | ||
| 129 | - const std::string& orgFile, const std::string& dstFile) | ||
| 130 | - { | ||
| 131 | - return sender_.CompareAndSendCommonSinkPkg(pkgPureName, hostPkgHash, peerNode, orgFile, dstFile); | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - TSD_StatusT GetDeviceCheckCode() { return checkCodeSvc_.GetDeviceCheckCode(); } | ||
| 135 | - TSD_StatusT GetDeviceCheckCodeOnce(const HDCMessage& msg) { return checkCodeSvc_.GetDeviceCheckCodeOnce(msg); } | ||
| 136 | - TSD_StatusT GetDeviceCheckCodeRetry(const HDCMessage& msg) { return checkCodeSvc_.GetDeviceCheckCodeRetry(msg); } | ||
| 137 | - void GetDeviceCheckCodeRetrySupport() { checkCodeSvc_.GetDeviceCheckCodeRetrySupport(); } | ||
| 138 | - TSD_StatusT PrepareForCheckCode() { return checkCodeSvc_.PrepareForCheckCode(); } | ||
| 139 | - TSD_StatusT GetDeviceHsPkgCheckCode( | ||
| 140 | - const uint32_t checkCode, const HDCMessage::MsgType msgType, const bool beforeSendFlag, | ||
| 141 | - const MessageContext& baseCtx) | ||
| 142 | - { | ||
| 143 | - return checkCodeSvc_.GetDeviceHsPkgCheckCode(checkCode, msgType, beforeSendFlag, baseCtx); | ||
| 144 | - } | ||
| 145 | - TSD_StatusT GetCannHsPkgCheckCode( | ||
| 146 | - const std::string& pkgPureName, const std::string& hostPkgHash, const MessageContext& baseCtx) | ||
| 147 | - { | ||
| 148 | - return checkCodeSvc_.GetCannHsPkgCheckCode(pkgPureName, hostPkgHash, baseCtx); | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - TSD_StatusT LoadSinglePackageToDevice( | ||
| 152 | - const std::string& pkgPureName, const PackConfDetail& detail, int32_t peerNode, const std::string& dstDirPreFix) | ||
| 153 | - { | ||
| 154 | - return loader_.LoadSinglePackageToDevice(pkgPureName, detail, peerNode, dstDirPreFix); | ||
| 155 | - } | ||
| 156 | - | ||
| 157 | - TSD_StatusT LoadCannHsPkgToDevice(const std::string& pkgPureName, const MessageContext& baseCtx) | ||
| 158 | - | ||
| 159 | - { | ||
| 160 | - return loader_.LoadCannHsPkgToDevice(pkgPureName, baseCtx); | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - TSD_StatusT LoadFileAndWaitRsp( | ||
| 164 | - const std::string& pkgPureName, const std::string& hostPkgHash, const int32_t peerNode, | ||
| 165 | - const std::string& orgFile, const std::string& dstFile, const MessageContext& baseCtx) | ||
| 166 | - { | ||
| 167 | - return loader_.LoadFileAndWaitRsp(pkgPureName, hostPkgHash, peerNode, orgFile, dstFile, baseCtx); | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | - TSD_StatusT LoadRuntimePkgToDevice(const MessageContext& baseCtx) | ||
| 171 | - { | ||
| 172 | - return loader_.LoadRuntimePkgToDevice(baseCtx); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - TSD_StatusT LoadDShapePkgToDevice(const MessageContext& baseCtx) { return loader_.LoadDShapePkgToDevice(baseCtx); } | ||
| 176 | - | ||
| 177 | - TSD_StatusT LoadOmFileToDevice( | ||
| 178 | - const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, | ||
| 179 | - const MessageContext& baseCtx) | ||
| 180 | - { | ||
| 181 | - return loader_.LoadOmFileToDevice(filePath, pathLen, fileName, fileNameLen, baseCtx); | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | - TSD_StatusT GetTrustedBasePathFromDevice(int32_t& peerNode, std::string& dstDirPreFix) | ||
| 185 | - { | ||
| 186 | - return envInfo_.GetTrustedBasePathFromDevice(peerNode, dstDirPreFix); | ||
| 187 | - } | ||
| 188 | - void SetDeviceCommonSinkPackHashValue(const std::string& pkgName, const std::string& hashValue) | ||
| 189 | - { | ||
| 190 | - hashStore_.SetDeviceCommonSinkPackHashValue(pkgName, hashValue); | ||
| 191 | - } | ||
| 192 | - std::string GetDeviceCommonSinkPackHashValue(const std::string& pkgName) const | ||
| 193 | - { | ||
| 194 | - return hashStore_.GetDeviceCommonSinkPackHashValue(pkgName); | ||
| 195 | - } | ||
| 196 | - void SetHostCommonSinkPackHashValue(const std::string& pkgName, const std::string& hashValue) | ||
| 197 | - { | ||
| 198 | - hashStore_.SetHostCommonSinkPackHashValue(pkgName, hashValue); | ||
| 199 | - } | ||
| 200 | - std::string GetHostCommonSinkPackHashValue(const std::string& pkgName) const | ||
| 201 | - { | ||
| 202 | - return hashStore_.GetHostCommonSinkPackHashValue(pkgName); | ||
| 203 | - } | ||
| 204 | - bool IsCommonSinkHostAndDevicePkgSame(const std::string& pkgName) const | ||
| 205 | - | ||
| 206 | - { | ||
| 207 | - return hashStore_.IsCommonSinkHostAndDevicePkgSame(pkgName); | ||
| 208 | - } | ||
| 209 | - bool IsCompatPluginPackage(const PackConfDetail& detail) const | ||
| 210 | - { | ||
| 211 | - return pluginVersion_.IsCompatPluginPackage(detail); | ||
| 212 | - } | ||
| 213 | - PluginUpdateStrategy GetPluginUpdateStrategy() { return pluginVersion_.GetPluginUpdateStrategy(); } | ||
| 214 | - bool ShouldLoadCompatPluginPkg(const std::string& pkgPureName) | ||
| 215 | - | ||
| 216 | - { | ||
| 217 | - return pluginVersion_.ShouldLoadCompatPluginPkg(pkgPureName); | ||
| 218 | - } | ||
| 219 | - bool CompareHostDeviceCompatPluginVersion(const std::string& pkgPureName) | ||
| 220 | - | ||
| 221 | - { | ||
| 222 | - return pluginVersion_.CompareHostDeviceCompatPluginVersion(pkgPureName); | ||
| 223 | - } | ||
| 224 | void HandleDevicePluginVersionRsp(const HDCMessage& msg) { pluginVersion_.HandleDevicePluginVersionRsp(msg); } | 64 | void HandleDevicePluginVersionRsp(const HDCMessage& msg) { pluginVersion_.HandleDevicePluginVersionRsp(msg); } |
| 225 | - void HandleNormalPackageCheckCodeRsp(const HDCMessage& msg) { checkCodeSvc_.HandleNormalPackageCheckCodeRsp(msg); } | ||
| 226 | - void HandleCannHsCheckCodeRsp(const HDCMessage& msg) { checkCodeSvc_.HandleCannHsCheckCodeRsp(msg); } | ||
| 227 | - bool SupportLoadPkg(const std::string& pkgName) const { return loader_.SupportLoadPkg(pkgName); } | ||
| 228 | - bool IsOkToLoadFileToDevice(const char_t* const fileName, const uint64_t fileNameLen) | ||
| 229 | - { | ||
| 230 | - return loader_.IsOkToLoadFileToDevice(fileName, fileNameLen); | ||
| 231 | - } | ||
| 232 | - void ReportSinkPkgRspError(const std::string& pkgPureName) { loader_.ReportSinkPkgRspError(pkgPureName); } | ||
| 233 | - std::string GetCurHostMutexFile(bool useCannPath) const { return envInfo_.GetCurHostMutexFile(useCannPath); } | ||
| 234 | - bool GetShortSocVersion(std::string& shortSocVersion) const { return envInfo_.GetShortSocVersion(shortSocVersion); } | ||
| 235 | - ResponseCode GetPkgRspCode() const { return pkgRspCode_; } | ||
| 236 | - void SetPkgRspCode(ResponseCode code) { pkgRspCode_ = code; } | ||
| 237 | - bool getCheckCodeRetrySupport_; | ||
| 238 | - bool deviceIdle_; | ||
| 239 | - std::string loadPackageErrorMsg_; | ||
| 240 | - ResponseCode pkgRspCode_ = ResponseCode::FAIL; | ||
| 241 | 65 | ||
| 242 | private: | 66 | private: |
| 243 | PackageEnvInfo envInfo_; | 67 | PackageEnvInfo envInfo_; |
| 244 | PackageHashStore hashStore_; | 68 | PackageHashStore hashStore_; |
| 69 | + | ||
| 70 | + PackageContext ctx_; | ||
| 71 | + | ||
| 245 | PluginVersionManager pluginVersion_; | 72 | PluginVersionManager pluginVersion_; |
| 246 | - std::string (&packageName_)[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | ||
| 247 | - std::map<std::string, std::string>& pkgHostHashValue_; | ||
| 248 | - std::map<std::string, std::string>& pkgDeviceHashValue_; | ||
| 249 | - std::string GetTrustedBasePath(bool useV2) const { return envInfo_.GetTrustedBasePath(useV2); } | ||
| 250 | 73 | ||
| 251 | DeviceCommAgent& commAgent_; | 74 | DeviceCommAgent& commAgent_; |
| 252 | CapabilityManager& capabilityMgr_; | 75 | CapabilityManager& capabilityMgr_; |
| 253 | 76 | ||
| 254 | - std::map<std::string, PluginPkgVersion>& devicePluginVersions_; | ||
| 255 | - PluginUpdateStrategy& pluginUpdateStrategy_; | ||
| 256 | - bool& hasComputedPluginStrategy_; | ||
| 257 | - PackageSender sender_; | ||
| 258 | PackageCheckCodeService checkCodeSvc_; | 77 | PackageCheckCodeService checkCodeSvc_; |
| 78 | + PackageSender sender_; | ||
| 259 | PackageLoader loader_; | 79 | PackageLoader loader_; |
| 260 | - | ||
| 261 | -public: | ||
| 262 | - bool& aicpuPackageExistInDevice_; | ||
| 263 | - uint32_t (&packagePeerCheckCode_)[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | ||
| 264 | - uint32_t (&packageHostCheckCode_)[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | ||
| 265 | }; | 80 | }; |
| 266 | 81 | ||
| 267 | } // namespace tsd | 82 | } // namespace tsd |
| 268 | 83 | ||
| 269 | -#endif // INNER_INC_PACKAGE_MANAGER_H | 84 | +#endif // TSD_PACKAGE_MANAGER_H |
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | 21 | ||
| @@ -24,18 +25,18 @@ | |||
| 24 | 25 | ||
| 25 | namespace tsd { | 26 | namespace tsd { |
| 26 | 27 | ||
| 27 | -class PackageManager; | 28 | +class PackageCheckCodeService; |
| 28 | 29 | ||
| 29 | class PackageSender { | 30 | class PackageSender { |
| 30 | public: | 31 | public: |
| 31 | PackageSender( | 32 | PackageSender( |
| 32 | - PackageManager& mgr, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, | 33 | + DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, |
| 33 | - PackageHashStore& hashStore, bool& deviceIdle, bool& getCheckCodeRetrySupport); | 34 | + PackageHashStore& hashStore, PackageContext& ctx, PackageCheckCodeService& checkCodeSvc); |
| 34 | ~PackageSender() = default; | 35 | ~PackageSender() = default; |
| 35 | 36 | ||
| 36 | TSD_StatusT SendAICPUPackage(const int32_t peerNode, const std::string& path); | 37 | TSD_StatusT SendAICPUPackage(const int32_t peerNode, const std::string& path); |
| 37 | TSD_StatusT SendAICPUPackageSimple( | 38 | TSD_StatusT SendAICPUPackageSimple( |
| 38 | - const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, bool useCannPath); | 39 | + const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, bool useCannPath) const; |
| 39 | TSD_StatusT SendHostPackageComplex( | 40 | TSD_StatusT SendHostPackageComplex( |
| 40 | const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, HDCMessage& msg, | 41 | const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, HDCMessage& msg, |
| 41 | const std::function<bool(void)>& compareCallBack, bool useCannPath); | 42 | const std::function<bool(void)>& compareCallBack, bool useCannPath); |
| @@ -45,19 +46,18 @@ public: | |||
| 45 | TSD_StatusT SendCommonPackage(const int32_t peerNode, const std::string& path, const uint32_t packageType); | 46 | TSD_StatusT SendCommonPackage(const int32_t peerNode, const std::string& path, const uint32_t packageType); |
| 46 | TSD_StatusT SendFileToDevice( | 47 | TSD_StatusT SendFileToDevice( |
| 47 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, | 48 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, |
| 48 | - const bool addPreFix = false); | 49 | + const bool addPreFix = false) const; |
| 49 | TSD_StatusT CompareAndSendCommonSinkPkg( | 50 | TSD_StatusT CompareAndSendCommonSinkPkg( |
| 50 | const std::string& pkgPureName, const std::string& hostPkgHash, const int32_t peerNode, | 51 | const std::string& pkgPureName, const std::string& hostPkgHash, const int32_t peerNode, |
| 51 | const std::string& orgFile, const std::string& dstFile); | 52 | const std::string& orgFile, const std::string& dstFile); |
| 52 | 53 | ||
| 53 | private: | 54 | private: |
| 54 | - PackageManager& mgr_; | ||
| 55 | DeviceCommAgent& commAgent_; | 55 | DeviceCommAgent& commAgent_; |
| 56 | CapabilityManager& capabilityMgr_; | 56 | CapabilityManager& capabilityMgr_; |
| 57 | PackageEnvInfo& envInfo_; | 57 | PackageEnvInfo& envInfo_; |
| 58 | PackageHashStore& hashStore_; | 58 | PackageHashStore& hashStore_; |
| 59 | - bool& deviceIdle_; | 59 | + PackageContext& ctx_; |
| 60 | - bool& getCheckCodeRetrySupport_; | 60 | + PackageCheckCodeService& checkCodeSvc_; |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | } // namespace tsd | 63 | } // namespace tsd |
| @@ -15,8 +15,9 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | 19 | ||
| 19 | -#include "inc/client_manager.h" | 20 | +#include "basic_define.h" |
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | 23 | ||
| @@ -26,7 +27,7 @@ namespace tsd { | |||
| 26 | 27 | ||
| 27 | class PluginVersionManager { | 28 | class PluginVersionManager { |
| 28 | public: | 29 | public: |
| 29 | - PluginVersionManager(PackageEnvInfo& envInfo, PackageHashStore& hashStore, ResponseCode& pkgRspCode); | 30 | + PluginVersionManager(PackageEnvInfo& envInfo, PackageHashStore& hashStore, PackageContext& ctx); |
| 30 | ~PluginVersionManager() = default; | 31 | ~PluginVersionManager() = default; |
| 31 | 32 | ||
| 32 | bool IsCompatPluginPackage(const PackConfDetail& detail) const; | 33 | bool IsCompatPluginPackage(const PackConfDetail& detail) const; |
| @@ -35,15 +36,19 @@ public: | |||
| 35 | bool CompareHostDeviceCompatPluginVersion(const std::string& pkgPureName); | 36 | bool CompareHostDeviceCompatPluginVersion(const std::string& pkgPureName); |
| 36 | void HandleDevicePluginVersionRsp(const HDCMessage& msg); | 37 | void HandleDevicePluginVersionRsp(const HDCMessage& msg); |
| 37 | 38 | ||
| 38 | - // 状态(public 供 Facade 引用别名访问) | 39 | + std::map<std::string, PluginPkgVersion>& GetDevicePluginVersions() { return devicePluginVersions_; } |
| 40 | + const std::map<std::string, PluginPkgVersion>& GetDevicePluginVersions() const { return devicePluginVersions_; } | ||
| 41 | + void SetPluginUpdateStrategy(PluginUpdateStrategy s) { pluginUpdateStrategy_ = s; } | ||
| 42 | + bool HasComputedPluginStrategy() const { return hasComputedPluginStrategy_; } | ||
| 43 | + void SetHasComputedPluginStrategy(bool v) { hasComputedPluginStrategy_ = v; } | ||
| 44 | + | ||
| 45 | +private: | ||
| 39 | std::map<std::string, PluginPkgVersion> devicePluginVersions_; | 46 | std::map<std::string, PluginPkgVersion> devicePluginVersions_; |
| 40 | PluginUpdateStrategy pluginUpdateStrategy_ = PluginUpdateStrategy::PLUGIN_NOT_FORCE_UPDATE; | 47 | PluginUpdateStrategy pluginUpdateStrategy_ = PluginUpdateStrategy::PLUGIN_NOT_FORCE_UPDATE; |
| 41 | bool hasComputedPluginStrategy_ = false; | 48 | bool hasComputedPluginStrategy_ = false; |
| 42 | - | ||
| 43 | -private: | ||
| 44 | PackageEnvInfo& envInfo_; | 49 | PackageEnvInfo& envInfo_; |
| 45 | PackageHashStore& hashStore_; | 50 | PackageHashStore& hashStore_; |
| 46 | - ResponseCode& pkgRspCode_; | 51 | + PackageContext& ctx_; |
| 47 | }; | 52 | }; |
| 48 | 53 | ||
| 49 | } // namespace tsd | 54 | } // namespace tsd |
| @@ -9,7 +9,6 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | - | ||
| 13 | 12 | ||
| 14 | 13 | ||
| 15 | 14 | ||
| @@ -29,8 +28,8 @@ struct CheckCodeRspHandler { | |||
| 29 | 28 | ||
| 30 | void HandleSingleCheckCodeRsp(tsd::PackageCheckCodeService& svc, const HDCMessage& msg, tsd::TsdLoadPackageType pkgType) | 29 | void HandleSingleCheckCodeRsp(tsd::PackageCheckCodeService& svc, const HDCMessage& msg, tsd::TsdLoadPackageType pkgType) |
| 31 | { | 30 | { |
| 32 | - svc.peerCheckCode_[static_cast<uint32_t>(pkgType)] = msg.check_code(); | 31 | + svc.SetPeerCheckCode(static_cast<uint32_t>(pkgType), msg.check_code()); |
| 33 | - svc.pkgRspCode_ = ((msg.tsd_rsp_code() == 0U) ? tsd::ResponseCode::SUCCESS : tsd::ResponseCode::FAIL); | 32 | + svc.GetPkgRspCode() = ((msg.tsd_rsp_code() == 0U) ? tsd::ResponseCode::SUCCESS : tsd::ResponseCode::FAIL); |
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | void HandleRuntimeCheckCodeRsp(tsd::PackageCheckCodeService& svc, const HDCMessage& msg) | 35 | void HandleRuntimeCheckCodeRsp(tsd::PackageCheckCodeService& svc, const HDCMessage& msg) |
| @@ -45,39 +44,26 @@ void HandleDshapeCheckCodeRsp(tsd::PackageCheckCodeService& svc, const HDCMessag | |||
| 45 | 44 | ||
| 46 | void HandleMultiCheckCodeRsp(tsd::PackageCheckCodeService& svc, const HDCMessage& msg) | 45 | void HandleMultiCheckCodeRsp(tsd::PackageCheckCodeService& svc, const HDCMessage& msg) |
| 47 | { | 46 | { |
| 48 | - svc.peerCheckCode_[static_cast<uint32_t>(tsd::TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL)] = msg.check_code(); | 47 | + svc.SetPeerCheckCode(static_cast<uint32_t>(tsd::TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL), msg.check_code()); |
| 49 | - svc.peerCheckCode_[static_cast<uint32_t>(tsd::TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL)] = | 48 | + svc.SetPeerCheckCode( |
| 50 | - msg.extendpkg_check_code(); | 49 | + static_cast<uint32_t>(tsd::TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL), msg.extendpkg_check_code()); |
| 51 | - svc.peerCheckCode_[static_cast<uint32_t>(tsd::TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)] = | 50 | + svc.SetPeerCheckCode( |
| 52 | - msg.ascendcpppkg_check_code(); | 51 | + static_cast<uint32_t>(tsd::TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP), msg.ascendcpppkg_check_code()); |
| 53 | } | 52 | } |
| 54 | 53 | ||
| 55 | -const CheckCodeRspHandler CHECK_CODE_RSP_HANDLERS[] = { | 54 | +constexpr const CheckCodeRspHandler CHECK_CODE_RSP_HANDLERS[] = { |
| 56 | - {HDCMessage::TSD_GET_DEVICE_RUNTIME_CHECKCODE_RSP, HandleRuntimeCheckCodeRsp}, | 55 | + {HDCMessage::TSD_GET_DEVICE_RUNTIME_CHECKCODE_RSP, &HandleRuntimeCheckCodeRsp}, |
| 57 | - {HDCMessage::TSD_GET_DEVICE_DSHAPE_CHECKCODE_RSP, HandleDshapeCheckCodeRsp}, | 56 | + {HDCMessage::TSD_GET_DEVICE_DSHAPE_CHECKCODE_RSP, &HandleDshapeCheckCodeRsp}, |
| 58 | - {HDCMessage::TSD_CHECK_PACKAGE_RETRY_RSP, HandleMultiCheckCodeRsp}, | 57 | + {HDCMessage::TSD_CHECK_PACKAGE_RETRY_RSP, &HandleMultiCheckCodeRsp}, |
| 59 | - {HDCMessage::TSD_CHECK_PACKAGE_RSP, HandleMultiCheckCodeRsp}, | 58 | + {HDCMessage::TSD_CHECK_PACKAGE_RSP, &HandleMultiCheckCodeRsp}, |
| 60 | }; | 59 | }; |
| 61 | } // namespace | 60 | } // namespace |
| 62 | 61 | ||
| 63 | PackageCheckCodeService::PackageCheckCodeService( | 62 | PackageCheckCodeService::PackageCheckCodeService( |
| 64 | - PackageManager& mgr, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, | 63 | + DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, PackageHashStore& hashStore, |
| 65 | - PackageHashStore& hashStore, ResponseCode& pkgRspCode, bool& getCheckCodeRetrySupport, | 64 | + PackageContext& ctx) |
| 66 | - std::string& loadPackageErrorMsg) | 65 | + : commAgent_(commAgent), capabilityMgr_(capabilityMgr), envInfo_(envInfo), hashStore_(hashStore), ctx_(ctx) |
| 67 | - : mgr_(mgr), | 66 | +{} |
| 68 | - commAgent_(commAgent), | ||
| 69 | - capabilityMgr_(capabilityMgr), | ||
| 70 | - envInfo_(envInfo), | ||
| 71 | - hashStore_(hashStore), | ||
| 72 | - pkgRspCode_(pkgRspCode), | ||
| 73 | - getCheckCodeRetrySupport_(getCheckCodeRetrySupport), | ||
| 74 | - loadPackageErrorMsg_(loadPackageErrorMsg) | ||
| 75 | -{ | ||
| 76 | - for (uint32_t index = 0U; index < static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX); index++) { | ||
| 77 | - peerCheckCode_[index] = 0U; | ||
| 78 | - hostCheckCode_[index] = 0U; | ||
| 79 | - } | ||
| 80 | -} | ||
| 81 | 67 | ||
| 82 | TSD_StatusT PackageCheckCodeService::InitTsdClient() | 68 | TSD_StatusT PackageCheckCodeService::InitTsdClient() |
| 83 | { | 69 | { |
| @@ -91,11 +77,11 @@ TSD_StatusT PackageCheckCodeService::InitTsdClient() | |||
| 91 | TSD_StatusT PackageCheckCodeService::WaitPkgRsp(const uint32_t timeout, const bool ignoreRecvErr) | 77 | TSD_StatusT PackageCheckCodeService::WaitPkgRsp(const uint32_t timeout, const bool ignoreRecvErr) |
| 92 | { | 78 | { |
| 93 | const TSD_StatusT ret = commAgent_.RecvData(ignoreRecvErr, timeout); | 79 | const TSD_StatusT ret = commAgent_.RecvData(ignoreRecvErr, timeout); |
| 94 | - if ((ret != TSD_OK) || (static_cast<uint32_t>(pkgRspCode_) != 0U)) { | 80 | + if ((ret != TSD_OK) || (static_cast<uint32_t>(ctx_.pkgRspCode) != 0U)) { |
| 95 | if (!ignoreRecvErr) { | 81 | if (!ignoreRecvErr) { |
| 96 | TSD_ERROR( | 82 | TSD_ERROR( |
| 97 | "tsd package wait response fail, ret[%u], rspCode[%u]", static_cast<uint32_t>(ret), | 83 | "tsd package wait response fail, ret[%u], rspCode[%u]", static_cast<uint32_t>(ret), |
| 98 | - static_cast<uint32_t>(pkgRspCode_)); | 84 | + static_cast<uint32_t>(ctx_.pkgRspCode)); |
| 99 | } | 85 | } |
| 100 | return TSD_INTERNAL_ERROR; | 86 | return TSD_INTERNAL_ERROR; |
| 101 | } | 87 | } |
| @@ -122,7 +108,7 @@ TSD_StatusT PackageCheckCodeService::GetDeviceCheckCodeOnce(const HDCMessage& ms | |||
| 122 | 108 | ||
| 123 | TSD_StatusT PackageCheckCodeService::PrepareForCheckCode() | 109 | TSD_StatusT PackageCheckCodeService::PrepareForCheckCode() |
| 124 | { | 110 | { |
| 125 | - const TSD_StatusT ret = mgr_.InitTsdClient(); | 111 | + const TSD_StatusT ret = this->InitTsdClient(); |
| 126 | if (ret != TSD_OK) { | 112 | if (ret != TSD_OK) { |
| 127 | TSD_RUN_WARN("[PackageManager][deviceId=%u] init failed for send aicpu package", envInfo_.GetLogicDeviceId()); | 113 | TSD_RUN_WARN("[PackageManager][deviceId=%u] init failed for send aicpu package", envInfo_.GetLogicDeviceId()); |
| 128 | if (ret >= TSD_SUBPROCESS_NUM_EXCEED_THE_LIMIT) { | 114 | if (ret >= TSD_SUBPROCESS_NUM_EXCEED_THE_LIMIT) { |
| @@ -137,13 +123,13 @@ TSD_StatusT PackageCheckCodeService::PrepareForCheckCode() | |||
| 137 | 123 | ||
| 138 | TSD_StatusT PackageCheckCodeService::GetDeviceCheckCode() | 124 | TSD_StatusT PackageCheckCodeService::GetDeviceCheckCode() |
| 139 | { | 125 | { |
| 140 | - if (mgr_.aicpuPackageExistInDevice_) { | 126 | + if (ctx_.aicpuPackageExistInDevice) { |
| 141 | TSD_RUN_INFO( | 127 | TSD_RUN_INFO( |
| 142 | "[PackageManager][deviceId=%u] aicpu package already exist in device", envInfo_.GetLogicDeviceId()); | 128 | "[PackageManager][deviceId=%u] aicpu package already exist in device", envInfo_.GetLogicDeviceId()); |
| 143 | return TSD_AICPUPACKAGE_EXISTED; | 129 | return TSD_AICPUPACKAGE_EXISTED; |
| 144 | } | 130 | } |
| 145 | 131 | ||
| 146 | - TSD_StatusT ret = mgr_.PrepareForCheckCode(); | 132 | + const TSD_StatusT ret = this->PrepareForCheckCode(); |
| 147 | if (ret != TSD_OK) { | 133 | if (ret != TSD_OK) { |
| 148 | return ret; | 134 | return ret; |
| 149 | } | 135 | } |
| @@ -155,17 +141,17 @@ TSD_StatusT PackageCheckCodeService::GetDeviceCheckCode() | |||
| 155 | 141 | ||
| 156 | if (!versionVerify->SpecialFeatureCheck(HDCMessage::TSD_CHECK_PACKAGE)) { | 142 | if (!versionVerify->SpecialFeatureCheck(HDCMessage::TSD_CHECK_PACKAGE)) { |
| 157 | TSD_RUN_INFO("[TsdClient] Device does not support search check_code before send aicpu package."); | 143 | TSD_RUN_INFO("[TsdClient] Device does not support search check_code before send aicpu package."); |
| 158 | - mgr_.aicpuPackageExistInDevice_ = true; | 144 | + ctx_.aicpuPackageExistInDevice = true; |
| 159 | return TSD_OK; | 145 | return TSD_OK; |
| 160 | } | 146 | } |
| 161 | 147 | ||
| 162 | MessageContext ctx{}; | 148 | MessageContext ctx{}; |
| 163 | ctx.logicDeviceId = envInfo_.GetLogicDeviceId(); | 149 | ctx.logicDeviceId = envInfo_.GetLogicDeviceId(); |
| 164 | ctx.asan = IsAsanMmSysEnv(); | 150 | ctx.asan = IsAsanMmSysEnv(); |
| 165 | - ctx.checkCode = hostCheckCode_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL)]; | 151 | + ctx.checkCode = ctx_.hostCheckCode[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL)]; |
| 166 | ctx.extendpkgCheckCode = | 152 | ctx.extendpkgCheckCode = |
| 167 | - hostCheckCode_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL)]; | 153 | + ctx_.hostCheckCode[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL)]; |
| 168 | - ctx.ascendcppCheckCode = hostCheckCode_[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)]; | 154 | + ctx.ascendcppCheckCode = ctx_.hostCheckCode[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)]; |
| 169 | HDCMessage msg; | 155 | HDCMessage msg; |
| 170 | if (HdcMessageBuilder::BuildCheckPackage(msg, ctx) != TSD_OK) { | 156 | if (HdcMessageBuilder::BuildCheckPackage(msg, ctx) != TSD_OK) { |
| 171 | TSD_ERROR("build check package msg failed"); | 157 | TSD_ERROR("build check package msg failed"); |
| @@ -174,13 +160,13 @@ TSD_StatusT PackageCheckCodeService::GetDeviceCheckCode() | |||
| 174 | SetHostCheckCode(msg, TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL); | 160 | SetHostCheckCode(msg, TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL); |
| 175 | SetHostCheckCode(msg, TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL); | 161 | SetHostCheckCode(msg, TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL); |
| 176 | SetHostCheckCode(msg, TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP); | 162 | SetHostCheckCode(msg, TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP); |
| 177 | - if (mgr_.GetDeviceCheckCodeOnce(msg) != TSD_OK) { | 163 | + if (this->GetDeviceCheckCodeOnce(msg) != TSD_OK) { |
| 178 | TSD_ERROR("get check code once failed."); | 164 | TSD_ERROR("get check code once failed."); |
| 179 | return TSD_INTERNAL_ERROR; | 165 | return TSD_INTERNAL_ERROR; |
| 180 | } | 166 | } |
| 181 | - mgr_.GetDeviceCheckCodeRetrySupport(); | 167 | + this->GetDeviceCheckCodeRetrySupport(); |
| 182 | 168 | ||
| 183 | - mgr_.aicpuPackageExistInDevice_ = true; | 169 | + ctx_.aicpuPackageExistInDevice = true; |
| 184 | 170 | ||
| 185 | return TSD_OK; | 171 | return TSD_OK; |
| 186 | } | 172 | } |
| @@ -193,17 +179,17 @@ void PackageCheckCodeService::GetDeviceCheckCodeRetrySupport() | |||
| 193 | TSD_ERROR("no VersionVerify available."); | 179 | TSD_ERROR("no VersionVerify available."); |
| 194 | return; | 180 | return; |
| 195 | } | 181 | } |
| 196 | - getCheckCodeRetrySupport_ = versionVerify->SpecialFeatureCheck(HDCMessage::TSD_CHECK_PACKAGE_RETRY); | 182 | + ctx_.getCheckCodeRetrySupport = versionVerify->SpecialFeatureCheck(HDCMessage::TSD_CHECK_PACKAGE_RETRY); |
| 197 | } | 183 | } |
| 198 | 184 | ||
| 199 | TSD_StatusT PackageCheckCodeService::GetDeviceCheckCodeRetry(const HDCMessage& msg) | 185 | TSD_StatusT PackageCheckCodeService::GetDeviceCheckCodeRetry(const HDCMessage& msg) |
| 200 | { | 186 | { |
| 201 | - TSD_StatusT ret = mgr_.PrepareForCheckCode(); | 187 | + const TSD_StatusT ret = this->PrepareForCheckCode(); |
| 202 | if (ret != TSD_OK) { | 188 | if (ret != TSD_OK) { |
| 203 | return ret; | 189 | return ret; |
| 204 | } | 190 | } |
| 205 | const ScopeGuard destroySessionGuard([this]() { this->commAgent_.ReleaseDeviceConnection(); }); | 191 | const ScopeGuard destroySessionGuard([this]() { this->commAgent_.ReleaseDeviceConnection(); }); |
| 206 | - if (mgr_.GetDeviceCheckCodeOnce(msg) != TSD_OK) { | 192 | + if (this->GetDeviceCheckCodeOnce(msg) != TSD_OK) { |
| 207 | TSD_ERROR("get check code once failed."); | 193 | TSD_ERROR("get check code once failed."); |
| 208 | return TSD_INTERNAL_ERROR; | 194 | return TSD_INTERNAL_ERROR; |
| 209 | } | 195 | } |
| @@ -213,20 +199,20 @@ TSD_StatusT PackageCheckCodeService::GetDeviceCheckCodeRetry(const HDCMessage& m | |||
| 213 | void PackageCheckCodeService::SetHostCheckCode(HDCMessage& msg, TsdLoadPackageType type) | 199 | void PackageCheckCodeService::SetHostCheckCode(HDCMessage& msg, TsdLoadPackageType type) |
| 214 | { | 200 | { |
| 215 | const uint32_t packageType = static_cast<uint32_t>(type); | 201 | const uint32_t packageType = static_cast<uint32_t>(type); |
| 216 | - if (envInfo_.packageName_[packageType].empty()) { | 202 | + if (envInfo_.GetPackageNameRef(packageType).empty()) { |
| 217 | return; | 203 | return; |
| 218 | } | 204 | } |
| 219 | - const std::string orgFile = envInfo_.packagePath_[packageType] + envInfo_.packageName_[packageType]; | 205 | + const std::string orgFile = envInfo_.GetPackagePathRef(packageType) + envInfo_.GetPackageNameRef(packageType); |
| 220 | - hostCheckCode_[packageType] = CalFileSize(orgFile.c_str()); | 206 | + ctx_.hostCheckCode[packageType] = static_cast<uint32_t>(CalFileSize(orgFile.c_str())); |
| 221 | switch (type) { | 207 | switch (type) { |
| 222 | case TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL: | 208 | case TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL: |
| 223 | - msg.set_check_code(hostCheckCode_[packageType]); | 209 | + msg.set_check_code(ctx_.hostCheckCode[packageType]); |
| 224 | break; | 210 | break; |
| 225 | case TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL: | 211 | case TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL: |
| 226 | - msg.set_extendpkg_check_code(hostCheckCode_[packageType]); | 212 | + msg.set_extendpkg_check_code(ctx_.hostCheckCode[packageType]); |
| 227 | break; | 213 | break; |
| 228 | case TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP: | 214 | case TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP: |
| 229 | - msg.set_ascendcpppkg_check_code(hostCheckCode_[packageType]); | 215 | + msg.set_ascendcpppkg_check_code(ctx_.hostCheckCode[packageType]); |
| 230 | break; | 216 | break; |
| 231 | default: | 217 | default: |
| 232 | break; | 218 | break; |
| @@ -237,7 +223,7 @@ TSD_StatusT PackageCheckCodeService::GetDeviceHsPkgCheckCode( | |||
| 237 | const uint32_t checkCode, const HDCMessage::MsgType msgType, const bool beforeSendFlag, | 223 | const uint32_t checkCode, const HDCMessage::MsgType msgType, const bool beforeSendFlag, |
| 238 | const MessageContext& baseCtx) | 224 | const MessageContext& baseCtx) |
| 239 | { | 225 | { |
| 240 | - TSD_StatusT ret = mgr_.InitTsdClient(); | 226 | + TSD_StatusT ret = this->InitTsdClient(); |
| 241 | if (ret != TSD_OK) { | 227 | if (ret != TSD_OK) { |
| 242 | TSD_ERROR("InitTsdClient failed"); | 228 | TSD_ERROR("InitTsdClient failed"); |
| 243 | return TSD_INTERNAL_ERROR; | 229 | return TSD_INTERNAL_ERROR; |
| @@ -260,7 +246,7 @@ TSD_StatusT PackageCheckCodeService::GetDeviceHsPkgCheckCode( | |||
| 260 | TSD_RUN_INFO( | 246 | TSD_RUN_INFO( |
| 261 | "[TsdClient][deviceId=%u] [sessionId=%u] wait package info response msgType:%u", envInfo_.GetLogicDeviceId(), | 247 | "[TsdClient][deviceId=%u] [sessionId=%u] wait package info response msgType:%u", envInfo_.GetLogicDeviceId(), |
| 262 | commAgent_.GetSessionId(), static_cast<uint32_t>(msgType)); | 248 | commAgent_.GetSessionId(), static_cast<uint32_t>(msgType)); |
| 263 | - ret = mgr_.WaitPkgRsp(HELPER_PKG_LOAD_TIMEOUT); | 249 | + ret = this->WaitPkgRsp(HELPER_PKG_LOAD_TIMEOUT); |
| 264 | if (ret != TSD_OK) { | 250 | if (ret != TSD_OK) { |
| 265 | if (beforeSendFlag) { | 251 | if (beforeSendFlag) { |
| 266 | TSD_RUN_INFO("not receive TSD_CHECK_PACKAGE rsp msg, just send pkg to server"); | 252 | TSD_RUN_INFO("not receive TSD_CHECK_PACKAGE rsp msg, just send pkg to server"); |
| @@ -276,7 +262,7 @@ TSD_StatusT PackageCheckCodeService::GetDeviceHsPkgCheckCode( | |||
| 276 | TSD_StatusT PackageCheckCodeService::GetCannHsPkgCheckCode( | 262 | TSD_StatusT PackageCheckCodeService::GetCannHsPkgCheckCode( |
| 277 | const std::string& pkgPureName, const std::string& hostPkgHash, const MessageContext& baseCtx) | 263 | const std::string& pkgPureName, const std::string& hostPkgHash, const MessageContext& baseCtx) |
| 278 | { | 264 | { |
| 279 | - TSD_StatusT ret = mgr_.InitTsdClient(); | 265 | + TSD_StatusT ret = this->InitTsdClient(); |
| 280 | if (ret != TSD_OK) { | 266 | if (ret != TSD_OK) { |
| 281 | TSD_ERROR("InitTsdClient failed"); | 267 | TSD_ERROR("InitTsdClient failed"); |
| 282 | return TSD_INTERNAL_ERROR; | 268 | return TSD_INTERNAL_ERROR; |
| @@ -302,7 +288,7 @@ TSD_StatusT PackageCheckCodeService::GetCannHsPkgCheckCode( | |||
| 302 | TSD_RUN_INFO( | 288 | TSD_RUN_INFO( |
| 303 | "[TsdClient][deviceId=%u] [sessionId=%u] wait cann package info response for %s", envInfo_.GetLogicDeviceId(), | 289 | "[TsdClient][deviceId=%u] [sessionId=%u] wait cann package info response for %s", envInfo_.GetLogicDeviceId(), |
| 304 | commAgent_.GetSessionId(), pkgPureName.c_str()); | 290 | commAgent_.GetSessionId(), pkgPureName.c_str()); |
| 305 | - ret = mgr_.WaitPkgRsp(DRIVER_EXTEND_MAX_PROCESS_TIME * 1000U); | 291 | + ret = this->WaitPkgRsp(DRIVER_EXTEND_MAX_PROCESS_TIME * 1000U); |
| 306 | if (ret != TSD_OK) { | 292 | if (ret != TSD_OK) { |
| 307 | TSD_ERROR("Wait response for package %s failed", pkgPureName.c_str()); | 293 | TSD_ERROR("Wait response for package %s failed", pkgPureName.c_str()); |
| 308 | return TSD_INTERNAL_ERROR; | 294 | return TSD_INTERNAL_ERROR; |
| @@ -322,14 +308,14 @@ void PackageCheckCodeService::HandleNormalPackageCheckCodeRsp(const HDCMessage& | |||
| 322 | if (packageType == static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_COMMON_SINK)) { | 308 | if (packageType == static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_COMMON_SINK)) { |
| 323 | hashStore_.StoreAllPkgHashValue(msg); | 309 | hashStore_.StoreAllPkgHashValue(msg); |
| 324 | } else { | 310 | } else { |
| 325 | - peerCheckCode_[packageType] = msg.check_code(); | 311 | + ctx_.peerCheckCode[packageType] = msg.check_code(); |
| 326 | } | 312 | } |
| 327 | - mgr_.deviceIdle_ = msg.device_idle(); | 313 | + ctx_.deviceIdle = msg.device_idle(); |
| 328 | - if (!mgr_.deviceIdle_) { | 314 | + if (!ctx_.deviceIdle) { |
| 329 | TSD_RUN_WARN("device has process is running, skip load driver extend package"); | 315 | TSD_RUN_WARN("device has process is running, skip load driver extend package"); |
| 330 | } | 316 | } |
| 331 | - pkgRspCode_ = ((msg.tsd_rsp_code() == 0U) ? ResponseCode::SUCCESS : ResponseCode::FAIL); | 317 | + ctx_.pkgRspCode = ((msg.tsd_rsp_code() == 0U) ? ResponseCode::SUCCESS : ResponseCode::FAIL); |
| 332 | - loadPackageErrorMsg_ = msg.error_info().error_log(); | 318 | + ctx_.loadPackageErrorMsg = msg.error_info().error_log(); |
| 333 | } | 319 | } |
| 334 | 320 | ||
| 335 | void PackageCheckCodeService::HandleCannHsCheckCodeRsp(const HDCMessage& msg) | 321 | void PackageCheckCodeService::HandleCannHsCheckCodeRsp(const HDCMessage& msg) |
| @@ -341,8 +327,8 @@ void PackageCheckCodeService::HandleCannHsCheckCodeRsp(const HDCMessage& msg) | |||
| 341 | std::string pkgName = msg.package_hash_code_list(0).package_name(); | 327 | std::string pkgName = msg.package_hash_code_list(0).package_name(); |
| 342 | std::string deviceHashValue = msg.package_hash_code_list(0).hash_code(); | 328 | std::string deviceHashValue = msg.package_hash_code_list(0).hash_code(); |
| 343 | hashStore_.SetDeviceCommonSinkPackHashValue(pkgName, deviceHashValue); | 329 | hashStore_.SetDeviceCommonSinkPackHashValue(pkgName, deviceHashValue); |
| 344 | - pkgRspCode_ = (msg.tsd_rsp_code() == 0U) ? ResponseCode::SUCCESS : ResponseCode::FAIL; | 330 | + ctx_.pkgRspCode = (msg.tsd_rsp_code() == 0U) ? ResponseCode::SUCCESS : ResponseCode::FAIL; |
| 345 | - TSD_INFO("Set check code for %s success. rsp=%u", pkgName.c_str(), pkgRspCode_); | 331 | + TSD_INFO("Set check code for %s success. rsp=%u", pkgName.c_str(), ctx_.pkgRspCode); |
| 346 | } | 332 | } |
| 347 | 333 | ||
| 348 | void PackageCheckCodeService::SaveDeviceCheckCode(const HDCMessage& msg) | 334 | void PackageCheckCodeService::SaveDeviceCheckCode(const HDCMessage& msg) |
| @@ -28,7 +28,7 @@ const std::string EXTEND_PACKAGE_PATTERN = "^Ascend([0-9]{3}(rc)?(P)?)?-aicpu_ex | |||
| 28 | const std::string ASCENDCPP_PACKAGE_PATTERN = "^transformer_tile_fwk_aicpu_kernel\\.tar\\.gz$"; | 28 | const std::string ASCENDCPP_PACKAGE_PATTERN = "^transformer_tile_fwk_aicpu_kernel\\.tar\\.gz$"; |
| 29 | constexpr uint32_t SOC_VERSION_LEN = 50U; | 29 | constexpr uint32_t SOC_VERSION_LEN = 50U; |
| 30 | const std::string QUEUE_SCHEDULE_SO = "libqueue_schedule.so"; | 30 | const std::string QUEUE_SCHEDULE_SO = "libqueue_schedule.so"; |
| 31 | -const int64_t SUPPORT_MAX_DEVICE_PER_HOST = 8; | 31 | +constexpr int64_t SUPPORT_MAX_DEVICE_PER_HOST = 8; |
| 32 | } // namespace | 32 | } // namespace |
| 33 | 33 | ||
| 34 | namespace tsd { | 34 | namespace tsd { |
| @@ -118,7 +118,7 @@ bool PackageEnvInfo::GetShortSocVersion(std::string& shortSocVersion) const | |||
| 118 | TSD_RUN_WARN("get soc_version by halGetSocVersion failed"); | 118 | TSD_RUN_WARN("get soc_version by halGetSocVersion failed"); |
| 119 | return false; | 119 | return false; |
| 120 | } | 120 | } |
| 121 | - TSD_INFO("get soc_version:%s", socVersion); | 121 | + TSD_INFO("get soc_version:%s", &socVersion[0]); |
| 122 | (void)fe::PlatformInfoManager::Instance().InitializePlatformInfo(); | 122 | (void)fe::PlatformInfoManager::Instance().InitializePlatformInfo(); |
| 123 | fe::OptionalInfos optionalInfos; | 123 | fe::OptionalInfos optionalInfos; |
| 124 | fe::PlatFormInfos platformInfos; | 124 | fe::PlatFormInfos platformInfos; |
| @@ -269,7 +269,7 @@ bool PackageEnvInfo::CheckPackageExists(const bool loadAicpuKernelFlag) | |||
| 269 | packageTypes.push_back(static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL)); | 269 | packageTypes.push_back(static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL)); |
| 270 | } | 270 | } |
| 271 | packageTypes.push_back(static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)); | 271 | packageTypes.push_back(static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)); |
| 272 | - for (const auto packageType : packageTypes) { | 272 | + for (const uint32_t packageType : packageTypes) { |
| 273 | if (CheckPackageExistsOnce(packageType)) { | 273 | if (CheckPackageExistsOnce(packageType)) { |
| 274 | TSD_INFO("[TsdClient][deviceId=%u] get package successfully, packageType[%u]", logicDeviceId_, packageType); | 274 | TSD_INFO("[TsdClient][deviceId=%u] get package successfully, packageType[%u]", logicDeviceId_, packageType); |
| 275 | hasPackage = true; | 275 | hasPackage = true; |
| @@ -9,7 +9,9 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#include "package_manager.h" | 12 | +#include "package_sender.h" |
| 13 | + | ||
| 14 | + | ||
| 13 | 15 | ||
| 14 | 16 | ||
| 15 | 17 | ||
| @@ -64,6 +66,8 @@ std::string ConstructVerifyPkgErrorReason(const std::string& loadPackageErrorMsg | |||
| 64 | reason = "Signature verification failed. The possible cause is that a multi-bit ECC error occurred " | 66 | reason = "Signature verification failed. The possible cause is that a multi-bit ECC error occurred " |
| 65 | "on the device or the software package has been tampered with. Obtain the device log, check whether " | 67 | "on the device or the software package has been tampered with. Obtain the device log, check whether " |
| 66 | "ECC errors are reported, and contact technical support at https://www.hiascend.com/support"; | 68 | "ECC errors are reported, and contact technical support at https://www.hiascend.com/support"; |
| 69 | + } else { | ||
| 70 | + TSD_RUN_WARN("unsupported verify error message"); | ||
| 67 | } | 71 | } |
| 68 | return reason; | 72 | return reason; |
| 69 | } | 73 | } |
| @@ -72,20 +76,22 @@ std::string ConstructVerifyPkgErrorReason(const std::string& loadPackageErrorMsg | |||
| 72 | namespace tsd { | 76 | namespace tsd { |
| 73 | 77 | ||
| 74 | PackageLoader::PackageLoader( | 78 | PackageLoader::PackageLoader( |
| 75 | - PackageManager& mgr, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, | 79 | + DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, PackageHashStore& hashStore, |
| 76 | - PackageHashStore& hashStore, ResponseCode& pkgRspCode, std::string& loadPackageErrorMsg) | 80 | + PackageContext& ctx, PackageSender& sender, PackageCheckCodeService& checkCodeSvc, |
| 77 | - : mgr_(mgr), | 81 | + PluginVersionManager& pluginVersion) |
| 78 | - commAgent_(commAgent), | 82 | + : commAgent_(commAgent), |
| 79 | capabilityMgr_(capabilityMgr), | 83 | capabilityMgr_(capabilityMgr), |
| 80 | envInfo_(envInfo), | 84 | envInfo_(envInfo), |
| 81 | hashStore_(hashStore), | 85 | hashStore_(hashStore), |
| 82 | - pkgRspCode_(pkgRspCode), | 86 | + ctx_(ctx), |
| 83 | - loadPackageErrorMsg_(loadPackageErrorMsg) | 87 | + sender_(sender), |
| 88 | + checkCodeSvc_(checkCodeSvc), | ||
| 89 | + pluginVersion_(pluginVersion) | ||
| 84 | {} | 90 | {} |
| 85 | 91 | ||
| 86 | void PackageLoader::Reset() | 92 | void PackageLoader::Reset() |
| 87 | { | 93 | { |
| 88 | - aicpuPackageExistInDevice_ = false; | 94 | + SetAicpuPackageExistInDevice(false); |
| 89 | hasSendConfigFile_ = false; | 95 | hasSendConfigFile_ = false; |
| 90 | hashStore_.Clear(); | 96 | hashStore_.Clear(); |
| 91 | } | 97 | } |
| @@ -93,12 +99,12 @@ void PackageLoader::Reset() | |||
| 93 | TSD_StatusT PackageLoader::LoadSysOpKernel() | 99 | TSD_StatusT PackageLoader::LoadSysOpKernel() |
| 94 | { | 100 | { |
| 95 | const bool loadAicpuKernelFlag = ShouldLoadLegacyPackage(); | 101 | const bool loadAicpuKernelFlag = ShouldLoadLegacyPackage(); |
| 96 | - if (!mgr_.CheckPackageExists(loadAicpuKernelFlag)) { | 102 | + if (!envInfo_.CheckPackageExists(loadAicpuKernelFlag)) { |
| 97 | TSD_RUN_INFO("[TsdClient][logicDeviceId_=%u] cannot find aicpu packages", envInfo_.GetLogicDeviceId()); | 103 | TSD_RUN_INFO("[TsdClient][logicDeviceId_=%u] cannot find aicpu packages", envInfo_.GetLogicDeviceId()); |
| 98 | return TSD_OK; | 104 | return TSD_OK; |
| 99 | } | 105 | } |
| 100 | 106 | ||
| 101 | - TSD_StatusT ret = mgr_.GetDeviceCheckCode(); | 107 | + const TSD_StatusT ret = checkCodeSvc_.GetDeviceCheckCode(); |
| 102 | if (ret == TSD_AICPUPACKAGE_EXISTED) { | 108 | if (ret == TSD_AICPUPACKAGE_EXISTED) { |
| 103 | return TSD_OK; | 109 | return TSD_OK; |
| 104 | } | 110 | } |
| @@ -142,14 +148,14 @@ TSD_StatusT PackageLoader::SendAllPackagesToPeer() | |||
| 142 | } | 148 | } |
| 143 | const std::string basePath(drvPath); | 149 | const std::string basePath(drvPath); |
| 144 | 150 | ||
| 145 | - TSD_StatusT ret = mgr_.SendAICPUPackage(peerNode, basePath); | 151 | + TSD_StatusT ret = sender_.SendAICPUPackage(peerNode, basePath); |
| 146 | if (ret != TSD_OK) { | 152 | if (ret != TSD_OK) { |
| 147 | REPORT_INPUT_ERROR("E39006", std::vector<std::string>(), std::vector<std::string>()); | 153 | REPORT_INPUT_ERROR("E39006", std::vector<std::string>(), std::vector<std::string>()); |
| 148 | TSD_ERROR("[TsdClient][deviceId=%u] send aicpu package to device failed", envInfo_.GetLogicDeviceId()); | 154 | TSD_ERROR("[TsdClient][deviceId=%u] send aicpu package to device failed", envInfo_.GetLogicDeviceId()); |
| 149 | return ret; | 155 | return ret; |
| 150 | } | 156 | } |
| 151 | 157 | ||
| 152 | - ret = mgr_.SendCommonPackage( | 158 | + ret = sender_.SendCommonPackage( |
| 153 | peerNode, basePath, static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL)); | 159 | peerNode, basePath, static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL)); |
| 154 | if (ret != TSD_OK) { | 160 | if (ret != TSD_OK) { |
| 155 | REPORT_INPUT_ERROR("E39006", std::vector<std::string>(), std::vector<std::string>()); | 161 | REPORT_INPUT_ERROR("E39006", std::vector<std::string>(), std::vector<std::string>()); |
| @@ -157,7 +163,8 @@ TSD_StatusT PackageLoader::SendAllPackagesToPeer() | |||
| 157 | return ret; | 163 | return ret; |
| 158 | } | 164 | } |
| 159 | 165 | ||
| 160 | - ret = mgr_.SendCommonPackage(peerNode, basePath, static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)); | 166 | + ret = sender_.SendCommonPackage( |
| 167 | + peerNode, basePath, static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)); | ||
| 161 | if (ret != TSD_OK) { | 168 | if (ret != TSD_OK) { |
| 162 | TSD_ERROR("[TsdClient][deviceId=%u] send ascendcpp package to device failed", envInfo_.GetLogicDeviceId()); | 169 | TSD_ERROR("[TsdClient][deviceId=%u] send ascendcpp package to device failed", envInfo_.GetLogicDeviceId()); |
| 163 | } | 170 | } |
| @@ -186,19 +193,19 @@ TSD_StatusT PackageLoader::LoadHsPkgToDevice( | |||
| 186 | "[TsdClient] file[%s] does not exist, deviceId[%u]", fullPkgPath.c_str(), envInfo_.GetLogicDeviceId()); | 193 | "[TsdClient] file[%s] does not exist, deviceId[%u]", fullPkgPath.c_str(), envInfo_.GetLogicDeviceId()); |
| 187 | return TSD_INTERNAL_ERROR; | 194 | return TSD_INTERNAL_ERROR; |
| 188 | } | 195 | } |
| 189 | - mgr_.packagePeerCheckCode_[static_cast<uint32_t>(pkgType)] = 0U; | 196 | + checkCodeSvc_.SetPeerCheckCode(static_cast<uint32_t>(pkgType), 0U); |
| 190 | - const uint32_t checkCode = CalFileSize(fullPkgPath.c_str()); | 197 | + const uint32_t checkCode = static_cast<uint32_t>(CalFileSize(fullPkgPath.c_str())); |
| 191 | const auto ret = | 198 | const auto ret = |
| 192 | - mgr_.SendFileToDevice(basePath.c_str(), basePath.length(), pkgName.c_str(), pkgName.length(), true); | 199 | + sender_.SendFileToDevice(basePath.c_str(), basePath.length(), pkgName.c_str(), pkgName.length(), true); |
| 193 | TSD_CHECK(ret == TSD_OK, ret, "send pkg to device failed."); | 200 | TSD_CHECK(ret == TSD_OK, ret, "send pkg to device failed."); |
| 194 | - if (mgr_.GetDeviceHsPkgCheckCode(checkCode, msgType, false, baseCtx) != TSD_OK) { | 201 | + if (checkCodeSvc_.GetDeviceHsPkgCheckCode(checkCode, msgType, false, baseCtx) != TSD_OK) { |
| 195 | TSD_ERROR("GetDeviceHsPkgCheckCode failed"); | 202 | TSD_ERROR("GetDeviceHsPkgCheckCode failed"); |
| 196 | return TSD_INTERNAL_ERROR; | 203 | return TSD_INTERNAL_ERROR; |
| 197 | } | 204 | } |
| 198 | - if (checkCode != mgr_.packagePeerCheckCode_[static_cast<uint32_t>(pkgType)]) { | 205 | + if (checkCode != checkCodeSvc_.GetPeerCheckCode(static_cast<uint32_t>(pkgType))) { |
| 199 | TSD_ERROR( | 206 | TSD_ERROR( |
| 200 | "checode verify is failed checkCode:%u, peerCheckCode:%u", checkCode, | 207 | "checode verify is failed checkCode:%u, peerCheckCode:%u", checkCode, |
| 201 | - mgr_.packagePeerCheckCode_[static_cast<uint32_t>(pkgType)]); | 208 | + checkCodeSvc_.GetPeerCheckCode(static_cast<uint32_t>(pkgType))); |
| 202 | return TSD_INTERNAL_ERROR; | 209 | return TSD_INTERNAL_ERROR; |
| 203 | } | 210 | } |
| 204 | return TSD_OK; | 211 | return TSD_OK; |
| @@ -208,12 +215,12 @@ TSD_StatusT PackageLoader::LoadRuntimePkgToDevice(const MessageContext& baseCtx) | |||
| 208 | { | 215 | { |
| 209 | if (capabilityMgr_.IsSupportCommonSink() && (&drvHdcSendFileV2 != nullptr) && | 216 | if (capabilityMgr_.IsSupportCommonSink() && (&drvHdcSendFileV2 != nullptr) && |
| 210 | (&drvHdcGetTrustedBasePathV2 != nullptr)) { | 217 | (&drvHdcGetTrustedBasePathV2 != nullptr)) { |
| 211 | - (void)mgr_.LoadPackageConfigInfoToDevice(false); | 218 | + (void)this->LoadPackageConfigInfoToDevice(false); |
| 212 | - if (mgr_.LoadCannHsPkgToDevice(UDF_PKG_NAME, baseCtx) != TSD_OK) { | 219 | + if (this->LoadCannHsPkgToDevice(UDF_PKG_NAME, baseCtx) != TSD_OK) { |
| 213 | TSD_ERROR("Load package failed, package:%s", UDF_PKG_NAME.c_str()); | 220 | TSD_ERROR("Load package failed, package:%s", UDF_PKG_NAME.c_str()); |
| 214 | return TSD_INTERNAL_ERROR; | 221 | return TSD_INTERNAL_ERROR; |
| 215 | } | 222 | } |
| 216 | - if (mgr_.LoadCannHsPkgToDevice(HCCD_PKG_NAME, baseCtx) != TSD_OK) { | 223 | + if (this->LoadCannHsPkgToDevice(HCCD_PKG_NAME, baseCtx) != TSD_OK) { |
| 217 | TSD_ERROR("Load package failed, package:%s", HCCD_PKG_NAME.c_str()); | 224 | TSD_ERROR("Load package failed, package:%s", HCCD_PKG_NAME.c_str()); |
| 218 | return TSD_INTERNAL_ERROR; | 225 | return TSD_INTERNAL_ERROR; |
| 219 | } | 226 | } |
| @@ -228,7 +235,7 @@ TSD_StatusT PackageLoader::LoadRuntimePkgToDevice(const MessageContext& baseCtx) | |||
| 228 | 235 | ||
| 229 | TSD_StatusT PackageLoader::LoadCannHsPkgToDevice(const std::string& pkgPureName, const MessageContext& baseCtx) | 236 | TSD_StatusT PackageLoader::LoadCannHsPkgToDevice(const std::string& pkgPureName, const MessageContext& baseCtx) |
| 230 | { | 237 | { |
| 231 | - int32_t peerNode = 0; | 238 | + const int32_t peerNode = 0; |
| 232 | const std::string dstDirPreFix = envInfo_.GetTrustedBasePath(true); | 239 | const std::string dstDirPreFix = envInfo_.GetTrustedBasePath(true); |
| 233 | 240 | ||
| 234 | PackageProcessConfig* pkgConInst = PackageProcessConfig::GetInstance(); | 241 | PackageProcessConfig* pkgConInst = PackageProcessConfig::GetInstance(); |
| @@ -245,17 +252,17 @@ TSD_StatusT PackageLoader::LoadCannHsPkgToDevice(const std::string& pkgPureName, | |||
| 245 | 252 | ||
| 246 | const std::string hostHash = CalFileSha256HashValue(orgFile); | 253 | const std::string hostHash = CalFileSha256HashValue(orgFile); |
| 247 | hashStore_.SetHostCommonSinkPackHashValue(pkgPureName, hostHash); | 254 | hashStore_.SetHostCommonSinkPackHashValue(pkgPureName, hostHash); |
| 248 | - if (mgr_.IsCommonSinkHostAndDevicePkgSame(pkgPureName)) { | 255 | + if (hashStore_.IsCommonSinkHostAndDevicePkgSame(pkgPureName)) { |
| 249 | TSD_INFO("current package:%s is same as device, skip load", pkgPureName.c_str()); | 256 | TSD_INFO("current package:%s is same as device, skip load", pkgPureName.c_str()); |
| 250 | return TSD_OK; | 257 | return TSD_OK; |
| 251 | } | 258 | } |
| 252 | 259 | ||
| 253 | - if (mgr_.LoadFileAndWaitRsp(pkgPureName, hostHash, peerNode, orgFile, dstFile, baseCtx) != TSD_OK) { | 260 | + if (this->LoadFileAndWaitRsp(pkgPureName, hostHash, peerNode, orgFile, dstFile, baseCtx) != TSD_OK) { |
| 254 | TSD_ERROR("compare and send package to device failed"); | 261 | TSD_ERROR("compare and send package to device failed"); |
| 255 | return TSD_INTERNAL_ERROR; | 262 | return TSD_INTERNAL_ERROR; |
| 256 | } | 263 | } |
| 257 | 264 | ||
| 258 | - if (static_cast<uint32_t>(pkgRspCode_) != 0U) { | 265 | + if (static_cast<uint32_t>(ctx_.pkgRspCode) != 0U) { |
| 259 | TSD_ERROR("host and device check code compare failed, package:%s", pkgPureName.c_str()); | 266 | TSD_ERROR("host and device check code compare failed, package:%s", pkgPureName.c_str()); |
| 260 | return TSD_INTERNAL_ERROR; | 267 | return TSD_INTERNAL_ERROR; |
| 261 | } | 268 | } |
| @@ -268,12 +275,12 @@ TSD_StatusT PackageLoader::LoadFileAndWaitRsp( | |||
| 268 | const std::string& pkgPureName, const std::string& hostPkgHash, const int32_t peerNode, const std::string& orgFile, | 275 | const std::string& pkgPureName, const std::string& hostPkgHash, const int32_t peerNode, const std::string& orgFile, |
| 269 | const std::string& dstFile, const MessageContext& baseCtx) | 276 | const std::string& dstFile, const MessageContext& baseCtx) |
| 270 | { | 277 | { |
| 271 | - if (mgr_.SendAICPUPackageSimple(peerNode, orgFile, dstFile, true) != TSD_OK) { | 278 | + if (sender_.SendAICPUPackageSimple(peerNode, orgFile, dstFile, true) != TSD_OK) { |
| 272 | TSD_ERROR("send package to device failed, package:%s", pkgPureName.c_str()); | 279 | TSD_ERROR("send package to device failed, package:%s", pkgPureName.c_str()); |
| 273 | return TSD_INTERNAL_ERROR; | 280 | return TSD_INTERNAL_ERROR; |
| 274 | } | 281 | } |
| 275 | 282 | ||
| 276 | - if (mgr_.GetCannHsPkgCheckCode(pkgPureName, hostPkgHash, baseCtx) != TSD_OK) { | 283 | + if (checkCodeSvc_.GetCannHsPkgCheckCode(pkgPureName, hostPkgHash, baseCtx) != TSD_OK) { |
| 277 | TSD_ERROR("get check code from device failed, package:%s", pkgPureName.c_str()); | 284 | TSD_ERROR("get check code from device failed, package:%s", pkgPureName.c_str()); |
| 278 | return TSD_INTERNAL_ERROR; | 285 | return TSD_INTERNAL_ERROR; |
| 279 | } | 286 | } |
| @@ -303,10 +310,10 @@ TSD_StatusT PackageLoader::LoadOmFileToDevice( | |||
| 303 | TSD_ERROR("input str is invalid reason:%s", e.what()); | 310 | TSD_ERROR("input str is invalid reason:%s", e.what()); |
| 304 | return TSD_INTERNAL_ERROR; | 311 | return TSD_INTERNAL_ERROR; |
| 305 | } | 312 | } |
| 306 | - auto ret = mgr_.SendFileToDevice(filePath, pathLen, fileName, fileNameLen, true); | 313 | + auto ret = sender_.SendFileToDevice(filePath, pathLen, fileName, fileNameLen, true); |
| 307 | TSD_CHECK(ret == TSD_OK, ret, "SendFileToDevice failed."); | 314 | TSD_CHECK(ret == TSD_OK, ret, "SendFileToDevice failed."); |
| 308 | 315 | ||
| 309 | - ret = mgr_.InitTsdClient(); | 316 | + ret = checkCodeSvc_.InitTsdClient(); |
| 310 | TSD_CHECK(ret == TSD_OK, ret, "Init hdc client failed."); | 317 | TSD_CHECK(ret == TSD_OK, ret, "Init hdc client failed."); |
| 311 | TSD_CHECK_NULLPTR(commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_FOUND, "devCommClient_ is null in send function"); | 318 | TSD_CHECK_NULLPTR(commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_FOUND, "devCommClient_ is null in send function"); |
| 312 | std::string curFile(fileName, fileNameLen); | 319 | std::string curFile(fileName, fileNameLen); |
| @@ -320,7 +327,7 @@ TSD_StatusT PackageLoader::LoadOmFileToDevice( | |||
| 320 | TSD_CHECK(ret == TSD_OK, ret, "build TSD_OM_PKG_DECOMPRESS_STATUS msg failed."); | 327 | TSD_CHECK(ret == TSD_OK, ret, "build TSD_OM_PKG_DECOMPRESS_STATUS msg failed."); |
| 321 | ret = commAgent_.SendMsg(msg); | 328 | ret = commAgent_.SendMsg(msg); |
| 322 | TSD_CHECK(ret == TSD_OK, ret, "send TSD_OM_PKG_DECOMPRESS_STATUS msg failed."); | 329 | TSD_CHECK(ret == TSD_OK, ret, "send TSD_OM_PKG_DECOMPRESS_STATUS msg failed."); |
| 323 | - ret = mgr_.WaitPkgRsp(OMFILE_LOAD_TIMEOUT); | 330 | + ret = checkCodeSvc_.WaitPkgRsp(OMFILE_LOAD_TIMEOUT); |
| 324 | TSD_CHECK(ret == TSD_OK, ret, "Wait TSD_OM_PKG_DECOMPRESS_STATUS response from device failed."); | 331 | TSD_CHECK(ret == TSD_OK, ret, "Wait TSD_OM_PKG_DECOMPRESS_STATUS response from device failed."); |
| 325 | TSD_INFO("LoadOmFileToDevice success filepath:%s, filename:%s", filePath, fileName); | 332 | TSD_INFO("LoadOmFileToDevice success filepath:%s, filename:%s", filePath, fileName); |
| 326 | return TSD_OK; | 333 | return TSD_OK; |
| @@ -330,18 +337,18 @@ TSD_StatusT PackageLoader::LoadFileToDevice( | |||
| 330 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, | 337 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, |
| 331 | const MessageContext& baseCtx) | 338 | const MessageContext& baseCtx) |
| 332 | { | 339 | { |
| 333 | - if (!mgr_.IsOkToLoadFileToDevice(fileName, fileNameLen)) { | 340 | + if (!this->IsOkToLoadFileToDevice(fileName, fileNameLen)) { |
| 334 | TSD_ERROR("IsOkToLoadFileToDevice is false"); | 341 | TSD_ERROR("IsOkToLoadFileToDevice is false"); |
| 335 | return TSD_INTERNAL_ERROR; | 342 | return TSD_INTERNAL_ERROR; |
| 336 | } | 343 | } |
| 337 | const std::string loadFile(fileName, fileNameLen); | 344 | const std::string loadFile(fileName, fileNameLen); |
| 338 | TSD_RUN_INFO("begin load file:%s", loadFile.c_str()); | 345 | TSD_RUN_INFO("begin load file:%s", loadFile.c_str()); |
| 339 | if (loadFile == RUNTIME_PKG_NAME) { | 346 | if (loadFile == RUNTIME_PKG_NAME) { |
| 340 | - return mgr_.LoadRuntimePkgToDevice(baseCtx); | 347 | + return this->LoadRuntimePkgToDevice(baseCtx); |
| 341 | } else if (loadFile == DSHAPE_PKG_NAME) { | 348 | } else if (loadFile == DSHAPE_PKG_NAME) { |
| 342 | - return mgr_.LoadDShapePkgToDevice(baseCtx); | 349 | + return this->LoadDShapePkgToDevice(baseCtx); |
| 343 | } else { | 350 | } else { |
| 344 | - return mgr_.LoadOmFileToDevice(filePath, pathLen, fileName, fileNameLen, baseCtx); | 351 | + return this->LoadOmFileToDevice(filePath, pathLen, fileName, fileNameLen, baseCtx); |
| 345 | } | 352 | } |
| 346 | } | 353 | } |
| 347 | 354 | ||
| @@ -379,7 +386,7 @@ TSD_StatusT PackageLoader::LoadPackageConfigInfoToDevice(const bool hasPluginVer | |||
| 379 | return TSD_OK; | 386 | return TSD_OK; |
| 380 | } | 387 | } |
| 381 | 388 | ||
| 382 | - TSD_StatusT ret = mgr_.InitTsdClient(); | 389 | + TSD_StatusT ret = checkCodeSvc_.InitTsdClient(); |
| 383 | if (ret != TSD_OK) { | 390 | if (ret != TSD_OK) { |
| 384 | TSD_ERROR("[TsdClient][deviceId_=%u] InitTsdClient failed, ret[%d]", envInfo_.GetLogicDeviceId(), ret); | 391 | TSD_ERROR("[TsdClient][deviceId_=%u] InitTsdClient failed, ret[%d]", envInfo_.GetLogicDeviceId(), ret); |
| 385 | return TSD_INTERNAL_ERROR; | 392 | return TSD_INTERNAL_ERROR; |
| @@ -455,7 +462,7 @@ TSD_StatusT PackageLoader::LoadSinglePackageToDevice( | |||
| 455 | std::string orgFile; | 462 | std::string orgFile; |
| 456 | std::string dstFile = dstDirPreFix; | 463 | std::string dstFile = dstDirPreFix; |
| 457 | TSD_RUN_INFO("begin to load package:%s to device:%u", pkgPureName.c_str(), envInfo_.GetLogicDeviceId()); | 464 | TSD_RUN_INFO("begin to load package:%s to device:%u", pkgPureName.c_str(), envInfo_.GetLogicDeviceId()); |
| 458 | - if ((!detail.loadAsPerSocFlag) && (!mgr_.SupportLoadPkg(pkgPureName))) { | 465 | + if ((!detail.loadAsPerSocFlag) && (!this->SupportLoadPkg(pkgPureName))) { |
| 459 | TSD_RUN_INFO( | 466 | TSD_RUN_INFO( |
| 460 | "current package:%s does not need to load to device:%u", pkgPureName.c_str(), envInfo_.GetLogicDeviceId()); | 467 | "current package:%s does not need to load to device:%u", pkgPureName.c_str(), envInfo_.GetLogicDeviceId()); |
| 461 | return TSD_OK; | 468 | return TSD_OK; |
| @@ -476,19 +483,19 @@ TSD_StatusT PackageLoader::LoadSinglePackageToDevice( | |||
| 476 | } | 483 | } |
| 477 | const std::string hostPkgHash = CalFileSha256HashValue(orgFile); | 484 | const std::string hostPkgHash = CalFileSha256HashValue(orgFile); |
| 478 | hashStore_.SetHostCommonSinkPackHashValue(pkgPureName, hostPkgHash); | 485 | hashStore_.SetHostCommonSinkPackHashValue(pkgPureName, hostPkgHash); |
| 479 | - if (mgr_.IsCompatPluginPackage(detail) && !mgr_.ShouldLoadCompatPluginPkg(pkgPureName)) { | 486 | + if (pluginVersion_.IsCompatPluginPackage(detail) && !pluginVersion_.ShouldLoadCompatPluginPkg(pkgPureName)) { |
| 480 | TSD_RUN_INFO("skip load compat plugin package:%s by version/strategy check", pkgPureName.c_str()); | 487 | TSD_RUN_INFO("skip load compat plugin package:%s by version/strategy check", pkgPureName.c_str()); |
| 481 | return TSD_OK; | 488 | return TSD_OK; |
| 482 | } | 489 | } |
| 483 | - if (!mgr_.IsCompatPluginPackage(detail) && mgr_.IsCommonSinkHostAndDevicePkgSame(pkgPureName)) { | 490 | + if (!pluginVersion_.IsCompatPluginPackage(detail) && hashStore_.IsCommonSinkHostAndDevicePkgSame(pkgPureName)) { |
| 484 | TSD_RUN_INFO("current package:%s is same as device, skip load", pkgPureName.c_str()); | 491 | TSD_RUN_INFO("current package:%s is same as device, skip load", pkgPureName.c_str()); |
| 485 | return TSD_OK; | 492 | return TSD_OK; |
| 486 | } | 493 | } |
| 487 | - if (mgr_.CompareAndSendCommonSinkPkg(pkgPureName, hostPkgHash, peerNode, orgFile, dstFile) != TSD_OK) { | 494 | + if (sender_.CompareAndSendCommonSinkPkg(pkgPureName, hostPkgHash, peerNode, orgFile, dstFile) != TSD_OK) { |
| 488 | TSD_ERROR("compare and send package to device failed package:%s", pkgPureName.c_str()); | 495 | TSD_ERROR("compare and send package to device failed package:%s", pkgPureName.c_str()); |
| 489 | return TSD_INTERNAL_ERROR; | 496 | return TSD_INTERNAL_ERROR; |
| 490 | } | 497 | } |
| 491 | - if (static_cast<uint32_t>(pkgRspCode_) != 0U) { | 498 | + if (static_cast<uint32_t>(ctx_.pkgRspCode) != 0U) { |
| 492 | this->ReportSinkPkgRspError(pkgPureName); | 499 | this->ReportSinkPkgRspError(pkgPureName); |
| 493 | return TSD_INTERNAL_ERROR; | 500 | return TSD_INTERNAL_ERROR; |
| 494 | } | 501 | } |
| @@ -499,18 +506,18 @@ TSD_StatusT PackageLoader::LoadSinglePackageToDevice( | |||
| 499 | void PackageLoader::ReportSinkPkgRspError(const std::string& pkgPureName) | 506 | void PackageLoader::ReportSinkPkgRspError(const std::string& pkgPureName) |
| 500 | { | 507 | { |
| 501 | bool reportedFlag = false; | 508 | bool reportedFlag = false; |
| 502 | - if (!loadPackageErrorMsg_.empty()) { | 509 | + if (!ctx_.loadPackageErrorMsg.empty()) { |
| 503 | - TSD_ERROR("[Device error message] %s", loadPackageErrorMsg_.c_str()); | 510 | + TSD_ERROR("[Device error message] %s", ctx_.loadPackageErrorMsg.c_str()); |
| 504 | - const bool isCmsVerifyFail = (loadPackageErrorMsg_.find("cms verify failed") != std::string::npos); | 511 | + const bool isCmsVerifyFail = (ctx_.loadPackageErrorMsg.find("cms verify failed") != std::string::npos); |
| 505 | const std::string reason = | 512 | const std::string reason = |
| 506 | - isCmsVerifyFail ? ConstructVerifyPkgErrorReason(loadPackageErrorMsg_) : std::string{}; | 513 | + isCmsVerifyFail ? ConstructVerifyPkgErrorReason(ctx_.loadPackageErrorMsg) : std::string{}; |
| 507 | if (!reason.empty()) { | 514 | if (!reason.empty()) { |
| 508 | const std::vector<std::string> keys{"package_name", "reason"}; | 515 | const std::vector<std::string> keys{"package_name", "reason"}; |
| 509 | const std::vector<std::string> values{pkgPureName, reason}; | 516 | const std::vector<std::string> values{pkgPureName, reason}; |
| 510 | REPORT_INPUT_ERROR("E30009", keys, values); | 517 | REPORT_INPUT_ERROR("E30009", keys, values); |
| 511 | reportedFlag = true; | 518 | reportedFlag = true; |
| 512 | } | 519 | } |
| 513 | - loadPackageErrorMsg_ = ""; | 520 | + ctx_.loadPackageErrorMsg = ""; |
| 514 | } | 521 | } |
| 515 | if (!reportedFlag) { | 522 | if (!reportedFlag) { |
| 516 | REPORT_INPUT_ERROR("E39011", std::vector<std::string>{"package_name"}, std::vector<std::string>{pkgPureName}); | 523 | REPORT_INPUT_ERROR("E39011", std::vector<std::string>{"package_name"}, std::vector<std::string>{pkgPureName}); |
| @@ -536,7 +543,7 @@ TSD_StatusT PackageLoader::LoadPackageToDeviceByConfig() | |||
| 536 | std::map<std::string, PackConfDetail> configMap = pkgConInst->GetAllPackageConfigInfo(); | 543 | std::map<std::string, PackConfDetail> configMap = pkgConInst->GetAllPackageConfigInfo(); |
| 537 | 544 | ||
| 538 | for (auto& entry : configMap) { | 545 | for (auto& entry : configMap) { |
| 539 | - if (mgr_.LoadSinglePackageToDevice(entry.first, entry.second, peerNode, dstDirPreFix) != TSD_OK) { | 546 | + if (this->LoadSinglePackageToDevice(entry.first, entry.second, peerNode, dstDirPreFix) != TSD_OK) { |
| 540 | return TSD_INTERNAL_ERROR; | 547 | return TSD_INTERNAL_ERROR; |
| 541 | } | 548 | } |
| 542 | } | 549 | } |
| @@ -15,32 +15,17 @@ namespace tsd { | |||
| 15 | PackageManager::PackageManager( | 15 | PackageManager::PackageManager( |
| 16 | uint32_t logicDeviceId, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, uint32_t platInfoMode, | 16 | uint32_t logicDeviceId, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, uint32_t platInfoMode, |
| 17 | bool isAdcEnv, uint32_t chipType) | 17 | bool isAdcEnv, uint32_t chipType) |
| 18 | - : getCheckCodeRetrySupport_(false), | 18 | + : envInfo_(logicDeviceId, platInfoMode, isAdcEnv, chipType), |
| 19 | - deviceIdle_(false), | ||
| 20 | - loadPackageErrorMsg_(""), | ||
| 21 | - envInfo_(logicDeviceId, platInfoMode, isAdcEnv, chipType), | ||
| 22 | hashStore_(), | 19 | hashStore_(), |
| 23 | - pluginVersion_(envInfo_, hashStore_, pkgRspCode_), | 20 | + ctx_(), |
| 24 | - packageName_(envInfo_.packageName_), | 21 | + pluginVersion_(envInfo_, hashStore_, ctx_), |
| 25 | - pkgHostHashValue_(hashStore_.pkgHostHashValue_), | ||
| 26 | - pkgDeviceHashValue_(hashStore_.pkgDeviceHashValue_), | ||
| 27 | commAgent_(commAgent), | 22 | commAgent_(commAgent), |
| 28 | capabilityMgr_(capabilityMgr), | 23 | capabilityMgr_(capabilityMgr), |
| 29 | - devicePluginVersions_(pluginVersion_.devicePluginVersions_), | 24 | + checkCodeSvc_(commAgent_, capabilityMgr_, envInfo_, hashStore_, ctx_), |
| 30 | - pluginUpdateStrategy_(pluginVersion_.pluginUpdateStrategy_), | 25 | + sender_(commAgent_, capabilityMgr_, envInfo_, hashStore_, ctx_, checkCodeSvc_), |
| 31 | - hasComputedPluginStrategy_(pluginVersion_.hasComputedPluginStrategy_), | 26 | + loader_(commAgent_, capabilityMgr_, envInfo_, hashStore_, ctx_, sender_, checkCodeSvc_, pluginVersion_) |
| 32 | - sender_(*this, commAgent_, capabilityMgr_, envInfo_, hashStore_, deviceIdle_, getCheckCodeRetrySupport_), | ||
| 33 | - checkCodeSvc_( | ||
| 34 | - *this, commAgent_, capabilityMgr_, envInfo_, hashStore_, pkgRspCode_, getCheckCodeRetrySupport_, | ||
| 35 | - loadPackageErrorMsg_), | ||
| 36 | - loader_(*this, commAgent_, capabilityMgr_, envInfo_, hashStore_, pkgRspCode_, loadPackageErrorMsg_), | ||
| 37 | - aicpuPackageExistInDevice_(loader_.aicpuPackageExistInDevice_), | ||
| 38 | - packagePeerCheckCode_(checkCodeSvc_.peerCheckCode_), | ||
| 39 | - packageHostCheckCode_(checkCodeSvc_.hostCheckCode_) | ||
| 40 | {} | 27 | {} |
| 41 | 28 | ||
| 42 | -PackageManager::~PackageManager() {} | ||
| 43 | - | ||
| 44 | void PackageManager::ResetOnClose() { loader_.Reset(); } | 29 | void PackageManager::ResetOnClose() { loader_.Reset(); } |
| 45 | 30 | ||
| 46 | } // namespace tsd | 31 | } // namespace tsd |
| @@ -9,7 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#include "package_manager.h" | 12 | +#include "package_check_code_service.h" |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -29,19 +29,18 @@ constexpr uint32_t DRIVER_EXTEND_MAX_PROCESS_TIME = 140U; | |||
| 29 | namespace tsd { | 29 | namespace tsd { |
| 30 | 30 | ||
| 31 | PackageSender::PackageSender( | 31 | PackageSender::PackageSender( |
| 32 | - PackageManager& mgr, DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, | 32 | + DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageEnvInfo& envInfo, PackageHashStore& hashStore, |
| 33 | - PackageHashStore& hashStore, bool& deviceIdle, bool& getCheckCodeRetrySupport) | 33 | + PackageContext& ctx, PackageCheckCodeService& checkCodeSvc) |
| 34 | - : mgr_(mgr), | 34 | + : commAgent_(commAgent), |
| 35 | - commAgent_(commAgent), | ||
| 36 | capabilityMgr_(capabilityMgr), | 35 | capabilityMgr_(capabilityMgr), |
| 37 | envInfo_(envInfo), | 36 | envInfo_(envInfo), |
| 38 | hashStore_(hashStore), | 37 | hashStore_(hashStore), |
| 39 | - deviceIdle_(deviceIdle), | 38 | + ctx_(ctx), |
| 40 | - getCheckCodeRetrySupport_(getCheckCodeRetrySupport) | 39 | + checkCodeSvc_(checkCodeSvc) |
| 41 | {} | 40 | {} |
| 42 | 41 | ||
| 43 | TSD_StatusT PackageSender::SendAICPUPackageSimple( | 42 | TSD_StatusT PackageSender::SendAICPUPackageSimple( |
| 44 | - const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, bool useCannPath) | 43 | + const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, bool useCannPath) const |
| 45 | { | 44 | { |
| 46 | TSD_RUN_INFO( | 45 | TSD_RUN_INFO( |
| 47 | "[TsdClient][deviceId=%u] no equal to begin send file[%s] to [%s]", envInfo_.GetLogicDeviceId(), | 46 | "[TsdClient][deviceId=%u] no equal to begin send file[%s] to [%s]", envInfo_.GetLogicDeviceId(), |
| @@ -77,7 +76,7 @@ TSD_StatusT PackageSender::SendMsgAndHostPackage( | |||
| 77 | const std::function<bool(void)>& compareCallBack, bool useCannPath) | 76 | const std::function<bool(void)>& compareCallBack, bool useCannPath) |
| 78 | { | 77 | { |
| 79 | msg.set_wait_flag(false); | 78 | msg.set_wait_flag(false); |
| 80 | - TSD_StatusT ret = mgr_.GetDeviceCheckCodeRetry(msg); | 79 | + TSD_StatusT ret = checkCodeSvc_.GetDeviceCheckCodeRetry(msg); |
| 81 | if (ret != TSD_OK) { | 80 | if (ret != TSD_OK) { |
| 82 | if (ret >= TSD_SUBPROCESS_NUM_EXCEED_THE_LIMIT) { | 81 | if (ret >= TSD_SUBPROCESS_NUM_EXCEED_THE_LIMIT) { |
| 83 | return ret; | 82 | return ret; |
| @@ -89,13 +88,13 @@ TSD_StatusT PackageSender::SendMsgAndHostPackage( | |||
| 89 | return TSD_OK; | 88 | return TSD_OK; |
| 90 | } | 89 | } |
| 91 | 90 | ||
| 92 | - if (mgr_.SendAICPUPackageSimple(peerNode, orgFile, dstFile, useCannPath) != TSD_OK) { | 91 | + if (this->SendAICPUPackageSimple(peerNode, orgFile, dstFile, useCannPath) != TSD_OK) { |
| 93 | REPORT_INPUT_ERROR("E39006", std::vector<std::string>(), std::vector<std::string>()); | 92 | REPORT_INPUT_ERROR("E39006", std::vector<std::string>(), std::vector<std::string>()); |
| 94 | return TSD_INTERNAL_ERROR; | 93 | return TSD_INTERNAL_ERROR; |
| 95 | } | 94 | } |
| 96 | 95 | ||
| 97 | msg.set_wait_flag(true); | 96 | msg.set_wait_flag(true); |
| 98 | - ret = mgr_.GetDeviceCheckCodeRetry(msg); | 97 | + ret = checkCodeSvc_.GetDeviceCheckCodeRetry(msg); |
| 99 | if (ret != TSD_OK) { | 98 | if (ret != TSD_OK) { |
| 100 | if (ret >= TSD_SUBPROCESS_NUM_EXCEED_THE_LIMIT) { | 99 | if (ret >= TSD_SUBPROCESS_NUM_EXCEED_THE_LIMIT) { |
| 101 | return ret; | 100 | return ret; |
| @@ -110,20 +109,20 @@ TSD_StatusT PackageSender::SendHostPackageComplex( | |||
| 110 | const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, HDCMessage& msg, | 109 | const int32_t peerNode, const std::string& orgFile, const std::string& dstFile, HDCMessage& msg, |
| 111 | const std::function<bool(void)>& compareCallBack, bool useCannPath) | 110 | const std::function<bool(void)>& compareCallBack, bool useCannPath) |
| 112 | { | 111 | { |
| 113 | - if (envInfo_.hostSoPath_.empty()) { | 112 | + if (envInfo_.GetHostSoPath().empty()) { |
| 114 | - return mgr_.SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); | 113 | + return this->SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); |
| 115 | } | 114 | } |
| 116 | const std::string mutexFileName = envInfo_.GetCurHostMutexFile(useCannPath); | 115 | const std::string mutexFileName = envInfo_.GetCurHostMutexFile(useCannPath); |
| 117 | - const std::string mutexFile = envInfo_.hostSoPath_ + mutexFileName; | 116 | + const std::string mutexFile = envInfo_.GetHostSoPath() + mutexFileName; |
| 118 | TSD_RUN_INFO("get host mutex file:%s, logicDeviceId:%u", mutexFile.c_str(), envInfo_.GetLogicDeviceId()); | 117 | TSD_RUN_INFO("get host mutex file:%s, logicDeviceId:%u", mutexFile.c_str(), envInfo_.GetLogicDeviceId()); |
| 119 | if (!CheckRealPath(mutexFile)) { | 118 | if (!CheckRealPath(mutexFile)) { |
| 120 | TSD_INFO("Cannot get realpath of mutexFile[%s]", mutexFile.c_str()); | 119 | TSD_INFO("Cannot get realpath of mutexFile[%s]", mutexFile.c_str()); |
| 121 | - return mgr_.SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); | 120 | + return this->SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); |
| 122 | } | 121 | } |
| 123 | const int32_t fileData = open(mutexFile.c_str(), O_RDONLY); | 122 | const int32_t fileData = open(mutexFile.c_str(), O_RDONLY); |
| 124 | if (fileData < 0) { | 123 | if (fileData < 0) { |
| 125 | TSD_INFO("Opening qs so [%s] was not successful, reason[%s]", mutexFile.c_str(), SafeStrerror().c_str()); | 124 | TSD_INFO("Opening qs so [%s] was not successful, reason[%s]", mutexFile.c_str(), SafeStrerror().c_str()); |
| 126 | - return mgr_.SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); | 125 | + return this->SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); |
| 127 | } else { | 126 | } else { |
| 128 | TSD_INFO("Open qs so [%s] success", mutexFile.c_str()); | 127 | TSD_INFO("Open qs so [%s] success", mutexFile.c_str()); |
| 129 | } | 128 | } |
| @@ -135,57 +134,56 @@ TSD_StatusT PackageSender::SendHostPackageComplex( | |||
| 135 | } | 134 | } |
| 136 | 135 | ||
| 137 | const ScopeGuard fileLockGuard([&fileData]() { (void)flock(fileData, LOCK_UN); }); | 136 | const ScopeGuard fileLockGuard([&fileData]() { (void)flock(fileData, LOCK_UN); }); |
| 138 | - return mgr_.SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); | 137 | + return this->SendMsgAndHostPackage(peerNode, orgFile, dstFile, msg, compareCallBack, useCannPath); |
| 139 | } | 138 | } |
| 140 | 139 | ||
| 141 | TSD_StatusT PackageSender::SendAICPUPackage(const int32_t peerNode, const std::string& path) | 140 | TSD_StatusT PackageSender::SendAICPUPackage(const int32_t peerNode, const std::string& path) |
| 142 | { | 141 | { |
| 143 | - const uint32_t packageType = static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL); | 142 | + constexpr uint32_t packageType = static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_KERNEL); |
| 144 | - if (envInfo_.packageName_[packageType].empty()) { | 143 | + if (envInfo_.GetPackageNameRef(packageType).empty()) { |
| 145 | TSD_RUN_INFO( | 144 | TSD_RUN_INFO( |
| 146 | "[TsdClient][deviceId_=%u] aicpu package is not existed, skip send package", envInfo_.GetLogicDeviceId()); | 145 | "[TsdClient][deviceId_=%u] aicpu package is not existed, skip send package", envInfo_.GetLogicDeviceId()); |
| 147 | return TSD_OK; | 146 | return TSD_OK; |
| 148 | } | 147 | } |
| 149 | 148 | ||
| 150 | - if (mgr_.packageHostCheckCode_[packageType] == mgr_.packagePeerCheckCode_[packageType]) { | 149 | + if (ctx_.hostCheckCode[packageType] == ctx_.peerCheckCode[packageType]) { |
| 151 | TSD_RUN_INFO( | 150 | TSD_RUN_INFO( |
| 152 | "[TsdClient][deviceId_=%u] the checksum of host package[%u] is the same as device[%u], skip send package.", | 151 | "[TsdClient][deviceId_=%u] the checksum of host package[%u] is the same as device[%u], skip send package.", |
| 153 | - envInfo_.GetLogicDeviceId(), mgr_.packageHostCheckCode_[packageType], | 152 | + envInfo_.GetLogicDeviceId(), ctx_.hostCheckCode[packageType], ctx_.peerCheckCode[packageType]); |
| 154 | - mgr_.packagePeerCheckCode_[packageType]); | ||
| 155 | return TSD_OK; | 153 | return TSD_OK; |
| 156 | } | 154 | } |
| 157 | 155 | ||
| 158 | - const std::string orgFile = envInfo_.packagePath_[packageType] + envInfo_.packageName_[packageType]; | 156 | + const std::string orgFile = envInfo_.GetPackagePathRef(packageType) + envInfo_.GetPackageNameRef(packageType); |
| 159 | const std::string dstFile = | 157 | const std::string dstFile = |
| 160 | - path + "/" + std::to_string(commAgent_.GetProcSign().tgid) + "_" + envInfo_.packageName_[packageType]; | 158 | + path + "/" + std::to_string(commAgent_.GetProcSign().tgid) + "_" + envInfo_.GetPackageNameRef(packageType); |
| 161 | - if ((!getCheckCodeRetrySupport_) || (IsAsanMmSysEnv()) || (IsFpgaMmSysEnv())) { | 159 | + if ((!ctx_.getCheckCodeRetrySupport) || (IsAsanMmSysEnv()) || (IsFpgaMmSysEnv())) { |
| 162 | - return mgr_.SendAICPUPackageSimple(peerNode, orgFile, dstFile, false); | 160 | + return this->SendAICPUPackageSimple(peerNode, orgFile, dstFile, false); |
| 163 | } else { | 161 | } else { |
| 164 | MessageContext ctx{}; | 162 | MessageContext ctx{}; |
| 165 | ctx.logicDeviceId = envInfo_.GetLogicDeviceId(); | 163 | ctx.logicDeviceId = envInfo_.GetLogicDeviceId(); |
| 166 | - ctx.checkCode = mgr_.packageHostCheckCode_[packageType]; | 164 | + ctx.checkCode = ctx_.hostCheckCode[packageType]; |
| 167 | ctx.packageType = packageType; | 165 | ctx.packageType = packageType; |
| 168 | HDCMessage msg; | 166 | HDCMessage msg; |
| 169 | if (HdcMessageBuilder::BuildCheckPackageRetry(msg, ctx) != TSD_OK) { | 167 | if (HdcMessageBuilder::BuildCheckPackageRetry(msg, ctx) != TSD_OK) { |
| 170 | return TSD_INTERNAL_ERROR; | 168 | return TSD_INTERNAL_ERROR; |
| 171 | } | 169 | } |
| 172 | auto aicpuPkgCompareMethd = [this, packageType]() { | 170 | auto aicpuPkgCompareMethd = [this, packageType]() { |
| 173 | - if (mgr_.packageHostCheckCode_[packageType] == mgr_.packagePeerCheckCode_[packageType]) { | 171 | + if (ctx_.hostCheckCode[packageType] == ctx_.peerCheckCode[packageType]) { |
| 174 | TSD_INFO( | 172 | TSD_INFO( |
| 175 | "[TsdClient] after lock, the checksum of aicpu package[%u] is same as device[%u], skip send", | 173 | "[TsdClient] after lock, the checksum of aicpu package[%u] is same as device[%u], skip send", |
| 176 | - mgr_.packageHostCheckCode_[packageType], mgr_.packagePeerCheckCode_[packageType]); | 174 | + ctx_.hostCheckCode[packageType], ctx_.peerCheckCode[packageType]); |
| 177 | return true; | 175 | return true; |
| 178 | } | 176 | } |
| 179 | return false; | 177 | return false; |
| 180 | }; | 178 | }; |
| 181 | - return mgr_.SendHostPackageComplex(peerNode, orgFile, dstFile, msg, aicpuPkgCompareMethd, false); | 179 | + return this->SendHostPackageComplex(peerNode, orgFile, dstFile, msg, aicpuPkgCompareMethd, false); |
| 182 | } | 180 | } |
| 183 | } | 181 | } |
| 184 | 182 | ||
| 185 | TSD_StatusT PackageSender::SendCommonPackage( | 183 | TSD_StatusT PackageSender::SendCommonPackage( |
| 186 | const int32_t peerNode, const std::string& path, const uint32_t packageType) | 184 | const int32_t peerNode, const std::string& path, const uint32_t packageType) |
| 187 | { | 185 | { |
| 188 | - if (envInfo_.packageName_[packageType].empty()) { | 186 | + if (envInfo_.GetPackageNameRef(packageType).empty()) { |
| 189 | TSD_RUN_INFO( | 187 | TSD_RUN_INFO( |
| 190 | "[TsdClient][deviceId_=%u] package is not existed, skip send, packageType[%u]", envInfo_.GetLogicDeviceId(), | 188 | "[TsdClient][deviceId_=%u] package is not existed, skip send, packageType[%u]", envInfo_.GetLogicDeviceId(), |
| 191 | packageType); | 189 | packageType); |
| @@ -197,39 +195,41 @@ TSD_StatusT PackageSender::SendCommonPackage( | |||
| 197 | supportLevelName = TSD_SUPPORT_EXTEND_PKG; | 195 | supportLevelName = TSD_SUPPORT_EXTEND_PKG; |
| 198 | } else if (packageType == static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)) { | 196 | } else if (packageType == static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP)) { |
| 199 | supportLevelName = TSD_SUPPORT_ASCENDCPP_PKG; | 197 | supportLevelName = TSD_SUPPORT_ASCENDCPP_PKG; |
| 198 | + } else { | ||
| 199 | + TSD_RUN_WARN("unsupported packageType:%u", packageType); | ||
| 200 | + return TSD_OK; | ||
| 200 | } | 201 | } |
| 201 | if (TSD_BITMAP_GET(capabilityMgr_.GetTsdSupportLevel(), supportLevelName) == 0U) { | 202 | if (TSD_BITMAP_GET(capabilityMgr_.GetTsdSupportLevel(), supportLevelName) == 0U) { |
| 202 | - mgr_.packageHostCheckCode_[packageType] = 0U; | 203 | + ctx_.hostCheckCode[packageType] = 0U; |
| 203 | TSD_RUN_INFO( | 204 | TSD_RUN_INFO( |
| 204 | "[TsdClient][deviceId_=%u] device does not support, skip send, packageType[%u]", | 205 | "[TsdClient][deviceId_=%u] device does not support, skip send, packageType[%u]", |
| 205 | envInfo_.GetLogicDeviceId(), packageType); | 206 | envInfo_.GetLogicDeviceId(), packageType); |
| 206 | return TSD_OK; | 207 | return TSD_OK; |
| 207 | } | 208 | } |
| 208 | 209 | ||
| 209 | - if (mgr_.packageHostCheckCode_[packageType] == mgr_.packagePeerCheckCode_[packageType]) { | 210 | + if (ctx_.hostCheckCode[packageType] == ctx_.peerCheckCode[packageType]) { |
| 210 | TSD_INFO( | 211 | TSD_INFO( |
| 211 | "[TsdClient][deviceId_=%u] the checksum of host package[%u] is same as device[%u], skip send package, " | 212 | "[TsdClient][deviceId_=%u] the checksum of host package[%u] is same as device[%u], skip send package, " |
| 212 | "packageType[%u]", | 213 | "packageType[%u]", |
| 213 | - envInfo_.GetLogicDeviceId(), mgr_.packageHostCheckCode_[packageType], | 214 | + envInfo_.GetLogicDeviceId(), ctx_.hostCheckCode[packageType], ctx_.peerCheckCode[packageType], packageType); |
| 214 | - mgr_.packagePeerCheckCode_[packageType], packageType); | ||
| 215 | return TSD_OK; | 215 | return TSD_OK; |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | - const std::string orgFile = envInfo_.packagePath_[packageType] + envInfo_.packageName_[packageType]; | 218 | + const std::string orgFile = envInfo_.GetPackagePathRef(packageType) + envInfo_.GetPackageNameRef(packageType); |
| 219 | const std::string dstFile = | 219 | const std::string dstFile = |
| 220 | - path + "/" + std::to_string(commAgent_.GetProcSign().tgid) + "_" + envInfo_.packageName_[packageType]; | 220 | + path + "/" + std::to_string(commAgent_.GetProcSign().tgid) + "_" + envInfo_.GetPackageNameRef(packageType); |
| 221 | TSD_INFO( | 221 | TSD_INFO( |
| 222 | "[TsdClient][deviceId=%u] hostCheckCode[%u] no equal to deviceCheckCode[%u], begin send file[%s] to [%s], " | 222 | "[TsdClient][deviceId=%u] hostCheckCode[%u] no equal to deviceCheckCode[%u], begin send file[%s] to [%s], " |
| 223 | "packageType[%u]", | 223 | "packageType[%u]", |
| 224 | - envInfo_.GetLogicDeviceId(), mgr_.packageHostCheckCode_[packageType], mgr_.packagePeerCheckCode_[packageType], | 224 | + envInfo_.GetLogicDeviceId(), ctx_.hostCheckCode[packageType], ctx_.peerCheckCode[packageType], orgFile.c_str(), |
| 225 | - orgFile.c_str(), dstFile.c_str(), packageType); | 225 | + dstFile.c_str(), packageType); |
| 226 | const auto ret = drvHdcSendFile( | 226 | const auto ret = drvHdcSendFile( |
| 227 | peerNode, static_cast<int32_t>(envInfo_.GetLogicDeviceId()), orgFile.c_str(), dstFile.c_str(), nullptr); | 227 | peerNode, static_cast<int32_t>(envInfo_.GetLogicDeviceId()), orgFile.c_str(), dstFile.c_str(), nullptr); |
| 228 | if (ret != DRV_ERROR_NONE) { | 228 | if (ret != DRV_ERROR_NONE) { |
| 229 | TSD_ERROR( | 229 | TSD_ERROR( |
| 230 | "[TsdClient][deviceId=%u] drvHdcSendFile file[%s] to [%s] failed, ret[%d], packageType[%u]", | 230 | "[TsdClient][deviceId=%u] drvHdcSendFile file[%s] to [%s] failed, ret[%d], packageType[%u]", |
| 231 | envInfo_.GetLogicDeviceId(), orgFile.c_str(), dstFile.c_str(), ret, packageType); | 231 | envInfo_.GetLogicDeviceId(), orgFile.c_str(), dstFile.c_str(), ret, packageType); |
| 232 | - mgr_.packageHostCheckCode_[packageType] = 0U; | 232 | + ctx_.hostCheckCode[packageType] = 0U; |
| 233 | return TSD_INTERNAL_ERROR; | 233 | return TSD_INTERNAL_ERROR; |
| 234 | } | 234 | } |
| 235 | TSD_INFO( | 235 | TSD_INFO( |
| @@ -240,7 +240,7 @@ TSD_StatusT PackageSender::SendCommonPackage( | |||
| 240 | 240 | ||
| 241 | TSD_StatusT PackageSender::SendFileToDevice( | 241 | TSD_StatusT PackageSender::SendFileToDevice( |
| 242 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, | 242 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, const uint64_t fileNameLen, |
| 243 | - const bool addPreFix) | 243 | + const bool addPreFix) const |
| 244 | { | 244 | { |
| 245 | TSD_RUN_INFO( | 245 | TSD_RUN_INFO( |
| 246 | "[TsdClient] [deviceId=%u][pathLen=%llu] SendFileToDevice enter", envInfo_.GetLogicDeviceId(), pathLen); | 246 | "[TsdClient] [deviceId=%u][pathLen=%llu] SendFileToDevice enter", envInfo_.GetLogicDeviceId(), pathLen); |
| @@ -310,12 +310,12 @@ TSD_StatusT PackageSender::CompareAndSendCommonSinkPkg( | |||
| 310 | TSD_INFO( | 310 | TSD_INFO( |
| 311 | "checksum of driver package[%s] is same as device[%u], idle[%d], skip send", | 311 | "checksum of driver package[%s] is same as device[%u], idle[%d], skip send", |
| 312 | hashStore_.GetHostCommonSinkPackHashValue(pkgPureName).c_str(), envInfo_.GetLogicDeviceId(), | 312 | hashStore_.GetHostCommonSinkPackHashValue(pkgPureName).c_str(), envInfo_.GetLogicDeviceId(), |
| 313 | - deviceIdle_); | 313 | + ctx_.deviceIdle); |
| 314 | return true; | 314 | return true; |
| 315 | } | 315 | } |
| 316 | return false; | 316 | return false; |
| 317 | }; | 317 | }; |
| 318 | - if (mgr_.SendHostPackageComplex(peerNode, orgFile, dstFile, msg, commonSinkPkgCompareMethd, true) != TSD_OK) { | 318 | + if (this->SendHostPackageComplex(peerNode, orgFile, dstFile, msg, commonSinkPkgCompareMethd, true) != TSD_OK) { |
| 319 | TSD_ERROR("send common sink package to device failed"); | 319 | TSD_ERROR("send common sink package to device failed"); |
| 320 | return TSD_INTERNAL_ERROR; | 320 | return TSD_INTERNAL_ERROR; |
| 321 | } | 321 | } |
| @@ -13,9 +13,8 @@ | |||
| 13 | 13 | ||
| 14 | namespace tsd { | 14 | namespace tsd { |
| 15 | 15 | ||
| 16 | -PluginVersionManager::PluginVersionManager( | 16 | +PluginVersionManager::PluginVersionManager(PackageEnvInfo& envInfo, PackageHashStore& hashStore, PackageContext& ctx) |
| 17 | - PackageEnvInfo& envInfo, PackageHashStore& hashStore, ResponseCode& pkgRspCode) | 17 | + : envInfo_(envInfo), hashStore_(hashStore), ctx_(ctx) |
| 18 | - : envInfo_(envInfo), hashStore_(hashStore), pkgRspCode_(pkgRspCode) | ||
| 19 | {} | 18 | {} |
| 20 | 19 | ||
| 21 | bool PluginVersionManager::IsCompatPluginPackage(const PackConfDetail& detail) const | 20 | bool PluginVersionManager::IsCompatPluginPackage(const PackConfDetail& detail) const |
| @@ -30,7 +29,7 @@ PluginUpdateStrategy PluginVersionManager::GetPluginUpdateStrategy() | |||
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | int64_t flag = 0; | 31 | int64_t flag = 0; |
| 33 | - auto drvRet = | 32 | + const auto drvRet = |
| 34 | halGetDeviceInfo(envInfo_.GetLogicDeviceId(), MODULE_TYPE_SYSTEM, INFO_TYPE_SWPLUGIN_UPGRADE_POLICY, &flag); | 33 | halGetDeviceInfo(envInfo_.GetLogicDeviceId(), MODULE_TYPE_SYSTEM, INFO_TYPE_SWPLUGIN_UPGRADE_POLICY, &flag); |
| 35 | if (drvRet != DRV_ERROR_NONE) { | 34 | if (drvRet != DRV_ERROR_NONE) { |
| 36 | TSD_RUN_WARN( | 35 | TSD_RUN_WARN( |
| @@ -91,10 +90,10 @@ bool PluginVersionManager::CompareHostDeviceCompatPluginVersion(const std::strin | |||
| 91 | deviceInfo.timestamp.c_str()); | 90 | deviceInfo.timestamp.c_str()); |
| 92 | return true; | 91 | return true; |
| 93 | } | 92 | } |
| 93 | + const char* const cmpStr = (cmp < 0) ? "older than" : "equals"; | ||
| 94 | TSD_RUN_INFO( | 94 | TSD_RUN_INFO( |
| 95 | - "host plugin pkg:%s %s device, skip. host[%s/%s] device[%s/%s]", pkgPureName.c_str(), | 95 | + "host plugin pkg:%s %s device, skip. host[%s/%s] device[%s/%s]", pkgPureName.c_str(), cmpStr, |
| 96 | - (cmp < 0 ? "older than" : "equals"), hostInfo.version.c_str(), hostInfo.timestamp.c_str(), | 96 | + hostInfo.version.c_str(), hostInfo.timestamp.c_str(), deviceInfo.version.c_str(), deviceInfo.timestamp.c_str()); |
| 97 | - deviceInfo.version.c_str(), deviceInfo.timestamp.c_str()); | ||
| 98 | return false; | 97 | return false; |
| 99 | } | 98 | } |
| 100 | 99 | ||
| @@ -111,7 +110,7 @@ void PluginVersionManager::HandleDevicePluginVersionRsp(const HDCMessage& msg) | |||
| 111 | "device plugin pkg:%s version:%s timestamp:%s", info.package_name().c_str(), ver.version.c_str(), | 110 | "device plugin pkg:%s version:%s timestamp:%s", info.package_name().c_str(), ver.version.c_str(), |
| 112 | ver.timestamp.c_str()); | 111 | ver.timestamp.c_str()); |
| 113 | } | 112 | } |
| 114 | - pkgRspCode_ = ((msg.tsd_rsp_code() == 0U) ? ResponseCode::SUCCESS : ResponseCode::FAIL); | 113 | + ctx_.pkgRspCode = ((msg.tsd_rsp_code() == 0U) ? ResponseCode::SUCCESS : ResponseCode::FAIL); |
| 115 | TSD_RUN_INFO("device plugin info rsp, pkgCount:%d", msg.device_plugin_versions_size()); | 114 | TSD_RUN_INFO("device plugin info rsp, pkgCount:%d", msg.device_plugin_versions_size()); |
| 116 | } | 115 | } |
| 117 | 116 | ||
| @@ -48,6 +48,38 @@ enum class TsdLoadPackageType : uint32_t { | |||
| 48 | TSD_PKG_TYPE_MAX = 32U | 48 | TSD_PKG_TYPE_MAX = 32U |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | +enum class ProfilingMode { | ||
| 52 | + PROFILING_CLOSE = 0, | ||
| 53 | + PROFILING_OPEN, | ||
| 54 | +}; | ||
| 55 | + | ||
| 56 | +enum class RunningMode { | ||
| 57 | + UNSET_MODE = 0, | ||
| 58 | + PROCESS_MODE, | ||
| 59 | + THREAD_MODE, | ||
| 60 | +}; | ||
| 61 | + | ||
| 62 | +typedef enum tagChipType { | ||
| 63 | + CHIP_BEGIN = 0, | ||
| 64 | + CHIP_MINI = CHIP_BEGIN, | ||
| 65 | + CHIP_ASCEND_910A = 1, | ||
| 66 | + CHIP_ADC = 2, | ||
| 67 | + CHIP_DC = 4, | ||
| 68 | + CHIP_ASCEND_910B = 5, | ||
| 69 | + CHIP_MINI_V3 = 7, | ||
| 70 | + CHIP_AS31XM1 = 11, | ||
| 71 | + CHIP_610LITE = 12, | ||
| 72 | + CHIP_ASCEND_950 = 15, | ||
| 73 | + CHIP_CLOUD_V5 = 16, | ||
| 74 | + CHIP_MC62CM12A = 17, /* MC62CM12A */ | ||
| 75 | + CHIP_MC32DM11A = 18, /* CHIP_MC32DM11A */ | ||
| 76 | + CHIP_ASCEND_350 = 19, | ||
| 77 | + CHIP_END | ||
| 78 | +} ChipType_t; | ||
| 79 | + | ||
| 80 | +// 返回给tsdclient的open/close确认码 | ||
| 81 | +enum class ResponseCode { SUCCESS = 0, FAIL = 1 }; | ||
| 82 | + | ||
| 51 | struct BaseInfo { | 83 | struct BaseInfo { |
| 52 | uint32_t deviceId; | 84 | uint32_t deviceId; |
| 53 | uint32_t hostPid; | 85 | uint32_t hostPid; |
| @@ -22,4 +22,4 @@ DLLEXPORT __attribute__((weak)) drvError_t drvHdcGetTrustedBasePathV2( | |||
| 22 | int peer_node, int peer_devid, char* base_path, unsigned int path_len); | 22 | int peer_node, int peer_devid, char* base_path, unsigned int path_len); |
| 23 | drvError_t __attribute__((weak)) halGetSocVersion(uint32_t devId, char* socVersion, uint32_t len); | 23 | drvError_t __attribute__((weak)) halGetSocVersion(uint32_t devId, char* socVersion, uint32_t len); |
| 24 | } | 24 | } |
| 25 | -#endif // TSD_WEAK_ASCEND_HAL_H | 25 | +#endif // TSD_WEAK_ASCEND_HAL_H |
| @@ -398,12 +398,12 @@ bool IsCurrentVfMode(const uint32_t deviceId, const uint32_t vfId) | |||
| 398 | 398 | ||
| 399 | std::string ExtractSubString(const std::string& input, const std::string& begin, const std::string& end) | 399 | std::string ExtractSubString(const std::string& input, const std::string& begin, const std::string& end) |
| 400 | { | 400 | { |
| 401 | - size_t pos = input.find(begin); | 401 | + const size_t pos = input.find(begin); |
| 402 | if (pos == std::string::npos) { | 402 | if (pos == std::string::npos) { |
| 403 | return ""; | 403 | return ""; |
| 404 | } | 404 | } |
| 405 | - size_t left = pos + begin.length(); | 405 | + const size_t left = pos + begin.length(); |
| 406 | - size_t right = input.find(end, left); | 406 | + const size_t right = input.find(end, left); |
| 407 | if (right == std::string::npos) { | 407 | if (right == std::string::npos) { |
| 408 | return ""; | 408 | return ""; |
| 409 | } | 409 | } |
| @@ -7,8 +7,8 @@ | |||
| 7 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 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. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | -#ifndef INNER_INC_CLIENT_MANAGER_H | 10 | +#ifndef TSD_CLIENT_MANAGER_H |
| 11 | -#define INNER_INC_CLIENT_MANAGER_H | 11 | +#define TSD_CLIENT_MANAGER_H |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| @@ -21,38 +21,8 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | namespace tsd { | 23 | namespace tsd { |
| 24 | -enum class ProfilingMode { | ||
| 25 | - PROFILING_CLOSE = 0, | ||
| 26 | - PROFILING_OPEN, | ||
| 27 | -}; | ||
| 28 | - | ||
| 29 | -enum class RunningMode { | ||
| 30 | - UNSET_MODE = 0, | ||
| 31 | - PROCESS_MODE, | ||
| 32 | - THREAD_MODE, | ||
| 33 | -}; | ||
| 34 | - | ||
| 35 | -typedef enum tagChipType { | ||
| 36 | - CHIP_BEGIN = 0, | ||
| 37 | - CHIP_MINI = CHIP_BEGIN, | ||
| 38 | - CHIP_ASCEND_910A = 1, | ||
| 39 | - CHIP_ADC = 2, | ||
| 40 | - CHIP_DC = 4, | ||
| 41 | - CHIP_ASCEND_910B = 5, | ||
| 42 | - CHIP_MINI_V3 = 7, | ||
| 43 | - CHIP_AS31XM1 = 11, | ||
| 44 | - CHIP_610LITE = 12, | ||
| 45 | - CHIP_ASCEND_950 = 15, | ||
| 46 | - CHIP_CLOUD_V5 = 16, | ||
| 47 | - CHIP_MC62CM12A = 17, /* MC62CM12A */ | ||
| 48 | - CHIP_MC32DM11A = 18, /* CHIP_MC32DM11A */ | ||
| 49 | - CHIP_ASCEND_350 = 19, | ||
| 50 | - CHIP_END | ||
| 51 | -} ChipType_t; | ||
| 52 | 24 | ||
| 53 | // 返回给tsdclient的open/close确认码 | 25 | // 返回给tsdclient的open/close确认码 |
| 54 | -enum class ResponseCode { SUCCESS = 0, FAIL = 1 }; | ||
| 55 | - | ||
| 56 | class ClientManager { | 26 | class ClientManager { |
| 57 | public: | 27 | public: |
| 58 | /** | 28 | /** |
| @@ -78,7 +48,7 @@ public: | |||
| 78 | * @ingroup ClientManager | 48 | * @ingroup ClientManager |
| 79 | * @brief 构造函数 | 49 | * @brief 构造函数 |
| 80 | */ | 50 | */ |
| 81 | - explicit ClientManager(const uint32_t& deviceId); | 51 | + explicit ClientManager(const uint32_t deviceId); |
| 82 | 52 | ||
| 83 | /** | 53 | /** |
| 84 | * @ingroup ClientManager | 54 | * @ingroup ClientManager |
| @@ -117,7 +87,7 @@ public: | |||
| 117 | * @param [in] flag: profiling 标志位 | 87 | * @param [in] flag: profiling 标志位 |
| 118 | * @return TSD_OK:成功 或者其他错误码 | 88 | * @return TSD_OK:成功 或者其他错误码 |
| 119 | */ | 89 | */ |
| 120 | - virtual TSD_StatusT UpdateProfilingConf(const uint32_t& flag) = 0; | 90 | + virtual TSD_StatusT UpdateProfilingConf(const uint32_t flag) = 0; |
| 121 | 91 | ||
| 122 | /** | 92 | /** |
| 123 | * @ingroup ClientManager | 93 | * @ingroup ClientManager |
| @@ -230,18 +200,6 @@ private: | |||
| 230 | ClientManager& operator=(const ClientManager&) = delete; | 200 | ClientManager& operator=(const ClientManager&) = delete; |
| 231 | ClientManager& operator=(ClientManager&) = delete; | 201 | ClientManager& operator=(ClientManager&) = delete; |
| 232 | ClientManager& operator=(ClientManager&&) = delete; | 202 | ClientManager& operator=(ClientManager&&) = delete; |
| 233 | - bool GetPackagePath(std::string& packagePath, const uint32_t packageType) const | ||
| 234 | - | ||
| 235 | - { | ||
| 236 | - return envInfo_.GetPackagePath(packagePath, packageType); | ||
| 237 | - } | ||
| 238 | - bool CheckPackageExistsOnce(const uint32_t packageType) { return envInfo_.CheckPackageExistsOnce(packageType); } | ||
| 239 | - std::vector<std::string> ScanAndMatchPackages(const std::string& packagePath, const uint32_t packageType) const | ||
| 240 | - | ||
| 241 | - { | ||
| 242 | - return envInfo_.ScanAndMatchPackages(packagePath, packageType); | ||
| 243 | - } | ||
| 244 | - std::string (&packagePattern_)[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)]; | ||
| 245 | }; | 203 | }; |
| 246 | } // namespace tsd | 204 | } // namespace tsd |
| 247 | -#endif // INNER_INC_CLIENT_MANAGER_H | 205 | +#endif // TSD_CLIENT_MANAGER_H |
| @@ -36,7 +36,7 @@ public: | |||
| 36 | 36 | ||
| 37 | TSD_StatusT GetHdcConctStatus(int32_t& hdcSessStat) override; | 37 | TSD_StatusT GetHdcConctStatus(int32_t& hdcSessStat) override; |
| 38 | 38 | ||
| 39 | - TSD_StatusT UpdateProfilingConf(const uint32_t& flag) override; | 39 | + TSD_StatusT UpdateProfilingConf(const uint32_t flag) override; |
| 40 | 40 | ||
| 41 | TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo) override; | 41 | TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo) override; |
| 42 | 42 | ||
| @@ -50,7 +50,7 @@ public: | |||
| 50 | 50 | ||
| 51 | void Destroy() override; | 51 | void Destroy() override; |
| 52 | 52 | ||
| 53 | - virtual ~ProcessModeManager() override; | 53 | + ~ProcessModeManager() override = default; |
| 54 | 54 | ||
| 55 | TSD_StatusT LoadFileToDevice( | 55 | TSD_StatusT LoadFileToDevice( |
| 56 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, | 56 | const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName, |
| @@ -57,7 +57,7 @@ public: | |||
| 57 | * @param flag : control number | 57 | * @param flag : control number |
| 58 | * @return TSD_OK when SUCCESS | 58 | * @return TSD_OK when SUCCESS |
| 59 | */ | 59 | */ |
| 60 | - TSD_StatusT UpdateProfilingConf(const uint32_t& flag) override; | 60 | + TSD_StatusT UpdateProfilingConf(const uint32_t flag) override; |
| 61 | 61 | ||
| 62 | TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo) override; | 62 | TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo) override; |
| 63 | 63 | ||
| @@ -35,20 +35,20 @@ public: | |||
| 35 | DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageManager& packageMgr, | 35 | DeviceCommAgent& commAgent, CapabilityManager& capabilityMgr, PackageManager& packageMgr, |
| 36 | ProcessSharedContext& sharedCtx, uint32_t aicpuDeviceMode); | 36 | ProcessSharedContext& sharedCtx, uint32_t aicpuDeviceMode); |
| 37 | 37 | ||
| 38 | - TSD_StatusT Open(uint32_t rankSize); | 38 | + TSD_StatusT Open(const uint32_t rankSize); |
| 39 | TSD_StatusT OpenAicpuSd(); | 39 | TSD_StatusT OpenAicpuSd(); |
| 40 | - TSD_StatusT OpenProcess(uint32_t rankSize); | 40 | + TSD_StatusT OpenProcess(const uint32_t rankSize); |
| 41 | TSD_StatusT Close(uint32_t flag); | 41 | TSD_StatusT Close(uint32_t flag); |
| 42 | TSD_StatusT GetHdcConctStatus(int32_t& hdcSessStat); | 42 | TSD_StatusT GetHdcConctStatus(int32_t& hdcSessStat); |
| 43 | TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo); | 43 | TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo); |
| 44 | - TSD_StatusT UpdateProfilingConf(const uint32_t& flag); | 44 | + TSD_StatusT UpdateProfilingConf(const uint32_t flag); |
| 45 | 45 | ||
| 46 | TSD_StatusT InitTsdClient(); | 46 | TSD_StatusT InitTsdClient(); |
| 47 | - TSD_StatusT WaitRsp(uint32_t timeout, bool ignoreRecvErr = false, bool isClose = false); | 47 | + TSD_StatusT WaitRsp(const uint32_t timeout, const bool ignoreRecvErr = false, const bool isClose = false); |
| 48 | MessageContext BuildBaseMessageContext() const; | 48 | MessageContext BuildBaseMessageContext() const; |
| 49 | 49 | ||
| 50 | - void SetTsdStartInfo(bool cpStatus, bool hccpStatus, bool qsStatus); | 50 | + void SetTsdStartInfo(const bool cpStatus, const bool hccpStatus, const bool qsStatus); |
| 51 | - bool CheckNeedToOpen(uint32_t rankSize, TsdStartStatusInfo& startInfo); | 51 | + bool CheckNeedToOpen(const uint32_t rankSize, TsdStartStatusInfo& startInfo); |
| 52 | 52 | ||
| 53 | TSD_StatusT ProcessQueueForAdc(); | 53 | TSD_StatusT ProcessQueueForAdc(); |
| 54 | TSD_StatusT SyncQueueAuthority() const; | 54 | TSD_StatusT SyncQueueAuthority() const; |
| @@ -75,16 +75,16 @@ private: | |||
| 75 | uint32_t quickCloseFlag : 1; | 75 | uint32_t quickCloseFlag : 1; |
| 76 | uint32_t res : 31; | 76 | uint32_t res : 31; |
| 77 | }; | 77 | }; |
| 78 | - enum TsdCloseMode { QUICK_CLOSE_MODE = 1 }; | 78 | + enum class TsdCloseMode : uint32_t { QUICK_CLOSE_MODE = 1 }; |
| 79 | 79 | ||
| 80 | - TSD_StatusT SendOpenMsg(uint32_t rankSize, TsdStartStatusInfo startInfo); | 80 | + TSD_StatusT SendOpenMsg(const uint32_t rankSize, const TsdStartStatusInfo startInfo); |
| 81 | TSD_StatusT SendCloseMsg(); | 81 | TSD_StatusT SendCloseMsg(); |
| 82 | - TSD_StatusT SendUpdateProfilingMsg(uint32_t flag); | 82 | + TSD_StatusT SendUpdateProfilingMsg(const uint32_t flag); |
| 83 | - TSD_StatusT ConstructOpenMsg(HDCMessage& hdcMsg, const TsdStartStatusInfo& startInfo); | 83 | + TSD_StatusT ConstructOpenMsg(HDCMessage& hdcMsg, const TsdStartStatusInfo& startInfo) const; |
| 84 | - TSD_StatusT ConstructCloseMsg(HDCMessage& msg); | 84 | + TSD_StatusT ConstructCloseMsg(HDCMessage& msg) const; |
| 85 | TSD_StatusT MapFailCodeToStatus() const; | 85 | TSD_StatusT MapFailCodeToStatus() const; |
| 86 | - std::string BuildWaitRspErrReport(TSD_StatusT recvRet) const; | 86 | + std::string BuildWaitRspErrReport(const TSD_StatusT recvRet) const; |
| 87 | - void ParseTsdCloseFlag(uint32_t flag, TsdCloseFlag& tsdCloseFlag) const; | 87 | + void ParseTsdCloseFlag(const uint32_t flag, TsdCloseFlag& tsdCloseFlag) const; |
| 88 | TSD_StatusT LoadPackagesToDevice(); | 88 | TSD_StatusT LoadPackagesToDevice(); |
| 89 | TSD_StatusT WaitOpenRsp(const uint32_t rankSize); | 89 | TSD_StatusT WaitOpenRsp(const uint32_t rankSize); |
| 90 | void LogOpenProcessDuration( | 90 | void LogOpenProcessDuration( |
| @@ -78,13 +78,12 @@ bool ClientManager::CheckDestructFlag(const uint32_t logicDevId) | |||
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | -ClientManager::ClientManager(const uint32_t& deviceId) | 81 | +ClientManager::ClientManager(const uint32_t deviceId) |
| 82 | : logicDeviceId_(deviceId), | 82 | : logicDeviceId_(deviceId), |
| 83 | profilingMode_(ProfilingMode::PROFILING_CLOSE), | 83 | profilingMode_(ProfilingMode::PROFILING_CLOSE), |
| 84 | envInfo_(deviceId, g_platInfo.onlineStatus, g_platInfo.isAdcEnv, static_cast<uint32_t>(g_platInfo.chipType)), | 84 | envInfo_(deviceId, g_platInfo.onlineStatus, g_platInfo.isAdcEnv, static_cast<uint32_t>(g_platInfo.chipType)), |
| 85 | - packagePath_(envInfo_.packagePath_), | 85 | + packagePath_(envInfo_.GetPackagePathArr()), |
| 86 | - packageName_(envInfo_.packageName_), | 86 | + packageName_(envInfo_.GetPackageNameArr()) |
| 87 | - packagePattern_(envInfo_.packagePattern_) | ||
| 88 | { | 87 | { |
| 89 | GetProfilingMode(); | 88 | GetProfilingMode(); |
| 90 | } | 89 | } |
| @@ -201,12 +201,10 @@ TSD_StatusT ProcessModeManager::GetHdcConctStatus(int32_t& hdcSessStat) | |||
| 201 | return tsdCtrl_.GetHdcConctStatus(hdcSessStat); | 201 | return tsdCtrl_.GetHdcConctStatus(hdcSessStat); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | -TSD_StatusT ProcessModeManager::UpdateProfilingConf(const uint32_t& flag) { return tsdCtrl_.UpdateProfilingConf(flag); } | 204 | +TSD_StatusT ProcessModeManager::UpdateProfilingConf(const uint32_t flag) { return tsdCtrl_.UpdateProfilingConf(flag); } |
| 205 | 205 | ||
| 206 | TSD_StatusT ProcessModeManager::InitQs(const InitFlowGwInfo* const initInfo) { return tsdCtrl_.InitQs(initInfo); } | 206 | TSD_StatusT ProcessModeManager::InitQs(const InitFlowGwInfo* const initInfo) { return tsdCtrl_.InitQs(initInfo); } |
| 207 | 207 | ||
| 208 | -ProcessModeManager::~ProcessModeManager() {} | ||
| 209 | - | ||
| 210 | TSD_StatusT ProcessModeManager::CapabilityGet(const int32_t type, const uint64_t ptr) | 208 | TSD_StatusT ProcessModeManager::CapabilityGet(const int32_t type, const uint64_t ptr) |
| 211 | { | 209 | { |
| 212 | return capabilityMgr_.CapabilityGet(type, ptr); | 210 | return capabilityMgr_.CapabilityGet(type, ptr); |
| @@ -284,7 +282,7 @@ TSD_StatusT ProcessModeManager::CloseNetService() | |||
| 284 | return TsdClose(0U); | 282 | return TsdClose(0U); |
| 285 | } else { | 283 | } else { |
| 286 | ProcStatusParam closeList; | 284 | ProcStatusParam closeList; |
| 287 | - closeList.pid = tsdCtrl_.GetHccpPid(); | 285 | + closeList.pid = static_cast<pid_t>(tsdCtrl_.GetHccpPid()); |
| 288 | closeList.curStat = SubProcessStatus::SUB_PROCESS_STATUS_NORMAL; | 286 | closeList.curStat = SubProcessStatus::SUB_PROCESS_STATUS_NORMAL; |
| 289 | closeList.procType = SubProcType::TSD_SUB_PROC_HCCP; | 287 | closeList.procType = SubProcType::TSD_SUB_PROC_HCCP; |
| 290 | return subProcCtrl_.CloseSubProcList(&closeList, 1U); | 288 | return subProcCtrl_.CloseSubProcList(&closeList, 1U); |
| @@ -188,7 +188,7 @@ TSD_StatusT SubProcessController::GetSubProcStatus(ProcStatusInfo* pidInfo, cons | |||
| 188 | commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null in Close function"); | 188 | commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null in Close function"); |
| 189 | HDCMessage msg; | 189 | HDCMessage msg; |
| 190 | MessageContext ctx = tsdCtrl_.BuildBaseMessageContext(); | 190 | MessageContext ctx = tsdCtrl_.BuildBaseMessageContext(); |
| 191 | - ctx.subProcPidList.reserve(arrayLen); | 191 | + ctx.subProcPidList.reserve(static_cast<size_t>(arrayLen)); |
| 192 | for (uint32_t index = 0; index < arrayLen; index++) { | 192 | for (uint32_t index = 0; index < arrayLen; index++) { |
| 193 | ctx.subProcPidList.push_back(static_cast<uint32_t>(pidInfo[index].pid)); | 193 | ctx.subProcPidList.push_back(static_cast<uint32_t>(pidInfo[index].pid)); |
| 194 | } | 194 | } |
| @@ -219,8 +219,8 @@ TSD_StatusT SubProcessController::GetSubProcListStatus(ProcStatusParam* pidInfo, | |||
| 219 | TSD_CHECK_NULLPTR(commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null"); | 219 | TSD_CHECK_NULLPTR(commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null"); |
| 220 | HDCMessage msg; | 220 | HDCMessage msg; |
| 221 | MessageContext ctx = tsdCtrl_.BuildBaseMessageContext(); | 221 | MessageContext ctx = tsdCtrl_.BuildBaseMessageContext(); |
| 222 | - ctx.subProcPidList.reserve(arrayLen); | 222 | + ctx.subProcPidList.reserve(static_cast<size_t>(arrayLen)); |
| 223 | - ctx.subProcTypeList.reserve(arrayLen); | 223 | + ctx.subProcTypeList.reserve(static_cast<size_t>(arrayLen)); |
| 224 | for (uint32_t index = 0; index < arrayLen; index++) { | 224 | for (uint32_t index = 0; index < arrayLen; index++) { |
| 225 | ctx.subProcPidList.push_back(static_cast<uint32_t>(pidInfo[index].pid)); | 225 | ctx.subProcPidList.push_back(static_cast<uint32_t>(pidInfo[index].pid)); |
| 226 | ctx.subProcTypeList.push_back(static_cast<uint32_t>(pidInfo[index].procType)); | 226 | ctx.subProcTypeList.push_back(static_cast<uint32_t>(pidInfo[index].procType)); |
| @@ -296,7 +296,7 @@ TSD_StatusT SubProcessController::CloseSubProcList(const ProcStatusParam* closeL | |||
| 296 | TSD_RUN_INFO("device comm client is null, skip close sub proc list"); | 296 | TSD_RUN_INFO("device comm client is null, skip close sub proc list"); |
| 297 | return TSD_HDC_CLIENT_CLOSED_EXTERNAL; | 297 | return TSD_HDC_CLIENT_CLOSED_EXTERNAL; |
| 298 | } | 298 | } |
| 299 | - if (!TSD_BITMAP_GET(capabilityMgr_.GetTsdSupportLevel(), TSD_SUPPORT_CLOSE_LIST_BIT)) { | 299 | + if (TSD_BITMAP_GET(capabilityMgr_.GetTsdSupportLevel(), TSD_SUPPORT_CLOSE_LIST_BIT) == 0U) { |
| 300 | TSD_StatusT singleCloseRet = TSD_OK; | 300 | TSD_StatusT singleCloseRet = TSD_OK; |
| 301 | for (uint32_t index = 0U; index < listSize; index++) { | 301 | for (uint32_t index = 0U; index < listSize; index++) { |
| 302 | if (CloseSubProc(closeList[index].pid) != TSD_OK) { | 302 | if (CloseSubProc(closeList[index].pid) != TSD_OK) { |
| @@ -336,8 +336,8 @@ TSD_StatusT SubProcessController::ExecuteClosePidList( | |||
| 336 | TSD_CHECK_NULLPTR(commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null"); | 336 | TSD_CHECK_NULLPTR(commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null"); |
| 337 | HDCMessage msg; | 337 | HDCMessage msg; |
| 338 | MessageContext ctx = tsdCtrl_.BuildBaseMessageContext(); | 338 | MessageContext ctx = tsdCtrl_.BuildBaseMessageContext(); |
| 339 | - ctx.subProcPidList.reserve(pidCnt); | 339 | + ctx.subProcPidList.reserve(static_cast<size_t>(pidCnt)); |
| 340 | - ctx.subProcTypeList.reserve(pidCnt); | 340 | + ctx.subProcTypeList.reserve(static_cast<size_t>(pidCnt)); |
| 341 | for (uint32_t index = 0U; index < pidCnt; index++) { | 341 | for (uint32_t index = 0U; index < pidCnt; index++) { |
| 342 | const uint32_t curPid = static_cast<uint32_t>(closeList[index + startIndex].pid); | 342 | const uint32_t curPid = static_cast<uint32_t>(closeList[index + startIndex].pid); |
| 343 | const uint32_t curType = static_cast<uint32_t>(closeList[index + startIndex].procType); | 343 | const uint32_t curType = static_cast<uint32_t>(closeList[index + startIndex].procType); |
| @@ -187,7 +187,7 @@ TSD_StatusT ThreadModeManager::Close(const uint32_t flag) | |||
| 187 | return ret; | 187 | return ret; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | -TSD_StatusT ThreadModeManager::UpdateProfilingConf(const uint32_t& flag) | 190 | +TSD_StatusT ThreadModeManager::UpdateProfilingConf(const uint32_t flag) |
| 191 | { | 191 | { |
| 192 | TSD_StatusT ret = TSD_OK; | 192 | TSD_StatusT ret = TSD_OK; |
| 193 | if (handle_ == nullptr) { | 193 | if (handle_ == nullptr) { |
| @@ -397,7 +397,7 @@ TSD_StatusT ThreadModeManager::ProcessOpenSubProc(ProcOpenArgs* openArgs) | |||
| 397 | return TSD_INTERNAL_ERROR; | 397 | return TSD_INTERNAL_ERROR; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | - TSD_StatusT ret = LoadAdprofLibrary(); | 400 | + const TSD_StatusT ret = LoadAdprofLibrary(); |
| 401 | if (ret != TSD_OK) { | 401 | if (ret != TSD_OK) { |
| 402 | return ret; | 402 | return ret; |
| 403 | } | 403 | } |
| @@ -134,12 +134,12 @@ void TsdProcessController::LogOpenProcessDuration( | |||
| 134 | std::chrono::duration_cast<std::chrono::milliseconds>(finOpen - beginOpen).count()); | 134 | std::chrono::duration_cast<std::chrono::milliseconds>(finOpen - beginOpen).count()); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | -TSD_StatusT TsdProcessController::ConstructCloseMsg(HDCMessage& msg) | 137 | +TSD_StatusT TsdProcessController::ConstructCloseMsg(HDCMessage& msg) const |
| 138 | { | 138 | { |
| 139 | return HdcMessageBuilder::BuildClose(msg, BuildBaseMessageContext()); | 139 | return HdcMessageBuilder::BuildClose(msg, BuildBaseMessageContext()); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | -TSD_StatusT TsdProcessController::Close(const uint32_t flag) | 142 | +TSD_StatusT TsdProcessController::Close(uint32_t flag) |
| 143 | { | 143 | { |
| 144 | if (!commAgent_.IsInit()) { | 144 | if (!commAgent_.IsInit()) { |
| 145 | TSD_RUN_INFO("[TsdClient] tsd client no need to close"); | 145 | TSD_RUN_INFO("[TsdClient] tsd client no need to close"); |
| @@ -149,7 +149,7 @@ TSD_StatusT TsdProcessController::Close(const uint32_t flag) | |||
| 149 | commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null in Close function"); | 149 | commAgent_.GetDeviceComm(), TSD_INSTANCE_NOT_INITIALED, "[TsdClient] devCommClient_ is null in Close function"); |
| 150 | TsdCloseFlag tsdCloseFlag = {}; | 150 | TsdCloseFlag tsdCloseFlag = {}; |
| 151 | ParseTsdCloseFlag(flag, tsdCloseFlag); | 151 | ParseTsdCloseFlag(flag, tsdCloseFlag); |
| 152 | - if (tsdCloseFlag.quickCloseFlag != QUICK_CLOSE_MODE) { | 152 | + if (tsdCloseFlag.quickCloseFlag != static_cast<uint32_t>(TsdCloseMode::QUICK_CLOSE_MODE)) { |
| 153 | TSD_RUN_INFO( | 153 | TSD_RUN_INFO( |
| 154 | "[TsdClient] Close [deviceId=%u][sessionId=%u] hccp and computer enter", sharedCtx_.logicDeviceId, | 154 | "[TsdClient] Close [deviceId=%u][sessionId=%u] hccp and computer enter", sharedCtx_.logicDeviceId, |
| 155 | commAgent_.GetSessionId()); | 155 | commAgent_.GetSessionId()); |
| @@ -170,7 +170,7 @@ TSD_StatusT TsdProcessController::Close(const uint32_t flag) | |||
| 170 | commAgent_.ReleaseDeviceConnection(); | 170 | commAgent_.ReleaseDeviceConnection(); |
| 171 | sharedCtx_.rspCode = ResponseCode::FAIL; | 171 | sharedCtx_.rspCode = ResponseCode::FAIL; |
| 172 | isStartedHccp_ = false; | 172 | isStartedHccp_ = false; |
| 173 | - hccpPid_ = 0; | 173 | + hccpPid_ = 0U; |
| 174 | SetTsdStartInfo(false, false, false); | 174 | SetTsdStartInfo(false, false, false); |
| 175 | packageMgr_.ResetOnClose(); | 175 | packageMgr_.ResetOnClose(); |
| 176 | TSD_RUN_INFO( | 176 | TSD_RUN_INFO( |
| @@ -260,13 +260,19 @@ MessageContext TsdProcessController::BuildBaseMessageContext() const | |||
| 260 | ctx.aicpuExtendKernelCheckCode = packageMgr_.GetHostCheckCode(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL); | 260 | ctx.aicpuExtendKernelCheckCode = packageMgr_.GetHostCheckCode(TsdLoadPackageType::TSD_PKG_TYPE_AICPU_EXTEND_KERNEL); |
| 261 | ctx.ascendcppCheckCode = packageMgr_.GetHostCheckCode(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP); | 261 | ctx.ascendcppCheckCode = packageMgr_.GetHostCheckCode(TsdLoadPackageType::TSD_PKG_TYPE_ASCENDCPP); |
| 262 | ctx.aicpuDeviceMode = aicpuDeviceMode_; | 262 | ctx.aicpuDeviceMode = aicpuDeviceMode_; |
| 263 | - ctx.aicpuSchedMode = static_cast<SchedMode>(sharedCtx_.aicpuSchedMode); | 263 | + if (sharedCtx_.aicpuSchedMode >= static_cast<uint64_t>(AICPU_SCHED_MODE_INVALID)) { |
| 264 | + TSD_RUN_WARN( | ||
| 265 | + "[TsdClient] invalid aicpuSchedMode:%llu", static_cast<unsigned long long>(sharedCtx_.aicpuSchedMode)); | ||
| 266 | + ctx.aicpuSchedMode = AICPU_SCHED_MODE_INTERRUPT; | ||
| 267 | + } else { | ||
| 268 | + ctx.aicpuSchedMode = static_cast<SchedMode>(sharedCtx_.aicpuSchedMode); | ||
| 269 | + } | ||
| 264 | ctx.qsInitGroupName = qsInitGrpName_; | 270 | ctx.qsInitGroupName = qsInitGrpName_; |
| 265 | ctx.schedPolicy = schedPolicy_; | 271 | ctx.schedPolicy = schedPolicy_; |
| 266 | return ctx; | 272 | return ctx; |
| 267 | } | 273 | } |
| 268 | 274 | ||
| 269 | -TSD_StatusT TsdProcessController::ConstructOpenMsg(HDCMessage& hdcMsg, const TsdStartStatusInfo& startInfo) | 275 | +TSD_StatusT TsdProcessController::ConstructOpenMsg(HDCMessage& hdcMsg, const TsdStartStatusInfo& startInfo) const |
| 270 | { | 276 | { |
| 271 | MessageContext ctx = BuildBaseMessageContext(); | 277 | MessageContext ctx = BuildBaseMessageContext(); |
| 272 | ctx.startHccp = startInfo.startHccp_; | 278 | ctx.startHccp = startInfo.startHccp_; |
| @@ -331,7 +337,7 @@ TSD_StatusT TsdProcessController::SendCloseMsg() | |||
| 331 | return TSD_OK; | 337 | return TSD_OK; |
| 332 | } | 338 | } |
| 333 | 339 | ||
| 334 | -TSD_StatusT TsdProcessController::UpdateProfilingConf(const uint32_t& flag) | 340 | +TSD_StatusT TsdProcessController::UpdateProfilingConf(const uint32_t flag) |
| 335 | { | 341 | { |
| 336 | TSD_RUN_INFO( | 342 | TSD_RUN_INFO( |
| 337 | "[TsdClient] Update profiling mode [deviceId=%u][sessionId=%u][flag=%u]", sharedCtx_.logicDeviceId, | 343 | "[TsdClient] Update profiling mode [deviceId=%u][sessionId=%u][flag=%u]", sharedCtx_.logicDeviceId, |
| @@ -454,7 +460,7 @@ bool TsdProcessController::CheckNeedToOpen(const uint32_t rankSize, TsdStartStat | |||
| 454 | void TsdProcessController::ParseTsdCloseFlag(const uint32_t flag, TsdCloseFlag& tsdCloseFlag) const | 460 | void TsdProcessController::ParseTsdCloseFlag(const uint32_t flag, TsdCloseFlag& tsdCloseFlag) const |
| 455 | { | 461 | { |
| 456 | TSD_RUN_INFO("Parse tsd close flag [%u]", flag); | 462 | TSD_RUN_INFO("Parse tsd close flag [%u]", flag); |
| 457 | - tsdCloseFlag.quickCloseFlag = TSD_BITMAP_GET(flag, 0U); | 463 | + tsdCloseFlag.quickCloseFlag = static_cast<uint32_t>(TSD_BITMAP_GET(flag, 0U)); |
| 458 | return; | 464 | return; |
| 459 | } | 465 | } |
| 460 | 466 | ||
| @@ -146,7 +146,7 @@ TEST_F(ClientManagerTest, GetPackagePathSucc) | |||
| 146 | MOCKER(mmSysGetEnv).stubs().will(returnValue(&envpath[0U])); | 146 | MOCKER(mmSysGetEnv).stubs().will(returnValue(&envpath[0U])); |
| 147 | setenv("ASCEND_AICPU_PATH", "/home", 1); | 147 | setenv("ASCEND_AICPU_PATH", "/home", 1); |
| 148 | std::string env = ""; | 148 | std::string env = ""; |
| 149 | - ClientManager::GetInstance(0)->GetPackagePath(env, 0U); | 149 | + ClientManager::GetInstance(0)->envInfo_.GetPackagePath(env, 0U); |
| 150 | EXPECT_EQ(env, "/home/opp/Ascend310/aicpu/"); | 150 | EXPECT_EQ(env, "/home/opp/Ascend310/aicpu/"); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| @@ -284,7 +284,7 @@ TEST_F(ClientManagerTest, GetPackagePathFail) | |||
| 284 | { | 284 | { |
| 285 | MOCKER_CPP(&PackageEnvInfo::GetPackageTitle).stubs().will(returnValue(false)); | 285 | MOCKER_CPP(&PackageEnvInfo::GetPackageTitle).stubs().will(returnValue(false)); |
| 286 | std::string kernelPath; | 286 | std::string kernelPath; |
| 287 | - const bool ret = ClientManager::GetInstance(0)->GetPackagePath(kernelPath, 0U); | 287 | + const bool ret = ClientManager::GetInstance(0)->envInfo_.GetPackagePath(kernelPath, 0U); |
| 288 | EXPECT_EQ(ret, false); | 288 | EXPECT_EQ(ret, false); |
| 289 | } | 289 | } |
| 290 | 290 | ||