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 "hcomm_adapter_rts.h"
12 :
13 : #include "log.h"
14 :
15 : namespace hcomm {
16 :
17 184 : HcclResult RtsUbDevQueryInfo(const rtUbDevQueryCmd cmd, rtMemUbTokenInfo& devInfo)
18 : {
19 184 : if (cmd != QUERY_PROCESS_TOKEN) {
20 0 : HCCL_ERROR("[%s] error cmd[%d].", __func__, cmd);
21 0 : return HcclResult::HCCL_E_PARA;
22 : }
23 :
24 184 : auto ret = rtUbDevQueryInfo(cmd, &devInfo);
25 184 : if (ret != RT_ERROR_NONE) {
26 0 : HCCL_ERROR("[%s] failed[%d], va[0x%llx] size[%llu].", __func__, ret, devInfo.va, devInfo.size);
27 0 : return HcclResult::HCCL_E_RUNTIME;
28 : }
29 :
30 184 : constexpr u32 TOKEN_ID_RIGHT_SHIF = 8;
31 184 : devInfo.tokenId = devInfo.tokenId >> TOKEN_ID_RIGHT_SHIF;
32 184 : return HcclResult::HCCL_SUCCESS;
33 : }
34 :
35 : } // namespace hcomm
|