LCOV - code coverage report
Current view: top level - aicpu_schedule/common/ts_to_aicpu_msg_adapter - ts_msg_adapter.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 87.1 % 31 27
Test Date: 2026-08-12 11:05:02 Functions: 100.0 % 5 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              : #include "ts_msg_adapter.h"
      11              : #include "aicpusd_message_queue.h"
      12              : 
      13              : namespace AicpuSchedule {
      14           49 : TsMsgAdapter::TsMsgAdapter(
      15           49 :     const uint32_t pid, const uint8_t cmdType, const uint8_t vfId, const uint8_t tid, const uint8_t tsId)
      16           49 :     : pid_(pid), cmdType_(cmdType), vfId_(vfId), tid_(tid), tsId_(tsId)
      17           49 : {}
      18              : 
      19           11 : TsMsgAdapter::TsMsgAdapter() : pid_(0U), cmdType_(0U), vfId_(0U), tid_(0U), tsId_(0U) {}
      20              : 
      21            9 : int32_t TsMsgAdapter::ResponseToTs(TsAicpuSqe& aicpuSqe, uint32_t handleId, uint32_t devId, uint32_t tsId) const
      22              : {
      23            9 :     aicpusd_info("Response start: payload=sqe.");
      24            9 :     const auto ret = tsDevSendMsgAsync(
      25              :         devId, static_cast<uint32_t>(tsId), PtrToPtr<TsAicpuSqe, char_t>(&aicpuSqe),
      26              :         static_cast<uint32_t>(sizeof(TsAicpuSqe)), handleId);
      27            9 :     AICPUSD_CHECK(
      28              :         (ret == DRV_ERROR_NONE), AICPU_SCHEDULE_ERROR_INNER_ERROR, "Response send failed: api=tsDevSendMsgAsync ret=%d",
      29              :         ret);
      30            9 :     if (FeatureCtrl::GetAicpuSchedMode() == SCHED_MODE_MSGQ) {
      31            9 :         MessageQueue::SendResponse(0U, 0U);
      32              :     }
      33            9 :     aicpusd_info("Response finish: payload=sqe.");
      34            9 :     return AICPU_SCHEDULE_OK;
      35              : }
      36              : 
      37           11 : int32_t TsMsgAdapter::ResponseToTs(TsAicpuMsgInfo& aicpuMsgInfo, uint32_t handleId, uint32_t devId, uint32_t tsId) const
      38              : {
      39           11 :     aicpusd_info("Response start: payload=msg_info.");
      40           11 :     const auto ret = tsDevSendMsgAsync(
      41              :         devId, static_cast<uint32_t>(tsId), PtrToPtr<TsAicpuMsgInfo, char_t>(&aicpuMsgInfo),
      42              :         static_cast<uint32_t>(sizeof(TsAicpuMsgInfo)), handleId);
      43           11 :     AICPUSD_CHECK(
      44              :         (ret == DRV_ERROR_NONE), AICPU_SCHEDULE_ERROR_INNER_ERROR, "Response send failed: api=tsDevSendMsgAsync ret=%d",
      45              :         ret);
      46           11 :     if (FeatureCtrl::GetAicpuSchedMode() == SCHED_MODE_MSGQ) {
      47           11 :         MessageQueue::SendResponse(0U, 0U);
      48              :     }
      49           11 :     aicpusd_info("Response finish: payload=msg_info.");
      50           11 :     return AICPU_SCHEDULE_OK;
      51              : }
      52              : 
      53            4 : int32_t TsMsgAdapter::ResponseToTs(
      54              :     hwts_response_t& hwtsResp, uint32_t devId, EVENT_ID eventId, uint32_t subeventId) const
      55              : {
      56            4 :     aicpusd_info("Response start: payload=hwts_response.");
      57            4 :     if (FeatureCtrl::GetAicpuSchedMode() == SCHED_MODE_MSGQ) {
      58            4 :         MessageQueue::SendResponse(hwtsResp.result, hwtsResp.status);
      59            4 :         aicpusd_info(
      60              :             "Response finish: payload=hwts_response, result[%u], status[%u].", hwtsResp.result, hwtsResp.status);
      61            4 :         return AICPU_SCHEDULE_OK;
      62              :     }
      63            0 :     const drvError_t ret = halEschedAckEvent(
      64              :         devId, eventId, subeventId, PtrToPtr<hwts_response_t, char_t>(&hwtsResp),
      65              :         static_cast<uint32_t>(sizeof(hwts_response_t)));
      66            0 :     AICPUSD_CHECK(
      67              :         (ret == DRV_ERROR_NONE), AICPU_SCHEDULE_ERROR_INNER_ERROR, "Response send failed: api=halEschedAckEvent ret=%d",
      68              :         ret);
      69            0 :     aicpusd_info("Response finish: payload=hwts_response.");
      70            0 :     return AICPU_SCHEDULE_OK;
      71              : }
      72              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1