1 // Copyright (C) 2023 Huawei Device Co., Ltd. 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 use super::QosLevel; 15 16 /// Capacity of different `Rss` level, which contains `m1`, `m2`, `m3`. 17 /// `m1` represents the size of the full-speed zone. 18 /// `m2` represents the size of the low-speed zone. 19 /// `m3` represents the size of the fair-adjustment zone. 20 #[derive(PartialEq, Eq)] 21 pub(crate) struct RssCapacity(usize, usize, usize, QosLevel, QosLevel, QosLevel); 22 23 impl RssCapacity { 24 pub(crate) const LEVEL0: Self = 25 Self(8, 32, 8, QosLevel::High, QosLevel::Middle, QosLevel::Middle); 26 pub(crate) const LEVEL1: Self = 27 Self(8, 32, 8, QosLevel::High, QosLevel::Middle, QosLevel::Middle); 28 pub(crate) const LEVEL2: Self = 29 Self(8, 32, 8, QosLevel::High, QosLevel::Middle, QosLevel::Middle); 30 pub(crate) const LEVEL3: Self = 31 Self(8, 16, 4, QosLevel::High, QosLevel::Middle, QosLevel::Middle); 32 pub(crate) const LEVEL4: Self = 33 Self(4, 16, 4, QosLevel::High, QosLevel::Middle, QosLevel::Middle); 34 pub(crate) const LEVEL5: Self = 35 Self(4, 8, 4, QosLevel::High, QosLevel::Middle, QosLevel::Middle); 36 pub(crate) const LEVEL6: Self = Self(4, 8, 2, QosLevel::High, QosLevel::Low, QosLevel::Low); 37 pub(crate) const LEVEL7: Self = Self(4, 4, 2, QosLevel::High, QosLevel::Low, QosLevel::Low); 38 new(level: i32) -> Self39 pub(crate) fn new(level: i32) -> Self { 40 match level { 41 0 => Self::LEVEL0, 42 1 => Self::LEVEL1, 43 2 => Self::LEVEL2, 44 3 => Self::LEVEL3, 45 4 => Self::LEVEL4, 46 5 => Self::LEVEL5, 47 6 => Self::LEVEL6, 48 7 => Self::LEVEL7, 49 _ => unreachable!(), 50 } 51 } 52 m1(&self) -> usize53 pub(crate) fn m1(&self) -> usize { 54 self.0 55 } 56 m2(&self) -> usize57 pub(crate) fn m2(&self) -> usize { 58 self.1 59 } 60 m3(&self) -> usize61 pub(crate) fn m3(&self) -> usize { 62 self.2 63 } 64 m1_speed(&self) -> QosLevel65 pub(crate) fn m1_speed(&self) -> QosLevel { 66 self.3 67 } 68 m2_speed(&self) -> QosLevel69 pub(crate) fn m2_speed(&self) -> QosLevel { 70 self.4 71 } 72 m3_speed(&self) -> QosLevel73 pub(crate) fn m3_speed(&self) -> QosLevel { 74 self.5 75 } 76 } 77 78 #[cfg(test)] 79 mod ut_rss { 80 include!("../../../../tests/ut/manage/scheduler/qos/ut_rss.rs"); 81 } 82