aboutsummaryrefslogtreecommitdiffstats
path: root/src/framework/ipc/ps/nsfw_ps_module.h
blob: ce2db130dc265dfdcf6748910a576c24f5fef5c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
*
* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef _NSFW_PS_MODULE_H
#define _NSFW_PS_MODULE_H

#include "nsfw_ps_api.h"
#include "nsfw_mem_api.h"

#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C"{
/* *INDENT-ON* */
#endif /* __cplusplus */

/*==============================================*
 *      constants or macros define              *
 *----------------------------------------------*/
#define NSFW_PS_INFO_MAX_COUNT 4095
#define MAX_NET_LINK_BUF_DEF 0x34000*32

#define NSFW_PS_WEXIT_TIMER  1
#define NSFW_PS_WEXIT_TVLAUE_DEF 180

#define NSFW_PS_WEXIT_TVLAUE (g_ps_cfg.ps_waite_exit_tvalue)
#define MAX_NET_LINK_BUF     (g_ps_cfg.net_link_buf)

typedef struct _nsfw_ps_init_cfg
{
    u32 ps_info_size;
    u32 net_link_buf;

    u16 ps_waite_exit_tvalue;
    u16 ps_chk_hbt_count;
    u16 ps_chk_hbt_soft_count;
    u16 ps_chk_hbt_tvalue;

    mring_handle ps_info_pool;
} nsfw_ps_init_cfg;

#define NSFW_PS_CHK_TIMER  1
#define NSFW_PS_FIRST_CHK_TVLAUE 1
#define NSFW_PS_CHK_EXIT_TVLAUE 1

typedef struct _nsfw_pid_item
{
    u8 proc_type;
    u8 u8_reserve;
    u16 u16_reserve;
    u32 starttime;
    nsfw_ps_info *ps_info;
} nsfw_pid_item;

u32 get_ps_exiting_cnt();

int nsfw_ps_change_fun(i32 epfd, i32 socket, u32 events);
u8 nsfw_sw_ps_state(nsfw_ps_info * pps_info, u8 new_state);

/* for heartbeat checking*/
#define NSFW_MAX_THREAD_DOGS_COUNT 8
#define NSFW_CHK_HBT_TIMER  1
#define NSFW_MAX_HBT_PROC_FUN  4

#define NSFW_CHK_HBT_TVLAUE_DEF 3

#define NSFW_MAX_HBT_CHK_COUNT   (g_ps_cfg.ps_chk_hbt_count)
#define NSFW_SOFT_HBT_CHK_COUNT   (g_ps_cfg.ps_chk_hbt_soft_count)
#define NSFW_CHK_HBT_TVLAUE      (g_ps_cfg.ps_chk_hbt_tvalue)

typedef struct _nsfw_ps_chk_msg
{
    u32 ps_state;
    i32 thread_chk_count;
} nsfw_ps_chk_msg;

int nsfw_ps_chk_timeout(u32 timer_type, void *data);

#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif /* __cplusplus */

#endif /* _NSFW_PS_MODULE_H  */