LCOV - code coverage report
Current view: top level - tsdclient/inc - client_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 2 0
Test Date: 2026-08-12 11:03:52 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : #ifndef TSD_CLIENT_MANAGER_H
      11              : #define TSD_CLIENT_MANAGER_H
      12              : 
      13              : #include <mmpa/mmpa_api.h>
      14              : #include <vector>
      15              : #include "tsd_util_func.h"
      16              : #include "proto/tsd_message.pb.h"
      17              : #include "tsd/status.h"
      18              : #include "tsd/tsd_client.h"
      19              : #include "basic_define.h"
      20              : #include "package_env_info.h"
      21              : #define TSD_PLAT_GET_CHIP(type) (((type) >> 8U) & 0xffU)
      22              : 
      23              : namespace tsd {
      24              : 
      25              : // 返回给tsdclient的open/close确认码
      26              : class ClientManager {
      27              : public:
      28              :     /**
      29              :      * @ingroup ClientManager
      30              :      * @brief 支持host侧单个APP进程,拉起多个device
      31              :      * @param [in] deviceId : 设备号
      32              :      * @return TsdClient对象的引用
      33              :      */
      34              :     static std::shared_ptr<ClientManager> GetInstance(
      35              :         const uint32_t& deviceId, const uint32_t deviceMode = DIE_MODE, const bool transDevIdFlag = true);
      36              : 
      37              :     static TSD_StatusT GetPlatformInfo(const uint32_t deviceId);
      38              : 
      39              :     static bool CheckDestructFlag(const uint32_t logicDevId);
      40              : 
      41              :     static void SetProfilingCallback(const MsprofReporterCallback& callback);
      42              : 
      43              :     static TSD_StatusT SetRunMode(const std::string& valueStr);
      44              : 
      45              :     static TSD_StatusT SetAicpuSchedMode(const uint32_t schedMode);
      46              : 
      47              :     /**
      48              :      * @ingroup ClientManager
      49              :      * @brief 构造函数
      50              :      */
      51              :     explicit ClientManager(const uint32_t deviceId);
      52              : 
      53              :     /**
      54              :      * @ingroup ClientManager
      55              :      * @brief 析构函数
      56              :      */
      57              :     virtual ~ClientManager();
      58              :     /**
      59              :      * @ingroup ClientManager
      60              :      * @brief framework发送拉起hccp和computer process的命令
      61              :      * @param [in] logicDeviceId : FMK传入逻辑ID
      62              :      * @param [in] rankSize : FMK传入rankSize
      63              :      * @return TSD_OK:成功 或者其他错误码
      64              :      */
      65              :     virtual TSD_StatusT Open(const uint32_t rankSize) = 0;
      66              : 
      67              :     /**
      68              :      * @ingroup ClientManager
      69              :      * @brief framework发送拉起computer process的命令
      70              :      * @param [in] logicDeviceId : FMK传入逻辑ID
      71              :      * @param [in] rankSize : FMK传入rankSize
      72              :      * @return TSD_OK:成功 或者其他错误码
      73              :      */
      74              :     virtual TSD_StatusT OpenAicpuSd() = 0;
      75              : 
      76              :     /**
      77              :      * @ingroup ClientManager
      78              :      * @brief 通知ClientManager关闭相关资源
      79              :      * @param [in] flag: 关闭标志位
      80              :      * @return TSD_OK:成功 或者其他错误码
      81              :      */
      82              :     virtual TSD_StatusT Close(const uint32_t flag) = 0;
      83              : 
      84              :     /**
      85              :      * @ingroup ClientManager
      86              :      * @brief 通知ClientManager更新profiling状态
      87              :      * @param [in] flag:  profiling 标志位
      88              :      * @return TSD_OK:成功 或者其他错误码
      89              :      */
      90              :     virtual TSD_StatusT UpdateProfilingConf(const uint32_t flag) = 0;
      91              : 
      92              :     /**
      93              :      * @ingroup ClientManager
      94              :      * @brief 用于按需拉起QS的接口
      95              :      * @param [in] initInfo : QS初始化参数
      96              :      * @return TSD_OK:成功 或者其他错误码
      97              :      */
      98              :     virtual TSD_StatusT InitQs(const InitFlowGwInfo* const initInfo) = 0;
      99              : 
     100              :     /**
     101              :      * @ingroup ClientManager
     102              :      * @brief carry aicpu ops package to device
     103              :      * @return TSD_OK:成功 或者其他错误码
     104              :      */
     105              :     virtual void Destroy() = 0;
     106              : 
     107              :     /**
     108              :      * @ingroup ClientManager
     109              :      * @brief 通过tsd获取一些能力
     110              :      * @return TSD_OK:成功 或者其他错误码
     111              :      */
     112              :     virtual TSD_StatusT CapabilityGet(const int32_t type, const uint64_t ptr) = 0;
     113              : 
     114              :     /**
     115              :      * @ingroup ClientManager
     116              :      * @brief get hdc session status
     117              :      * @return TSD_OK:成功 或者其他错误码
     118              :      */
     119              :     virtual TSD_StatusT GetHdcConctStatus(int32_t& hdcSessStat);
     120              : 
     121              :     static RunningMode GetClientRunMode(const uint32_t logicDeviceId);
     122              : 
     123              :     virtual TSD_StatusT LoadFileToDevice(
     124              :         const char_t* const filePath, const uint64_t pathLen, const char_t* const fileName,
     125              :         const uint64_t fileNameLen) = 0;
     126              : 
     127              :     virtual TSD_StatusT ProcessOpenSubProc(ProcOpenArgs* openArgs) = 0;
     128              : 
     129              :     virtual TSD_StatusT ProcessCloseSubProc(const pid_t closePid) = 0;
     130              : 
     131              :     virtual TSD_StatusT GetSubProcStatus(ProcStatusInfo* pidInfo, const uint32_t arrayLen) = 0;
     132              : 
     133              :     virtual TSD_StatusT RemoveFileOnDevice(const char_t* const filePath, const uint64_t pathLen) = 0;
     134              : 
     135              :     virtual TSD_StatusT GetSubProcListStatus(ProcStatusParam* pidInfo, const uint32_t arrayLen) = 0;
     136              : 
     137              :     bool IsAdcEnv() const;
     138              : 
     139              :     static uint32_t GetPlatInfoChipType();
     140              : 
     141              :     virtual TSD_StatusT ProcessCloseSubProcList(const ProcStatusParam* closeList, const uint32_t listSize) = 0;
     142              : 
     143              :     static bool IsNumeric(const std::string& str);
     144              : 
     145              :     static bool IsSupportSetVisibleDevices();
     146              : 
     147              :     static void SplitString(const std::string& str, std::vector<std::string>& result);
     148              : 
     149              :     static bool GetVisibleDevices();
     150              : 
     151              :     static TSD_StatusT ChangeUserDeviceIdToLogicDeviceId(const uint32_t userDevId, uint32_t& logicDevId);
     152              : 
     153              :     virtual TSD_StatusT OpenNetService(const NetServiceOpenArgs* args) = 0;
     154              : 
     155              :     virtual TSD_StatusT CloseNetService() = 0;
     156              : 
     157              :     bool GetPackageTitle(std::string& packageTitle) const;
     158              : 
     159              :     uint32_t GetPlatInfoMode() const;
     160              : 
     161            0 :     bool CheckPackageExists(const bool loadAicpuKernelFlag = true)
     162              : 
     163              :     {
     164            0 :         return envInfo_.CheckPackageExists(loadAicpuKernelFlag);
     165              :     }
     166              : 
     167              : protected:
     168              :     /**
     169              :      * @ingroup ClientManager
     170              :      * @brief GetProfilingMode获取pid
     171              :      */
     172              :     void GetProfilingMode();
     173              : 
     174              :     /**
     175              :      * @ingroup ClientManager
     176              :      * @brief SetPlatInfoMode set platinfo mode value
     177              :      * @param [in] platInfoMode : used to set g_platInfo.mode
     178              :      */
     179              :     void SetPlatInfoMode(const uint32_t platInfoMode) const;
     180              : 
     181              :     static void SetPlatInfoChipType(const ChipType_t curType);
     182              : 
     183              :     static void ResetPlatInfoFlag();
     184              : 
     185              :     uint32_t logicDeviceId_;
     186              :     ProfilingMode profilingMode_;
     187              :     static RunningMode g_runningMode;
     188              :     static std::mutex g_profilingCallbackMut;
     189              :     static MsprofReporterCallback g_profilingCallback;
     190              :     static SchedMode aicpuSchedMode_;
     191              : 
     192              : protected:
     193              :     PackageEnvInfo envInfo_;
     194              :     std::string (&packagePath_)[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)];
     195              :     std::string (&packageName_)[static_cast<uint32_t>(TsdLoadPackageType::TSD_PKG_TYPE_MAX)];
     196              : 
     197              : private:
     198              :     ClientManager(const ClientManager&) = delete;
     199              :     ClientManager(ClientManager&&) = delete;
     200              :     ClientManager& operator=(const ClientManager&) = delete;
     201              :     ClientManager& operator=(ClientManager&) = delete;
     202              :     ClientManager& operator=(ClientManager&&) = delete;
     203              : };
     204              : } // namespace tsd
     205              : #endif // TSD_CLIENT_MANAGER_H
        

Generated by: LCOV version 2.0-1