Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 1 | /* |
Joey Armstrong | 11f5a57 | 2024-01-12 19:11:32 -0500 | [diff] [blame] | 2 | * Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 3 | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 16 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 17 | // Package core provides the utility for olt devices, flows and statistics |
Scott Baker | dbd960e | 2020-02-28 08:57:51 -0800 | [diff] [blame] | 18 | package core |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 19 | |
| 20 | import ( |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 21 | "container/list" |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 22 | "context" |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 23 | "fmt" |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 24 | "sync" |
| 25 | "time" |
| 26 | |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 27 | plt "github.com/opencord/voltha-lib-go/v7/pkg/platform" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 28 | rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager" |
| 29 | |
| 30 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 31 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 32 | "github.com/opencord/voltha-protos/v5/go/extension" |
| 33 | "github.com/opencord/voltha-protos/v5/go/openolt" |
| 34 | "github.com/opencord/voltha-protos/v5/go/voltha" |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 35 | ) |
| 36 | |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 37 | const ( |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 38 | // NNIStats statType constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 39 | NNIStats = "NNIStats" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 40 | // PONStats statType constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 41 | PONStats = "PONStats" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 42 | // ONUStats statType constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 43 | ONUStats = "ONUStats" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 44 | // GEMStats statType constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 45 | GEMStats = "GEMStats" |
| 46 | |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 47 | // RxBytes constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 48 | RxBytes = "RxBytes" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 49 | // RxPackets constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 50 | RxPackets = "RxPackets" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 51 | // TxBytes constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 52 | TxBytes = "TxBytes" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 53 | // TxPackets constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 54 | TxPackets = "TxPackets" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 55 | // FecCodewords constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 56 | FecCodewords = "FecCodewords" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 57 | // BipUnits constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 58 | BipUnits = "BipUnits" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 59 | // BipErrors constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 60 | BipErrors = "BipErrors" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 61 | // RxPloamsNonIdle constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 62 | RxPloamsNonIdle = "RxPloamsNonIdle" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 63 | // RxPloamsError constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 64 | RxPloamsError = "RxPloamsError" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 65 | // RxOmci constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 66 | RxOmci = "RxOmci" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 67 | // RxOmciPacketsCrcError constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 68 | RxOmciPacketsCrcError = "RxOmciPacketsCrcError" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 69 | // PositiveDrift constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 70 | PositiveDrift = "PositiveDrift" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 71 | // NegativeDrift constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 72 | NegativeDrift = "NegativeDrift" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 73 | // DelimiterMissDetection constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 74 | DelimiterMissDetection = "DelimiterMissDetection" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 75 | // FecCorrectedSymbols constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 76 | FecCorrectedSymbols = "FecCorrectedSymbols" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 77 | // FecCodewordsCorrected constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 78 | FecCodewordsCorrected = "FecCodewordsCorrected" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 79 | // fecCodewordsUncorrectable constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 80 | fecCodewordsUncorrectable = "fec_codewords_uncorrectable" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 81 | // FecCorrectedUnits constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 82 | FecCorrectedUnits = "FecCorrectedUnits" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 83 | // XGEMKeyErrors constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 84 | XGEMKeyErrors = "XGEMKeyErrors" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 85 | // XGEMLoss constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 86 | XGEMLoss = "XGEMLOSS" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 87 | // BerReported constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 88 | BerReported = "BerReported" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 89 | // LcdgErrors constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 90 | LcdgErrors = "LcdgErrors" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 91 | // RdiErrors constant |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 92 | RdiErrors = "RdiErrors" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 93 | // Timestamp constant |
Himani Chawla | 2c8ae0f | 2021-05-18 23:27:00 +0530 | [diff] [blame] | 94 | Timestamp = "Timestamp" |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 95 | ) |
| 96 | |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 97 | var mutex = &sync.Mutex{} |
| 98 | |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 99 | var onuStats = make(chan *openolt.OnuStatistics, 100) |
| 100 | var gemStats = make(chan *openolt.GemPortStatistics, 100) |
| 101 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 102 | // statRegInfo is used to register for notifications |
| 103 | // on receiving port stats and flow stats indication |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 104 | type statRegInfo struct { |
| 105 | chn chan bool |
| 106 | portNo uint32 |
| 107 | portType extension.GetOltPortCounters_PortType |
| 108 | } |
| 109 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 110 | // PonPort representation |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 111 | type PonPort struct { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 112 | ONUs map[uint32]interface{} |
| 113 | ONUsByID map[uint32]interface{} |
| 114 | |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 115 | DeviceID string |
| 116 | Label string |
| 117 | |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 118 | RxBytes uint64 |
| 119 | RxPackets uint64 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 120 | RxUcastPackets uint64 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 121 | RxMcastPackets uint64 |
| 122 | RxBcastPackets uint64 |
| 123 | RxErrorPackets uint64 |
| 124 | TxBytes uint64 |
| 125 | TxPackets uint64 |
| 126 | TxUcastPackets uint64 |
| 127 | TxMcastPackets uint64 |
| 128 | TxBcastPackets uint64 |
| 129 | TxErrorPackets uint64 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 130 | RxCrcErrors uint64 |
| 131 | BipErrors uint64 |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 132 | /* |
| 133 | This is a highly reduced version taken from the adtran pon_port. |
| 134 | TODO: Extend for use in the openolt adapter set. |
| 135 | */ |
| 136 | /* MAX_ONUS_SUPPORTED = 256 |
| 137 | DEFAULT_ENABLED = False |
| 138 | MAX_DEPLOYMENT_RANGE = 25000 # Meters (OLT-PB maximum) |
| 139 | |
| 140 | _MCAST_ONU_ID = 253 |
| 141 | _MCAST_ALLOC_BASE = 0x500 |
| 142 | |
| 143 | _SUPPORTED_ACTIVATION_METHODS = ['autodiscovery'] # , 'autoactivate'] |
| 144 | _SUPPORTED_AUTHENTICATION_METHODS = ['serial-number'] |
| 145 | */ |
| 146 | PONID uint32 |
| 147 | IntfID uint32 |
| 148 | PortNum uint32 |
| 149 | PortID uint32 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 150 | } |
| 151 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 152 | // NewPONPort returns a new instance of PonPort initialized with given PONID, DeviceID, IntfID and PortNum |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 153 | func NewPONPort(PONID uint32, DeviceID string, IntfID uint32, PortNum uint32) *PonPort { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 154 | var PON PonPort |
| 155 | |
| 156 | PON.PONID = PONID |
| 157 | PON.DeviceID = DeviceID |
| 158 | PON.IntfID = IntfID |
| 159 | PON.PortNum = PortNum |
| 160 | PON.PortID = 0 |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 161 | PON.Label = fmt.Sprintf("%s%d", "pon-", PONID) |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 162 | |
| 163 | PON.ONUs = make(map[uint32]interface{}) |
| 164 | PON.ONUsByID = make(map[uint32]interface{}) |
| 165 | |
| 166 | /* |
| 167 | Statistics taken from nni_port |
| 168 | self.intf_id = 0 #handled by getter |
| 169 | self.port_no = 0 #handled by getter |
| 170 | self.port_id = 0 #handled by getter |
| 171 | |
| 172 | Note: In the current implementation of the kpis coming from the BAL the stats are the |
| 173 | samne model for NNI and PON. |
| 174 | |
| 175 | TODO: Integrate additional kpis for the PON and other southbound port objecgts. |
| 176 | |
| 177 | */ |
| 178 | |
| 179 | PON.RxBytes = 0 |
| 180 | PON.RxPackets = 0 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 181 | PON.RxUcastPackets = 0 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 182 | PON.RxMcastPackets = 0 |
| 183 | PON.RxBcastPackets = 0 |
| 184 | PON.RxErrorPackets = 0 |
| 185 | PON.TxBytes = 0 |
| 186 | PON.TxPackets = 0 |
| 187 | PON.TxUcastPackets = 0 |
| 188 | PON.TxMcastPackets = 0 |
| 189 | PON.TxBcastPackets = 0 |
| 190 | PON.TxErrorPackets = 0 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 191 | PON.RxCrcErrors = 0 |
| 192 | PON.BipErrors = 0 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 193 | |
| 194 | /* def __str__(self): |
| 195 | return "PonPort-{}: Admin: {}, Oper: {}, OLT: {}".format(self._label, |
| 196 | self._admin_state, |
| 197 | self._oper_status, |
| 198 | self.olt) |
| 199 | */ |
| 200 | return &PON |
| 201 | } |
| 202 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 203 | // NniPort representation |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 204 | type NniPort struct { |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 205 | Name string |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 206 | |
| 207 | RxBytes uint64 |
| 208 | RxPackets uint64 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 209 | RxUcastPackets uint64 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 210 | RxMcastPackets uint64 |
| 211 | RxBcastPackets uint64 |
| 212 | RxErrorPackets uint64 |
| 213 | TxBytes uint64 |
| 214 | TxPackets uint64 |
| 215 | TxUcastPackets uint64 |
| 216 | TxMcastPackets uint64 |
| 217 | TxBcastPackets uint64 |
| 218 | TxErrorPackets uint64 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 219 | RxCrcErrors uint64 |
| 220 | BipErrors uint64 |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 221 | /* |
| 222 | Northbound network port, often Ethernet-based |
| 223 | |
| 224 | This is a highly reduced version taken from the adtran nni_port code set |
| 225 | TODO: add functions to allow for port specific values and operations |
| 226 | */ |
| 227 | PortNum uint32 |
| 228 | LogicalPort uint32 |
| 229 | IntfID uint32 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 230 | } |
| 231 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 232 | // NewNniPort returns a new instance of NniPort initialized with the given PortNum and IntfID |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 233 | func NewNniPort(PortNum uint32, IntfID uint32) *NniPort { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 234 | var NNI NniPort |
| 235 | |
| 236 | NNI.PortNum = PortNum |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 237 | NNI.Name = fmt.Sprintf("%s%d", "nni-", PortNum) |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 238 | NNI.IntfID = IntfID |
| 239 | |
| 240 | NNI.RxBytes = 0 |
| 241 | NNI.RxPackets = 0 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 242 | NNI.RxUcastPackets = 0 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 243 | NNI.RxMcastPackets = 0 |
| 244 | NNI.RxBcastPackets = 0 |
| 245 | NNI.RxErrorPackets = 0 |
| 246 | NNI.TxBytes = 0 |
| 247 | NNI.TxPackets = 0 |
| 248 | NNI.TxUcastPackets = 0 |
| 249 | NNI.TxMcastPackets = 0 |
| 250 | NNI.TxBcastPackets = 0 |
| 251 | NNI.TxErrorPackets = 0 |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 252 | NNI.RxCrcErrors = 0 |
| 253 | NNI.BipErrors = 0 |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 254 | |
| 255 | return &NNI |
| 256 | } |
| 257 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 258 | // StatType defines portStatsType and flowStatsType types |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 259 | type StatType int |
| 260 | |
| 261 | const ( |
| 262 | portStatsType StatType = iota |
| 263 | flowStatsType |
| 264 | ) |
| 265 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 266 | // OpenOltStatisticsMgr structure |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 267 | type OpenOltStatisticsMgr struct { |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 268 | Device *DeviceHandler |
| 269 | NorthBoundPort map[uint32]*NniPort |
| 270 | SouthBoundPort map[uint32]*PonPort |
| 271 | statIndListners map[StatType]*list.List |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 272 | // TODO PMMetrics Metrics |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 273 | // statIndListners is the list of requests to be notified when port and flow stats indication is received |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 274 | statIndListnerMu sync.Mutex |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 275 | } |
| 276 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 277 | // NewOpenOltStatsMgr returns a new instance of the OpenOltStatisticsMgr |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 278 | func NewOpenOltStatsMgr(ctx context.Context, Dev *DeviceHandler) *OpenOltStatisticsMgr { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 279 | var StatMgr OpenOltStatisticsMgr |
| 280 | |
| 281 | StatMgr.Device = Dev |
| 282 | // TODO call metric PMMetric = |
| 283 | // Northbound and Southbound ports |
| 284 | // added to initialize the pm_metrics |
| 285 | var Ports interface{} |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 286 | Ports, _ = InitPorts(ctx, "nni", Dev.device.Id, 1) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 287 | StatMgr.NorthBoundPort, _ = Ports.(map[uint32]*NniPort) |
Girish Gowdra | 8a0bdcd | 2021-05-13 12:31:04 -0700 | [diff] [blame] | 288 | NumPonPorts := Dev.resourceMgr[0].DevInfo.GetPonPorts() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 289 | Ports, _ = InitPorts(ctx, "pon", Dev.device.Id, NumPonPorts) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 290 | StatMgr.SouthBoundPort, _ = Ports.(map[uint32]*PonPort) |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 291 | if StatMgr.Device.openOLT.enableONUStats { |
| 292 | go StatMgr.publishOnuStats() |
| 293 | } |
| 294 | if StatMgr.Device.openOLT.enableGemStats { |
| 295 | go StatMgr.publishGemStats() |
| 296 | } |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 297 | StatMgr.statIndListners = make(map[StatType]*list.List) |
| 298 | StatMgr.statIndListners[portStatsType] = list.New() |
| 299 | StatMgr.statIndListners[flowStatsType] = list.New() |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 300 | return &StatMgr |
| 301 | } |
| 302 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 303 | // InitPorts collects the port objects: nni and pon that are updated with the current data from the OLT |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 304 | func InitPorts(ctx context.Context, Intftype string, DeviceID string, numOfPorts uint32) (interface{}, error) { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 305 | /* |
| 306 | This method collects the port objects: nni and pon that are updated with the |
| 307 | current data from the OLT |
| 308 | |
| 309 | Both the northbound (nni) and southbound ports are indexed by the interface id (intf_id) |
| 310 | and NOT the port number. When the port object is instantiated it will contain the intf_id and |
| 311 | port_no values |
| 312 | |
| 313 | :param type: |
| 314 | :return: |
| 315 | */ |
| 316 | var i uint32 |
| 317 | if Intftype == "nni" { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 318 | NniPorts := make(map[uint32]*NniPort) |
| 319 | for i = 0; i < numOfPorts; i++ { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 320 | Port := BuildPortObject(ctx, i, "nni", DeviceID).(*NniPort) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 321 | NniPorts[Port.IntfID] = Port |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 322 | } |
| 323 | return NniPorts, nil |
| 324 | } else if Intftype == "pon" { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 325 | PONPorts := make(map[uint32]*PonPort) |
| 326 | for i = 0; i < numOfPorts; i++ { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 327 | PONPort := BuildPortObject(ctx, i, "pon", DeviceID).(*PonPort) |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 328 | PONPorts[plt.PortNoToIntfID(PONPort.IntfID, voltha.Port_PON_OLT)] = PONPort |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 329 | } |
| 330 | return PONPorts, nil |
| 331 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 332 | logger.Errorw(ctx, "invalid-type-of-interface", log.Fields{"interface-type": Intftype}) |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 333 | return nil, olterrors.NewErrInvalidValue(log.Fields{"interface-type": Intftype}, nil) |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 337 | // BuildPortObject allows for updating north and southbound ports, newly discovered ports, and devices |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 338 | func BuildPortObject(ctx context.Context, PortNum uint32, IntfType string, DeviceID string) interface{} { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 339 | /* |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 340 | Separate method to allow for updating north and southbound ports |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 341 | newly discovered ports and devices |
| 342 | |
| 343 | :param port_num: |
| 344 | :param type: |
| 345 | :return: |
| 346 | */ |
| 347 | |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 348 | // This builds a port object which is added to the |
| 349 | // appropriate northbound or southbound values |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 350 | if IntfType == "nni" { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 351 | IntfID := plt.IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI) |
| 352 | nniID := plt.PortNoToIntfID(IntfID, voltha.Port_ETHERNET_NNI) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 353 | logger.Debugw(ctx, "interface-type-nni", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 354 | log.Fields{ |
| 355 | "nni-id": nniID, |
| 356 | "intf-type": IntfType}) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 357 | return NewNniPort(PortNum, nniID) |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 358 | } else if IntfType == "pon" { |
| 359 | // PON ports require a different configuration |
| 360 | // intf_id and pon_id are currently equal. |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 361 | IntfID := plt.IntfIDToPortNo(PortNum, voltha.Port_PON_OLT) |
| 362 | PONID := plt.PortNoToIntfID(IntfID, voltha.Port_PON_OLT) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 363 | logger.Debugw(ctx, "interface-type-pon", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 364 | log.Fields{ |
| 365 | "pon-id": PONID, |
| 366 | "intf-type": IntfType}) |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 367 | return NewPONPort(PONID, DeviceID, IntfID, PortNum) |
| 368 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 369 | logger.Errorw(ctx, "invalid-type-of-interface", log.Fields{"intf-type": IntfType}) |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 370 | return nil |
| 371 | } |
| 372 | } |
| 373 | |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 374 | // collectNNIMetrics will collect the nni port metrics |
| 375 | func (StatMgr *OpenOltStatisticsMgr) collectNNIMetrics(nniID uint32) map[string]float32 { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 376 | nnival := make(map[string]float32) |
| 377 | mutex.Lock() |
| 378 | cm := StatMgr.Device.portStats.NorthBoundPort[nniID] |
| 379 | mutex.Unlock() |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 380 | metricNames := StatMgr.Device.metrics.GetSubscriberMetrics() |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 381 | |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 382 | var metrics []string |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 383 | for metric := range metricNames { |
| 384 | if metricNames[metric].Enabled { |
| 385 | metrics = append(metrics, metric) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 386 | } |
| 387 | } |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 388 | |
| 389 | for _, mName := range metrics { |
| 390 | switch mName { |
| 391 | case "rx_bytes": |
| 392 | nnival["RxBytes"] = float32(cm.RxBytes) |
| 393 | case "rx_packets": |
| 394 | nnival["RxPackets"] = float32(cm.RxPackets) |
| 395 | case "rx_ucast_packets": |
| 396 | nnival["RxUcastPackets"] = float32(cm.RxUcastPackets) |
| 397 | case "rx_mcast_packets": |
| 398 | nnival["RxMcastPackets"] = float32(cm.RxMcastPackets) |
| 399 | case "rx_bcast_packets": |
| 400 | nnival["RxBcastPackets"] = float32(cm.RxBcastPackets) |
| 401 | case "tx_bytes": |
| 402 | nnival["TxBytes"] = float32(cm.TxBytes) |
| 403 | case "tx_packets": |
| 404 | nnival["TxPackets"] = float32(cm.TxPackets) |
| 405 | case "tx_mcast_packets": |
| 406 | nnival["TxMcastPackets"] = float32(cm.TxMcastPackets) |
| 407 | case "tx_bcast_packets": |
| 408 | nnival["TxBcastPackets"] = float32(cm.TxBcastPackets) |
| 409 | } |
| 410 | } |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 411 | return nnival |
| 412 | } |
| 413 | |
| 414 | // collectPONMetrics will collect the pon port metrics |
| 415 | func (StatMgr *OpenOltStatisticsMgr) collectPONMetrics(pID uint32) map[string]float32 { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 416 | ponval := make(map[string]float32) |
| 417 | mutex.Lock() |
| 418 | cm := StatMgr.Device.portStats.SouthBoundPort[pID] |
| 419 | mutex.Unlock() |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 420 | metricNames := StatMgr.Device.metrics.GetSubscriberMetrics() |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 421 | |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 422 | var metrics []string |
Kent Hagerman | e6ff101 | 2020-07-14 15:07:53 -0400 | [diff] [blame] | 423 | for metric := range metricNames { |
| 424 | if metricNames[metric].Enabled { |
| 425 | metrics = append(metrics, metric) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 426 | } |
| 427 | } |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 428 | |
| 429 | for _, mName := range metrics { |
| 430 | switch mName { |
| 431 | case "rx_bytes": |
| 432 | ponval["RxBytes"] = float32(cm.RxBytes) |
| 433 | case "rx_packets": |
| 434 | ponval["RxPackets"] = float32(cm.RxPackets) |
| 435 | case "rx_ucast_packets": |
| 436 | ponval["RxUcastPackets"] = float32(cm.RxUcastPackets) |
| 437 | case "rx_mcast_packets": |
| 438 | ponval["RxMcastPackets"] = float32(cm.RxMcastPackets) |
| 439 | case "rx_bcast_packets": |
| 440 | ponval["RxBcastPackets"] = float32(cm.RxBcastPackets) |
| 441 | case "tx_bytes": |
| 442 | ponval["TxBytes"] = float32(cm.TxBytes) |
| 443 | case "tx_packets": |
| 444 | ponval["TxPackets"] = float32(cm.TxPackets) |
| 445 | case "tx_mcast_packets": |
| 446 | ponval["TxMcastPackets"] = float32(cm.TxMcastPackets) |
| 447 | case "tx_bcast_packets": |
| 448 | ponval["TxBcastPackets"] = float32(cm.TxBcastPackets) |
| 449 | } |
| 450 | } |
| 451 | |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 452 | return ponval |
| 453 | } |
| 454 | |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 455 | // converGemStats will convert gem stats response to kpi context |
| 456 | func (StatMgr *OpenOltStatisticsMgr) convertGemStats(gemStats *openolt.GemPortStatistics) map[string]float32 { |
| 457 | gemStatsVal := make(map[string]float32) |
| 458 | gemStatsVal[IntfID] = float32(gemStats.IntfId) |
| 459 | gemStatsVal[GemID] = float32(gemStats.GemportId) |
| 460 | gemStatsVal[RxPackets] = float32(gemStats.RxPackets) |
| 461 | gemStatsVal[RxBytes] = float32(gemStats.RxBytes) |
| 462 | gemStatsVal[TxPackets] = float32(gemStats.TxPackets) |
| 463 | gemStatsVal[TxBytes] = float32(gemStats.TxBytes) |
| 464 | return gemStatsVal |
| 465 | } |
| 466 | |
| 467 | // convertONUStats will convert onu stats response to kpi context |
| 468 | func (StatMgr *OpenOltStatisticsMgr) convertONUStats(onuStats *openolt.OnuStatistics) map[string]float32 { |
| 469 | onuStatsVal := make(map[string]float32) |
| 470 | onuStatsVal[IntfID] = float32(onuStats.IntfId) |
| 471 | onuStatsVal[OnuID] = float32(onuStats.OnuId) |
| 472 | onuStatsVal[PositiveDrift] = float32(onuStats.PositiveDrift) |
| 473 | onuStatsVal[NegativeDrift] = float32(onuStats.NegativeDrift) |
| 474 | onuStatsVal[DelimiterMissDetection] = float32(onuStats.DelimiterMissDetection) |
| 475 | onuStatsVal[BipErrors] = float32(onuStats.BipErrors) |
| 476 | onuStatsVal[BipUnits] = float32(onuStats.BipUnits) |
| 477 | onuStatsVal[FecCorrectedSymbols] = float32(onuStats.FecCorrectedSymbols) |
| 478 | onuStatsVal[FecCodewordsCorrected] = float32(onuStats.FecCodewordsCorrected) |
| 479 | onuStatsVal[fecCodewordsUncorrectable] = float32(onuStats.FecCodewordsUncorrectable) |
| 480 | onuStatsVal[FecCodewords] = float32(onuStats.FecCodewords) |
| 481 | onuStatsVal[FecCorrectedUnits] = float32(onuStats.FecCorrectedUnits) |
| 482 | onuStatsVal[XGEMKeyErrors] = float32(onuStats.XgemKeyErrors) |
| 483 | onuStatsVal[XGEMLoss] = float32(onuStats.XgemLoss) |
| 484 | onuStatsVal[RxPloamsError] = float32(onuStats.RxPloamsError) |
| 485 | onuStatsVal[RxPloamsNonIdle] = float32(onuStats.RxPloamsNonIdle) |
| 486 | onuStatsVal[RxOmci] = float32(onuStats.RxOmci) |
| 487 | onuStatsVal[RxOmciPacketsCrcError] = float32(onuStats.RxOmciPacketsCrcError) |
| 488 | onuStatsVal[RxBytes] = float32(onuStats.RxBytes) |
| 489 | onuStatsVal[RxPackets] = float32(onuStats.RxPackets) |
| 490 | onuStatsVal[TxBytes] = float32(onuStats.TxBytes) |
| 491 | onuStatsVal[TxPackets] = float32(onuStats.TxPackets) |
| 492 | onuStatsVal[BerReported] = float32(onuStats.BerReported) |
| 493 | onuStatsVal[LcdgErrors] = float32(onuStats.LcdgErrors) |
| 494 | onuStatsVal[RdiErrors] = float32(onuStats.RdiErrors) |
Himani Chawla | 2c8ae0f | 2021-05-18 23:27:00 +0530 | [diff] [blame] | 495 | onuStatsVal[Timestamp] = float32(onuStats.Timestamp) |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 496 | return onuStatsVal |
| 497 | } |
| 498 | |
| 499 | // collectOnuStats will collect the onu metrics |
| 500 | func (StatMgr *OpenOltStatisticsMgr) collectOnuStats(ctx context.Context, onuGemInfo rsrcMgr.OnuGemInfo) { |
| 501 | onu := &openolt.Onu{IntfId: onuGemInfo.IntfID, OnuId: onuGemInfo.OnuID} |
| 502 | logger.Debugw(ctx, "pulling-onu-stats", log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID}) |
| 503 | if stats, err := StatMgr.Device.Client.GetOnuStatistics(context.Background(), onu); err == nil { |
| 504 | onuStats <- stats |
| 505 | } else { |
| 506 | logger.Errorw(ctx, "error-while-getting-onu-stats-for-onu", log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID, "err": err}) |
| 507 | } |
| 508 | } |
| 509 | |
Himani Chawla | 2c8ae0f | 2021-05-18 23:27:00 +0530 | [diff] [blame] | 510 | // collectOnDemandOnuStats will collect the onui-pon metrics |
| 511 | func (StatMgr *OpenOltStatisticsMgr) collectOnDemandOnuStats(ctx context.Context, intfID uint32, onuID uint32) map[string]float32 { |
| 512 | onu := &openolt.Onu{IntfId: intfID, OnuId: onuID} |
| 513 | var stats *openolt.OnuStatistics |
| 514 | var err error |
| 515 | logger.Debugw(ctx, "pulling-onu-stats-on-demand", log.Fields{"IntfID": intfID, "OnuID": onuID}) |
| 516 | if stats, err = StatMgr.Device.Client.GetOnuStatistics(context.Background(), onu); err == nil { |
| 517 | statValue := StatMgr.convertONUStats(stats) |
| 518 | return statValue |
Himani Chawla | 2c8ae0f | 2021-05-18 23:27:00 +0530 | [diff] [blame] | 519 | } |
| 520 | logger.Errorw(ctx, "error-while-getting-onu-stats-for-onu", log.Fields{"IntfID": intfID, "OnuID": onuID, "err": err}) |
| 521 | return nil |
| 522 | } |
| 523 | |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 524 | // collectOnuAndGemStats will collect both onu and gem metrics |
| 525 | func (StatMgr *OpenOltStatisticsMgr) collectOnuAndGemStats(ctx context.Context, onuGemInfo []rsrcMgr.OnuGemInfo) { |
| 526 | if !StatMgr.Device.openOLT.enableONUStats && !StatMgr.Device.openOLT.enableGemStats { |
| 527 | return |
| 528 | } |
| 529 | |
| 530 | for _, onuInfo := range onuGemInfo { |
| 531 | if StatMgr.Device.openOLT.enableONUStats { |
| 532 | go StatMgr.collectOnuStats(ctx, onuInfo) |
| 533 | } |
| 534 | if StatMgr.Device.openOLT.enableGemStats { |
| 535 | go StatMgr.collectGemStats(ctx, onuInfo) |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | // collectGemStats will collect gem metrics |
| 541 | func (StatMgr *OpenOltStatisticsMgr) collectGemStats(ctx context.Context, onuGemInfo rsrcMgr.OnuGemInfo) { |
| 542 | for _, gem := range onuGemInfo.GemPorts { |
| 543 | logger.Debugw(ctx, "pulling-gem-stats", log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID, "GemID": gem}) |
| 544 | onuPacket := &openolt.OnuPacket{IntfId: onuGemInfo.IntfID, OnuId: onuGemInfo.OnuID, GemportId: gem} |
| 545 | if stats, err := StatMgr.Device.Client.GetGemPortStatistics(context.Background(), onuPacket); err == nil { |
| 546 | gemStats <- stats |
| 547 | } else { |
| 548 | logger.Errorw(ctx, "error-while-getting-gem-stats-for-onu", |
| 549 | log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID, "GemID": gem, "err": err}) |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | // publishGemStats will publish the gem metrics |
| 555 | func (StatMgr *OpenOltStatisticsMgr) publishGemStats() { |
| 556 | for { |
| 557 | statValue := StatMgr.convertGemStats(<-gemStats) |
| 558 | StatMgr.publishMetrics(context.Background(), GEMStats, statValue, &voltha.Port{Label: "GEM"}, StatMgr.Device.device.Id, StatMgr.Device.device.Type) |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | // publishOnuStats will publish the onu metrics |
| 563 | func (StatMgr *OpenOltStatisticsMgr) publishOnuStats() { |
| 564 | for { |
| 565 | statValue := StatMgr.convertONUStats(<-onuStats) |
| 566 | StatMgr.publishMetrics(context.Background(), ONUStats, statValue, &voltha.Port{Label: "ONU"}, StatMgr.Device.device.Id, StatMgr.Device.device.Type) |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | // publishMetrics will publish the pon port metrics |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 571 | func (StatMgr *OpenOltStatisticsMgr) publishMetrics(ctx context.Context, statType string, val map[string]float32, |
Girish Gowdra | 34815db | 2020-05-11 17:18:04 -0700 | [diff] [blame] | 572 | port *voltha.Port, devID string, devType string) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 573 | logger.Debugw(ctx, "publish-metrics", |
Shrey Baid | 2691297 | 2020-04-16 21:02:31 +0530 | [diff] [blame] | 574 | log.Fields{ |
| 575 | "port": port.Label, |
| 576 | "metrics": val}) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 577 | |
| 578 | var metricInfo voltha.MetricInformation |
| 579 | var ke voltha.KpiEvent2 |
Esin Karaman | ccb714b | 2019-11-29 15:02:06 +0000 | [diff] [blame] | 580 | var volthaEventSubCatgry voltha.EventSubCategory_Types |
Girish Gowdra | 34815db | 2020-05-11 17:18:04 -0700 | [diff] [blame] | 581 | metricsContext := make(map[string]string) |
| 582 | metricsContext["oltid"] = devID |
| 583 | metricsContext["devicetype"] = devType |
| 584 | metricsContext["portlabel"] = port.Label |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 585 | |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 586 | if statType == NNIStats { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 587 | volthaEventSubCatgry = voltha.EventSubCategory_NNI |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 588 | } else if statType == PONStats { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 589 | volthaEventSubCatgry = voltha.EventSubCategory_PON |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 590 | } else if statType == GEMStats || statType == ONUStats { |
| 591 | volthaEventSubCatgry = voltha.EventSubCategory_ONT |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 592 | } |
| 593 | |
Girish Gowdra | c1b9d5e | 2021-04-22 12:47:44 -0700 | [diff] [blame] | 594 | raisedTs := time.Now().Unix() |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 595 | mmd := voltha.MetricMetaData{ |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 596 | Title: statType, |
Girish Gowdra | c1b9d5e | 2021-04-22 12:47:44 -0700 | [diff] [blame] | 597 | Ts: float64(raisedTs), |
Girish Gowdra | 34815db | 2020-05-11 17:18:04 -0700 | [diff] [blame] | 598 | Context: metricsContext, |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 599 | DeviceId: devID, |
| 600 | } |
| 601 | |
| 602 | metricInfo.Metadata = &mmd |
| 603 | metricInfo.Metrics = val |
| 604 | |
| 605 | ke.SliceData = []*voltha.MetricInformation{&metricInfo} |
| 606 | ke.Type = voltha.KpiEventType_slice |
Girish Gowdra | c1b9d5e | 2021-04-22 12:47:44 -0700 | [diff] [blame] | 607 | ke.Ts = float64(raisedTs) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 608 | |
Himani Chawla | 473496d | 2021-12-01 00:10:30 +0530 | [diff] [blame] | 609 | if err := StatMgr.Device.EventProxy.SendKpiEvent(ctx, "STATS_PUBLISH_EVENT", &ke, voltha.EventCategory_EQUIPMENT, volthaEventSubCatgry, raisedTs); err != nil { |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 610 | logger.Errorw(ctx, "failed-to-send-stats", log.Fields{"err": err}) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 611 | } |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 612 | } |
| 613 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 614 | // PortStatisticsIndication handles the port statistics indication |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 615 | func (StatMgr *OpenOltStatisticsMgr) PortStatisticsIndication(ctx context.Context, PortStats *openolt.PortStatistics, NumPonPorts uint32) { |
| 616 | StatMgr.PortsStatisticsKpis(ctx, PortStats, NumPonPorts) |
| 617 | logger.Debugw(ctx, "received-port-stats-indication", log.Fields{"port-stats": PortStats}) |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 618 | // Indicate that PortStatisticsIndication is handled |
| 619 | // PortStats.IntfId is actually the port number |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 620 | StatMgr.processStatIndication(ctx, portStatsType, PortStats.IntfId) |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 621 | // TODO send stats to core topic to the voltha kafka or a different kafka ? |
| 622 | } |
| 623 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 624 | // FlowStatisticsIndication to be implemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 625 | func FlowStatisticsIndication(ctx context.Context, self, FlowStats *openolt.FlowStatistics) { |
| 626 | logger.Debugw(ctx, "flow-stats-collected", log.Fields{"flow-stats": FlowStats}) |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 627 | // TODO send to kafka ? |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 628 | } |
| 629 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 630 | // PortsStatisticsKpis map the port stats values into a dictionary, creates the kpiEvent and then publish to Kafka |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 631 | func (StatMgr *OpenOltStatisticsMgr) PortsStatisticsKpis(ctx context.Context, PortStats *openolt.PortStatistics, NumPonPorts uint32) { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 632 | /*map the port stats values into a dictionary |
| 633 | Create a kpoEvent and publish to Kafka |
| 634 | |
| 635 | :param port_stats: |
| 636 | :return: |
| 637 | */ |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 638 | // var err error |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 639 | IntfID := PortStats.IntfId |
| 640 | |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 641 | if (plt.IntfIDToPortNo(1, voltha.Port_ETHERNET_NNI) < IntfID) && |
| 642 | (IntfID < plt.IntfIDToPortNo(4, voltha.Port_ETHERNET_NNI)) { |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 643 | /* |
| 644 | for this release we are only interested in the first NNI for |
| 645 | Northbound. |
| 646 | we are not using the other 3 |
| 647 | */ |
| 648 | return |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 649 | } else if plt.IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) == IntfID { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 650 | var portNNIStat NniPort |
| 651 | portNNIStat.IntfID = IntfID |
| 652 | portNNIStat.PortNum = uint32(0) |
| 653 | portNNIStat.RxBytes = PortStats.RxBytes |
| 654 | portNNIStat.RxPackets = PortStats.RxPackets |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 655 | portNNIStat.RxUcastPackets = PortStats.RxUcastPackets |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 656 | portNNIStat.RxMcastPackets = PortStats.RxMcastPackets |
| 657 | portNNIStat.RxBcastPackets = PortStats.RxBcastPackets |
| 658 | portNNIStat.TxBytes = PortStats.TxBytes |
| 659 | portNNIStat.TxPackets = PortStats.TxPackets |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 660 | portNNIStat.TxUcastPackets = PortStats.TxUcastPackets |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 661 | portNNIStat.TxMcastPackets = PortStats.TxMcastPackets |
| 662 | portNNIStat.TxBcastPackets = PortStats.TxBcastPackets |
| 663 | mutex.Lock() |
| 664 | StatMgr.NorthBoundPort[0] = &portNNIStat |
| 665 | mutex.Unlock() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 666 | logger.Debugw(ctx, "received-nni-stats", log.Fields{"nni-stats": StatMgr.NorthBoundPort}) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 667 | } |
| 668 | for i := uint32(0); i < NumPonPorts; i++ { |
Mahir Gunyel | 85f61c1 | 2021-10-06 11:53:45 -0700 | [diff] [blame] | 669 | if plt.IntfIDToPortNo(i, voltha.Port_PON_OLT) == IntfID { |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 670 | var portPonStat PonPort |
| 671 | portPonStat.IntfID = IntfID |
| 672 | portPonStat.PortNum = i |
| 673 | portPonStat.PONID = i |
| 674 | portPonStat.RxBytes = PortStats.RxBytes |
| 675 | portPonStat.RxPackets = PortStats.RxPackets |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 676 | portPonStat.RxUcastPackets = PortStats.RxUcastPackets |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 677 | portPonStat.RxMcastPackets = PortStats.RxMcastPackets |
| 678 | portPonStat.RxBcastPackets = PortStats.RxBcastPackets |
| 679 | portPonStat.TxBytes = PortStats.TxBytes |
| 680 | portPonStat.TxPackets = PortStats.TxPackets |
Dileep Kuchhangi | 52cfbe1 | 2020-01-15 20:16:21 +0000 | [diff] [blame] | 681 | portPonStat.TxUcastPackets = PortStats.TxUcastPackets |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 682 | portPonStat.TxMcastPackets = PortStats.TxMcastPackets |
| 683 | portPonStat.TxBcastPackets = PortStats.TxBcastPackets |
| 684 | mutex.Lock() |
| 685 | StatMgr.SouthBoundPort[i] = &portPonStat |
| 686 | mutex.Unlock() |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 687 | logger.Debugw(ctx, "received-pon-stats-for-port", log.Fields{"port-pon-stats": portPonStat}) |
Naga Manjunath | 7615e55 | 2019-10-11 22:35:47 +0530 | [diff] [blame] | 688 | } |
| 689 | } |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 690 | /* |
| 691 | Based upon the intf_id map to an nni port or a pon port |
| 692 | the intf_id is the key to the north or south bound collections |
| 693 | |
| 694 | Based upon the intf_id the port object (nni_port or pon_port) will |
| 695 | have its data attr. updated by the current dataset collected. |
| 696 | |
| 697 | For prefixing the rule is currently to use the port number and not the intf_id |
| 698 | */ |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame^] | 699 | // FIXME : Just use first NNI for now |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 700 | /* TODO should the data be marshaled before sending it ? |
| 701 | if IntfID == IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) { |
| 702 | //NNI port (just the first one) |
| 703 | err = UpdatePortObjectKpiData(StatMgr.NorthBoundPorts[PortStats.IntfID], PMData) |
| 704 | } else { |
| 705 | //PON ports |
| 706 | err = UpdatePortObjectKpiData(SouthboundPorts[PortStats.IntfID], PMData) |
| 707 | } |
| 708 | if (err != nil) { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 709 | logger.Error(ctx, "Error publishing statistics data") |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 710 | } |
| 711 | */ |
Abhilash S.L | 765ad00 | 2019-04-24 16:40:57 +0530 | [diff] [blame] | 712 | } |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 713 | |
| 714 | func (StatMgr *OpenOltStatisticsMgr) updateGetOltPortCountersResponse(ctx context.Context, singleValResp *extension.SingleGetValueResponse, stats map[string]float32) { |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 715 | metrics := singleValResp.GetResponse().GetPortCoutners() |
| 716 | metrics.TxBytes = uint64(stats["TxBytes"]) |
| 717 | metrics.RxBytes = uint64(stats["RxBytes"]) |
| 718 | metrics.TxPackets = uint64(stats["TxPackets"]) |
| 719 | metrics.RxPackets = uint64(stats["RxPackets"]) |
| 720 | metrics.TxErrorPackets = uint64(stats["TxErrorPackets"]) |
| 721 | metrics.RxErrorPackets = uint64(stats["RxErrorPackets"]) |
| 722 | metrics.TxBcastPackets = uint64(stats["TxBcastPackets"]) |
| 723 | metrics.RxBcastPackets = uint64(stats["RxBcastPackets"]) |
| 724 | metrics.TxUcastPackets = uint64(stats["TxUcastPackets"]) |
| 725 | metrics.RxUcastPackets = uint64(stats["RxUcastPackets"]) |
| 726 | metrics.TxMcastPackets = uint64(stats["TxMcastPackets"]) |
| 727 | metrics.RxMcastPackets = uint64(stats["RxMcastPackets"]) |
| 728 | |
| 729 | singleValResp.Response.Status = extension.GetValueResponse_OK |
| 730 | logger.Debugw(ctx, "updateGetOltPortCountersResponse", log.Fields{"resp": singleValResp}) |
| 731 | } |
| 732 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 733 | // RegisterForStatIndication registers ch as a channel on which indication is sent when statistics of type t is received |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 734 | func (StatMgr *OpenOltStatisticsMgr) RegisterForStatIndication(ctx context.Context, t StatType, ch chan bool, portNo uint32, portType extension.GetOltPortCounters_PortType) { |
| 735 | statInd := statRegInfo{ |
| 736 | chn: ch, |
| 737 | portNo: portNo, |
| 738 | portType: portType, |
| 739 | } |
| 740 | |
| 741 | logger.Debugf(ctx, "RegisterForStatIndication stat type %v portno %v porttype %v chan %v", t, portNo, portType, ch) |
| 742 | StatMgr.statIndListnerMu.Lock() |
| 743 | StatMgr.statIndListners[t].PushBack(statInd) |
| 744 | StatMgr.statIndListnerMu.Unlock() |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 745 | } |
| 746 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 747 | // DeRegisterFromStatIndication removes the previously registered channel ch for type t of statistics |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 748 | func (StatMgr *OpenOltStatisticsMgr) DeRegisterFromStatIndication(ctx context.Context, t StatType, ch chan bool) { |
| 749 | StatMgr.statIndListnerMu.Lock() |
| 750 | defer StatMgr.statIndListnerMu.Unlock() |
| 751 | |
| 752 | for e := StatMgr.statIndListners[t].Front(); e != nil; e = e.Next() { |
| 753 | statInd := e.Value.(statRegInfo) |
| 754 | if statInd.chn == ch { |
| 755 | StatMgr.statIndListners[t].Remove(e) |
| 756 | return |
| 757 | } |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | func (StatMgr *OpenOltStatisticsMgr) processStatIndication(ctx context.Context, t StatType, portNo uint32) { |
| 762 | var deRegList []*list.Element |
| 763 | var statInd statRegInfo |
| 764 | |
| 765 | StatMgr.statIndListnerMu.Lock() |
| 766 | defer StatMgr.statIndListnerMu.Unlock() |
| 767 | |
| 768 | if StatMgr.statIndListners[t] == nil || StatMgr.statIndListners[t].Len() == 0 { |
| 769 | logger.Debugf(ctx, "processStatIndication %v list is empty ", t) |
| 770 | return |
| 771 | } |
| 772 | |
| 773 | for e := StatMgr.statIndListners[t].Front(); e != nil; e = e.Next() { |
| 774 | statInd = e.Value.(statRegInfo) |
| 775 | if statInd.portNo != portNo { |
| 776 | fmt.Printf("Skipping %v\n", e.Value) |
| 777 | continue |
| 778 | } |
| 779 | // message sent |
| 780 | statInd.chn <- true |
| 781 | deRegList = append(deRegList, e) |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 782 | } |
| 783 | for _, e := range deRegList { |
| 784 | StatMgr.statIndListners[t].Remove(e) |
| 785 | } |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 786 | } |
Himani Chawla | 2c8ae0f | 2021-05-18 23:27:00 +0530 | [diff] [blame] | 787 | |
| 788 | func (StatMgr *OpenOltStatisticsMgr) updateGetOnuPonCountersResponse(ctx context.Context, singleValResp *extension.SingleGetValueResponse, stats map[string]float32) { |
Himani Chawla | 2c8ae0f | 2021-05-18 23:27:00 +0530 | [diff] [blame] | 789 | metrics := singleValResp.GetResponse().GetOnuPonCounters() |
| 790 | metrics.IsIntfId = &extension.GetOnuCountersResponse_IntfId{ |
| 791 | IntfId: uint32(stats[IntfID]), |
| 792 | } |
| 793 | metrics.IsOnuId = &extension.GetOnuCountersResponse_OnuId{ |
| 794 | OnuId: uint32(stats[OnuID]), |
| 795 | } |
| 796 | metrics.IsPositiveDrift = &extension.GetOnuCountersResponse_PositiveDrift{ |
| 797 | PositiveDrift: uint64(stats[PositiveDrift]), |
| 798 | } |
| 799 | metrics.IsNegativeDrift = &extension.GetOnuCountersResponse_NegativeDrift{ |
| 800 | NegativeDrift: uint64(stats[NegativeDrift]), |
| 801 | } |
| 802 | metrics.IsDelimiterMissDetection = &extension.GetOnuCountersResponse_DelimiterMissDetection{ |
| 803 | DelimiterMissDetection: uint64(stats[DelimiterMissDetection]), |
| 804 | } |
| 805 | metrics.IsBipErrors = &extension.GetOnuCountersResponse_BipErrors{ |
| 806 | BipErrors: uint64(stats[BipErrors]), |
| 807 | } |
| 808 | metrics.IsBipUnits = &extension.GetOnuCountersResponse_BipUnits{ |
| 809 | BipUnits: uint64(stats[BipUnits]), |
| 810 | } |
| 811 | metrics.IsFecCorrectedSymbols = &extension.GetOnuCountersResponse_FecCorrectedSymbols{ |
| 812 | FecCorrectedSymbols: uint64(stats[FecCorrectedSymbols]), |
| 813 | } |
| 814 | metrics.IsFecCodewordsCorrected = &extension.GetOnuCountersResponse_FecCodewordsCorrected{ |
| 815 | FecCodewordsCorrected: uint64(stats[FecCodewordsCorrected]), |
| 816 | } |
| 817 | metrics.IsFecCodewordsUncorrectable = &extension.GetOnuCountersResponse_FecCodewordsUncorrectable{ |
| 818 | FecCodewordsUncorrectable: uint64(stats[fecCodewordsUncorrectable]), |
| 819 | } |
| 820 | metrics.IsFecCodewords = &extension.GetOnuCountersResponse_FecCodewords{ |
| 821 | FecCodewords: uint64(stats[FecCodewords]), |
| 822 | } |
| 823 | metrics.IsFecCorrectedUnits = &extension.GetOnuCountersResponse_FecCorrectedUnits{ |
| 824 | FecCorrectedUnits: uint64(stats[FecCorrectedUnits]), |
| 825 | } |
| 826 | metrics.IsXgemKeyErrors = &extension.GetOnuCountersResponse_XgemKeyErrors{ |
| 827 | XgemKeyErrors: uint64(stats[XGEMKeyErrors]), |
| 828 | } |
| 829 | metrics.IsXgemLoss = &extension.GetOnuCountersResponse_XgemLoss{ |
| 830 | XgemLoss: uint64(stats[XGEMLoss]), |
| 831 | } |
| 832 | metrics.IsRxPloamsError = &extension.GetOnuCountersResponse_RxPloamsError{ |
| 833 | RxPloamsError: uint64(stats[RxPloamsError]), |
| 834 | } |
| 835 | metrics.IsRxPloamsNonIdle = &extension.GetOnuCountersResponse_RxPloamsNonIdle{ |
| 836 | RxPloamsNonIdle: uint64(stats[RxPloamsNonIdle]), |
| 837 | } |
| 838 | metrics.IsRxOmci = &extension.GetOnuCountersResponse_RxOmci{ |
| 839 | RxOmci: uint64(stats[RxOmci]), |
| 840 | } |
| 841 | metrics.IsRxOmciPacketsCrcError = &extension.GetOnuCountersResponse_RxOmciPacketsCrcError{ |
| 842 | RxOmciPacketsCrcError: uint64(stats[RxOmciPacketsCrcError]), |
| 843 | } |
| 844 | metrics.IsRxBytes = &extension.GetOnuCountersResponse_RxBytes{ |
| 845 | RxBytes: uint64(stats[RxBytes]), |
| 846 | } |
| 847 | metrics.IsRxPackets = &extension.GetOnuCountersResponse_RxPackets{ |
| 848 | RxPackets: uint64(stats[RxPackets]), |
| 849 | } |
| 850 | metrics.IsTxBytes = &extension.GetOnuCountersResponse_TxBytes{ |
| 851 | TxBytes: uint64(stats[TxBytes]), |
| 852 | } |
| 853 | metrics.IsTxPackets = &extension.GetOnuCountersResponse_TxPackets{ |
| 854 | TxPackets: uint64(stats[TxPackets]), |
| 855 | } |
| 856 | metrics.IsBerReported = &extension.GetOnuCountersResponse_BerReported{ |
| 857 | BerReported: uint64(stats[BerReported]), |
| 858 | } |
| 859 | metrics.IsLcdgErrors = &extension.GetOnuCountersResponse_LcdgErrors{ |
| 860 | LcdgErrors: uint64(stats[LcdgErrors]), |
| 861 | } |
| 862 | metrics.IsRdiErrors = &extension.GetOnuCountersResponse_RdiErrors{ |
| 863 | RdiErrors: uint64(stats[RdiErrors]), |
| 864 | } |
| 865 | metrics.IsTimestamp = &extension.GetOnuCountersResponse_Timestamp{ |
| 866 | Timestamp: uint32(stats[Timestamp]), |
| 867 | } |
| 868 | |
| 869 | singleValResp.Response.Status = extension.GetValueResponse_OK |
| 870 | logger.Debugw(ctx, "updateGetOnuPonCountersResponse", log.Fields{"resp": singleValResp}) |
| 871 | } |