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 LNN_LANE_QOS_H 17 #define LNN_LANE_QOS_H 18 19 #include "lnn_lane_interface.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define TRAFFIC_DATA_LEN 32 26 27 typedef enum { 28 FRAME_COST_TIME_SMALL = 0, /* less than 10ms */ 29 FRAME_COST_TIME_MEDIUM, /* [10ms, 100ms) */ 30 FRAME_COST_TIME_LARGE, /* greater than or equal to 100ms */ 31 FRAME_COST_TIME_MAX, 32 } FrameCostTimeStats; 33 34 typedef enum { 35 FRAME_BIT_RATE_SMALL = 0, /* less than 3Mbps */ 36 FRAME_BIT_RATE_MEDIUM, /* [3Mbps, 30Mbps) */ 37 FRAME_BIT_RATE_LARGE, /* greater than or equal to 30Mbps */ 38 FRAME_BIT_RATE_MAX, 39 } FrameBitRateStats; 40 41 typedef struct { 42 uint32_t costTimeStatsCnt[FRAME_COST_TIME_MAX]; 43 uint32_t sendBitRateStatsCnt[FRAME_BIT_RATE_MAX]; 44 } FrameSendStats; 45 46 typedef struct { 47 uint32_t rtt; 48 uint32_t peakBw; 49 } MsgStats; 50 51 typedef struct { 52 uint32_t peakBw; 53 } ByteStats; 54 55 typedef struct { 56 uint32_t retransRate; 57 uint32_t recvPktLoss; 58 uint32_t sendPktLoss; 59 } FileStats; 60 61 typedef struct { 62 FrameSendStats frameStats; 63 } StreamInfo; 64 65 typedef struct { 66 uint64_t laneId; 67 LaneTransType statsType; 68 union { 69 MsgStats msg; 70 ByteStats bytes; 71 FileStats file; 72 StreamInfo stream; 73 } statsInfo; 74 } LaneIdStatsInfo; 75 76 typedef enum { 77 OPT_RESULT_SUCCESS = 0, 78 OPT_RESULT_REQUEST_FREQUENTLY, 79 OPT_RESULT_CANNOT_OPTIMIZE, 80 } QosOptResult; 81 82 typedef struct { 83 unsigned char stats[TRAFFIC_DATA_LEN]; 84 } LnnRippleData; 85 86 typedef void (*OnStatsPeriodAdjustment)(uint32_t ms); 87 88 int32_t LnnInitQos(void); 89 void LnnDeinitQos(void); 90 int32_t LnnRegPeriodAdjustmentCallback(OnStatsPeriodAdjustment callback); 91 void LnnReportLaneIdStatsInfo(const LaneIdStatsInfo *statsList, uint32_t listSize); 92 void LnnReportRippleData(uint64_t laneId, const LnnRippleData *data); 93 int32_t LnnRequestQosOptimization(const uint64_t *laneIdList, 94 uint32_t listSize, int32_t *result, uint32_t resultSize); 95 void LnnCancelQosOptimization(const uint64_t *laneIdList, uint32_t listSize); 96 97 #ifdef __cplusplus 98 } 99 #endif 100 #endif 101