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