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 "tsd_path_mgr.h"
12 : #include "tsd_util_func.h"
13 : namespace tsd {
14 : namespace {
15 : const std::string AICPU_PACKAGE_DECOMPRESSION_PATH = "/usr/lib64/aicpu_kernels/";
16 : // aicpu kernels so inner dir name
17 : constexpr const char_t* AICPU_KERNELS_SO_INNER_DIR_NAME = "aicpu_kernels_device/";
18 : constexpr const char_t* AICPU_EXTEND_KERNELS_SO_INNER_DIR_NAME = "aicpu_extend_syskernels/";
19 : // version.info file name
20 : constexpr const char_t* VERSION_INFO_FILE_NAME = "version.info";
21 : constexpr const char_t* HOME_SO_PATH_FOR_THREADMODE = "aicpu_kernels/";
22 : const std::string HELPER_AICPU_OPKERNEL_PATH_HEAD = "/home/HwHiAiUser/inuse/";
23 : const std::string AICPU_OPKERNEL_PATH_HEAD = "/home/HwHiAiUser/aicpu_kernels/";
24 : const std::string AICPU_EXTEND_HASH_CFG_FILE = "aicpuExtend_bin_hash.cfg";
25 : } // namespace
26 :
27 : // /usr/lib64/aicpu_kernels/2/
28 23 : std::string TsdPathMgr::BuildKernelSoRootPath(const uint32_t uniqueVfId, const std::string& destPath)
29 : {
30 23 : if (!destPath.empty()) {
31 11 : std::string path = destPath;
32 11 : return path.append(std::string(HOME_SO_PATH_FOR_THREADMODE)).append(std::to_string(uniqueVfId)).append("/");
33 11 : }
34 :
35 12 : if (IsHeterogeneousProduct()) {
36 2 : std::string curPath = HELPER_AICPU_OPKERNEL_PATH_HEAD;
37 2 : return curPath.append(std::string(HOME_SO_PATH_FOR_THREADMODE)).append(std::to_string(uniqueVfId)).append("/");
38 2 : } else {
39 10 : return std::string(AICPU_PACKAGE_DECOMPRESSION_PATH).append(std::to_string(uniqueVfId)).append("/");
40 : }
41 : }
42 :
43 : // /usr/lib64/aicpu_kernels/2/aicpu_kernels_device/
44 5 : std::string TsdPathMgr::BuildKernelSoPath(const uint32_t uniqueVfId)
45 : {
46 10 : return TsdPathMgr::BuildKernelSoRootPath(uniqueVfId).append(AICPU_KERNELS_SO_INNER_DIR_NAME);
47 : }
48 :
49 10 : std::string TsdPathMgr::BuildKernelSoPath(const std::string& kernelSoRootPath)
50 : {
51 10 : return std::string(kernelSoRootPath).append(AICPU_KERNELS_SO_INNER_DIR_NAME);
52 : }
53 :
54 7 : std::string TsdPathMgr::BuildExtendKernelSoPath(const std::string& kernelSoRootPath)
55 : {
56 7 : return std::string(kernelSoRootPath).append(AICPU_EXTEND_KERNELS_SO_INNER_DIR_NAME);
57 : }
58 :
59 7 : std::string TsdPathMgr::BuildExtendKernelHashCfgPath(const std::string& kernelSoRootPath)
60 : {
61 7 : return std::string(kernelSoRootPath).append(AICPU_KERNELS_SO_INNER_DIR_NAME).append(AICPU_EXTEND_HASH_CFG_FILE);
62 : }
63 :
64 : // /usr/lib64/aicpu_kernels/2/aicpu_kernels_device/version.info
65 11 : std::string TsdPathMgr::AddVersionInfoName(const std::string& kernelSoPath)
66 : {
67 11 : return std::string(kernelSoPath).append(VERSION_INFO_FILE_NAME);
68 : }
69 : } // namespace tsd
|