Userspace Resource Manager
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2// SPDX-License-Identifier: BSD-3-Clause-Clear
3
8#ifndef UTILS_H
9#define UTILS_H
10
11#include <string>
12
13#include "ErrCodes.h"
14
19enum ModuleID : int8_t {
20 MOD_RESTUNE,
21 MOD_CLASSIFIER,
22};
23
28enum RequestType : int8_t {
29 REQ_RESOURCE_TUNING,
30 REQ_RESOURCE_RETUNING,
31 REQ_RESOURCE_UNTUNING,
32 REQ_PROP_GET,
33 REQ_SIGNAL_TUNING,
34 REQ_SIGNAL_UNTUNING,
35 REQ_SIGNAL_RELAY
36};
37
48
56 SYSTEM_HIGH = 0, // Highest Level of Priority
57 SYSTEM_LOW,
58 THIRD_PARTY_HIGH,
59 THIRD_PARTY_LOW,
60 TOTAL_PRIORITIES
61};
62
76
77enum TranslationUnit {
78 U_NA = 1,
79 U_BYTE = 1,
80 U_KB = 1024,
81 U_MB = 1024 * 1024,
82 U_GB = 1024 * 1024 * 1024,
83 U_Hz = 1,
84 U_KHz = 1000,
85 U_MHz = 1000 * 1000,
86 U_GHz = 1000 * 1000 * 1000,
87};
88
89typedef struct {
90 int8_t mModuleID;
91 int8_t mRequestType;
92 uint64_t mBufferSize;
93 int64_t mHandle;
94 char* mBuffer;
95} MsgForwardInfo;
96
97typedef struct {
98 std::string mPropName;
99 std::string mResult;
100 uint64_t mBufferSize;
101} PropConfig;
102
103// Global Typedefs: Declare Function Pointers as types
104typedef ErrCode (*EventCallback)(void*);
105typedef int8_t (*ServerOnlineCheckCallback)();
106typedef void (*MessageReceivedCallback)(int32_t, MsgForwardInfo*);
107
108#define HIGH_TRANSFER_PRIORITY -1
109#define SERVER_CLEANUP_TRIGGER_PRIORITY -2
110
111// System Properties
112#define MAX_CONCURRENT_REQUESTS "resource_tuner.maximum.concurrent.requests"
113#define MAX_RESOURCES_PER_REQUEST "resource_tuner.maximum.resources.per.request"
114#define PULSE_MONITOR_DURATION "resource_tuner.pulse.duration"
115#define GARBAGE_COLLECTOR_DURATION "resource_tuner.garbage_collection.duration"
116#define GARBAGE_COLLECTOR_BATCH_SIZE "resource_tuner.garbage_collection.batch_size"
117#define RATE_LIMITER_DELTA "resource_tuner.rate_limiter.delta"
118#define RATE_LIMITER_PENALTY_FACTOR "resource_tuner.penalty.factor"
119#define RATE_LIMITER_REWARD_FACTOR "resource_tuner.reward.factor"
120#define LOGGER_LOGGING_LEVEL "urm.logging.level"
121#define LOGGER_LOGGING_LEVEL_TYPE "urm.logging.level.exact"
122#define LOGGER_LOGGING_OUTPUT_REDIRECT "urm.logging.redirect_to"
123#define URM_MAX_PLUGIN_COUNT "urm.extensions_lib.count"
124
125#define COMM(pid) ("/proc/" + std::to_string(pid) + "/comm")
126#define COMM_S(pidstr) ("/proc/" + pidstr + "/comm")
127#define STATUS(pid) ("/proc/" + std::to_string(pid) + "/status")
128#define CMDLINE(pid) ("/proc/" + std::to_string(pid) + "/cmdline")
129#define STAT(pid) ("/proc/" + std::to_string(pid) + "/stat")
130
131#define CONCAT_IMPL(a, b) a##b
132#define CONCAT(a, b) CONCAT_IMPL(a, b)
133
134#endif
ErrCode
Custom Error Codes used by Resource Tuner APIs and Internal Functions.
Definition ErrCodes.h:19
PriorityLevel
Resource Tuner Priority Levels.
Definition Utils.h:55
Permissions
Certain resources can be accessed only by system clients and some which have no such restrictions and...
Definition Utils.h:43
@ NUMBER_PERMISSIONS
Total number of permissions currently supported.
Definition Utils.h:46
@ PERMISSION_THIRD_PARTY
Third party clients. Default value.
Definition Utils.h:45
@ PERMISSION_SYSTEM
Special permission level for system clients.
Definition Utils.h:44
RequestType
Enumeration for different types of Resource-Tuner Requests.
Definition Utils.h:28
Policy
Different Resource Policies supported by Resource Tuner.
Definition Utils.h:69
@ HIGHER_BETTER
This policy first applies the request writing the highest value to the node.
Definition Utils.h:71
@ LAZY_APPLY
The requests are applied in a first-in-first-out manner.
Definition Utils.h:73
@ INSTANT_APPLY
This policy is for resources where the latest request needs to be honored.
Definition Utils.h:70
@ LOWER_BETTER
Self-explanatory. Works exactly opposite of the higher is better policy.
Definition Utils.h:72