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