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 #ifndef FILLP_FC_H 17 #define FILLP_FC_H 18 19 #include "fillp/fillp_pcb.h" 20 #include "fillp/fillp.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 27 #define FILLP_FC_IN_KBPS (8 * 1000) 28 #define FILLP_FC_IN_BIT 8 29 30 #define FILLP_FC_VAL_IN_BITS(value) ((value) << 3) // value*8 31 32 #define FILLP_FC_KEEP_ALIVE_DURATION (180 * 1000 * 1000) 33 #define FILLP_INITIAL_RATE (g_resource.flowControl.initialRate) 34 35 #define NACK_HISTORY_BY_MEMBER_INDEX 1 36 37 #define FILLP_FC_RTT_PACK_RATIO 4 // The ratio of rtt and pack period 38 39 #define FILLP_FC_OWD_NEW 1 /* Update one-way-delay(owd) at receiver, new_owd = (7 * old_owd + current_owd) / 8 */ 40 #define FILLP_FC_OWD_OLD 7 41 #define FILLP_FC_OWD_DIVISOR 8 42 43 #define FILLP_MAX_LOST_NUM_FOR_REDUN 8 44 45 struct FillpRateSample { 46 FILLP_UINT8 i; /* pack index measurement was taken */ 47 FILLP_UINT32 v; /* value measured */ 48 }; 49 50 struct FillpMaxRateSample { 51 FILLP_UINT32 maxCnt; 52 struct FillpRateSample *rateSample; 53 }; 54 55 void FillpUpdateRecvRateSample(struct FillpMaxRateSample *maxRateSample, FILLP_UINT32 rateValue, FILLP_UINT8 rateI); 56 void FillpCalSendInterval(struct FillpPcb *flowControl); 57 void fillp_analyse_pack(struct FillpPcb *pcb, struct FillpPktPack *pack); 58 void FillpFcTailProtected(struct FillpPcb *pcb, struct FillpPktPack *pack); 59 void FillpFcPackInput(struct FillpPcb *pcb, struct FillpPktPack *pack); 60 void FillpFcNackInput(struct FillpPcb *pcb, struct FillpPktNack *nack); 61 62 FILLP_INT FillpFcInit(struct FillpPcb *pcb); 63 void FillpFcDeinit(struct FillpPcb *pcb); 64 void FillpFcDataInput(struct FillpPcb *pcb, FILLP_CONST struct FillpPktHead *pkt); 65 void FillpFcRecvDropOne(struct FillpPcb *pcb); 66 void FillpFcRecvOutOfOrder(struct FillpPcb *pcb); 67 void FillpFcCycle(void *arg); 68 void FillpFcRecvLost(struct FillpPcb *pcb, FILLP_UINT32 ones); 69 FILLP_BOOL FillpAppLimitedStatus(struct FillpPcb *pcb, FILLP_UINT32 beginPktNum, FILLP_UINT32 endPktNum); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif 76