Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef RTS_NOTIFY_H
12 : #define RTS_NOTIFY_H
13 :
14 : #include "notify_base.h"
15 :
16 : namespace hccl {
17 :
18 : class RtsNotify : public NotifyBase {
19 : public:
20 : explicit RtsNotify(NotifyType notifyType);
21 : RtsNotify(NotifyType notifyType, HcclNotifyInfo notifyInfo);
22 : RtsNotify(NotifyType notifyType, const HcclSignalInfo& notifyInfo);
23 : ~RtsNotify() override;
24 :
25 : HcclResult Alloc() override;
26 : HcclResult Destroy() override;
27 :
28 : HcclResult Open() override;
29 : HcclResult Close() override;
30 :
31 : HcclResult Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut) override;
32 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage) override;
33 :
34 : HcclResult
35 : Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut, u32 userRank, u32 remoteUserRank) override;
36 : HcclResult Wait(Stream& stream, u32 timeOut) override;
37 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 remoteUserRank) override;
38 : HcclResult Post(Stream& stream) override;
39 :
40 : HcclResult SetIpc() override;
41 : HcclResult Grant(s64 recvId) override;
42 :
43 8176 : HcclResult GetNotifyData(HcclSignalInfo& notifyInfo) override
44 : {
45 8176 : notifyInfo.resId = static_cast<u64>(id);
46 8176 : notifyInfo.addr = address;
47 8176 : notifyInfo.devId = devId;
48 8176 : notifyInfo.tsId = tsId;
49 8176 : notifyInfo.flag = flag;
50 8176 : HCCL_DEBUG(
51 : "GetNotifyData resId[%lld], addr[%llu], devId[%u], tsId[%u]", notifyInfo.resId, notifyInfo.addr,
52 : notifyInfo.devId, notifyInfo.tsId);
53 8180 : return HCCL_SUCCESS;
54 : }
55 :
56 4353 : HcclResult SetNotifyData(const HcclSignalInfo& notifyInfo) override
57 : {
58 4353 : id = notifyInfo.resId;
59 4353 : address = notifyInfo.addr;
60 4353 : devId = notifyInfo.devId;
61 4353 : tsId = notifyInfo.tsId;
62 4353 : flag = notifyInfo.flag;
63 4353 : HCCL_DEBUG("SetNotifyData resId[%lld], addr[%llu], devId[%u], tsId[%u]", id, address, devId, tsId);
64 4353 : return HCCL_SUCCESS;
65 : }
66 :
67 11 : HcclResult GetNotifyOffset(u64& notifyOffset) override
68 : {
69 11 : notifyOffset = notifyInfo_.ipcNotify.offset;
70 11 : return HCCL_SUCCESS;
71 : }
72 :
73 : HcclResult InitAndVerifySingleSignal();
74 :
75 : private:
76 : HcclResult UpdateNotifyInfo();
77 :
78 : bool isDestroyed{false};
79 : bool inchip{true};
80 : bool isLocal{true};
81 :
82 : u32 id{INVALID_UINT};
83 : u64 address{INVALID_U64};
84 : u32 size{INVALID_UINT};
85 : u32 devId{INVALID_UINT};
86 : u32 tsId{INVALID_UINT};
87 : u32 flag{INVALID_UINT};
88 : };
89 :
90 : } // namespace hccl
91 :
92 : #endif // RTS_NOTIFY_H
|