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