blob: c9e15eb6088b21e23b4238683c490a174bf0924f [file] [log] [blame]
Abhilash S.L765ad002019-04-24 16:40:57 +05301/*
Joey Armstrong11f5a572024-01-12 19:11:32 -05002 * Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors
Abhilash S.L765ad002019-04-24 16:40:57 +05303
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 Gowdru6a80bbd2019-07-02 07:36:09 -070016
Joey Armstrong3f0e2422023-07-05 18:25:41 -040017// Package core provides the utility for olt devices, flows and statistics
Scott Bakerdbd960e2020-02-28 08:57:51 -080018package core
Abhilash S.L765ad002019-04-24 16:40:57 +053019
20import (
kesavand62126212021-01-12 04:56:06 -050021 "container/list"
Neha Sharma96b7bf22020-06-15 10:37:32 +000022 "context"
Abhilash S.L765ad002019-04-24 16:40:57 +053023 "fmt"
Shrey Baid26912972020-04-16 21:02:31 +053024 "sync"
25 "time"
26
Mahir Gunyel85f61c12021-10-06 11:53:45 -070027 plt "github.com/opencord/voltha-lib-go/v7/pkg/platform"
khenaidoo106c61a2021-08-11 18:05:46 -040028 rsrcMgr "github.com/opencord/voltha-openolt-adapter/internal/pkg/resourcemanager"
29
30 "github.com/opencord/voltha-lib-go/v7/pkg/log"
Thomas Lee S94109f12020-03-03 16:39:29 +053031 "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
khenaidoo106c61a2021-08-11 18:05:46 -040032 "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.L765ad002019-04-24 16:40:57 +053035)
36
Gamze Abakafcbd6e72020-12-17 13:25:16 +000037const (
38 //NNIStats statType constant
39 NNIStats = "NNIStats"
40 //PONStats statType constant
41 PONStats = "PONStats"
42 //ONUStats statType constant
43 ONUStats = "ONUStats"
44 //GEMStats statType constant
45 GEMStats = "GEMStats"
46
47 //RxBytes constant
48 RxBytes = "RxBytes"
49 //RxPackets constant
50 RxPackets = "RxPackets"
51 //TxBytes constant
52 TxBytes = "TxBytes"
53 //TxPackets constant
54 TxPackets = "TxPackets"
55 //FecCodewords constant
56 FecCodewords = "FecCodewords"
57 //BipUnits constant
58 BipUnits = "BipUnits"
59 //BipErrors constant
60 BipErrors = "BipErrors"
61 //RxPloamsNonIdle constant
62 RxPloamsNonIdle = "RxPloamsNonIdle"
63 //RxPloamsError constant
64 RxPloamsError = "RxPloamsError"
65 //RxOmci constant
66 RxOmci = "RxOmci"
67 //RxOmciPacketsCrcError constant
68 RxOmciPacketsCrcError = "RxOmciPacketsCrcError"
69 //PositiveDrift constant
70 PositiveDrift = "PositiveDrift"
71 //NegativeDrift constant
72 NegativeDrift = "NegativeDrift"
73 //DelimiterMissDetection constant
74 DelimiterMissDetection = "DelimiterMissDetection"
75 //FecCorrectedSymbols constant
76 FecCorrectedSymbols = "FecCorrectedSymbols"
77 //FecCodewordsCorrected constant
78 FecCodewordsCorrected = "FecCodewordsCorrected"
79 //fecCodewordsUncorrectable constant
80 fecCodewordsUncorrectable = "fec_codewords_uncorrectable"
81 //FecCorrectedUnits constant
82 FecCorrectedUnits = "FecCorrectedUnits"
83 //XGEMKeyErrors constant
84 XGEMKeyErrors = "XGEMKeyErrors"
85 //XGEMLoss constant
86 XGEMLoss = "XGEMLOSS"
87 //BerReported constant
88 BerReported = "BerReported"
89 //LcdgErrors constant
90 LcdgErrors = "LcdgErrors"
91 //RdiErrors constant
92 RdiErrors = "RdiErrors"
Himani Chawla2c8ae0f2021-05-18 23:27:00 +053093 //Timestamp constant
94 Timestamp = "Timestamp"
Gamze Abakafcbd6e72020-12-17 13:25:16 +000095)
96
Naga Manjunath7615e552019-10-11 22:35:47 +053097var mutex = &sync.Mutex{}
98
Gamze Abakafcbd6e72020-12-17 13:25:16 +000099var onuStats = make(chan *openolt.OnuStatistics, 100)
100var gemStats = make(chan *openolt.GemPortStatistics, 100)
101
Joey Armstrong3f0e2422023-07-05 18:25:41 -0400102// statRegInfo is used to register for notifications
103// on receiving port stats and flow stats indication
kesavand62126212021-01-12 04:56:06 -0500104type statRegInfo struct {
105 chn chan bool
106 portNo uint32
107 portType extension.GetOltPortCounters_PortType
108}
109
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700110// PonPort representation
Abhilash S.L765ad002019-04-24 16:40:57 +0530111type PonPort struct {
112 /*
113 This is a highly reduced version taken from the adtran pon_port.
114 TODO: Extend for use in the openolt adapter set.
115 */
116 /* MAX_ONUS_SUPPORTED = 256
117 DEFAULT_ENABLED = False
118 MAX_DEPLOYMENT_RANGE = 25000 # Meters (OLT-PB maximum)
119
120 _MCAST_ONU_ID = 253
121 _MCAST_ALLOC_BASE = 0x500
122
123 _SUPPORTED_ACTIVATION_METHODS = ['autodiscovery'] # , 'autoactivate']
124 _SUPPORTED_AUTHENTICATION_METHODS = ['serial-number']
125 */
126 PONID uint32
127 DeviceID string
128 IntfID uint32
129 PortNum uint32
130 PortID uint32
131 Label string
132 ONUs map[uint32]interface{}
133 ONUsByID map[uint32]interface{}
134
135 RxBytes uint64
136 RxPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000137 RxUcastPackets uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530138 RxMcastPackets uint64
139 RxBcastPackets uint64
140 RxErrorPackets uint64
141 TxBytes uint64
142 TxPackets uint64
143 TxUcastPackets uint64
144 TxMcastPackets uint64
145 TxBcastPackets uint64
146 TxErrorPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000147 RxCrcErrors uint64
148 BipErrors uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530149}
150
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700151// NewPONPort returns a new instance of PonPort initialized with given PONID, DeviceID, IntfID and PortNum
Abhilash S.L765ad002019-04-24 16:40:57 +0530152func NewPONPort(PONID uint32, DeviceID string, IntfID uint32, PortNum uint32) *PonPort {
153
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 Manjunath7615e552019-10-11 22:35:47 +0530161 PON.Label = fmt.Sprintf("%s%d", "pon-", PONID)
Abhilash S.L765ad002019-04-24 16:40:57 +0530162
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 Kuchhangi52cfbe12020-01-15 20:16:21 +0000181 PON.RxUcastPackets = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530182 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 Kuchhangi52cfbe12020-01-15 20:16:21 +0000191 PON.RxCrcErrors = 0
192 PON.BipErrors = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530193
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 Gowdru6a80bbd2019-07-02 07:36:09 -0700203// NniPort representation
Abhilash S.L765ad002019-04-24 16:40:57 +0530204type NniPort struct {
205 /*
206 Northbound network port, often Ethernet-based
207
208 This is a highly reduced version taken from the adtran nni_port code set
209 TODO: add functions to allow for port specific values and operations
210 */
211 PortNum uint32
212 Name string
213 LogicalPort uint32
214 IntfID uint32
215
216 RxBytes uint64
217 RxPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000218 RxUcastPackets uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530219 RxMcastPackets uint64
220 RxBcastPackets uint64
221 RxErrorPackets uint64
222 TxBytes uint64
223 TxPackets uint64
224 TxUcastPackets uint64
225 TxMcastPackets uint64
226 TxBcastPackets uint64
227 TxErrorPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000228 RxCrcErrors uint64
229 BipErrors uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530230}
231
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700232// NewNniPort returns a new instance of NniPort initialized with the given PortNum and IntfID
Abhilash S.L765ad002019-04-24 16:40:57 +0530233func NewNniPort(PortNum uint32, IntfID uint32) *NniPort {
234
235 var NNI NniPort
236
237 NNI.PortNum = PortNum
Naga Manjunath7615e552019-10-11 22:35:47 +0530238 NNI.Name = fmt.Sprintf("%s%d", "nni-", PortNum)
Abhilash S.L765ad002019-04-24 16:40:57 +0530239 NNI.IntfID = IntfID
240
241 NNI.RxBytes = 0
242 NNI.RxPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000243 NNI.RxUcastPackets = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530244 NNI.RxMcastPackets = 0
245 NNI.RxBcastPackets = 0
246 NNI.RxErrorPackets = 0
247 NNI.TxBytes = 0
248 NNI.TxPackets = 0
249 NNI.TxUcastPackets = 0
250 NNI.TxMcastPackets = 0
251 NNI.TxBcastPackets = 0
252 NNI.TxErrorPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000253 NNI.RxCrcErrors = 0
254 NNI.BipErrors = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530255
256 return &NNI
257}
258
Joey Armstrong3f0e2422023-07-05 18:25:41 -0400259// StatType defines portStatsType and flowStatsType types
kesavand62126212021-01-12 04:56:06 -0500260type StatType int
261
262const (
263 portStatsType StatType = iota
264 flowStatsType
265)
266
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700267// OpenOltStatisticsMgr structure
Abhilash S.L765ad002019-04-24 16:40:57 +0530268type OpenOltStatisticsMgr struct {
269 Device *DeviceHandler
Naga Manjunath7615e552019-10-11 22:35:47 +0530270 NorthBoundPort map[uint32]*NniPort
271 SouthBoundPort map[uint32]*PonPort
Abhilash S.L765ad002019-04-24 16:40:57 +0530272 // TODO PMMetrics Metrics
kesavand62126212021-01-12 04:56:06 -0500273 //statIndListners is the list of requests to be notified when port and flow stats indication is received
274 statIndListnerMu sync.Mutex
275 statIndListners map[StatType]*list.List
Abhilash S.L765ad002019-04-24 16:40:57 +0530276}
277
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700278// NewOpenOltStatsMgr returns a new instance of the OpenOltStatisticsMgr
Neha Sharma96b7bf22020-06-15 10:37:32 +0000279func NewOpenOltStatsMgr(ctx context.Context, Dev *DeviceHandler) *OpenOltStatisticsMgr {
Abhilash S.L765ad002019-04-24 16:40:57 +0530280
281 var StatMgr OpenOltStatisticsMgr
282
283 StatMgr.Device = Dev
284 // TODO call metric PMMetric =
285 // Northbound and Southbound ports
286 // added to initialize the pm_metrics
287 var Ports interface{}
Neha Sharma96b7bf22020-06-15 10:37:32 +0000288 Ports, _ = InitPorts(ctx, "nni", Dev.device.Id, 1)
Naga Manjunath7615e552019-10-11 22:35:47 +0530289 StatMgr.NorthBoundPort, _ = Ports.(map[uint32]*NniPort)
Girish Gowdra8a0bdcd2021-05-13 12:31:04 -0700290 NumPonPorts := Dev.resourceMgr[0].DevInfo.GetPonPorts()
Neha Sharma96b7bf22020-06-15 10:37:32 +0000291 Ports, _ = InitPorts(ctx, "pon", Dev.device.Id, NumPonPorts)
Naga Manjunath7615e552019-10-11 22:35:47 +0530292 StatMgr.SouthBoundPort, _ = Ports.(map[uint32]*PonPort)
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000293 if StatMgr.Device.openOLT.enableONUStats {
294 go StatMgr.publishOnuStats()
295 }
296 if StatMgr.Device.openOLT.enableGemStats {
297 go StatMgr.publishGemStats()
298 }
kesavand62126212021-01-12 04:56:06 -0500299 StatMgr.statIndListners = make(map[StatType]*list.List)
300 StatMgr.statIndListners[portStatsType] = list.New()
301 StatMgr.statIndListners[flowStatsType] = list.New()
Abhilash S.L765ad002019-04-24 16:40:57 +0530302 return &StatMgr
303}
304
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700305// InitPorts collects the port objects: nni and pon that are updated with the current data from the OLT
Neha Sharma96b7bf22020-06-15 10:37:32 +0000306func InitPorts(ctx context.Context, Intftype string, DeviceID string, numOfPorts uint32) (interface{}, error) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530307 /*
308 This method collects the port objects: nni and pon that are updated with the
309 current data from the OLT
310
311 Both the northbound (nni) and southbound ports are indexed by the interface id (intf_id)
312 and NOT the port number. When the port object is instantiated it will contain the intf_id and
313 port_no values
314
315 :param type:
316 :return:
317 */
318 var i uint32
319 if Intftype == "nni" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530320 NniPorts := make(map[uint32]*NniPort)
321 for i = 0; i < numOfPorts; i++ {
Neha Sharma96b7bf22020-06-15 10:37:32 +0000322 Port := BuildPortObject(ctx, i, "nni", DeviceID).(*NniPort)
Naga Manjunath7615e552019-10-11 22:35:47 +0530323 NniPorts[Port.IntfID] = Port
Abhilash S.L765ad002019-04-24 16:40:57 +0530324 }
325 return NniPorts, nil
326 } else if Intftype == "pon" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530327 PONPorts := make(map[uint32]*PonPort)
328 for i = 0; i < numOfPorts; i++ {
Neha Sharma96b7bf22020-06-15 10:37:32 +0000329 PONPort := BuildPortObject(ctx, i, "pon", DeviceID).(*PonPort)
Mahir Gunyel85f61c12021-10-06 11:53:45 -0700330 PONPorts[plt.PortNoToIntfID(PONPort.IntfID, voltha.Port_PON_OLT)] = PONPort
Abhilash S.L765ad002019-04-24 16:40:57 +0530331 }
332 return PONPorts, nil
333 } else {
Neha Sharma96b7bf22020-06-15 10:37:32 +0000334 logger.Errorw(ctx, "invalid-type-of-interface", log.Fields{"interface-type": Intftype})
Thomas Lee S94109f12020-03-03 16:39:29 +0530335 return nil, olterrors.NewErrInvalidValue(log.Fields{"interface-type": Intftype}, nil)
Abhilash S.L765ad002019-04-24 16:40:57 +0530336 }
337}
338
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700339// BuildPortObject allows for updating north and southbound ports, newly discovered ports, and devices
Neha Sharma96b7bf22020-06-15 10:37:32 +0000340func BuildPortObject(ctx context.Context, PortNum uint32, IntfType string, DeviceID string) interface{} {
Abhilash S.L765ad002019-04-24 16:40:57 +0530341 /*
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700342 Separate method to allow for updating north and southbound ports
Abhilash S.L765ad002019-04-24 16:40:57 +0530343 newly discovered ports and devices
344
345 :param port_num:
346 :param type:
347 :return:
348 */
349
350 //This builds a port object which is added to the
351 //appropriate northbound or southbound values
352 if IntfType == "nni" {
Mahir Gunyel85f61c12021-10-06 11:53:45 -0700353 IntfID := plt.IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
354 nniID := plt.PortNoToIntfID(IntfID, voltha.Port_ETHERNET_NNI)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000355 logger.Debugw(ctx, "interface-type-nni",
Shrey Baid26912972020-04-16 21:02:31 +0530356 log.Fields{
357 "nni-id": nniID,
358 "intf-type": IntfType})
Naga Manjunath7615e552019-10-11 22:35:47 +0530359 return NewNniPort(PortNum, nniID)
Abhilash S.L765ad002019-04-24 16:40:57 +0530360 } else if IntfType == "pon" {
361 // PON ports require a different configuration
362 // intf_id and pon_id are currently equal.
Mahir Gunyel85f61c12021-10-06 11:53:45 -0700363 IntfID := plt.IntfIDToPortNo(PortNum, voltha.Port_PON_OLT)
364 PONID := plt.PortNoToIntfID(IntfID, voltha.Port_PON_OLT)
Neha Sharma96b7bf22020-06-15 10:37:32 +0000365 logger.Debugw(ctx, "interface-type-pon",
Shrey Baid26912972020-04-16 21:02:31 +0530366 log.Fields{
367 "pon-id": PONID,
368 "intf-type": IntfType})
Abhilash S.L765ad002019-04-24 16:40:57 +0530369 return NewPONPort(PONID, DeviceID, IntfID, PortNum)
370 } else {
Neha Sharma96b7bf22020-06-15 10:37:32 +0000371 logger.Errorw(ctx, "invalid-type-of-interface", log.Fields{"intf-type": IntfType})
Abhilash S.L765ad002019-04-24 16:40:57 +0530372 return nil
373 }
374}
375
Naga Manjunath7615e552019-10-11 22:35:47 +0530376// collectNNIMetrics will collect the nni port metrics
377func (StatMgr *OpenOltStatisticsMgr) collectNNIMetrics(nniID uint32) map[string]float32 {
378
379 nnival := make(map[string]float32)
380 mutex.Lock()
381 cm := StatMgr.Device.portStats.NorthBoundPort[nniID]
382 mutex.Unlock()
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000383 metricNames := StatMgr.Device.metrics.GetSubscriberMetrics()
Naga Manjunath7615e552019-10-11 22:35:47 +0530384
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000385 var metrics []string
Kent Hagermane6ff1012020-07-14 15:07:53 -0400386 for metric := range metricNames {
387 if metricNames[metric].Enabled {
388 metrics = append(metrics, metric)
Naga Manjunath7615e552019-10-11 22:35:47 +0530389 }
390 }
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000391
392 for _, mName := range metrics {
393 switch mName {
394 case "rx_bytes":
395 nnival["RxBytes"] = float32(cm.RxBytes)
396 case "rx_packets":
397 nnival["RxPackets"] = float32(cm.RxPackets)
398 case "rx_ucast_packets":
399 nnival["RxUcastPackets"] = float32(cm.RxUcastPackets)
400 case "rx_mcast_packets":
401 nnival["RxMcastPackets"] = float32(cm.RxMcastPackets)
402 case "rx_bcast_packets":
403 nnival["RxBcastPackets"] = float32(cm.RxBcastPackets)
404 case "tx_bytes":
405 nnival["TxBytes"] = float32(cm.TxBytes)
406 case "tx_packets":
407 nnival["TxPackets"] = float32(cm.TxPackets)
408 case "tx_mcast_packets":
409 nnival["TxMcastPackets"] = float32(cm.TxMcastPackets)
410 case "tx_bcast_packets":
411 nnival["TxBcastPackets"] = float32(cm.TxBcastPackets)
412 }
413 }
Naga Manjunath7615e552019-10-11 22:35:47 +0530414 return nnival
415}
416
417// collectPONMetrics will collect the pon port metrics
418func (StatMgr *OpenOltStatisticsMgr) collectPONMetrics(pID uint32) map[string]float32 {
419
420 ponval := make(map[string]float32)
421 mutex.Lock()
422 cm := StatMgr.Device.portStats.SouthBoundPort[pID]
423 mutex.Unlock()
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000424 metricNames := StatMgr.Device.metrics.GetSubscriberMetrics()
Naga Manjunath7615e552019-10-11 22:35:47 +0530425
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000426 var metrics []string
Kent Hagermane6ff1012020-07-14 15:07:53 -0400427 for metric := range metricNames {
428 if metricNames[metric].Enabled {
429 metrics = append(metrics, metric)
Naga Manjunath7615e552019-10-11 22:35:47 +0530430 }
431 }
Rohan Agrawalda5e0b22020-05-20 11:10:26 +0000432
433 for _, mName := range metrics {
434 switch mName {
435 case "rx_bytes":
436 ponval["RxBytes"] = float32(cm.RxBytes)
437 case "rx_packets":
438 ponval["RxPackets"] = float32(cm.RxPackets)
439 case "rx_ucast_packets":
440 ponval["RxUcastPackets"] = float32(cm.RxUcastPackets)
441 case "rx_mcast_packets":
442 ponval["RxMcastPackets"] = float32(cm.RxMcastPackets)
443 case "rx_bcast_packets":
444 ponval["RxBcastPackets"] = float32(cm.RxBcastPackets)
445 case "tx_bytes":
446 ponval["TxBytes"] = float32(cm.TxBytes)
447 case "tx_packets":
448 ponval["TxPackets"] = float32(cm.TxPackets)
449 case "tx_mcast_packets":
450 ponval["TxMcastPackets"] = float32(cm.TxMcastPackets)
451 case "tx_bcast_packets":
452 ponval["TxBcastPackets"] = float32(cm.TxBcastPackets)
453 }
454 }
455
Naga Manjunath7615e552019-10-11 22:35:47 +0530456 return ponval
457}
458
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000459// converGemStats will convert gem stats response to kpi context
460func (StatMgr *OpenOltStatisticsMgr) convertGemStats(gemStats *openolt.GemPortStatistics) map[string]float32 {
461 gemStatsVal := make(map[string]float32)
462 gemStatsVal[IntfID] = float32(gemStats.IntfId)
463 gemStatsVal[GemID] = float32(gemStats.GemportId)
464 gemStatsVal[RxPackets] = float32(gemStats.RxPackets)
465 gemStatsVal[RxBytes] = float32(gemStats.RxBytes)
466 gemStatsVal[TxPackets] = float32(gemStats.TxPackets)
467 gemStatsVal[TxBytes] = float32(gemStats.TxBytes)
468 return gemStatsVal
469}
470
471// convertONUStats will convert onu stats response to kpi context
472func (StatMgr *OpenOltStatisticsMgr) convertONUStats(onuStats *openolt.OnuStatistics) map[string]float32 {
473 onuStatsVal := make(map[string]float32)
474 onuStatsVal[IntfID] = float32(onuStats.IntfId)
475 onuStatsVal[OnuID] = float32(onuStats.OnuId)
476 onuStatsVal[PositiveDrift] = float32(onuStats.PositiveDrift)
477 onuStatsVal[NegativeDrift] = float32(onuStats.NegativeDrift)
478 onuStatsVal[DelimiterMissDetection] = float32(onuStats.DelimiterMissDetection)
479 onuStatsVal[BipErrors] = float32(onuStats.BipErrors)
480 onuStatsVal[BipUnits] = float32(onuStats.BipUnits)
481 onuStatsVal[FecCorrectedSymbols] = float32(onuStats.FecCorrectedSymbols)
482 onuStatsVal[FecCodewordsCorrected] = float32(onuStats.FecCodewordsCorrected)
483 onuStatsVal[fecCodewordsUncorrectable] = float32(onuStats.FecCodewordsUncorrectable)
484 onuStatsVal[FecCodewords] = float32(onuStats.FecCodewords)
485 onuStatsVal[FecCorrectedUnits] = float32(onuStats.FecCorrectedUnits)
486 onuStatsVal[XGEMKeyErrors] = float32(onuStats.XgemKeyErrors)
487 onuStatsVal[XGEMLoss] = float32(onuStats.XgemLoss)
488 onuStatsVal[RxPloamsError] = float32(onuStats.RxPloamsError)
489 onuStatsVal[RxPloamsNonIdle] = float32(onuStats.RxPloamsNonIdle)
490 onuStatsVal[RxOmci] = float32(onuStats.RxOmci)
491 onuStatsVal[RxOmciPacketsCrcError] = float32(onuStats.RxOmciPacketsCrcError)
492 onuStatsVal[RxBytes] = float32(onuStats.RxBytes)
493 onuStatsVal[RxPackets] = float32(onuStats.RxPackets)
494 onuStatsVal[TxBytes] = float32(onuStats.TxBytes)
495 onuStatsVal[TxPackets] = float32(onuStats.TxPackets)
496 onuStatsVal[BerReported] = float32(onuStats.BerReported)
497 onuStatsVal[LcdgErrors] = float32(onuStats.LcdgErrors)
498 onuStatsVal[RdiErrors] = float32(onuStats.RdiErrors)
Himani Chawla2c8ae0f2021-05-18 23:27:00 +0530499 onuStatsVal[Timestamp] = float32(onuStats.Timestamp)
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000500 return onuStatsVal
501}
502
503// collectOnuStats will collect the onu metrics
504func (StatMgr *OpenOltStatisticsMgr) collectOnuStats(ctx context.Context, onuGemInfo rsrcMgr.OnuGemInfo) {
505 onu := &openolt.Onu{IntfId: onuGemInfo.IntfID, OnuId: onuGemInfo.OnuID}
506 logger.Debugw(ctx, "pulling-onu-stats", log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID})
507 if stats, err := StatMgr.Device.Client.GetOnuStatistics(context.Background(), onu); err == nil {
508 onuStats <- stats
509 } else {
510 logger.Errorw(ctx, "error-while-getting-onu-stats-for-onu", log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID, "err": err})
511 }
512}
513
Himani Chawla2c8ae0f2021-05-18 23:27:00 +0530514// collectOnDemandOnuStats will collect the onui-pon metrics
515func (StatMgr *OpenOltStatisticsMgr) collectOnDemandOnuStats(ctx context.Context, intfID uint32, onuID uint32) map[string]float32 {
516 onu := &openolt.Onu{IntfId: intfID, OnuId: onuID}
517 var stats *openolt.OnuStatistics
518 var err error
519 logger.Debugw(ctx, "pulling-onu-stats-on-demand", log.Fields{"IntfID": intfID, "OnuID": onuID})
520 if stats, err = StatMgr.Device.Client.GetOnuStatistics(context.Background(), onu); err == nil {
521 statValue := StatMgr.convertONUStats(stats)
522 return statValue
523
524 }
525 logger.Errorw(ctx, "error-while-getting-onu-stats-for-onu", log.Fields{"IntfID": intfID, "OnuID": onuID, "err": err})
526 return nil
527}
528
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000529// collectOnuAndGemStats will collect both onu and gem metrics
530func (StatMgr *OpenOltStatisticsMgr) collectOnuAndGemStats(ctx context.Context, onuGemInfo []rsrcMgr.OnuGemInfo) {
531 if !StatMgr.Device.openOLT.enableONUStats && !StatMgr.Device.openOLT.enableGemStats {
532 return
533 }
534
535 for _, onuInfo := range onuGemInfo {
536 if StatMgr.Device.openOLT.enableONUStats {
537 go StatMgr.collectOnuStats(ctx, onuInfo)
538 }
539 if StatMgr.Device.openOLT.enableGemStats {
540 go StatMgr.collectGemStats(ctx, onuInfo)
541 }
542 }
543}
544
545// collectGemStats will collect gem metrics
546func (StatMgr *OpenOltStatisticsMgr) collectGemStats(ctx context.Context, onuGemInfo rsrcMgr.OnuGemInfo) {
547 for _, gem := range onuGemInfo.GemPorts {
548 logger.Debugw(ctx, "pulling-gem-stats", log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID, "GemID": gem})
549 onuPacket := &openolt.OnuPacket{IntfId: onuGemInfo.IntfID, OnuId: onuGemInfo.OnuID, GemportId: gem}
550 if stats, err := StatMgr.Device.Client.GetGemPortStatistics(context.Background(), onuPacket); err == nil {
551 gemStats <- stats
552 } else {
553 logger.Errorw(ctx, "error-while-getting-gem-stats-for-onu",
554 log.Fields{"IntfID": onuGemInfo.IntfID, "OnuID": onuGemInfo.OnuID, "GemID": gem, "err": err})
555 }
556 }
557}
558
559// publishGemStats will publish the gem metrics
560func (StatMgr *OpenOltStatisticsMgr) publishGemStats() {
561 for {
562 statValue := StatMgr.convertGemStats(<-gemStats)
563 StatMgr.publishMetrics(context.Background(), GEMStats, statValue, &voltha.Port{Label: "GEM"}, StatMgr.Device.device.Id, StatMgr.Device.device.Type)
564 }
565}
566
567// publishOnuStats will publish the onu metrics
568func (StatMgr *OpenOltStatisticsMgr) publishOnuStats() {
569 for {
570 statValue := StatMgr.convertONUStats(<-onuStats)
571 StatMgr.publishMetrics(context.Background(), ONUStats, statValue, &voltha.Port{Label: "ONU"}, StatMgr.Device.device.Id, StatMgr.Device.device.Type)
572 }
573}
574
575// publishMetrics will publish the pon port metrics
kesavand62126212021-01-12 04:56:06 -0500576func (StatMgr *OpenOltStatisticsMgr) publishMetrics(ctx context.Context, statType string, val map[string]float32,
Girish Gowdra34815db2020-05-11 17:18:04 -0700577 port *voltha.Port, devID string, devType string) {
Neha Sharma96b7bf22020-06-15 10:37:32 +0000578 logger.Debugw(ctx, "publish-metrics",
Shrey Baid26912972020-04-16 21:02:31 +0530579 log.Fields{
580 "port": port.Label,
581 "metrics": val})
Naga Manjunath7615e552019-10-11 22:35:47 +0530582
583 var metricInfo voltha.MetricInformation
584 var ke voltha.KpiEvent2
Esin Karamanccb714b2019-11-29 15:02:06 +0000585 var volthaEventSubCatgry voltha.EventSubCategory_Types
Girish Gowdra34815db2020-05-11 17:18:04 -0700586 metricsContext := make(map[string]string)
587 metricsContext["oltid"] = devID
588 metricsContext["devicetype"] = devType
589 metricsContext["portlabel"] = port.Label
Naga Manjunath7615e552019-10-11 22:35:47 +0530590
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000591 if statType == NNIStats {
Naga Manjunath7615e552019-10-11 22:35:47 +0530592 volthaEventSubCatgry = voltha.EventSubCategory_NNI
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000593 } else if statType == PONStats {
Naga Manjunath7615e552019-10-11 22:35:47 +0530594 volthaEventSubCatgry = voltha.EventSubCategory_PON
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000595 } else if statType == GEMStats || statType == ONUStats {
596 volthaEventSubCatgry = voltha.EventSubCategory_ONT
Naga Manjunath7615e552019-10-11 22:35:47 +0530597 }
598
Girish Gowdrac1b9d5e2021-04-22 12:47:44 -0700599 raisedTs := time.Now().Unix()
Naga Manjunath7615e552019-10-11 22:35:47 +0530600 mmd := voltha.MetricMetaData{
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000601 Title: statType,
Girish Gowdrac1b9d5e2021-04-22 12:47:44 -0700602 Ts: float64(raisedTs),
Girish Gowdra34815db2020-05-11 17:18:04 -0700603 Context: metricsContext,
Naga Manjunath7615e552019-10-11 22:35:47 +0530604 DeviceId: devID,
605 }
606
607 metricInfo.Metadata = &mmd
608 metricInfo.Metrics = val
609
610 ke.SliceData = []*voltha.MetricInformation{&metricInfo}
611 ke.Type = voltha.KpiEventType_slice
Girish Gowdrac1b9d5e2021-04-22 12:47:44 -0700612 ke.Ts = float64(raisedTs)
Naga Manjunath7615e552019-10-11 22:35:47 +0530613
Himani Chawla473496d2021-12-01 00:10:30 +0530614 if err := StatMgr.Device.EventProxy.SendKpiEvent(ctx, "STATS_PUBLISH_EVENT", &ke, voltha.EventCategory_EQUIPMENT, volthaEventSubCatgry, raisedTs); err != nil {
Gamze Abakafcbd6e72020-12-17 13:25:16 +0000615 logger.Errorw(ctx, "failed-to-send-stats", log.Fields{"err": err})
Naga Manjunath7615e552019-10-11 22:35:47 +0530616 }
Naga Manjunath7615e552019-10-11 22:35:47 +0530617}
618
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700619// PortStatisticsIndication handles the port statistics indication
Neha Sharma96b7bf22020-06-15 10:37:32 +0000620func (StatMgr *OpenOltStatisticsMgr) PortStatisticsIndication(ctx context.Context, PortStats *openolt.PortStatistics, NumPonPorts uint32) {
621 StatMgr.PortsStatisticsKpis(ctx, PortStats, NumPonPorts)
622 logger.Debugw(ctx, "received-port-stats-indication", log.Fields{"port-stats": PortStats})
kesavand62126212021-01-12 04:56:06 -0500623 //Indicate that PortStatisticsIndication is handled
624 //PortStats.IntfId is actually the port number
625 StatMgr.processStatIndication(ctx, portStatsType, PortStats.IntfId)
Abhilash S.L765ad002019-04-24 16:40:57 +0530626 // TODO send stats to core topic to the voltha kafka or a different kafka ?
627}
628
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700629// FlowStatisticsIndication to be implemented
Neha Sharma96b7bf22020-06-15 10:37:32 +0000630func FlowStatisticsIndication(ctx context.Context, self, FlowStats *openolt.FlowStatistics) {
631 logger.Debugw(ctx, "flow-stats-collected", log.Fields{"flow-stats": FlowStats})
Abhilash S.L765ad002019-04-24 16:40:57 +0530632 //TODO send to kafka ?
633}
634
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700635// PortsStatisticsKpis map the port stats values into a dictionary, creates the kpiEvent and then publish to Kafka
Neha Sharma96b7bf22020-06-15 10:37:32 +0000636func (StatMgr *OpenOltStatisticsMgr) PortsStatisticsKpis(ctx context.Context, PortStats *openolt.PortStatistics, NumPonPorts uint32) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530637
638 /*map the port stats values into a dictionary
639 Create a kpoEvent and publish to Kafka
640
641 :param port_stats:
642 :return:
643 */
644 //var err error
645 IntfID := PortStats.IntfId
646
Mahir Gunyel85f61c12021-10-06 11:53:45 -0700647 if (plt.IntfIDToPortNo(1, voltha.Port_ETHERNET_NNI) < IntfID) &&
648 (IntfID < plt.IntfIDToPortNo(4, voltha.Port_ETHERNET_NNI)) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530649 /*
650 for this release we are only interested in the first NNI for
651 Northbound.
652 we are not using the other 3
653 */
654 return
Mahir Gunyel85f61c12021-10-06 11:53:45 -0700655 } else if plt.IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) == IntfID {
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700656
Naga Manjunath7615e552019-10-11 22:35:47 +0530657 var portNNIStat NniPort
658 portNNIStat.IntfID = IntfID
659 portNNIStat.PortNum = uint32(0)
660 portNNIStat.RxBytes = PortStats.RxBytes
661 portNNIStat.RxPackets = PortStats.RxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000662 portNNIStat.RxUcastPackets = PortStats.RxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530663 portNNIStat.RxMcastPackets = PortStats.RxMcastPackets
664 portNNIStat.RxBcastPackets = PortStats.RxBcastPackets
665 portNNIStat.TxBytes = PortStats.TxBytes
666 portNNIStat.TxPackets = PortStats.TxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000667 portNNIStat.TxUcastPackets = PortStats.TxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530668 portNNIStat.TxMcastPackets = PortStats.TxMcastPackets
669 portNNIStat.TxBcastPackets = PortStats.TxBcastPackets
670 mutex.Lock()
671 StatMgr.NorthBoundPort[0] = &portNNIStat
672 mutex.Unlock()
Neha Sharma96b7bf22020-06-15 10:37:32 +0000673 logger.Debugw(ctx, "received-nni-stats", log.Fields{"nni-stats": StatMgr.NorthBoundPort})
Naga Manjunath7615e552019-10-11 22:35:47 +0530674 }
675 for i := uint32(0); i < NumPonPorts; i++ {
676
Mahir Gunyel85f61c12021-10-06 11:53:45 -0700677 if plt.IntfIDToPortNo(i, voltha.Port_PON_OLT) == IntfID {
Naga Manjunath7615e552019-10-11 22:35:47 +0530678 var portPonStat PonPort
679 portPonStat.IntfID = IntfID
680 portPonStat.PortNum = i
681 portPonStat.PONID = i
682 portPonStat.RxBytes = PortStats.RxBytes
683 portPonStat.RxPackets = PortStats.RxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000684 portPonStat.RxUcastPackets = PortStats.RxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530685 portPonStat.RxMcastPackets = PortStats.RxMcastPackets
686 portPonStat.RxBcastPackets = PortStats.RxBcastPackets
687 portPonStat.TxBytes = PortStats.TxBytes
688 portPonStat.TxPackets = PortStats.TxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000689 portPonStat.TxUcastPackets = PortStats.TxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530690 portPonStat.TxMcastPackets = PortStats.TxMcastPackets
691 portPonStat.TxBcastPackets = PortStats.TxBcastPackets
692 mutex.Lock()
693 StatMgr.SouthBoundPort[i] = &portPonStat
694 mutex.Unlock()
Neha Sharma96b7bf22020-06-15 10:37:32 +0000695 logger.Debugw(ctx, "received-pon-stats-for-port", log.Fields{"port-pon-stats": portPonStat})
Naga Manjunath7615e552019-10-11 22:35:47 +0530696 }
697 }
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700698
699 /*
700 Based upon the intf_id map to an nni port or a pon port
701 the intf_id is the key to the north or south bound collections
702
703 Based upon the intf_id the port object (nni_port or pon_port) will
704 have its data attr. updated by the current dataset collected.
705
706 For prefixing the rule is currently to use the port number and not the intf_id
707 */
708 //FIXME : Just use first NNI for now
709 /* TODO should the data be marshaled before sending it ?
710 if IntfID == IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) {
711 //NNI port (just the first one)
712 err = UpdatePortObjectKpiData(StatMgr.NorthBoundPorts[PortStats.IntfID], PMData)
713 } else {
714 //PON ports
715 err = UpdatePortObjectKpiData(SouthboundPorts[PortStats.IntfID], PMData)
716 }
717 if (err != nil) {
Neha Sharma96b7bf22020-06-15 10:37:32 +0000718 logger.Error(ctx, "Error publishing statistics data")
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700719 }
720 */
721
Abhilash S.L765ad002019-04-24 16:40:57 +0530722}
kesavand62126212021-01-12 04:56:06 -0500723
724func (StatMgr *OpenOltStatisticsMgr) updateGetOltPortCountersResponse(ctx context.Context, singleValResp *extension.SingleGetValueResponse, stats map[string]float32) {
725
726 metrics := singleValResp.GetResponse().GetPortCoutners()
727 metrics.TxBytes = uint64(stats["TxBytes"])
728 metrics.RxBytes = uint64(stats["RxBytes"])
729 metrics.TxPackets = uint64(stats["TxPackets"])
730 metrics.RxPackets = uint64(stats["RxPackets"])
731 metrics.TxErrorPackets = uint64(stats["TxErrorPackets"])
732 metrics.RxErrorPackets = uint64(stats["RxErrorPackets"])
733 metrics.TxBcastPackets = uint64(stats["TxBcastPackets"])
734 metrics.RxBcastPackets = uint64(stats["RxBcastPackets"])
735 metrics.TxUcastPackets = uint64(stats["TxUcastPackets"])
736 metrics.RxUcastPackets = uint64(stats["RxUcastPackets"])
737 metrics.TxMcastPackets = uint64(stats["TxMcastPackets"])
738 metrics.RxMcastPackets = uint64(stats["RxMcastPackets"])
739
740 singleValResp.Response.Status = extension.GetValueResponse_OK
741 logger.Debugw(ctx, "updateGetOltPortCountersResponse", log.Fields{"resp": singleValResp})
742}
743
Joey Armstrong3f0e2422023-07-05 18:25:41 -0400744// RegisterForStatIndication registers ch as a channel on which indication is sent when statistics of type t is received
kesavand62126212021-01-12 04:56:06 -0500745func (StatMgr *OpenOltStatisticsMgr) RegisterForStatIndication(ctx context.Context, t StatType, ch chan bool, portNo uint32, portType extension.GetOltPortCounters_PortType) {
746 statInd := statRegInfo{
747 chn: ch,
748 portNo: portNo,
749 portType: portType,
750 }
751
752 logger.Debugf(ctx, "RegisterForStatIndication stat type %v portno %v porttype %v chan %v", t, portNo, portType, ch)
753 StatMgr.statIndListnerMu.Lock()
754 StatMgr.statIndListners[t].PushBack(statInd)
755 StatMgr.statIndListnerMu.Unlock()
756
757}
758
Joey Armstrong3f0e2422023-07-05 18:25:41 -0400759// DeRegisterFromStatIndication removes the previously registered channel ch for type t of statistics
kesavand62126212021-01-12 04:56:06 -0500760func (StatMgr *OpenOltStatisticsMgr) DeRegisterFromStatIndication(ctx context.Context, t StatType, ch chan bool) {
761 StatMgr.statIndListnerMu.Lock()
762 defer StatMgr.statIndListnerMu.Unlock()
763
764 for e := StatMgr.statIndListners[t].Front(); e != nil; e = e.Next() {
765 statInd := e.Value.(statRegInfo)
766 if statInd.chn == ch {
767 StatMgr.statIndListners[t].Remove(e)
768 return
769 }
770 }
771}
772
773func (StatMgr *OpenOltStatisticsMgr) processStatIndication(ctx context.Context, t StatType, portNo uint32) {
774 var deRegList []*list.Element
775 var statInd statRegInfo
776
777 StatMgr.statIndListnerMu.Lock()
778 defer StatMgr.statIndListnerMu.Unlock()
779
780 if StatMgr.statIndListners[t] == nil || StatMgr.statIndListners[t].Len() == 0 {
781 logger.Debugf(ctx, "processStatIndication %v list is empty ", t)
782 return
783 }
784
785 for e := StatMgr.statIndListners[t].Front(); e != nil; e = e.Next() {
786 statInd = e.Value.(statRegInfo)
787 if statInd.portNo != portNo {
788 fmt.Printf("Skipping %v\n", e.Value)
789 continue
790 }
791 // message sent
792 statInd.chn <- true
793 deRegList = append(deRegList, e)
794
795 }
796 for _, e := range deRegList {
797 StatMgr.statIndListners[t].Remove(e)
798 }
799
800}
Himani Chawla2c8ae0f2021-05-18 23:27:00 +0530801
802func (StatMgr *OpenOltStatisticsMgr) updateGetOnuPonCountersResponse(ctx context.Context, singleValResp *extension.SingleGetValueResponse, stats map[string]float32) {
803
804 metrics := singleValResp.GetResponse().GetOnuPonCounters()
805 metrics.IsIntfId = &extension.GetOnuCountersResponse_IntfId{
806 IntfId: uint32(stats[IntfID]),
807 }
808 metrics.IsOnuId = &extension.GetOnuCountersResponse_OnuId{
809 OnuId: uint32(stats[OnuID]),
810 }
811 metrics.IsPositiveDrift = &extension.GetOnuCountersResponse_PositiveDrift{
812 PositiveDrift: uint64(stats[PositiveDrift]),
813 }
814 metrics.IsNegativeDrift = &extension.GetOnuCountersResponse_NegativeDrift{
815 NegativeDrift: uint64(stats[NegativeDrift]),
816 }
817 metrics.IsDelimiterMissDetection = &extension.GetOnuCountersResponse_DelimiterMissDetection{
818 DelimiterMissDetection: uint64(stats[DelimiterMissDetection]),
819 }
820 metrics.IsBipErrors = &extension.GetOnuCountersResponse_BipErrors{
821 BipErrors: uint64(stats[BipErrors]),
822 }
823 metrics.IsBipUnits = &extension.GetOnuCountersResponse_BipUnits{
824 BipUnits: uint64(stats[BipUnits]),
825 }
826 metrics.IsFecCorrectedSymbols = &extension.GetOnuCountersResponse_FecCorrectedSymbols{
827 FecCorrectedSymbols: uint64(stats[FecCorrectedSymbols]),
828 }
829 metrics.IsFecCodewordsCorrected = &extension.GetOnuCountersResponse_FecCodewordsCorrected{
830 FecCodewordsCorrected: uint64(stats[FecCodewordsCorrected]),
831 }
832 metrics.IsFecCodewordsUncorrectable = &extension.GetOnuCountersResponse_FecCodewordsUncorrectable{
833 FecCodewordsUncorrectable: uint64(stats[fecCodewordsUncorrectable]),
834 }
835 metrics.IsFecCodewords = &extension.GetOnuCountersResponse_FecCodewords{
836 FecCodewords: uint64(stats[FecCodewords]),
837 }
838 metrics.IsFecCorrectedUnits = &extension.GetOnuCountersResponse_FecCorrectedUnits{
839 FecCorrectedUnits: uint64(stats[FecCorrectedUnits]),
840 }
841 metrics.IsXgemKeyErrors = &extension.GetOnuCountersResponse_XgemKeyErrors{
842 XgemKeyErrors: uint64(stats[XGEMKeyErrors]),
843 }
844 metrics.IsXgemLoss = &extension.GetOnuCountersResponse_XgemLoss{
845 XgemLoss: uint64(stats[XGEMLoss]),
846 }
847 metrics.IsRxPloamsError = &extension.GetOnuCountersResponse_RxPloamsError{
848 RxPloamsError: uint64(stats[RxPloamsError]),
849 }
850 metrics.IsRxPloamsNonIdle = &extension.GetOnuCountersResponse_RxPloamsNonIdle{
851 RxPloamsNonIdle: uint64(stats[RxPloamsNonIdle]),
852 }
853 metrics.IsRxOmci = &extension.GetOnuCountersResponse_RxOmci{
854 RxOmci: uint64(stats[RxOmci]),
855 }
856 metrics.IsRxOmciPacketsCrcError = &extension.GetOnuCountersResponse_RxOmciPacketsCrcError{
857 RxOmciPacketsCrcError: uint64(stats[RxOmciPacketsCrcError]),
858 }
859 metrics.IsRxBytes = &extension.GetOnuCountersResponse_RxBytes{
860 RxBytes: uint64(stats[RxBytes]),
861 }
862 metrics.IsRxPackets = &extension.GetOnuCountersResponse_RxPackets{
863 RxPackets: uint64(stats[RxPackets]),
864 }
865 metrics.IsTxBytes = &extension.GetOnuCountersResponse_TxBytes{
866 TxBytes: uint64(stats[TxBytes]),
867 }
868 metrics.IsTxPackets = &extension.GetOnuCountersResponse_TxPackets{
869 TxPackets: uint64(stats[TxPackets]),
870 }
871 metrics.IsBerReported = &extension.GetOnuCountersResponse_BerReported{
872 BerReported: uint64(stats[BerReported]),
873 }
874 metrics.IsLcdgErrors = &extension.GetOnuCountersResponse_LcdgErrors{
875 LcdgErrors: uint64(stats[LcdgErrors]),
876 }
877 metrics.IsRdiErrors = &extension.GetOnuCountersResponse_RdiErrors{
878 RdiErrors: uint64(stats[RdiErrors]),
879 }
880 metrics.IsTimestamp = &extension.GetOnuCountersResponse_Timestamp{
881 Timestamp: uint32(stats[Timestamp]),
882 }
883
884 singleValResp.Response.Status = extension.GetValueResponse_OK
885 logger.Debugw(ctx, "updateGetOnuPonCountersResponse", log.Fields{"resp": singleValResp})
886}