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 : #ifndef COMMON_BQS_FEATURE_CTRL_H
12 : #define COMMON_BQS_FEATURE_CTRL_H
13 : #include "driver/ascend_hal_define.h"
14 : namespace bqs {
15 : const std::string AOSCORE_PREFIX = "sea_";
16 : // min number of vDeviceId
17 : constexpr const uint32_t VDEVICE_MIN_CPU_NUM = 32U;
18 : // mid number of vDeviceId
19 : constexpr const uint32_t VDEVICE_MID_CPU_NUM = 48U;
20 : // max number of vDeviceId
21 : constexpr const uint32_t VDEVICE_MAX_CPU_NUM = 64U;
22 :
23 : class FeatureCtrl {
24 : public:
25 29 : static inline bool IsAosCore()
26 : {
27 : #ifdef _AOSCORE_
28 : return true;
29 : #else
30 29 : return false;
31 : #endif
32 : }
33 :
34 0 : static inline bool BindCpuOnlyOneDevice()
35 : {
36 : #ifdef BIND_CPU_ONLY_ONE_DEVICE
37 : return true;
38 : #else
39 0 : return false;
40 : #endif
41 : }
42 :
43 19 : static inline bool IsVfModeCheckedByDeviceId(const uint32_t deviceId)
44 : {
45 19 : if ((deviceId >= VDEVICE_MIN_CPU_NUM) && (deviceId < VDEVICE_MAX_CPU_NUM)) {
46 2 : return true;
47 : } else {
48 17 : return false;
49 : }
50 : }
51 :
52 21 : static inline bool IsVfModeDie1(const uint32_t deviceId)
53 : {
54 21 : if ((deviceId >= VDEVICE_MID_CPU_NUM) && (deviceId < VDEVICE_MAX_CPU_NUM)) {
55 3 : return true;
56 : } else {
57 18 : return false;
58 : }
59 : }
60 :
61 33 : static inline bool IsHostQs()
62 : {
63 : #ifdef QS_DEPLOY_ON_HOST
64 : return true;
65 : #else
66 33 : return false;
67 : #endif
68 : }
69 :
70 : private:
71 : FeatureCtrl() = default;
72 : ~FeatureCtrl() = default;
73 :
74 : FeatureCtrl(FeatureCtrl const&) = delete;
75 : FeatureCtrl& operator=(FeatureCtrl const&) = delete;
76 : FeatureCtrl(FeatureCtrl&&) = delete;
77 : FeatureCtrl& operator=(FeatureCtrl&&) = delete;
78 : };
79 :
80 : } // namespace bqs
81 :
82 : #endif // COMMON_BQS_FEATURE_CTRL_H
|