1484543d1Sopenharmony_ci/* 2484543d1Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3484543d1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4484543d1Sopenharmony_ci * you may not use this file except in compliance with the License. 5484543d1Sopenharmony_ci * You may obtain a copy of the License at 6484543d1Sopenharmony_ci * 7484543d1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8484543d1Sopenharmony_ci * 9484543d1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10484543d1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11484543d1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12484543d1Sopenharmony_ci * See the License for the specific language governing permissions and 13484543d1Sopenharmony_ci * limitations under the License. 14484543d1Sopenharmony_ci */ 15484543d1Sopenharmony_ci 16484543d1Sopenharmony_ci#ifndef _UAPI_LINUX_WGCM_H 17484543d1Sopenharmony_ci#define _UAPI_LINUX_WGCM_H 18484543d1Sopenharmony_ci 19484543d1Sopenharmony_ci#include <linux/types.h> 20484543d1Sopenharmony_ci 21484543d1Sopenharmony_ciconstexpr int WGCM_TASK_ALIGN = 64; 22484543d1Sopenharmony_ci 23484543d1Sopenharmony_ciconstexpr int WGCM_ACTIVELY_WAKE = 0x10; 24484543d1Sopenharmony_ciconstexpr int PR_WGCM_CTL = 59; 25484543d1Sopenharmony_ci/* 26484543d1Sopenharmony_ci * struct wgcm_workergrp_data: controls the state of WGCM tasks. 27484543d1Sopenharmony_ci * 28484543d1Sopenharmony_ci * The struct is aligned at 64 bytes to ensure that it fits into 29484543d1Sopenharmony_ci * a single cache line. 30484543d1Sopenharmony_ci */ 31484543d1Sopenharmony_cistruct wgcm_workergrp_data { 32484543d1Sopenharmony_ci /* wgcm workergroup's id */ 33484543d1Sopenharmony_ci __u32 gid; 34484543d1Sopenharmony_ci 35484543d1Sopenharmony_ci /* server's thread id */ 36484543d1Sopenharmony_ci __u32 server_tid; 37484543d1Sopenharmony_ci 38484543d1Sopenharmony_ci /* 39484543d1Sopenharmony_ci * min_concur_workers & max_workers_sum: 40484543d1Sopenharmony_ci * These two paras are used to detemine wether to wake up the server. 41484543d1Sopenharmony_ci * 42484543d1Sopenharmony_ci * When (workers_sum - blk_workers_sum < min_concur_workers) && 43484543d1Sopenharmony_ci * (workers_sum < max_workers_sum), wake up server. 44484543d1Sopenharmony_ci */ 45484543d1Sopenharmony_ci __u32 min_concur_workers; 46484543d1Sopenharmony_ci __u32 max_workers_sum; 47484543d1Sopenharmony_ci 48484543d1Sopenharmony_ci /* count the number of workers which is bound with server */ 49484543d1Sopenharmony_ci __u32 workers_sum; 50484543d1Sopenharmony_ci 51484543d1Sopenharmony_ci /* count the number of block workers */ 52484543d1Sopenharmony_ci __u32 blk_workers_sum; 53484543d1Sopenharmony_ci 54484543d1Sopenharmony_ci /* indicates whether the server task is actively woken up */ 55484543d1Sopenharmony_ci __u32 woken_flag; 56484543d1Sopenharmony_ci 57484543d1Sopenharmony_ci __u32 reserved; 58484543d1Sopenharmony_ci} __attribute__((packed, aligned(WGCM_TASK_ALIGN))); 59484543d1Sopenharmony_ci 60484543d1Sopenharmony_ci/** 61484543d1Sopenharmony_ci * enum wgcm_ctl_flag - flags to pass to wgcm_ctl() 62484543d1Sopenharmony_ci * @WGCM_CTL_SERVER_REG: register the current task as a WGCM server 63484543d1Sopenharmony_ci * @WGCM_CTL_WORKER_REG: register the current task as a WGCM worker 64484543d1Sopenharmony_ci * @WGCM_CTL_UNREGISTER: unregister the current task as a WGCM task 65484543d1Sopenharmony_ci * @WGCM_CTL_GET: get infomation about workergroup 66484543d1Sopenharmony_ci * @WGCM_CTL_SET_GRP: set min_concur_workers & max_workers_sum to workergroup 67484543d1Sopenharmony_ci * @WGCM_CTL_WAIT: server thread enter the hibernation state 68484543d1Sopenharmony_ci * @WGCM_CTL_WAKE: actively wakes up WGCM server 69484543d1Sopenharmony_ci */ 70484543d1Sopenharmony_cienum wgcm_ctl_flag { 71484543d1Sopenharmony_ci WGCM_CTL_SERVER_REG = 1, 72484543d1Sopenharmony_ci WGCM_CTL_WORKER_REG, 73484543d1Sopenharmony_ci WGCM_CTL_SET_GRP, 74484543d1Sopenharmony_ci WGCM_CTL_UNREGISTER, 75484543d1Sopenharmony_ci WGCM_CTL_GET = 5, 76484543d1Sopenharmony_ci WGCM_CTL_WAIT, 77484543d1Sopenharmony_ci WGCM_CTL_WAKE, 78484543d1Sopenharmony_ci WGCM_CTL_MAX_NR, 79484543d1Sopenharmony_ci}; 80484543d1Sopenharmony_ci 81484543d1Sopenharmony_ci#endif /* _UAPI_LINUX_WGCM_H */ 82