LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_dfx - ccu_error_info_v1.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 24 24
Test Date: 2026-07-28 12:11:00 Functions: 92.9 % 14 13

            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_INFO_V1_H
      12              : #define CCU_ERROR_INFO_V1_H
      13              : #include <cstdint>
      14              : #include "enum_factory.h"
      15              : #include "ccu_rep_type_v1.h"
      16              : 
      17              : namespace hcomm {
      18              : constexpr uint32_t MISSION_STATUS_MSG_LEN = 64;
      19              : constexpr uint32_t WAIT_SIGNAL_CHANNEL_SIZE = 16;
      20              : constexpr uint32_t BUF_REDUCE_ID_SIZE = 8;
      21              : 
      22          187 : MAKE_ENUM(CcuErrorType, DEFAULT, MISSION, WAIT_SIGNAL, TRANS_MEM, BUF_TRANS_MEM, BUF_REDUCE, LOOP, LOOP_GROUP)
      23              : 
      24              : struct CcuErrorInfo {
      25              :     // 根据不同的typeId解析不同的union类型
      26              :     CcuErrorType type;
      27              : 
      28              :     // 出异常的Rep类型
      29              :     CcuRep::CcuRepType repType;
      30              : 
      31              :     // CCU任务执行的DieId
      32              :     uint8_t dieId;
      33              : 
      34              :     // CCU任务执行的MissionId
      35              :     uint8_t missionId;
      36              : 
      37              :     // Error所在的指令Id
      38              :     uint16_t instrId;
      39              : 
      40              :     union {
      41              :         struct {
      42              :             char missionError[MISSION_STATUS_MSG_LEN];
      43              :         } mission;
      44              : 
      45              :         struct {
      46              :             uint16_t signalId;
      47              :             uint16_t signalMask;
      48              :             uint16_t signalValue;
      49              :             uint16_t paramId;
      50              :             uint64_t paramValue;
      51              :             uint16_t channelId[WAIT_SIGNAL_CHANNEL_SIZE];
      52              :         } waitSignal;
      53              : 
      54              :         struct {
      55              :             uint64_t locAddr;
      56              :             uint64_t locToken;
      57              :             uint64_t rmtAddr;
      58              :             uint64_t rmtToken;
      59              :             uint64_t len;
      60              :             uint16_t signalId;
      61              :             uint16_t signalMask;
      62              :             uint16_t channelId;
      63              :             uint16_t dataType;
      64              :             uint16_t opType;
      65              :         } transMem;
      66              : 
      67              :         struct {
      68              :             uint16_t bufId;
      69              :             uint16_t signalId;
      70              :             uint16_t signalMask;
      71              :             uint16_t channelId;
      72              :             uint64_t addr;
      73              :             uint64_t token;
      74              :             uint64_t len;
      75              :         } bufTransMem;
      76              : 
      77              :         struct {
      78              :             uint16_t bufIds[BUF_REDUCE_ID_SIZE];
      79              :             uint16_t count;
      80              :             uint16_t dataType;
      81              :             uint16_t outputDataType;
      82              :             uint16_t opType;
      83              :             uint16_t signalId;
      84              :             uint16_t signalMask;
      85              :             uint16_t xnIdLength;
      86              :         } bufReduce;
      87              : 
      88              :         struct {
      89              :             uint16_t startInstrId;
      90              :             uint16_t endInstrId;
      91              :             uint16_t loopEngineId;
      92              :             uint16_t loopCnt;           // 该Loop需要循环执行的次数
      93              :             uint16_t loopCurrentCnt;    // 该Loop已经循环次数
      94              :             uint32_t addrStride;
      95              :         } loop;
      96              : 
      97              :         struct {
      98              :             uint16_t startLoopInsId;
      99              :             uint16_t loopInsCnt;
     100              :             uint16_t expandOffset;
     101              :             uint16_t expandCnt;
     102              :         } loopGroup;
     103              :     } msg;
     104              : 
     105           12 :     void SetBaseInfo(CcuRep::CcuRepType ccuRepType, uint8_t ccuDieId, uint8_t ccuMissionId, uint16_t insId)
     106              :     {
     107           12 :         this->repType = ccuRepType;
     108           12 :         this->dieId = ccuDieId;
     109           12 :         this->missionId = ccuMissionId;
     110           12 :         this->instrId = insId;
     111           12 :     }
     112              : };
     113              : 
     114              : struct ErrorInfoBase {
     115              :     int32_t  deviceId;
     116              :     uint8_t  dieId;
     117              :     uint8_t  missionId;
     118              :     uint16_t currentInsId;
     119              :     uint16_t status;
     120              : };
     121              : 
     122              : union LoopXm {
     123              :     uint64_t value;
     124              :     struct {
     125              :         uint64_t loopCnt : 13;
     126              :         uint64_t gsaStride : 32;
     127              :         uint64_t loopCtxId : 8;
     128              :         uint64_t reserved : 11;
     129              :     };
     130              : };
     131              : 
     132              : struct CcuLoopContext {
     133              :     union {
     134              :         uint16_t value;
     135              :         uint16_t timestamp;
     136              :     } part0;
     137              : 
     138              :     union {
     139              :         uint16_t value;
     140              :         uint16_t timestamp;
     141              :     } part1;
     142              : 
     143              :     union {
     144              :         uint16_t value;
     145              :         struct {
     146              :             uint16_t timestamp : 4;
     147              :             uint16_t ckeOffset : 10;
     148              :             uint16_t msOffset : 2;
     149              :         };
     150              :     } part2;
     151              : 
     152              :     union {
     153              :         uint16_t value;
     154              :         struct {
     155              :             uint16_t msOffset : 9;
     156              :             uint16_t addrOffset : 7;
     157              :         };
     158              :     } part3;
     159              : 
     160              :     union {
     161              :         uint16_t value;
     162              :         uint16_t addrOffset;
     163              :     } part4;
     164              : 
     165              :     union {
     166              :         uint16_t value;
     167              :         struct {
     168              :             uint16_t addrOffset : 9;
     169              :             uint16_t ckBit : 7;
     170              :         };
     171              :     } part5;
     172              : 
     173              :     union {
     174              :         uint16_t value;
     175              :         uint16_t ckBit;
     176              :     } part6;
     177              : 
     178              :     union {
     179              :         uint16_t value;
     180              :         struct {
     181              :             uint16_t ckBit : 9;
     182              :             uint16_t perfMode : 1;
     183              :             uint16_t waitLoopCkbitValue : 6;
     184              :         };
     185              :     } part7;
     186              : 
     187              :     union {
     188              :         uint16_t value;
     189              :         uint16_t waitLoopCkbitValue;
     190              :     } part8;
     191              : 
     192              :     union {
     193              :         uint16_t value;
     194              :         struct {
     195              :             uint16_t waitLoopCkbitValue : 10;
     196              :             uint16_t currentIns : 6;    // Current_ins [5:0]
     197              :         };
     198              :     } part9;
     199              : 
     200              :     union {
     201              :         uint16_t value;
     202              :         struct {
     203              :             uint16_t currentIns : 10;   // Current_ins [15:6]
     204              :             uint16_t addrStride : 6;    // Addr_stride [5:0]
     205              :         };
     206              :     } part10;
     207              : 
     208              :     union {
     209              :         uint16_t value;
     210              :         uint16_t addrStride;            // Addr_stride [21:6]
     211              :     } part11;
     212              : 
     213              :     union {
     214              :         uint16_t value;
     215              :         struct {
     216              :             uint16_t addrStride : 10;   // Addr_stride [31:22]
     217              :             uint16_t denyCnt : 6;
     218              :         };
     219              :     } part12;
     220              : 
     221              :     union {
     222              :         uint16_t value;
     223              :         struct {
     224              :             uint16_t denyCnt : 4;
     225              :             uint16_t currentCnt : 12;   // Current_cnt [11:0]
     226              :         };
     227              :     } part13;
     228              : 
     229              :     union {
     230              :         uint16_t value;
     231              :         struct {
     232              :             uint16_t currentCnt : 1;    // Current_cnt [12]
     233              :             uint16_t totalCnt : 13;
     234              :             uint16_t endIns : 2;
     235              :         };
     236              :     } part14;
     237              : 
     238              :     union {
     239              :         uint16_t value;
     240              :         struct {
     241              :             uint16_t endIns : 14;
     242              :             uint16_t startIns : 2;
     243              :         };
     244              :     } part15;
     245              : 
     246              :     union {
     247              :         uint16_t value;
     248              :         struct {
     249              :             uint16_t startIns : 14;
     250              :             uint16_t missionId : 2;
     251              :         };
     252              :     } part16;
     253              : 
     254              :     union {
     255              :         uint16_t value;
     256              :         struct {
     257              :             uint16_t missionId : 2;
     258              :             uint16_t reserved : 14;
     259              :         };
     260              :     } part17;
     261              : 
     262              :     uint16_t reserved[14]; // part 18-31
     263              : 
     264            1 :     uint16_t GetCurrentIns() const
     265              :     {
     266            1 :         return (part10.currentIns << 6) | (part9.currentIns);   // part10.currentIns为[15:6]位
     267              :     }
     268              : 
     269            2 :     uint16_t GetCurrentCnt() const
     270              :     {
     271            2 :         return (part14.currentCnt << 12) | (part13.currentCnt); // part14.currentCnt为第[12]位
     272              :     }
     273              : 
     274            2 :     uint32_t GetAddrStride() const
     275              :     {
     276            2 :         const uint32_t low = static_cast<uint32_t>(part10.addrStride);
     277            2 :         const uint32_t mid = static_cast<uint32_t>(part11.addrStride) << 6;     // part11.addrStride为[21:6]位
     278            2 :         const uint32_t high = static_cast<uint32_t>(part12.addrStride) << 22;   // part12.addrStride为[31:22]位
     279            2 :         return high | mid | low;
     280              :     }
     281              : };
     282              : 
     283              : struct CcuMissionContext {
     284              :     union {
     285              :         uint16_t value;
     286              :         uint16_t taskId;
     287              :     } part0;
     288              : 
     289              :     union {
     290              :         uint16_t value;
     291              :         uint16_t streamId;
     292              :     } part1;
     293              : 
     294              :     union {
     295              :         uint16_t value;
     296              :         struct {
     297              :             uint16_t taskKill : 1;
     298              :             uint16_t dieId : 2;
     299              :             uint16_t status : 13; // Status [12:0]
     300              :         };
     301              :     } part2;
     302              : 
     303              :     union {
     304              :         uint16_t value;
     305              :         struct {
     306              :             uint16_t status : 3; // Status [15:13]
     307              :             uint16_t counter : 8;
     308              :             uint16_t denyCnt : 5;
     309              :         };
     310              :     } part3;
     311              : 
     312              :     union {
     313              :         uint16_t value;
     314              :         struct {
     315              :             uint16_t denyCnt : 5;
     316              :             uint16_t currentIns : 11; // Current Ins [10:0]
     317              :         };
     318              :     } part4;
     319              : 
     320              :     union {
     321              :         uint16_t value;
     322              :         struct {
     323              :             uint16_t currentIns : 5; // Current Ins [15:11]
     324              :             uint16_t endIns : 11;
     325              :         };
     326              :     } part5;
     327              : 
     328              :     union {
     329              :         uint16_t value;
     330              :         struct {
     331              :             uint16_t endIns : 5;
     332              :             uint16_t startIns : 11;
     333              :         };
     334              :     } part6;
     335              : 
     336              :     union {
     337              :         uint16_t value;
     338              :         struct {
     339              :             uint16_t startIns : 5;
     340              :             uint16_t profileEn : 1;
     341              :             uint16_t missionVld : 1;
     342              :             uint16_t reserved : 9;
     343              :         };
     344              :     } part7;
     345              : 
     346              :     uint16_t reserved[24]; // part 8-31
     347              : 
     348            1 :     uint16_t GetStatus() const
     349              :     {
     350            1 :         return (part3.status << 13) | (part2.status);   // part3.status为[15:13]位
     351              :     }
     352              : 
     353            2 :     uint16_t GetCurrentIns() const
     354              :     {
     355            2 :         return (part5.currentIns << 11) | (part4.currentIns);   // part5.currentIns为[15:11]位
     356              :     }
     357              : 
     358            2 :     uint16_t GetStartIns() const
     359              :     {
     360            2 :         return (part7.startIns << 11) | (part6.startIns);    // part7.startIns[15:11]位
     361              :     }
     362              : 
     363            2 :     uint16_t GetEndIns() const
     364              :     {
     365            2 :         return (part6.endIns << 11) | (part5.endIns);     // part6.endIns[15:11]位
     366              :     }
     367              : };
     368              : 
     369              : union LoopGroupXn {
     370              :     uint64_t value;
     371              :     struct {
     372              :         uint64_t reservedLow : 41;
     373              :         uint64_t loopInsCnt : 7;
     374              :         uint64_t expandOffset : 7;
     375              :         uint64_t expandCnt : 7;
     376              :         uint64_t reservedHigh : 2;
     377              :     };
     378              : };
     379              : 
     380              : }; // namespace hcomm
     381              : 
     382              : #endif // CCU_ERROR_INFO_V1_H
        

Generated by: LCOV version 2.0-1