1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "fillpinc.h"
17 #include "res.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /*
24 Description: Global resource
25 Value Range: None
26 Access: Used to maintain global udp resources, common resources and floe control resources
27 Remarks:
28 */
29 struct GlobalResource g_resource = {
30     {
31         FILLP_DEFAULT_RX_BURST,         /* udp.rxBurst */
32         FILLP_DEFAULT_UDP_SEND_MSG_NUM, /* udp.numMsgSend */
33         FILLP_DEFAULT_MMSG_SUPPORT,     /* udp.supportMmsg */
34         0                               /* udp.Padd */
35     },
36     {
37         FILLP_DEFAULT_RECV_CACHE_PKT_NUM_BUFFER_SIZE,    /* common.recvCachePktNumBufferSize */
38         FILLP_DEFAULT_RECV_CACHE_PKT_NUM_BUFFER_TIMEOUT, /* common.recvCachePktNumBufferTimeout */
39         FILLP_DEFAULT_MAX_SOCK_NUM,                      /* common.maxSockNum */
40         FILLP_DEFAULT_MAX_CONNECTION_NUM,                /* common.maxConnNum */
41         FILLP_DEFAULT_INST_NUM,                          /* common.maxInstNum */
42         FILLP_DEFAULT_BFULL_CPU,                         /* common.fullCpuEnable */
43         FILLP_DEFAULT_BOUT_OF_ORDER_CACHE_FEATURE,       /* common.outOfOrderCacheEnable */
44         FILLP_DEFAULT_CPU_CORE_USE,                      /* common.cpuCoreUse */
45         0,                                               /* common.reserve */
46         FILLP_DYMM_INST_SEND_BUF_SIZE,                   /* common.sendCache */
47         FILLP_DYMM_INST_RECV_BUF_SIZE,                   /* common.recvCache */
48         0,                                               /* uint32_reserve */
49     },
50     {
51         FILLP_DEFAULT_CORE_MAX_RATE,           /* flowControl.maxRate */
52         FILLP_DEFAULT_CORE_MAX_RECV_RATE,      /* flowControl.maxRecvRate */
53         FILLP_DEFAULT_INITIAL_RATE,            /* flowControl.initialRate in Kbps */
54         FILLP_DEFAULT_OPPOSITE_SET_PERCENTAGE, /* flowControl.oppositeSetPercentage */
55         FILLP_DEFAULT_MAX_RATE_PERCENTAGE,     /* flowControl.maxRatePercentage */
56         FILLP_DEFAULT_NACK_REPEAT_TIMES,       /* flowControl.nackRepeatTimes */
57         FILLP_DEFAULT_PKT_LOSS_ALLOW,          /* flowControl.pktLossAllow */
58         FILLP_ALG_DEFAULT_TYPE,                /* flowControl.fcAlg */
59         FILLP_FAIRNESS_TYPE_NONE,              /* flowControl.supportFairness */
60         FILLP_DEFAULT_STACK_CORE_LIMIT_RATE    /* flowControl.limitRate */
61     },
62     FILLP_FC_PKT_LOSS_PROBE_THRESH_MAX_EXT,       /* pktLossThresHoldMax */
63     FILLP_TIMING_WHEEL_ACCURACY_EXT,              /* timingWheelAccuracy */
64     FILLP_MAXIMAL_ACK_NUM_LIMITATION_EXT,         /* maximalAckNumLimit */
65     FILLP_SEND_ONE_ACK_NUM_EXT,                   /* sendOneAckNum */
66     FILLP_CPU_PAUSE_TIME_EXT,                     /* cpuPauseTime */
67     FILLP_RETRANSMIT_CMP_TIME_EXT,                /* retransmitCmpTime */
68     0,                                            /* reserve */
69     FILLP_DEFAULT_MIN_RATE_EXT,                   /* minRate */
70     FILLP_MIN_PACK_INTERVAL_EXT,                  /* minPackInterval */
71     FILLP_UNSEND_BOX_LOOP_CHECK_BURST_EXT,        /* unsendBoxLoopCheckBurst */
72     0,                                            /* reserv */
73     FILLP_INST_UNSEND_BOX_SIZE_EXT,               /* instUnsendBoxSize */
74     FILLP_DEFAULT_NACK_RETRY_LEN_EXT,             /* nackRetryLen */
75     0,                                            /* reserved */
76     FILLP_FLOW_CONTROL_MULTI_NUM_INITIAL_VAL_EXT, /* fcControlMultiNumInitialValue */
77     FILLP_FC_MULTI_ADJUST_CONST_EXT,              /* fcMultiAdjustConst */
78     FILLP_FLOW_CONTROL_MULTI_NUM_STEP_EXT,        /* fcMultiNumStep */
79     FILLP_FC_NINETY_PERCENT_VAL_EXT,               /* fcNightyPercentVal */
80     FILLP_DEFAULT_BFULL_CPU_THRESHOLD_RATE_EXT,   /* fullCpuUseThresholdRate */
81     0                                             /* uint32_reserve */
82 };
83 
84 
85 #if FILLP_DEFAULT_UDP_SEND_MSG_NUM > FILLP_VLEN /* refer to FillpSendOne function for more details */
86 #error "FILLP_DEFAULT_UDP_SEND_MSG_NUM can't be greater then FILLP_VLEN"
87 #endif
88 
InitGlobalResourceDefault(void)89 void InitGlobalResourceDefault(void)
90 {
91     g_resource.udp.rxBurst = FILLP_DEFAULT_RX_BURST;
92     g_resource.udp.supportMmsg = FILLP_DEFAULT_MMSG_SUPPORT;
93     g_resource.udp.numMsgSend = FILLP_DEFAULT_UDP_SEND_MSG_NUM;
94     g_resource.common.recvCachePktNumBufferSize = FILLP_DEFAULT_RECV_CACHE_PKT_NUM_BUFFER_SIZE;
95     g_resource.common.recvCachePktNumBufferTimeout = FILLP_DEFAULT_RECV_CACHE_PKT_NUM_BUFFER_TIMEOUT;
96     g_resource.common.maxSockNum = FILLP_DEFAULT_MAX_SOCK_NUM;
97     g_resource.common.maxConnNum = FILLP_DEFAULT_MAX_CONNECTION_NUM;
98     g_resource.common.maxInstNum = FILLP_DEFAULT_INST_NUM;
99     g_resource.common.fullCpuEnable = FILLP_DEFAULT_BFULL_CPU;
100     g_resource.common.outOfOrderCacheEnable = FILLP_DEFAULT_BOUT_OF_ORDER_CACHE_FEATURE;
101     g_resource.common.cpuCoreUse = FILLP_DEFAULT_CPU_CORE_USE;
102     g_resource.common.sendCache = FILLP_DYMM_INST_SEND_BUF_SIZE;
103     g_resource.common.recvCache = FILLP_DYMM_INST_RECV_BUF_SIZE;
104 
105     g_resource.flowControl.maxRate = FILLP_DEFAULT_MAX_RATE;
106     g_resource.flowControl.maxRecvRate = FILLP_DEFAULT_MAX_RECV_RATE;
107     g_resource.flowControl.initialRate = FILLP_DEFAULT_INITIAL_RATE; /* Kbps */
108     g_resource.flowControl.oppositeSetPercentage = FILLP_DEFAULT_OPPOSITE_SET_PERCENTAGE;
109     g_resource.flowControl.maxRatePercentage = FILLP_DEFAULT_MAX_RATE_PERCENTAGE;
110     g_resource.flowControl.nackRepeatTimes = FILLP_DEFAULT_NACK_REPEAT_TIMES;
111     g_resource.flowControl.pktLossAllow = FILLP_DEFAULT_PKT_LOSS_ALLOW;
112 
113     g_resource.flowControl.supportFairness = FILLP_FAIRNESS_TYPE_NONE;
114     g_resource.flowControl.limitRate = FILLP_DEFAULT_STACK_CORE_LIMIT_RATE;
115 
116     g_resource.pktLossThresHoldMax = FILLP_FC_PKT_LOSS_PROBE_THRESH_MAX_EXT;
117     g_resource.timingWheelAccuracy = FILLP_TIMING_WHEEL_ACCURACY_EXT;
118     g_resource.maximalAckNumLimit = FILLP_MAXIMAL_ACK_NUM_LIMITATION_EXT;
119     g_resource.sendOneAckNum = FILLP_SEND_ONE_ACK_NUM_EXT;
120     g_resource.cpuPauseTime = FILLP_CPU_PAUSE_TIME_EXT;
121     g_resource.retransmitCmpTime = FILLP_RETRANSMIT_CMP_TIME_EXT;
122     g_resource.minRate = FILLP_DEFAULT_MIN_RATE_EXT;
123     g_resource.minPackInterval = FILLP_MIN_PACK_INTERVAL_EXT;
124     g_resource.unsendBoxLoopCheckBurst = FILLP_UNSEND_BOX_LOOP_CHECK_BURST_EXT;
125     g_resource.instUnsendBoxSize = FILLP_INST_UNSEND_BOX_SIZE_EXT;
126     g_resource.nackRetryLen = FILLP_DEFAULT_NACK_RETRY_LEN_EXT;
127     g_resource.fcControlMultiNumInitialValue = FILLP_FLOW_CONTROL_MULTI_NUM_INITIAL_VAL_EXT;
128     g_resource.fcMultiAdjustConst = FILLP_FC_MULTI_ADJUST_CONST_EXT;
129     g_resource.fcMultiNumStep = FILLP_FLOW_CONTROL_MULTI_NUM_STEP_EXT;
130     g_resource.fcNightyPercentVal = FILLP_FC_NINETY_PERCENT_VAL_EXT;
131     g_resource.fullCpuUseThresholdRate = FILLP_DEFAULT_BFULL_CPU_THRESHOLD_RATE_EXT;
132 }
133 #ifdef __cplusplus
134 }
135 #endif
136