LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/ccu/dfx - ccu_error_handler.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 76.5 % 17 13
Test Date: 2026-08-04 10:52:23 Functions: 71.4 % 7 5

            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 CCU_ERROR_HANDLER_H
      12              : #define CCU_ERROR_HANDLER_H
      13              : 
      14              : #include <vector>
      15              : #include "hccl_types.h"
      16              : #include "task_param.h"
      17              : #include "ccu_error_info.h"
      18              : #include "ccu_rep_base.h"
      19              : #include "ccu_rep_context.h"
      20              : 
      21              : namespace Hccl {
      22              : 
      23              : struct CcuMissionContext {
      24              :     union {
      25              :         uint16_t value;
      26              :         uint16_t taskId;
      27              :     } part0;
      28              : 
      29              :     union {
      30              :         uint16_t value;
      31              :         uint16_t streamId;
      32              :     } part1;
      33              : 
      34              :     union {
      35              :         uint16_t value;
      36              :         struct {
      37              :             uint16_t taskKill : 1;
      38              :             uint16_t dieId : 2;
      39              :             uint16_t status : 13; // Status [12:0]
      40              :         };
      41              :     } part2;
      42              : 
      43              :     union {
      44              :         uint16_t value;
      45              :         struct {
      46              :             uint16_t status : 3; // Status [15:13]
      47              :             uint16_t counter : 8;
      48              :             uint16_t denyCnt : 5;
      49              :         };
      50              :     } part3;
      51              : 
      52              :     union {
      53              :         uint16_t value;
      54              :         struct {
      55              :             uint16_t denyCnt : 5;
      56              :             uint16_t currentIns : 11; // Current Ins [10:0]
      57              :         };
      58              :     } part4;
      59              : 
      60              :     union {
      61              :         uint16_t value;
      62              :         struct {
      63              :             uint16_t currentIns : 5; // Current Ins [15:11]
      64              :             uint16_t endIns : 11;
      65              :         };
      66              :     } part5;
      67              : 
      68              :     union {
      69              :         uint16_t value;
      70              :         struct {
      71              :             uint16_t endIns : 5;
      72              :             uint16_t startIns : 11;
      73              :         };
      74              :     } part6;
      75              : 
      76              :     union {
      77              :         uint16_t value;
      78              :         struct {
      79              :             uint16_t startIns : 5;
      80              :             uint16_t profileEn : 1;
      81              :             uint16_t missionVld : 1;
      82              :             uint16_t reserved : 9;
      83              :         };
      84              :     } part7;
      85              : 
      86              :     uint16_t reserved[24]; // part 8-31
      87              : 
      88          770 :     uint16_t GetStatus() const
      89              :     {
      90          770 :         return (part3.status << 13) | (part2.status);   // part3.status为[15:13]位
      91              :     }
      92              : 
      93            2 :     uint16_t GetCurrentIns() const
      94              :     {
      95            2 :         return (part5.currentIns << 11) | (part4.currentIns);   // part5.currentIns为[15:11]位
      96              :     }
      97              : 
      98            0 :     uint16_t GetStartIns() const
      99              :     {
     100            0 :         return (part7.startIns << 11) | (part6.startIns);    // part7.startIns[15:11]位
     101              :     }
     102              : 
     103            0 :     uint16_t GetEndIns() const
     104              :     {
     105            0 :         return (part6.endIns << 11) | (part5.endIns);     // part6.endIns[15:11]位
     106              :     }
     107              : };
     108              : 
     109              : struct CcuLoopContext {
     110              :     union {
     111              :         uint16_t value;
     112              :         uint16_t timestamp;
     113              :     } part0;
     114              : 
     115              :     union {
     116              :         uint16_t value;
     117              :         uint16_t timestamp;
     118              :     } part1;
     119              : 
     120              :     union {
     121              :         uint16_t value;
     122              :         struct {
     123              :             uint16_t timestamp : 4;
     124              :             uint16_t ckeOffset : 10;
     125              :             uint16_t msOffset : 2;
     126              :         };
     127              :     } part2;
     128              : 
     129              :     union {
     130              :         uint16_t value;
     131              :         struct {
     132              :             uint16_t msOffset : 9;
     133              :             uint16_t addrOffset : 7;
     134              :         };
     135              :     } part3;
     136              : 
     137              :     union {
     138              :         uint16_t value;
     139              :         uint16_t addrOffset;
     140              :     } part4;
     141              : 
     142              :     union {
     143              :         uint16_t value;
     144              :         struct {
     145              :             uint16_t addrOffset : 9;
     146              :             uint16_t ckBit : 7;
     147              :         };
     148              :     } part5;
     149              : 
     150              :     union {
     151              :         uint16_t value;
     152              :         uint16_t ckBit;
     153              :     } part6;
     154              : 
     155              :     union {
     156              :         uint16_t value;
     157              :         struct {
     158              :             uint16_t ckBit : 9;
     159              :             uint16_t perfMode : 1;
     160              :             uint16_t waitLoopCkbitValue : 6;
     161              :         };
     162              :     } part7;
     163              : 
     164              :     union {
     165              :         uint16_t value;
     166              :         uint16_t waitLoopCkbitValue;
     167              :     } part8;
     168              : 
     169              :     union {
     170              :         uint16_t value;
     171              :         struct {
     172              :             uint16_t waitLoopCkbitValue : 10;
     173              :             uint16_t currentIns : 6;    // Current_ins [5:0]
     174              :         };
     175              :     } part9;
     176              : 
     177              :     union {
     178              :         uint16_t value;
     179              :         struct {
     180              :             uint16_t currentIns : 10;   // Current_ins [15:6]
     181              :             uint16_t addrStride : 6;    // Addr_stride [5:0]
     182              :         };
     183              :     } part10;
     184              : 
     185              :     union {
     186              :         uint16_t value;
     187              :         uint16_t addrStride;            // Addr_stride [21:6]
     188              :     } part11;
     189              : 
     190              :     union {
     191              :         uint16_t value;
     192              :         struct {
     193              :             uint16_t addrStride : 10;   // Addr_stride [31:22]
     194              :             uint16_t denyCnt : 6;
     195              :         };
     196              :     } part12;
     197              : 
     198              :     union {
     199              :         uint16_t value;
     200              :         struct {
     201              :             uint16_t denyCnt : 4;
     202              :             uint16_t currentCnt : 12;   // Current_cnt [11:0]
     203              :         };
     204              :     } part13;
     205              : 
     206              :     union {
     207              :         uint16_t value;
     208              :         struct {
     209              :             uint16_t currentCnt : 1;    // Current_cnt [12]
     210              :             uint16_t totalCnt : 13;
     211              :             uint16_t endIns : 2;
     212              :         };
     213              :     } part14;
     214              : 
     215              :     union {
     216              :         uint16_t value;
     217              :         struct {
     218              :             uint16_t endIns : 14;
     219              :             uint16_t startIns : 2;
     220              :         };
     221              :     } part15;
     222              : 
     223              :     union {
     224              :         uint16_t value;
     225              :         struct {
     226              :             uint16_t startIns : 14;
     227              :             uint16_t missionId : 2;
     228              :         };
     229              :     } part16;
     230              : 
     231              :     union {
     232              :         uint16_t value;
     233              :         struct {
     234              :             uint16_t missionId : 2;
     235              :             uint16_t reserved : 14;
     236              :         };
     237              :     } part17;
     238              : 
     239              :     uint16_t reserved[14]; // part 18-31
     240              : 
     241            2 :     uint16_t GetCurrentIns() const
     242              :     {
     243            2 :         return (part10.currentIns << 6) | (part9.currentIns);   // part10.currentIns为[15:6]位
     244              :     }
     245              : 
     246            4 :     uint16_t GetCurrentCnt() const
     247              :     {
     248            4 :         return (part14.currentCnt << 12) | (part13.currentCnt); // part14.currentCnt为第[12]位
     249              :     }
     250              : 
     251            4 :     uint32_t GetAddrStride() const
     252              :     {
     253            4 :         const uint32_t low = static_cast<uint32_t>(part10.addrStride);
     254            4 :         const uint32_t mid = static_cast<uint32_t>(part11.addrStride) << 6;     // part11.addrStride为[21:6]位
     255            4 :         const uint32_t high = static_cast<uint32_t>(part12.addrStride) << 22;   // part12.addrStride为[31:22]位
     256            4 :         return high | mid | low;
     257              :     }
     258              : };
     259              : 
     260              : union LoopXm {
     261              :     uint64_t value;
     262              :     struct {
     263              :         uint64_t loopCnt : 13;
     264              :         uint64_t gsaStride : 32;
     265              :         uint64_t loopCtxId : 8;
     266              :         uint64_t reserved : 11;
     267              :     };
     268              : };
     269              : 
     270              : union LoopGroupXn {
     271              :     uint64_t value;
     272              :     struct {
     273              :         uint64_t reservedLow : 41;
     274              :         uint64_t loopInsCnt : 7;
     275              :         uint64_t expandOffset : 7;
     276              :         uint64_t expandCnt : 7;
     277              :         uint64_t reservedHigh : 2;
     278              :     };
     279              : };
     280              : 
     281              : union LoopGroupXm {
     282              :     uint64_t value;
     283              :     struct {
     284              :         uint64_t ckOffset : 10;
     285              :         uint64_t msOffset : 11;
     286              :         uint64_t gsaOffset : 32;
     287              :         uint64_t reserved : 11;
     288              :     };
     289              : };
     290              : 
     291              : struct ErrorInfoBase {
     292              :     int32_t  deviceId;
     293              :     uint8_t  dieId;
     294              :     uint8_t  missionId;
     295              :     uint16_t currentInsId;
     296              :     uint16_t status;
     297              : };
     298              : 
     299              : class CcuErrorHandler {
     300              : public:
     301              :     CcuErrorHandler() = delete;
     302              :     CcuErrorHandler(const CcuErrorHandler&) = delete;
     303              :     void operator=(const CcuErrorHandler&) = delete;
     304              : 
     305              :      static void GetCcuErrorMsg(int32_t deviceId, uint16_t missionStatus, const ParaCcu &ccuTaskParam, std::vector<CcuErrorInfo> &errorInfo);
     306              :     static void GetCcuJettys(int32_t deviceId, const ParaCcu &ccuTaskParam, std::vector<CcuJetty *> ccuJettys);
     307              :     static CcuMissionContext GetCcuMissionContext(int32_t deviceId, uint32_t dieId, uint32_t missionId);
     308              : 
     309              : private:
     310              :     static void GenStatusInfo(const ErrorInfoBase &baseInfo, std::vector<CcuErrorInfo> &errorInfo);
     311              : 
     312              :     // LoopGroup
     313              :     static void GenErrorInfoLoopGroup(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     314              :                                       CcuRep::CcuRepContext &ctx, std::vector<CcuErrorInfo> &errorInfo);
     315              :     // Loop
     316              :     static void GenErrorInfoLoop(const ErrorInfoBase &baseInfo, CcuRep::CcuRepContext &ctx,
     317              :                                  std::vector<CcuErrorInfo> &errorInfo);
     318              : 
     319              :     static void GenErrorInfoByRepType(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     320              :                                       std::vector<CcuErrorInfo> &errorInfo);
     321              :     // Default
     322              :     static void GenErrorInfoDefault(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     323              :                                     std::vector<CcuErrorInfo> &errorInfo);
     324              :     // WaitSignal
     325              :     static void GenErrorInfoLocPostSem(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     326              :                                        std::vector<CcuErrorInfo> &errorInfo);
     327              :     static void GenErrorInfoLocWaitSem(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     328              :                                        std::vector<CcuErrorInfo> &errorInfo);
     329              :     static void GenErrorInfoRemPostSem(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     330              :                                        std::vector<CcuErrorInfo> &errorInfo);
     331              :     static void GenErrorInfoRemWaitSem(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     332              :                                        std::vector<CcuErrorInfo> &errorInfo);
     333              :     static void GenErrorInfoRemPostVar(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     334              :                                        std::vector<CcuErrorInfo> &errorInfo);
     335              :     static void GenErrorInfoRemWaitGroup(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     336              :                                          std::vector<CcuErrorInfo> &errorInfo);
     337              :     static void GenErrorInfoPostSharedVar(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     338              :                                           std::vector<CcuErrorInfo> &errorInfo);
     339              :     static void GenErrorInfoPostSharedSem(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     340              :                                           std::vector<CcuErrorInfo> &errorInfo);
     341              :     // TransMem
     342              :     static void GenErrorInfoRead(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     343              :                                  std::vector<CcuErrorInfo> &errorInfo);
     344              :     static void GenErrorInfoWrite(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     345              :                                   std::vector<CcuErrorInfo> &errorInfo);
     346              :     static void GenErrorInfoLocalCpy(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     347              :                                      std::vector<CcuErrorInfo> &errorInfo);
     348              :     static void GenErrorInfoLocalReduce(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     349              :                                         std::vector<CcuErrorInfo> &errorInfo);
     350              :     // BufTransMem
     351              :     static void GenErrorInfoBufRead(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     352              :                                     std::vector<CcuErrorInfo> &errorInfo);
     353              :     static void GenErrorInfoBufWrite(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     354              :                                      std::vector<CcuErrorInfo> &errorInfo);
     355              :     static void GenErrorInfoBufLocRead(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     356              :                                        std::vector<CcuErrorInfo> &errorInfo);
     357              :     static void GenErrorInfoBufLocWrite(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     358              :                                         std::vector<CcuErrorInfo> &errorInfo);
     359              :     // BufReduce
     360              :     static void GenErrorInfoBufReduce(const ErrorInfoBase &baseInfo, std::shared_ptr<CcuRep::CcuRepBase> repBase,
     361              :                                       std::vector<CcuErrorInfo> &errorInfo);
     362              : 
     363              :     static CcuLoopContext    GetCcuLoopContext(int32_t deviceId, uint32_t dieId, uint32_t loopCtxId);
     364              :     static uint64_t          GetCcuXnValue(int32_t deviceId, uint32_t dieId, uint32_t xnId);
     365              :     static uint64_t          GetCcuGSAValue(int32_t deviceId, uint32_t dieId, uint32_t gsaId);
     366              :     static uint16_t          GetCcuCKEValue(int32_t deviceId, uint32_t dieId, uint32_t ckeId);
     367              : };
     368              : 
     369              : } // namespace Hccl
     370              : #endif // CCU_ERROR_HANDLER_H
        

Generated by: LCOV version 2.0-1