LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/connection - host_ub_connection.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 4 4
Test Date: 2026-08-25 19:18:03 Functions: 83.3 % 6 5

            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 HCCLV2_HOST_UB_CONNECTION_H
      12              : #define HCCLV2_HOST_UB_CONNECTION_H
      13              : 
      14              : #include "rma_connection.h"
      15              : #include "op_mode.h"
      16              : #include "orion_adapter_hccp.h"
      17              : #include "tp_manager.h"
      18              : #include "local_ub_rma_buffer.h"
      19              : #include "stream.h"
      20              : #include "task.h"
      21              : #include "mc2_type.h"
      22              : #include "env_config/env_config_v2.h"
      23              : 
      24              : namespace Hccl {
      25              : 
      26              : class HostUbConnection : public RmaConnection {
      27              : public:
      28              :     HostUbConnection(
      29              :         const RdmaHandle rdmaHandle, const IpAddress& locAddr, const IpAddress& rmtAddr, const OpMode opMode,
      30           32 :         const HrtUbJfcMode jfcMode = HrtUbJfcMode::NORMAL, u8 qos = static_cast<u8>(UB_QOS_DEFAULT));
      31              :     void Connect() override;
      32              :     RmaConnStatus GetStatus() override;
      33              :     bool Suspend() override;
      34              : 
      35              :     std::unique_ptr<Serializable> GetExchangeDto() override;
      36              :     void ParseRmtExchangeDto(const Serializable& rmtDto) override;
      37              :     void ImportRmtDto() override;
      38              : 
      39              :     std::vector<char> GetUniqueId() const override;
      40              : 
      41              :     void SetCqInfo(HcclAiRMACQ& cq);
      42              : 
      43              :     void SetWqInfo(HcclAiRMAWQ& wq);
      44              : 
      45              :     unique_ptr<BaseTask>
      46              :     PrepareRead(const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, const SqeConfig& config) override;
      47              : 
      48              :     unique_ptr<BaseTask> PrepareReadReduce(
      49              :         const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, DataType dataType, ReduceOp reduceOp,
      50              :         const SqeConfig& config) override;
      51              : 
      52              :     unique_ptr<BaseTask>
      53              :     PrepareWrite(const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, const SqeConfig& config) override;
      54              : 
      55              :     unique_ptr<BaseTask> PrepareWriteReduce(
      56              :         const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, DataType dataType, ReduceOp reduceOp,
      57              :         const SqeConfig& config) override;
      58              : 
      59              :     unique_ptr<BaseTask>
      60              :     PrepareInlineWrite(const MemoryBuffer& remoteMemBuf, u64 data, const SqeConfig& config) override;
      61              : 
      62              :     class UbCiUpdater;
      63              : 
      64              :     void AddNop(const Stream& stream) override;
      65              : 
      66              :     void ReleaseTp();
      67              :     ~HostUbConnection() override;
      68              : 
      69              :     string Describe() const override;
      70              : 
      71              :     HrtUbJfcMode GetUbJfcMode() const;
      72              :     JettyHandle& GetJettyHandle();
      73              :     JettyHandle& GetRemoteJettyHandle();
      74              :     RdmaHandle& GetRdmaHandle();
      75              :     u32 GetPiVal() const;
      76              :     u32 GetCiVal() const;
      77              :     u32 GetSqDepth() const;
      78              : 
      79              :     uint64_t GetCqVa() const;
      80              :     u64 GetJettyVa() const;
      81              :     JettyHandle GetTJettyVa() const;
      82              : 
      83              : protected:
      84              :     TpProtocol tpProtocol{TpProtocol::INVALID};
      85              : 
      86              : private:
      87           87 :     MAKE_ENUM(UbConnStatus, INIT, TP_INFO_GETTING, JETTY_CREATED, JETTY_IMPORTING, READY, CONN_INVALID);
      88              : 
      89              :     UbConnStatus ubConnStatus{UbConnStatus::INIT};
      90              : 
      91              :     RdmaHandle rdmaHandle{nullptr};
      92              :     IpAddress locAddr{};
      93              :     IpAddress rmtAddr{};
      94              :     OpMode opMode{OpMode::OPBASE};
      95              :     HrtUbJfcMode jfcMode{HrtUbJfcMode::NORMAL}; // Peer模式只支持jfcMode为NORMAL类型
      96              :     u32 tokenValue{GetUbToken()};
      97              :     Eid rmtEid{};
      98              :     Eid locEid{};
      99              :     Eid rmtReverseEid{}; // 反序Eid,仅用于传递给硬件
     100              : 
     101              :     u32 dieId{0};
     102              :     u32 funcId{0};
     103              :     JfcHandle jfcHandle{0};
     104              :     u32 sqDepth{0};
     105              :     uint64_t sqBuffVa{0};
     106              : 
     107              :     RequestHandle reqHandle{0};
     108              :     vector<char_t> reqDataBuffer;
     109              :     HrtRaUbJettyCreatedOutParam repJetty_{};
     110              :     HrtRaUbJettyImportedOutParam remOutParam_{};
     111              : 
     112              :     u8 remoteQpKey[HRT_UB_QP_KEY_MAX_LEN] = {0};
     113              :     u32 keySize{0};
     114              :     u32 remoteTokenValue{0};
     115              :     JettyImportCfg jettyImportCfg{};
     116              : 
     117              :     JettyHandle jettyHandle_{0};
     118              :     u64 jettyVa_{0};
     119              :     void* jettyHandlePtr{nullptr};
     120              :     JettyHandle remoteJettyVa_{0};
     121              :     TargetJettyHandle remoteJettyHandle_{0};
     122              :     u8 localQpKey[HRT_UB_QP_KEY_MAX_LEN]{0};
     123              : 
     124              :     u32 jettyId_{0};
     125              :     u64 dbAddr{0};
     126              :     u32 tpn{0};
     127              : 
     128              :     u32 localTpnStart{0};
     129              :     u32 localTpNum{0};
     130              :     TpInfo tpInfo{};
     131              : 
     132              :     u8 qos_{static_cast<u8>(UB_QOS_DEFAULT)}; // 业务 QoS,GetTpInfo / ReleaseTpInfo 缓存键
     133              : 
     134              :     u32 piVal{0};
     135              :     u32 ciVal{0};
     136              : 
     137              :     CqCreateInfo cqInfo_{};
     138              : 
     139              :     bool CheckRequestResult();
     140              :     void ThrowAbnormalStatus(std::string funcName);
     141              : 
     142              :     void GenerateLocalPsn();
     143              :     void CreateJetty();
     144              :     void SetJettyInfo();
     145              :     bool GetTpInfo();
     146              :     void ImportJetty();
     147              :     void SetImportInfo();
     148              :     void ReleaseResource();
     149              : 
     150              :     void ProcessSlices(
     151              :         const MemoryBuffer& loc, const MemoryBuffer& rmt,
     152              :         std::function<void(const MemoryBuffer&, const MemoryBuffer&, u32)> processOneSlice,
     153              :         DataType dataType = DataType::INVALID) const;
     154              : 
     155              :     std::unique_ptr<BaseTask>
     156              :     ConstructTaskUbSend(const HrtRaUbSendWrRespParam& sendWrResp, const SqeConfig& config) const;
     157              :     void UpdateCiVal(u32 ci);
     158              : };
     159              : 
     160              : class HostUbTpConnection : public HostUbConnection {
     161              : public:
     162              :     HostUbTpConnection(
     163              :         const RdmaHandle rdmaHandle, const IpAddress& locAddr, const IpAddress& rmtAddr, const OpMode opMode,
     164            1 :         const HrtUbJfcMode jfcMode = HrtUbJfcMode::NORMAL, u8 qos = static_cast<u8>(UB_QOS_DEFAULT));
     165              : };
     166              : 
     167              : class HostUbCtpConnection : public HostUbConnection {
     168              : public:
     169              :     HostUbCtpConnection(
     170              :         const RdmaHandle rdmaHandle, const IpAddress& locAddr, const IpAddress& rmtAddr, const OpMode opMode,
     171            1 :         const HrtUbJfcMode jfcMode = HrtUbJfcMode::NORMAL, u8 qos = static_cast<u8>(UB_QOS_DEFAULT));
     172              : };
     173              : 
     174              : bool IfNeedUpdatingUbCi(const std::vector<HostUbConnection*>& ubConns);
     175              : 
     176              : } // namespace Hccl
     177              : 
     178              : #endif // HCCLV2_HOST_UB_CONNECTION_H
        

Generated by: LCOV version 2.0-1