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.5 % 32 28
Test Date: 2026-07-28 10:54:05 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           11 : {}
      21              : 
      22            9 : int32_t TsMsgAdapter::ResponseToTs(
      23              :     TsAicpuSqe& aicpuSqe, uint32_t handleId, uint32_t devId, uint32_t tsId) const
      24              : {
      25            9 :     aicpusd_info("Response start: payload=sqe.");
      26            9 :     const auto ret = tsDevSendMsgAsync(
      27              :         devId, static_cast<uint32_t>(tsId), PtrToPtr<TsAicpuSqe, char_t>(&aicpuSqe),
      28              :         static_cast<uint32_t>(sizeof(TsAicpuSqe)), handleId);
      29            9 :     AICPUSD_CHECK(
      30              :         (ret == DRV_ERROR_NONE), AICPU_SCHEDULE_ERROR_INNER_ERROR,
      31              :         "Response send failed: api=tsDevSendMsgAsync ret=%d",
      32              :         ret);
      33            9 :     if (FeatureCtrl::GetAicpuSchedMode() == SCHED_MODE_MSGQ) {
      34            9 :         MessageQueue::SendResponse(0U, 0U);
      35              :     }
      36            9 :     aicpusd_info("Response finish: payload=sqe.");
      37            9 :     return AICPU_SCHEDULE_OK;
      38              : }
      39              : 
      40           11 : int32_t TsMsgAdapter::ResponseToTs(
      41              :     TsAicpuMsgInfo& aicpuMsgInfo, uint32_t handleId, uint32_t devId, uint32_t tsId) const
      42              : {
      43           11 :     aicpusd_info("Response start: payload=msg_info.");
      44           11 :     const auto ret = tsDevSendMsgAsync(
      45              :         devId, static_cast<uint32_t>(tsId), PtrToPtr<TsAicpuMsgInfo, char_t>(&aicpuMsgInfo),
      46              :         static_cast<uint32_t>(sizeof(TsAicpuMsgInfo)), handleId);
      47           11 :     AICPUSD_CHECK(
      48              :         (ret == DRV_ERROR_NONE), AICPU_SCHEDULE_ERROR_INNER_ERROR,
      49              :         "Response send failed: api=tsDevSendMsgAsync ret=%d",
      50              :         ret);
      51           11 :     if (FeatureCtrl::GetAicpuSchedMode() == SCHED_MODE_MSGQ) {
      52           11 :         MessageQueue::SendResponse(0U, 0U);
      53              :     }
      54           11 :     aicpusd_info("Response finish: payload=msg_info.");
      55           11 :     return AICPU_SCHEDULE_OK;
      56              : }
      57              : 
      58            4 : int32_t TsMsgAdapter::ResponseToTs(
      59              :     hwts_response_t& hwtsResp, uint32_t devId, EVENT_ID eventId, uint32_t subeventId) const
      60              : {
      61            4 :     aicpusd_info("Response start: payload=hwts_response.");
      62            4 :     if (FeatureCtrl::GetAicpuSchedMode() == SCHED_MODE_MSGQ) {
      63            4 :         MessageQueue::SendResponse(hwtsResp.result, hwtsResp.status);
      64            4 :         aicpusd_info("Response finish: payload=hwts_response, result[%u], status[%u].", hwtsResp.result, hwtsResp.status);
      65            4 :         return AICPU_SCHEDULE_OK;
      66              :     }
      67            0 :     const drvError_t ret = halEschedAckEvent(
      68              :         devId, eventId, subeventId, PtrToPtr<hwts_response_t, char_t>(&hwtsResp),
      69              :         static_cast<uint32_t>(sizeof(hwts_response_t)));
      70            0 :     AICPUSD_CHECK(
      71              :         (ret == DRV_ERROR_NONE), AICPU_SCHEDULE_ERROR_INNER_ERROR,
      72              :         "Response send failed: api=halEschedAckEvent ret=%d",
      73              :         ret);
      74            0 :     aicpusd_info("Response finish: payload=hwts_response.");
      75            0 :     return AICPU_SCHEDULE_OK;
      76              : }
      77              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1