Line data Source code
1 : /**
2 : * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef TSD_BASIC_COMPONENT_DEVICE_COMM_DEVICE_COMM_AGENT_H
12 : #define TSD_BASIC_COMPONENT_DEVICE_COMM_DEVICE_COMM_AGENT_H
13 :
14 : #include <memory>
15 : #include "device_comm.h"
16 : #include "driver/ascend_hal.h"
17 : #include "proto/tsd_message.pb.h"
18 : #include "tsd/status.h"
19 : #include "tsd_version_verify.h"
20 :
21 : namespace tsd {
22 : class DeviceCommAgent {
23 : public:
24 : explicit DeviceCommAgent(const uint32_t logicDeviceId);
25 : ~DeviceCommAgent();
26 :
27 : DeviceCommAgent(const DeviceCommAgent&) = delete;
28 : DeviceCommAgent& operator=(const DeviceCommAgent&) = delete;
29 :
30 : TSD_StatusT InitTsdClient(bool isAdcEnv);
31 : TSD_StatusT SendMsg(const HDCMessage& msg);
32 : TSD_StatusT RecvData(bool ignoreRecvErr = false, uint32_t timeout = 0U);
33 : TSD_StatusT GetHdcConctStatus(int32_t& sessStat, bool isAdcEnv);
34 : TSD_StatusT GetVersionVerify(std::shared_ptr<VersionVerify>& inspector);
35 : void ReleaseDeviceConnection();
36 :
37 117 : std::shared_ptr<DeviceComm> GetDeviceComm() const { return devCommClient_; }
38 119 : uint32_t GetSessionId() const { return tsdSessionId_; }
39 133 : bool IsInit() const { return devCommClient_ != nullptr; }
40 196 : const process_sign& GetProcSign() const { return procSign_; }
41 :
42 : private:
43 : uint32_t logicDeviceId_;
44 : bool isAdcEnv_ = false;
45 : std::shared_ptr<DeviceComm> devCommClient_ = nullptr;
46 : uint32_t tsdSessionId_ = 0;
47 : process_sign procSign_ = {};
48 : };
49 : } // namespace tsd
50 : #endif // TSD_BASIC_COMPONENT_DEVICE_COMM_DEVICE_COMM_AGENT_H
|