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 : #ifndef UBOE_UBG_ENDPOINT_HELPER_H
11 : #define UBOE_UBG_ENDPOINT_HELPER_H
12 :
13 : #include <cstdint>
14 : #include <memory>
15 : #include <string>
16 : #include "endpoint.h"
17 :
18 : namespace hcomm {
19 : /**
20 : * @note 职责:UBOE/UBG协议Endpoint的公共基类,提供内存管理和Socket监听等公共实现。
21 : * 子类只需实现 Init() 完成各自的地址获取(UBOE做IP→EID转换,UBG直接使用EID)。
22 : */
23 : class UboeUbgEndpointHelper : public Endpoint {
24 : public:
25 : explicit UboeUbgEndpointHelper(const EndpointDesc &endpointDesc);
26 15 : ~UboeUbgEndpointHelper() = default;
27 :
28 : HcclResult ServerSocketListen(const uint32_t port) override;
29 : HcclResult ServerSocketStopListen(const uint32_t port) override;
30 :
31 0 : std::shared_ptr<RegedMemMgr> GetRegedMemMgr() override {
32 0 : return regedMemMgr_;
33 : }
34 :
35 : HcclResult RegisterMemory(HcommMem mem, const char *memTag, void **memHandle) override;
36 : HcclResult UnregisterMemory(void* memHandle) override;
37 : HcclResult MemoryExport(void *memHandle, void **memDesc, uint32_t *memDescLen) override;
38 : HcclResult MemoryImport(const void *memDesc, uint32_t descLen, HcommMem *outMem) override;
39 : HcclResult MemoryUnimport(const void *memDesc, uint32_t descLen) override;
40 : HcclResult GetAllMemHandles(void **memHandles, uint32_t *memHandleNum) override;
41 : };
42 :
43 : }
44 :
45 : #endif // UBOE_UBG_ENDPOINT_HELPER_H
|