LCOV - code coverage report
Current view: top level - aicpu_cust_schedule/common - aicpusd_sqe_adapter.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 1 1

            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 AICPUSD_SQE_ADAPTER_H
      11              : #define AICPUSD_SQE_ADAPTER_H
      12              : 
      13              : #include <map>
      14              : #include "aicpusd_common.h"
      15              : #include "aicpusd_drv_manager.h"
      16              : #include "type_def.h"
      17              : #include "ts_api.h"
      18              : 
      19              : namespace AicpuSchedule {
      20              : class AicpuSqeAdapter {
      21              : public:
      22              :     static constexpr uint16_t INVALID_VALUE16 = 0xFFFF;
      23              :     static constexpr uint32_t INVALID_VALUE32 = 0xFFFFFFFF;
      24              :     static constexpr uint8_t STARS_DATADUMP_LOAD_INFO = 8;
      25              :     static constexpr uint8_t VERSION_0 = 0;
      26              :     static constexpr uint8_t VERSION_1 = 1;
      27              : 
      28              :     struct AicpuDataDumpInfoLoad {
      29              :         volatile uint64_t dumpinfoPtr;
      30              :         volatile uint32_t length;
      31              :         volatile uint16_t stream_id;
      32              :         volatile uint32_t task_id;
      33              :     };
      34              : 
      35              :     struct AicpuMsgVersionInfo {
      36              :         volatile uint16_t magic_num;
      37              :         volatile uint16_t version;
      38              :     };
      39              : 
      40              :     struct AicpuOpMappingDumpTaskInfo {
      41              :         AicpuOpMappingDumpTaskInfo(uint32_t protoTaskId, uint32_t protoStreamId, uint32_t taskId, uint32_t streamId)
      42              :             : proto_info_task_id(protoTaskId), proto_info_stream_id(protoStreamId), task_id(taskId), stream_id(streamId)
      43              :         {}
      44              :         volatile uint32_t proto_info_task_id;
      45              :         volatile uint32_t proto_info_stream_id;
      46              :         volatile uint32_t task_id;
      47              :         volatile uint32_t stream_id;
      48              :     };
      49              : 
      50              :     struct AicpuDumpTaskInfo {
      51              :         volatile uint32_t task_id;
      52              :         volatile uint32_t stream_id;
      53              :         volatile uint32_t context_id;
      54              :         volatile uint32_t thread_id;
      55              :     };
      56              : 
      57              :     AicpuSqeAdapter(const TsAicpuSqe &sqe, const int16_t version);
      58              : 
      59              :     AicpuSqeAdapter(const TsAicpuMsgInfo &msgInfo, const int16_t version);
      60              : 
      61              :     AicpuSqeAdapter(const int16_t version);
      62              : 
      63              :     AicpuSqeAdapter(const AicpuSqeAdapter &) = delete;
      64              : 
      65              :     AicpuSqeAdapter(AicpuSqeAdapter &&) = delete;
      66              : 
      67              :     AicpuSqeAdapter &operator=(const AicpuSqeAdapter &) = delete;
      68              : 
      69              :     AicpuSqeAdapter &operator=(AicpuSqeAdapter &&) = delete;
      70              : 
      71           13 :     ~AicpuSqeAdapter() = default;
      72              : 
      73              :     void InitAdapterFuncMap();
      74              : 
      75              :     uint8_t GetCmdType() const;
      76              : 
      77              :     bool IsAdapterInvalidParameter() const;
      78              : 
      79              :     bool IsOpMappingDumpTaskInfoVaild(AicpuOpMappingDumpTaskInfo &info);
      80              : 
      81              :     void GetAicpuDataDumpInfoLoad(AicpuDataDumpInfoLoad &info);
      82              : 
      83              :     int32_t AicpuDataDumpLoadResponseToTs(const int32_t ret);
      84              : 
      85              :     void GetAicpuMsgVersionInfo(AicpuMsgVersionInfo &info);
      86              : 
      87              :     int32_t AicpuMsgVersionResponseToTs(const int32_t ret);
      88              : 
      89              : private:
      90              :     void GetAicpuDataDumpInfoLoadV0(AicpuDataDumpInfoLoad &info);
      91              : 
      92              :     void GetAicpuDataDumpInfoLoadV1(AicpuDataDumpInfoLoad &info);
      93              : 
      94              :     int32_t AicpuDataDumpLoadResponseToTsV1(const int32_t ret);
      95              : 
      96              :     int32_t AicpuDataDumpLoadResponseToTsV0(const int32_t ret);
      97              : 
      98              :     void GetAicpuDumpTaskInfoV0(AicpuOpMappingDumpTaskInfo &opmappingInfo, AicpuDumpTaskInfo &dumpTaskInfo);
      99              : 
     100              :     void GetAicpuDumpTaskInfoV1(AicpuOpMappingDumpTaskInfo &opmappingInfo, AicpuDumpTaskInfo &dumpTaskInfo);
     101              : 
     102              :     int32_t ResponseToTs(TsAicpuSqe &aicpuSqe, unsigned int handleId, unsigned int devId, unsigned int tsId);
     103              : 
     104              :     int32_t ResponseToTs(TsAicpuMsgInfo &aicpuMsgInfo, unsigned int handleId, unsigned int devId, unsigned int tsId);
     105              : 
     106              :     int32_t ResponseToTs(hwts_response_t &hwtsResp, uint32_t devId, EVENT_ID eventId, uint32_t subeventId);
     107              : 
     108              :     using getRspFunc = int32_t (AicpuSqeAdapter::*)(const int32_t);
     109              : 
     110              :     using getDataDumpLoadInfoFunc = void (AicpuSqeAdapter::*)(AicpuDataDumpInfoLoad &);
     111              : 
     112              :     std::map<uint16_t, getDataDumpLoadInfoFunc> getDataDumpLoadInfoFuncMap_;
     113              : 
     114              :     std::map<uint16_t, getRspFunc> getDataDumpLoadRspFuncMap_;
     115              : 
     116              :     uint32_t pid_ = 0U;
     117              : 
     118              :     uint8_t cmd_type_ = 0U;
     119              : 
     120              :     uint8_t vf_id_ = 0U;
     121              : 
     122              :     uint8_t tid_ = 0U;
     123              : 
     124              :     uint8_t ts_id_ = 0U;
     125              : 
     126              :     TsAicpuSqe sqe_ = { };
     127              : 
     128              :     TsAicpuMsgInfo msg_Info_ = { };
     129              : 
     130              :     uint16_t version_ = 0U;
     131              : 
     132              :     bool invalid_msg_info_ = false;
     133              : 
     134              :     bool invalid_sqe_ = false;
     135              : };
     136              : 
     137              : }  // namespace AicpuSchedule
     138              : #endif
        

Generated by: LCOV version 2.0-1