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 URMA_ENDPOINT_H
11 : #define URMA_ENDPOINT_H
12 :
13 : #include <memory>
14 : #include <vector>
15 : #include <string>
16 : #include "endpoint.h"
17 : #include "ccu_channel_ctx_pool.h"
18 : #include "socket/socket.h"
19 : #include "externalinput_pub.h"
20 : #include <mutex>
21 :
22 : namespace hcomm {
23 : /**
24 : * @note 职责:Host CPU通信引擎+RoCE协议的通信设备Endpoint,管理通信设备上下文,以及设备上的注册内存。
25 : */
26 : class UrmaEndpoint : public Endpoint {
27 : public:
28 : explicit UrmaEndpoint(const EndpointDesc &endpointDesc);
29 : ~UrmaEndpoint() noexcept override;
30 :
31 : HcclResult Init() override;
32 :
33 : HcclResult ServerSocketListen(const uint32_t port) override;
34 : HcclResult ServerSocketStopListen(const uint32_t port) override;
35 : inline HcclResult ServerSocketStopListenImpl(const uint32_t port);
36 : HcclResult ServerSocketGetListenPort(uint32_t *port) override;
37 :
38 0 : std::shared_ptr<RegedMemMgr> GetRegedMemMgr() override {
39 0 : return regedMemMgr_;
40 : }
41 :
42 : CcuChannelCtxPool *GetCcuChannelCtxPool();
43 :
44 : HcclResult RegisterMemory(HcommMem mem, const char *memTag, void **memHandle) override;
45 : HcclResult UnregisterMemory(void* memHandle) override;
46 : HcclResult MemoryExport(void *memHandle, void **memDesc, uint32_t *memDescLen) override;
47 : HcclResult MemoryImport(const void *memDesc, uint32_t descLen, HcommMem *outMem) override;
48 : HcclResult MemoryUnimport(const void *memDesc, uint32_t descLen) override;
49 : HcclResult GetAllMemHandles(void **memHandles, uint32_t *memHandleNum) override;
50 : HcclResult GetAsyncEvents(uint32_t devPhyId, struct AsyncEvent events[], uint32_t &num) override;
51 :
52 : private:
53 : std::mutex portMutex_;
54 : u32 dynamicPort_{HCCL_INVALID_PORT};
55 : std::unique_ptr<CcuChannelCtxPool> ccuChannelCtxPool_{nullptr};
56 : };
57 : }
58 :
59 : #endif // URMA_ENDPOINT_H
|