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 : #ifndef INTERFACE_AICPUSD_SUB_MODULE_INTERFACE_H
11 : #define INTERFACE_AICPUSD_SUB_MODULE_INTERFACE_H
12 :
13 : #include <string>
14 : #include <atomic>
15 : #include "tsd.h"
16 : #include "aicpusd_args_parser.h"
17 :
18 : namespace AicpuSchedule {
19 : class SubModuleInterface {
20 : public:
21 : struct TsdEventKey {
22 : uint32_t deviceId;
23 : uint32_t hostPid;
24 : uint32_t vfId;
25 : };
26 :
27 89 : static SubModuleInterface& GetInstance()
28 : {
29 : static SubModuleInterface instance;
30 89 : return instance;
31 : }
32 : int32_t StartAicpuSchedulerModule(const struct TsdSubEventInfo* const eventInfo);
33 : int32_t StopAicpuSchedulerModule(const struct TsdSubEventInfo* const eventInfo);
34 :
35 24 : inline bool GetStartFlag() const { return startFlag_.load(); }
36 :
37 : private:
38 : SubModuleInterface() = default;
39 : ~SubModuleInterface() = default;
40 :
41 : void SetTsdEventKey(const struct TsdSubEventInfo* const eventInfo);
42 : bool ParseArgsFromFile(ArgsParser& startParas) const;
43 : std::string BuildArgsFilePath() const;
44 : static void DeleteArgsFile(const std::string& argsFilePath);
45 :
46 : void ReportErrMsgToTsd(const int32_t errCode) const;
47 : static bool AttachHostGroup(const ArgsParser& startParas);
48 : void SendPidQosMsgToTsd(const uint32_t pidQos) const;
49 : int32_t SendSubModuleRsponse(const uint32_t eventType) const;
50 :
51 : TsdEventKey tsdEventKey_;
52 : std::atomic<bool> startFlag_;
53 : };
54 :
55 : } // namespace AicpuSchedule
56 :
57 : extern "C" {
58 : __attribute__((visibility("default"))) int32_t StartAicpuSchedulerModule(const struct TsdSubEventInfo* const eventInfo);
59 : __attribute__((visibility("default"))) int32_t StopAicpuSchedulerModule(const struct TsdSubEventInfo* const eventInfo);
60 : }
61 :
62 : #endif // INTERFACE_AICPUSD_SUB_MODULE_INTERFACE_H
|