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 54 : HcclResult RtsUbDevQueryInfo(const rtUbDevQueryCmd cmd, rtMemUbTokenInfo &devInfo)
18 : {
19 54 : 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 54 : auto ret = rtUbDevQueryInfo(cmd, &devInfo);
25 54 : if (ret != RT_ERROR_NONE) {
26 0 : HCCL_ERROR("[%s] failed[%d], va[0x%llx] size[%llu].",
27 : __func__, ret, devInfo.va, devInfo.size);
28 0 : return HcclResult::HCCL_E_RUNTIME;
29 : }
30 :
31 54 : constexpr u32 TOKEN_ID_RIGHT_SHIF = 8;
32 54 : devInfo.tokenId = devInfo.tokenId >> TOKEN_ID_RIGHT_SHIF;
33 54 : return HcclResult::HCCL_SUCCESS;
34 : }
35 :
36 : } // namespace hcomm
|