LCOV - code coverage report
Current view: top level - acl/acl_tdt_queue - queue.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 65.8 % 395 260
Test Date: 2026-08-06 15:29:52 Functions: 69.2 % 39 27

            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              : #include "queue.h"
      12              : #include <map>
      13              : #include <sstream>
      14              : #include "common/log_inner.h"
      15              : #include "toolchain/prof_api_reg.h"
      16              : #include "common/resource_statistics.h"
      17              : #include "queue_process.h"
      18              : #include "queue_manager.h"
      19              : #include "runtime/rt_mem_queue.h"
      20              : #include "utils/data_type_utils.h"
      21              : 
      22              : namespace {
      23           14 :     aclError CopyParam(const void *const src, const size_t srcLen, void *const dst, const size_t dstLen,
      24              :         size_t *const realCopySize = nullptr)
      25              :     {
      26           14 :         ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT_AND_FUNC_DESC(src, "Parameter copy");
      27           14 :         ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT_AND_FUNC_DESC(dst, "Parameter copy");
      28           14 :         ACL_CHECK_INVALID_PARAM_WITH_REASON_AND_FUNC_DESC(srcLen > dstLen, srcLen, "srcLen must not be larger than dstLen", "Parameter copy");
      29           14 :         const auto ret = memcpy_s(dst, dstLen, src, srcLen);
      30           14 :         if (ret != EOK) {
      31            0 :             const std::string retVal = std::to_string(ret);
      32            0 :             std::stringstream ss;
      33            0 :             ss << std::hex << "src=0x" << reinterpret_cast<uintptr_t>(src)
      34            0 :                 << ", dest=0x" << reinterpret_cast<uintptr_t>(dst)
      35            0 :                 << std::dec << ", dest_max=" << dstLen << ", count=" << srcLen << ".";
      36            0 :             const std::string extendInfo = ss.str();
      37            0 :             acl::AclErrorLogManager::ReportInputError(acl::STANDARD_FUNC_FAILED_MSG,
      38            0 :                 std::vector<const char *>({"func1", "func2", "ret_code", "reason", "extend_info"}),
      39            0 :                 std::vector<const char *>({"Parameter copy", "memcpy_s", retVal.c_str(),
      40            0 :                     strerror(ret), extendInfo.c_str()}));
      41            0 :             ACL_LOG_ERROR("[Call][MemCpy]call memcpy failed, result=%d, srcLen=%zu, dstLen=%zu",
      42              :                 ret, srcLen, dstLen);
      43            0 :             return ACL_ERROR_FAILURE;
      44            0 :         }
      45           14 :         if (realCopySize != nullptr) {
      46            5 :             *realCopySize = srcLen;
      47              :         }
      48           14 :         return ACL_SUCCESS;
      49              :     }
      50              : }
      51              : 
      52              : namespace acl {
      53           10 :     aclError CheckQueueRouteQueryInfo(const acltdtQueueRouteQueryInfo *const queryInfo)
      54              :     {
      55           10 :         if (!queryInfo->isConfigMode) {
      56            2 :             ACL_LOG_ERROR("mode must be set in acltdtQueueRouteQueryInfo, please use acltdtSetQueueRouteQueryInfo");
      57            2 :             acl::AclErrorLogManager::ReportInputError(acl::INVALID_PARAM_REASON_MSG,
      58            4 :                         std::vector<const char *>({"func", "value", "param", "reason"}),
      59            2 :                         std::vector<const char *>({"Checking the validity of the queue route query operation", "false", "queryInfo->isConfigMode",
      60              :                                 "Currently, the query is configured based on queue. The queue must be configured through "
      61            2 :                                 "acltdtSetQueueRouteQueryInfo"}));
      62            2 :             return ACL_ERROR_INVALID_PARAM;
      63              :         }
      64            8 :         switch (queryInfo->mode) {
      65            3 :             case ACL_TDT_QUEUE_ROUTE_QUERY_SRC: {
      66            3 :                 if (!queryInfo->isConfigSrc) {
      67            2 :                     ACL_LOG_ERROR("src qid must be set in acltdtQueueRouteQueryInfo, "
      68              :                                 "please use acltdtSetQueueRouteQueryInfo");
      69            2 :                     acl::AclErrorLogManager::ReportInputError(acl::INVALID_PARAM_REASON_MSG,
      70            4 :                         std::vector<const char *>({"func", "value", "param", "reason"}),
      71            2 :                         std::vector<const char *>({"Checking the validity of the queue route query operation", "false", "queryInfo->isConfigSrc",
      72              :                                 "Currently, the query is configured based on the source queue. The source queue must be configured through "
      73            2 :                                 "acltdtSetQueueRouteQueryInfo"}));
      74            2 :                     return ACL_ERROR_INVALID_PARAM;
      75              :                 }
      76            1 :                 break;
      77              :             }
      78            2 :             case ACL_TDT_QUEUE_ROUTE_QUERY_DST: {
      79            2 :                 if (!queryInfo->isConfigDst) {
      80            1 :                     ACL_LOG_ERROR("dst qid must be set in acltdtQueueRouteQueryInfo, "
      81              :                                 "please use acltdtSetQueueRouteQueryInfo");
      82            1 :                     acl::AclErrorLogManager::ReportInputError(acl::INVALID_PARAM_REASON_MSG,
      83            2 :                         std::vector<const char *>({"func", "value", "param", "reason"}),
      84            1 :                         std::vector<const char *>({"Checking the validity of the queue route query operation", "false", "queryInfo->isConfigDst",
      85              :                             "Currently, the query is configured based on the destination queue. The destination queue must be configured through "
      86            1 :                             "acltdtSetQueueRouteQueryInfo"}));
      87            1 :                     return ACL_ERROR_INVALID_PARAM;
      88              :                 }
      89            1 :                 break;
      90              :             }
      91            3 :             case ACL_TDT_QUEUE_ROUTE_QUERY_SRC_AND_DST: {
      92            3 :                 if ((!queryInfo->isConfigSrc) || (!queryInfo->isConfigDst)) {
      93            1 :                     ACL_LOG_ERROR("src and dst qid must be set in acltdtQueueRouteQueryInfo, "
      94              :                                 "please use acltdtSetQueueRouteQueryInfo");
      95            1 :                     const char_t *argList[] = {"func", "value", "param", "reason"};
      96            1 :                     std::string value = std::to_string(queryInfo->isConfigSrc) + '/' + std::to_string(queryInfo->isConfigDst);
      97            1 :                     const char_t *argVal[] = {"Checking the validity of the queue route query operation", value.c_str(), "queryInfo->isConfigSrc/isConfigDst", 
      98              :                         "Currently, the query is configured based on the source queue and the destination queue. The source queue and destination queue must be configured through "
      99            1 :                         "acltdtSetQueueRouteQueryInfo"};
     100            1 :                     acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_REASON_MSG, argList, argVal, 4UL);
     101            1 :                     return ACL_ERROR_INVALID_PARAM;
     102            1 :                 }
     103            2 :                 break;
     104              :             }
     105            0 :             case ACL_TDT_QUEUE_ROUTE_QUERY_ABNORMAL: {
     106            0 :                 break;
     107              :             }
     108            0 :             default: {
     109            0 :                 ACL_LOG_ERROR("[Check][Type]unknown mode %d.", queryInfo->mode);
     110            0 :                 const char_t *argList[] = {"func", "value", "param", "expect"};
     111            0 :                 const char_t *argVal[] = {"Checking the validity of the queue route query operation", acl::GetQueueRouteQueryModeDesc(static_cast<acltdtQueueRouteQueryMode>(queryInfo->mode)),
     112            0 :                         "queryInfo->mode", "ACL_TDT_QUEUE_ROUTE_QUERY_SRC or ACL_TDT_QUEUE_ROUTE_QUERY_DST or ACL_TDT_QUEUE_ROUTE_QUERY_SRC_AND_DST or ACL_TDT_QUEUE_ROUTE_QUERY_ABNORMAL"};
     113            0 :                 acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_VALUE_MSG, argList, argVal, 4UL);
     114            0 :                 return ACL_ERROR_INVALID_PARAM;
     115              :             }
     116              :         }
     117            4 :         return ACL_SUCCESS;
     118              :     }
     119              : }
     120              : 
     121            3 : aclError acltdtCreateQueue(const acltdtQueueAttr *attr, uint32_t *qid)
     122              : {
     123            3 :     ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ID);
     124            3 :     auto& qManager = acl::QueueManager::GetInstance();
     125            3 :     const auto processor = qManager.GetQueueProcessor();
     126            3 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     127            3 :     ACL_REQUIRES_OK(processor->acltdtCreateQueue(attr, qid));
     128            2 :     ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ID);
     129            2 :     return ACL_SUCCESS;
     130              : }
     131              : 
     132            1 : aclError acltdtDestroyQueue(uint32_t qid)
     133              : {
     134            1 :     ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ID);
     135            1 :     auto& qManager = acl::QueueManager::GetInstance();
     136            1 :     const auto processor = qManager.GetQueueProcessor();
     137            1 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     138            1 :     ACL_REQUIRES_OK(processor->acltdtDestroyQueue(qid));
     139            1 :     ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ID);
     140            1 :     return ACL_SUCCESS;
     141              : }
     142              : 
     143            0 : aclError acltdtEnqueue(uint32_t qid, acltdtBuf buf, int32_t timeout)
     144              : {
     145            0 :     ACL_PROFILING_REG(acl::AclTdtQueueProfType::AcltdtEnqueue);
     146            0 :     auto& qManager = acl::QueueManager::GetInstance();
     147            0 :     const auto processor = qManager.GetQueueProcessor();
     148            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     149            0 :     ACL_REQUIRES_OK(processor->acltdtEnqueue(qid, buf, timeout));
     150            0 :     return ACL_SUCCESS;
     151            0 : }
     152              : 
     153            0 : aclError acltdtDequeue(uint32_t qid, acltdtBuf *buf, int32_t timeout)
     154              : {
     155            0 :     ACL_PROFILING_REG(acl::AclTdtQueueProfType::AcltdtDequeue);
     156            0 :     auto& qManager = acl::QueueManager::GetInstance();
     157            0 :     const auto processor = qManager.GetQueueProcessor();
     158            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     159            0 :     ACL_REQUIRES_OK(processor->acltdtDequeue(qid, buf, timeout));
     160            0 :     return ACL_SUCCESS;
     161            0 : }
     162              : 
     163            1 : aclError acltdtEnqueueData(uint32_t qid, const void *data, size_t dataSize,
     164              :     const void *userData, size_t userDataSize, int32_t timeout, uint32_t rsv)
     165              : {
     166            1 :     ACL_PROFILING_REG(acl::AclTdtQueueProfType::AcltdtEnqueueData);
     167            1 :     auto& qManager = acl::QueueManager::GetInstance();
     168            1 :     const auto processor = qManager.GetQueueProcessor();
     169            1 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     170            1 :     ACL_REQUIRES_OK(processor->acltdtEnqueueData(qid, data, dataSize, userData, userDataSize, timeout, rsv));
     171            1 :     return ACL_SUCCESS;
     172            1 : }
     173              : 
     174            3 : aclError acltdtDequeueData(uint32_t qid, void *data, size_t dataSize, size_t *retDataSize,
     175              :     void *userData, size_t userDataSize, int32_t timeout)
     176              : {
     177            3 :     ACL_PROFILING_REG(acl::AclTdtQueueProfType::AcltdtDequeueData);
     178            3 :     auto& qManager = acl::QueueManager::GetInstance();
     179            3 :     const auto processor = qManager.GetQueueProcessor();
     180            3 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     181            3 :     ACL_REQUIRES_OK(processor->acltdtDequeueData(qid, data, dataSize, retDataSize, userData, userDataSize, timeout));
     182            1 :     return ACL_SUCCESS;
     183            3 : }
     184              : 
     185            1 : aclError acltdtGrantQueue(uint32_t qid, int32_t pid, uint32_t permission, int32_t timeout)
     186              : {
     187            1 :     auto& qManager = acl::QueueManager::GetInstance();
     188            1 :     const auto processor = qManager.GetQueueProcessor();
     189            1 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     190            1 :     ACL_REQUIRES_OK(processor->acltdtGrantQueue(qid, pid, permission, timeout));
     191            0 :     return ACL_SUCCESS;
     192              : }
     193              : 
     194            1 : aclError acltdtAttachQueue(uint32_t qid, int32_t timeout, uint32_t *permission)
     195              : {
     196            1 :     auto& qManager = acl::QueueManager::GetInstance();
     197            1 :     const auto processor = qManager.GetQueueProcessor();
     198            1 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     199            1 :     ACL_REQUIRES_OK(processor->acltdtAttachQueue(qid, timeout, permission));
     200            0 :     return ACL_SUCCESS;
     201              : }
     202              : 
     203            2 : aclError acltdtBindQueueRoutes(acltdtQueueRouteList *qRouteList)
     204              : {
     205            2 :     auto& qManager = acl::QueueManager::GetInstance();
     206            2 :     const auto processor = qManager.GetQueueProcessor();
     207            2 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     208            2 :     ACL_REQUIRES_OK(processor->acltdtBindQueueRoutes(qRouteList));
     209            1 :     return ACL_SUCCESS;
     210              : }
     211              : 
     212            4 : aclError acltdtUnbindQueueRoutes(acltdtQueueRouteList *qRouteList)
     213              : {
     214            4 :     auto& qManager = acl::QueueManager::GetInstance();
     215            4 :     const auto processor = qManager.GetQueueProcessor();
     216            4 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     217            4 :     ACL_REQUIRES_OK(processor->acltdtUnbindQueueRoutes(qRouteList));
     218            4 :     return ACL_SUCCESS;
     219              : }
     220              : 
     221            2 : aclError acltdtQueryQueueRoutes(const acltdtQueueRouteQueryInfo *queryInfo, acltdtQueueRouteList *qRouteList)
     222              : {
     223            2 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(qRouteList);
     224            2 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(queryInfo);
     225            2 :     qRouteList->routeList.clear();
     226            2 :     ACL_REQUIRES_OK(acl::CheckQueueRouteQueryInfo(queryInfo));
     227            1 :     auto& qManager = acl::QueueManager::GetInstance();
     228            1 :     const auto processor = qManager.GetQueueProcessor();
     229            1 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     230            1 :     ACL_REQUIRES_OK(processor->acltdtQueryQueueRoutes(queryInfo, qRouteList));
     231            1 :     return ACL_SUCCESS;
     232              : }
     233              : 
     234            1 : aclError acltdtAllocBuf(size_t size, uint32_t type, acltdtBuf *buf)
     235              : {
     236            1 :     if ((type != static_cast<uint32_t>(ACL_TDT_NORMAL_MEM)) &&
     237              :         (type != static_cast<uint32_t>(ACL_TDT_DVPP_MEM))) {
     238            1 :         const char_t *argList[] = {"func", "value", "param", "expect"};
     239            1 :             std::string expect = "[" + std::to_string(ACL_TDT_NORMAL_MEM) + ", " + std::to_string(ACL_TDT_DVPP_MEM) + "]";
     240            1 :             const std::string typeVal = acl::GetAllocBufTypeDesc(static_cast<acltdtAllocBufType>(type));
     241            1 :             const char_t *argVal[] = {__func__, typeVal.c_str(), "type", expect.c_str()};
     242            1 :             acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_VALUE_MSG, argList, argVal, 4UL);
     243            1 :         ACL_LOG_ERROR("[Check][Param]param type must be equal to 0 or 1 currently");
     244            1 :         return ACL_ERROR_INVALID_PARAM;
     245            1 :     }
     246            0 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(buf);
     247            0 :     ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_MBUF);
     248            0 :     auto& qManager = acl::QueueManager::GetInstance();
     249            0 :     const auto processor = qManager.GetQueueProcessor();
     250            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     251            0 :     ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_MBUF);
     252            0 :     return processor->acltdtAllocBuf(size, type, buf);
     253              : }
     254              : 
     255            0 : aclError acltdtFreeBuf(acltdtBuf buf)
     256              : {
     257            0 :     ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_MBUF);
     258            0 :     auto& qManager = acl::QueueManager::GetInstance();
     259            0 :     const auto processor = qManager.GetQueueProcessor();
     260            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     261            0 :     ACL_REQUIRES_OK(processor->acltdtFreeBuf(buf));
     262            0 :     ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_MBUF);
     263            0 :     return ACL_SUCCESS;
     264              : }
     265              : 
     266            0 : aclError acltdtGetBufData(const acltdtBuf buf, void **dataPtr, size_t *size)
     267              : {
     268            0 :     auto& qManager = acl::QueueManager::GetInstance();
     269            0 :     const auto processor = qManager.GetQueueProcessor();
     270            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     271            0 :     ACL_REQUIRES_OK(processor->acltdtGetBufData(buf, dataPtr, size));
     272            0 :     return ACL_SUCCESS;
     273              : }
     274              : 
     275            0 : aclError acltdtSetBufDataLen(acltdtBuf buf, size_t len)
     276              : {
     277            0 :     auto& qManager = acl::QueueManager::GetInstance();
     278            0 :     const auto processor = qManager.GetQueueProcessor();
     279            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     280            0 :     ACL_REQUIRES_OK(processor->acltdtSetBufDataLen(buf, len));
     281            0 :     return ACL_SUCCESS;
     282              : }
     283              : 
     284            0 : aclError acltdtGetBufDataLen(acltdtBuf buf, size_t *len)
     285              : {
     286            0 :     auto& qManager = acl::QueueManager::GetInstance();
     287            0 :     const auto processor = qManager.GetQueueProcessor();
     288            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     289            0 :     ACL_REQUIRES_OK(processor->acltdtGetBufDataLen(buf, len));
     290            0 :     return ACL_SUCCESS;
     291              : }
     292              : 
     293            0 : aclError acltdtAppendBufChain(acltdtBuf headBuf, acltdtBuf buf)
     294              : {
     295            0 :     auto& qManager = acl::QueueManager::GetInstance();
     296            0 :     const auto processor = qManager.GetQueueProcessor();
     297            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     298            0 :     ACL_REQUIRES_OK(processor->acltdtAppendBufChain(headBuf, buf));
     299            0 :     return ACL_SUCCESS;
     300              : }
     301              : 
     302            0 : aclError acltdtGetBufChainNum(acltdtBuf headBuf, uint32_t *num)
     303              : {
     304            0 :     auto& qManager = acl::QueueManager::GetInstance();
     305            0 :     const auto processor = qManager.GetQueueProcessor();
     306            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     307            0 :     ACL_REQUIRES_OK(processor->acltdtGetBufChainNum(headBuf, num));
     308            0 :     return ACL_SUCCESS;
     309              : }
     310              : 
     311            0 : aclError acltdtGetBufFromChain(acltdtBuf headBuf, uint32_t index, acltdtBuf *buf)
     312              : {
     313            0 :     auto& qManager = acl::QueueManager::GetInstance();
     314            0 :     const auto processor = qManager.GetQueueProcessor();
     315            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     316            0 :     ACL_REQUIRES_OK(processor->acltdtGetBufFromChain(headBuf, index, buf));
     317            0 :     return ACL_SUCCESS;
     318              : }
     319              : 
     320            0 : aclError acltdtGetBufUserData(const acltdtBuf buf, void *dataPtr, size_t size, size_t offset)
     321              : {
     322            0 :     auto& qManager = acl::QueueManager::GetInstance();
     323            0 :     const auto processor = qManager.GetQueueProcessor();
     324            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     325            0 :     ACL_REQUIRES_OK(processor->acltdtGetBufUserData(buf, dataPtr, size, offset));
     326            0 :     return ACL_SUCCESS;
     327              : }
     328              : 
     329            0 : aclError acltdtSetBufUserData(acltdtBuf buf, const void *dataPtr, size_t size, size_t offset)
     330              : {
     331            0 :     auto& qManager = acl::QueueManager::GetInstance();
     332            0 :     const auto processor = qManager.GetQueueProcessor();
     333            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     334            0 :     ACL_REQUIRES_OK(processor->acltdtSetBufUserData(buf, dataPtr, size, offset));
     335            0 :     return ACL_SUCCESS;
     336              : }
     337              : 
     338            0 : aclError acltdtCopyBufRef(const acltdtBuf buf, acltdtBuf *newBuf)
     339              : {
     340            0 :     auto& qManager = acl::QueueManager::GetInstance();
     341            0 :     const auto processor = qManager.GetQueueProcessor();
     342            0 :     ACL_REQUIRES_NOT_NULL_WITH_INNER_REPORT(processor);
     343            0 :     ACL_REQUIRES_OK(processor->acltdtCopyBufRef(buf, newBuf));
     344            0 :     return ACL_SUCCESS;
     345              : }
     346              : 
     347            1 : acltdtQueueAttr* acltdtCreateQueueAttr()
     348              : {
     349            1 :     ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ATTR);
     350            1 :     acltdtQueueAttr *const attr = new(std::nothrow) acltdtQueueAttr();
     351            1 :     ACL_CHECK_MALLOC_RESULT_REPORT_RET(attr, sizeof(acltdtQueueAttr), "new", nullptr);
     352            1 :     acl::QueueProcessor::acltdtSetDefaultQueueAttr(*attr);
     353            1 :     ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ATTR);
     354            1 :     return attr;
     355              : }
     356              : 
     357            1 : aclError acltdtDestroyQueueAttr(const acltdtQueueAttr *attr)
     358              : {
     359            1 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(attr);
     360            1 :     ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ATTR);
     361            1 :     ACL_DELETE_AND_SET_NULL(attr);
     362            1 :     ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ATTR);
     363            1 :     return ACL_SUCCESS;
     364              : }
     365              : 
     366            6 : aclError acltdtSetQueueAttr(acltdtQueueAttr *attr,
     367              :                             acltdtQueueAttrType type,
     368              :                             size_t len,
     369              :                             const void *param)
     370              : {
     371            6 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(attr);
     372            5 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
     373            4 :     switch (type) {
     374            3 :         case ACL_TDT_QUEUE_NAME_PTR: {
     375            3 :                 char_t *tmp = nullptr;
     376            3 :                 ACL_REQUIRES_OK(CopyParam(param, len, static_cast<void *>(&tmp), sizeof(size_t)));
     377            3 :                 ACL_REQUIRES_NOT_NULL(tmp);
     378            3 :                 const size_t tmpLen = strnlen(tmp, static_cast<size_t>(RT_MQ_MAX_NAME_LEN));
     379            3 :                 if ((tmpLen + 1U) > static_cast<size_t>(RT_MQ_MAX_NAME_LEN)) {
     380            1 :                     const std::string tmpLenVal = std::to_string(tmpLen + 1U);
     381            1 :                     const std::string expectVal = "[0, " + std::to_string(RT_MQ_MAX_NAME_LEN) + "]";
     382            1 :                     acl::AclErrorLogManager::ReportInputError(acl::INVALID_VALUE_MSG,
     383            2 :                         std::vector<const char *>({"func", "value", "param", "expect"}),
     384            2 :                         std::vector<const char *>({__func__, tmpLenVal.c_str(), "queue name length", expectVal.c_str()}));
     385            1 :                     return ACL_ERROR_INVALID_PARAM;
     386            1 :                 }
     387            2 :                 return CopyParam(tmp, tmpLen + 1U, static_cast<void *>(attr->name),
     388            2 :                     static_cast<size_t>(RT_MQ_MAX_NAME_LEN));
     389              :             }
     390            1 :         case ACL_TDT_QUEUE_DEPTH_UINT32:
     391            1 :             return CopyParam(param, len, static_cast<void *>(&attr->depth), sizeof(uint32_t));
     392            0 :         default: {
     393            0 :             ACL_LOG_ERROR("[Check][Type]unknown acltdtQueueAttrType %d.", type);
     394            0 :             acl::AclErrorLogManager::ReportInputError(acl::INVALID_VALUE_MSG,
     395            0 :             std::vector<const char *>({"func", "value", "param", "expect"}),
     396            0 :             std::vector<const char *>({__func__, acl::GetQueueAttrTypeDesc(type), "type", "[ACL_TDT_QUEUE_NAME_PTR, ACL_TDT_QUEUE_DEPTH_UINT32]"}));
     397            0 :             return ACL_ERROR_INVALID_PARAM;
     398              :         }
     399              :     }
     400              : }
     401              : 
     402            5 : aclError acltdtGetQueueAttr(const acltdtQueueAttr *attr,
     403              :                             acltdtQueueAttrType type,
     404              :                             size_t len,
     405              :                             size_t *paramRetSize,
     406              :                             void *param)
     407              : {
     408            5 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(attr);
     409            4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
     410            3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(paramRetSize);
     411            2 :     ACL_LOG_INFO("start to get queue attr, type is %d, len is %zu", type, len);
     412            2 :     switch (type) {
     413            1 :         case ACL_TDT_QUEUE_NAME_PTR: {
     414            1 :                 const char_t *tmp = &attr->name[0];
     415            1 :                 return CopyParam(static_cast<const void *>(&tmp), sizeof(size_t), param, len, paramRetSize);
     416              :             }
     417            1 :         case ACL_TDT_QUEUE_DEPTH_UINT32:
     418            1 :             return CopyParam(static_cast<const void *>(&attr->depth), sizeof(uint32_t), param, len, paramRetSize);
     419            0 :         default: {
     420            0 :             ACL_LOG_ERROR("[Check][Type]unknown acltdtQueueAttrType %d.", type);
     421            0 :             acl::AclErrorLogManager::ReportInputError(acl::INVALID_VALUE_MSG,
     422            0 :                 std::vector<const char *>({"func", "value", "param", "expect"}),
     423            0 :                 std::vector<const char *>({__func__, acl::GetQueueAttrTypeDesc(type), "type", "[ACL_TDT_QUEUE_NAME_PTR, ACL_TDT_QUEUE_DEPTH_UINT32]"}));
     424            0 :             return ACL_ERROR_INVALID_PARAM;
     425              :         }
     426              :     }
     427              : }
     428              : 
     429            1 : acltdtQueueRoute* acltdtCreateQueueRoute(uint32_t srcId, uint32_t dstId)
     430              : {
     431            1 :     ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE);
     432            1 :     acltdtQueueRoute *const route = new(std::nothrow) acltdtQueueRoute();
     433            1 :     ACL_CHECK_MALLOC_RESULT_REPORT_RET(route, sizeof(acltdtQueueRoute), "new", nullptr);
     434            1 :     route->srcId = srcId;
     435            1 :     route->dstId = dstId;
     436            1 :     route->status = 0;
     437            1 :     ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE);
     438            1 :     return route;
     439              : }
     440              : 
     441            1 : aclError acltdtDestroyQueueRoute(const acltdtQueueRoute *route)
     442              : {
     443            1 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(route);
     444            1 :     ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE);
     445            1 :     ACL_DELETE_AND_SET_NULL(route);
     446            1 :     ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE);
     447            1 :     return ACL_SUCCESS;
     448              : }
     449              : 
     450            6 : aclError acltdtGetQueueRouteParam(const acltdtQueueRoute *route,
     451              :                                   acltdtQueueRouteParamType type,
     452              :                                   size_t len,
     453              :                                   size_t *paramRetSize,
     454              :                                   void *param)
     455              : {
     456            6 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(route);
     457            5 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
     458            4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(paramRetSize);
     459            3 :     ACL_LOG_INFO("get route type %d, len is %zu", type, len);
     460            3 :     switch (type) {
     461            1 :         case ACL_TDT_QUEUE_ROUTE_SRC_UINT32:
     462            1 :             return CopyParam(static_cast<const void *>(&route->srcId), sizeof(uint32_t), param, len, paramRetSize);
     463            1 :         case ACL_TDT_QUEUE_ROUTE_DST_UINT32:
     464            1 :             return CopyParam(static_cast<const void *>(&route->dstId), sizeof(uint32_t), param, len, paramRetSize);
     465            1 :         case ACL_TDT_QUEUE_ROUTE_STATUS_INT32:
     466            1 :             return CopyParam(static_cast<const void *>(&route->status), sizeof(int32_t), param, len, paramRetSize);
     467            0 :         default: {
     468            0 :             ACL_LOG_ERROR("[Check][Type]unknown acltdtQueueRouteParamType %d.", type);
     469            0 :             acl::AclErrorLogManager::ReportInputError(acl::INVALID_VALUE_MSG,
     470            0 :                 std::vector<const char *>({"func", "value", "param", "expect"}),
     471            0 :                 std::vector<const char *>({__func__, acl::GetQueueRouteParamTypeDesc(type), "type",
     472            0 :                 "[ACL_TDT_QUEUE_ROUTE_SRC_UINT32, ACL_TDT_QUEUE_ROUTE_STATUS_INT32]"}));
     473            0 :             return ACL_ERROR_INVALID_PARAM;
     474              :         }
     475              :     }
     476              : }
     477              : 
     478            1 : acltdtQueueRouteList* acltdtCreateQueueRouteList()
     479              : {
     480            1 :     ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_LIST);
     481            1 :     ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_LIST);
     482            1 :     return new(std::nothrow) acltdtQueueRouteList();
     483              : }
     484              : 
     485            1 : aclError acltdtDestroyQueueRouteList(const acltdtQueueRouteList *routeList)
     486              : {
     487            1 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(routeList);
     488            1 :     ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_LIST);
     489            1 :     ACL_DELETE_AND_SET_NULL(routeList);
     490            1 :     ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_LIST);
     491            1 :     return ACL_SUCCESS;
     492              : }
     493              : 
     494            4 : aclError acltdtAddQueueRoute(acltdtQueueRouteList *routeList, const acltdtQueueRoute *route)
     495              : {
     496            4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(routeList);
     497            3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(route);
     498            2 :     routeList->routeList.emplace_back(*route);
     499            2 :     return ACL_SUCCESS;
     500              : }
     501              : 
     502            4 : aclError acltdtGetQueueRoute(const acltdtQueueRouteList *routeList,
     503              :                              size_t index,
     504              :                              acltdtQueueRoute *route)
     505              : {
     506            4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(routeList);
     507            3 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(route);
     508            2 :     if (index >= routeList->routeList.size()) {
     509            1 :         ACL_LOG_ERROR("[Check][index] index [%zu] must be smaller than [%zu]", index, routeList->routeList.size());
     510            1 :         const char_t *argList[] = {"func", "value", "param", "reason"};
     511            1 :             std::string reason = "must be less than routeList size " + std::to_string(routeList->routeList.size());
     512            1 :             const std::string indexVal = std::to_string(index);
     513            1 :             const char_t *argVal[] = {__func__, indexVal.c_str(), "index", reason.c_str()};
     514            1 :             acl::AclErrorLogManager::ReportInputErrorWithChar(acl::INVALID_PARAM_REASON_MSG, argList, argVal, 4UL);
     515            1 :         return ACL_ERROR_INVALID_PARAM;
     516            1 :     }
     517            1 :     *route = routeList->routeList[index];
     518            1 :     return ACL_SUCCESS;
     519              : }
     520              : 
     521            2 : size_t acltdtGetQueueRouteNum(const acltdtQueueRouteList *routeList)
     522              : {
     523            6 :     ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(routeList, 0U);
     524            1 :     return routeList->routeList.size();
     525              : }
     526              : 
     527            2 : acltdtQueueRouteQueryInfo* acltdtCreateQueueRouteQueryInfo()
     528              : {
     529            2 :     ACL_ADD_APPLY_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_QUERY);
     530            2 :     acltdtQueueRouteQueryInfo *const info = new(std::nothrow) acltdtQueueRouteQueryInfo();
     531            2 :     ACL_CHECK_MALLOC_RESULT_REPORT_RET(info, sizeof(acltdtQueueRouteQueryInfo), "new", nullptr);
     532            2 :     ACL_ADD_APPLY_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_QUERY);
     533            2 :     info->isConfigDst = false;
     534            2 :     info->isConfigSrc = false;
     535            2 :     info->isConfigMode = false;
     536            2 :     return info;
     537              : }
     538              : 
     539            5 : aclError acltdtSetQueueRouteQueryInfo(acltdtQueueRouteQueryInfo *param,
     540              :                                       acltdtQueueRouteQueryInfoParamType type,
     541              :                                       size_t len,
     542              :                                       const void *value)
     543              : {
     544            5 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(param);
     545            4 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
     546            3 :     switch (type) {
     547            1 :         case ACL_TDT_QUEUE_ROUTE_QUERY_MODE_ENUM: {
     548            1 :             const auto ret = CopyParam(value, len, static_cast<void *>(&param->mode),
     549              :                 sizeof(acltdtQueueRouteQueryMode));
     550            1 :             if (ret == ACL_SUCCESS) {
     551            1 :                 param->isConfigMode = true;
     552              :             }
     553            1 :             return ret;
     554              :             }
     555            1 :         case ACL_TDT_QUEUE_ROUTE_QUERY_SRC_ID_UINT32: {
     556            1 :             const auto ret = CopyParam(value, len, static_cast<void *>(&param->srcId), sizeof(uint32_t));
     557            1 :             if (ret == ACL_SUCCESS) {
     558            1 :                 param->isConfigSrc = true;
     559              :             }
     560            1 :             return ret;
     561              :             }
     562            1 :         case ACL_TDT_QUEUE_ROUTE_QUERY_DST_ID_UINT32: {
     563            1 :             const auto ret = CopyParam(value, len, static_cast<void *>(&param->dstId), sizeof(uint32_t));
     564            1 :             if (ret == ACL_SUCCESS) {
     565            1 :                 param->isConfigDst = true;
     566              :             }
     567            1 :             return ret;
     568              :         }
     569            0 :         default: {
     570            0 :             ACL_LOG_ERROR("[Check][Type]unknown acltdtQueueRouteQueryInfoParamType %d.", type);
     571            0 :             acl::AclErrorLogManager::ReportInputError(acl::INVALID_VALUE_MSG,
     572            0 :                 std::vector<const char *>({"func", "value", "param", "expect"}),
     573            0 :                 std::vector<const char *>({__func__, acl::GetQueueRouteQueryInfoParamTypeDesc(type), "type",
     574            0 :                     "[ACL_TDT_QUEUE_ROUTE_QUERY_MODE_ENUM, ACL_TDT_QUEUE_ROUTE_QUERY_DST_ID_UINT32]"}));
     575            0 :             return ACL_ERROR_INVALID_PARAM;
     576              :         }
     577              :     }
     578              : }
     579              : 
     580            2 : aclError acltdtDestroyQueueRouteQueryInfo(const acltdtQueueRouteQueryInfo *info)
     581              : {
     582            2 :     ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(info);
     583            2 :     ACL_ADD_RELEASE_TOTAL_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_QUERY);
     584            2 :     ACL_DELETE_AND_SET_NULL(info);
     585            2 :     ACL_ADD_RELEASE_SUCCESS_COUNT(acl::ACL_STATISTICS_CREATE_DESTROY_QUEUE_ROUTE_QUERY);
     586            2 :     return ACL_SUCCESS;
     587              : }
        

Generated by: LCOV version 2.0-1