LCOV - code coverage report
Current view: top level - acl/acl_tdt_queue - queue.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 230 336 68.5 %
Date: 2026-08-27 13:24:42 Functions: 27 39 69.2 %

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

Generated by: LCOV version 1.14