blob: 3133bced09abee41b78d14f7371878f7fbee641d [file] [log] [blame]
Abhilash S.L765ad002019-04-24 16:40:57 +05301/*
2 * Copyright 2019-present Open Networking Foundation
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 Gowdru6a80bbd2019-07-02 07:36:09 -070016
Scott Bakerdbd960e2020-02-28 08:57:51 -080017//Package core provides the utility for olt devices, flows and statistics
18package core
Abhilash S.L765ad002019-04-24 16:40:57 +053019
20import (
Abhilash S.L765ad002019-04-24 16:40:57 +053021 "fmt"
Esin Karamanccb714b2019-11-29 15:02:06 +000022 "github.com/opencord/voltha-lib-go/v3/pkg/log"
23 "github.com/opencord/voltha-protos/v3/go/openolt"
24 "github.com/opencord/voltha-protos/v3/go/voltha"
David K. Bainbridge794735f2020-02-11 21:01:37 -080025 "sync"
26 "time"
Abhilash S.L765ad002019-04-24 16:40:57 +053027)
28
Naga Manjunath7615e552019-10-11 22:35:47 +053029var mutex = &sync.Mutex{}
30
Girish Gowdru6a80bbd2019-07-02 07:36:09 -070031// PonPort representation
Abhilash S.L765ad002019-04-24 16:40:57 +053032type PonPort struct {
33 /*
34 This is a highly reduced version taken from the adtran pon_port.
35 TODO: Extend for use in the openolt adapter set.
36 */
37 /* MAX_ONUS_SUPPORTED = 256
38 DEFAULT_ENABLED = False
39 MAX_DEPLOYMENT_RANGE = 25000 # Meters (OLT-PB maximum)
40
41 _MCAST_ONU_ID = 253
42 _MCAST_ALLOC_BASE = 0x500
43
44 _SUPPORTED_ACTIVATION_METHODS = ['autodiscovery'] # , 'autoactivate']
45 _SUPPORTED_AUTHENTICATION_METHODS = ['serial-number']
46 */
47 PONID uint32
48 DeviceID string
49 IntfID uint32
50 PortNum uint32
51 PortID uint32
52 Label string
53 ONUs map[uint32]interface{}
54 ONUsByID map[uint32]interface{}
55
56 RxBytes uint64
57 RxPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +000058 RxUcastPackets uint64
Abhilash S.L765ad002019-04-24 16:40:57 +053059 RxMcastPackets uint64
60 RxBcastPackets uint64
61 RxErrorPackets uint64
62 TxBytes uint64
63 TxPackets uint64
64 TxUcastPackets uint64
65 TxMcastPackets uint64
66 TxBcastPackets uint64
67 TxErrorPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +000068 RxCrcErrors uint64
69 BipErrors uint64
Abhilash S.L765ad002019-04-24 16:40:57 +053070}
71
Girish Gowdru6a80bbd2019-07-02 07:36:09 -070072// NewPONPort returns a new instance of PonPort initialized with given PONID, DeviceID, IntfID and PortNum
Abhilash S.L765ad002019-04-24 16:40:57 +053073func NewPONPort(PONID uint32, DeviceID string, IntfID uint32, PortNum uint32) *PonPort {
74
75 var PON PonPort
76
77 PON.PONID = PONID
78 PON.DeviceID = DeviceID
79 PON.IntfID = IntfID
80 PON.PortNum = PortNum
81 PON.PortID = 0
Naga Manjunath7615e552019-10-11 22:35:47 +053082 PON.Label = fmt.Sprintf("%s%d", "pon-", PONID)
Abhilash S.L765ad002019-04-24 16:40:57 +053083
84 PON.ONUs = make(map[uint32]interface{})
85 PON.ONUsByID = make(map[uint32]interface{})
86
87 /*
88 Statistics taken from nni_port
89 self.intf_id = 0 #handled by getter
90 self.port_no = 0 #handled by getter
91 self.port_id = 0 #handled by getter
92
93 Note: In the current implementation of the kpis coming from the BAL the stats are the
94 samne model for NNI and PON.
95
96 TODO: Integrate additional kpis for the PON and other southbound port objecgts.
97
98 */
99
100 PON.RxBytes = 0
101 PON.RxPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000102 PON.RxUcastPackets = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530103 PON.RxMcastPackets = 0
104 PON.RxBcastPackets = 0
105 PON.RxErrorPackets = 0
106 PON.TxBytes = 0
107 PON.TxPackets = 0
108 PON.TxUcastPackets = 0
109 PON.TxMcastPackets = 0
110 PON.TxBcastPackets = 0
111 PON.TxErrorPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000112 PON.RxCrcErrors = 0
113 PON.BipErrors = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530114
115 /* def __str__(self):
116 return "PonPort-{}: Admin: {}, Oper: {}, OLT: {}".format(self._label,
117 self._admin_state,
118 self._oper_status,
119 self.olt)
120 */
121 return &PON
122}
123
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700124// NniPort representation
Abhilash S.L765ad002019-04-24 16:40:57 +0530125type NniPort struct {
126 /*
127 Northbound network port, often Ethernet-based
128
129 This is a highly reduced version taken from the adtran nni_port code set
130 TODO: add functions to allow for port specific values and operations
131 */
132 PortNum uint32
133 Name string
134 LogicalPort uint32
135 IntfID uint32
136
137 RxBytes uint64
138 RxPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000139 RxUcastPackets uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530140 RxMcastPackets uint64
141 RxBcastPackets uint64
142 RxErrorPackets uint64
143 TxBytes uint64
144 TxPackets uint64
145 TxUcastPackets uint64
146 TxMcastPackets uint64
147 TxBcastPackets uint64
148 TxErrorPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000149 RxCrcErrors uint64
150 BipErrors uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530151}
152
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700153// NewNniPort returns a new instance of NniPort initialized with the given PortNum and IntfID
Abhilash S.L765ad002019-04-24 16:40:57 +0530154func NewNniPort(PortNum uint32, IntfID uint32) *NniPort {
155
156 var NNI NniPort
157
158 NNI.PortNum = PortNum
Naga Manjunath7615e552019-10-11 22:35:47 +0530159 NNI.Name = fmt.Sprintf("%s%d", "nni-", PortNum)
Abhilash S.L765ad002019-04-24 16:40:57 +0530160 NNI.IntfID = IntfID
161
162 NNI.RxBytes = 0
163 NNI.RxPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000164 NNI.RxUcastPackets = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530165 NNI.RxMcastPackets = 0
166 NNI.RxBcastPackets = 0
167 NNI.RxErrorPackets = 0
168 NNI.TxBytes = 0
169 NNI.TxPackets = 0
170 NNI.TxUcastPackets = 0
171 NNI.TxMcastPackets = 0
172 NNI.TxBcastPackets = 0
173 NNI.TxErrorPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000174 NNI.RxCrcErrors = 0
175 NNI.BipErrors = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530176
177 return &NNI
178}
179
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700180// OpenOltStatisticsMgr structure
Abhilash S.L765ad002019-04-24 16:40:57 +0530181type OpenOltStatisticsMgr struct {
182 Device *DeviceHandler
Naga Manjunath7615e552019-10-11 22:35:47 +0530183 NorthBoundPort map[uint32]*NniPort
184 SouthBoundPort map[uint32]*PonPort
Abhilash S.L765ad002019-04-24 16:40:57 +0530185 // TODO PMMetrics Metrics
186}
187
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700188// NewOpenOltStatsMgr returns a new instance of the OpenOltStatisticsMgr
Abhilash S.L765ad002019-04-24 16:40:57 +0530189func NewOpenOltStatsMgr(Dev *DeviceHandler) *OpenOltStatisticsMgr {
190
191 var StatMgr OpenOltStatisticsMgr
192
193 StatMgr.Device = Dev
194 // TODO call metric PMMetric =
195 // Northbound and Southbound ports
196 // added to initialize the pm_metrics
197 var Ports interface{}
Naga Manjunath7615e552019-10-11 22:35:47 +0530198 Ports, _ = InitPorts("nni", Dev.deviceID, 1)
199 StatMgr.NorthBoundPort, _ = Ports.(map[uint32]*NniPort)
200 NumPonPorts := Dev.resourceMgr.DevInfo.GetPonPorts()
201 Ports, _ = InitPorts("pon", Dev.deviceID, NumPonPorts)
202 StatMgr.SouthBoundPort, _ = Ports.(map[uint32]*PonPort)
Abhilash S.L765ad002019-04-24 16:40:57 +0530203 return &StatMgr
204}
205
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700206// InitPorts collects the port objects: nni and pon that are updated with the current data from the OLT
Naga Manjunath7615e552019-10-11 22:35:47 +0530207func InitPorts(Intftype string, DeviceID string, numOfPorts uint32) (interface{}, error) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530208 /*
209 This method collects the port objects: nni and pon that are updated with the
210 current data from the OLT
211
212 Both the northbound (nni) and southbound ports are indexed by the interface id (intf_id)
213 and NOT the port number. When the port object is instantiated it will contain the intf_id and
214 port_no values
215
216 :param type:
217 :return:
218 */
219 var i uint32
220 if Intftype == "nni" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530221 NniPorts := make(map[uint32]*NniPort)
222 for i = 0; i < numOfPorts; i++ {
kdarapu768708d2019-09-16 23:19:15 +0530223 Port := BuildPortObject(i, "nni", DeviceID).(*NniPort)
Naga Manjunath7615e552019-10-11 22:35:47 +0530224 NniPorts[Port.IntfID] = Port
Abhilash S.L765ad002019-04-24 16:40:57 +0530225 }
226 return NniPorts, nil
227 } else if Intftype == "pon" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530228 PONPorts := make(map[uint32]*PonPort)
229 for i = 0; i < numOfPorts; i++ {
kdarapu768708d2019-09-16 23:19:15 +0530230 PONPort := BuildPortObject(i, "pon", DeviceID).(*PonPort)
Naga Manjunath7615e552019-10-11 22:35:47 +0530231 PONPorts[PortNoToIntfID(PONPort.IntfID, voltha.Port_PON_OLT)] = PONPort
Abhilash S.L765ad002019-04-24 16:40:57 +0530232 }
233 return PONPorts, nil
234 } else {
235 log.Errorf("Invalid type of interface %s", Intftype)
David K. Bainbridge794735f2020-02-11 21:01:37 -0800236 return nil, NewErrInvalidValue(log.Fields{"interface-type": Intftype}, nil)
Abhilash S.L765ad002019-04-24 16:40:57 +0530237 }
238}
239
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700240// BuildPortObject allows for updating north and southbound ports, newly discovered ports, and devices
Abhilash S.L765ad002019-04-24 16:40:57 +0530241func BuildPortObject(PortNum uint32, IntfType string, DeviceID string) interface{} {
242 /*
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700243 Separate method to allow for updating north and southbound ports
Abhilash S.L765ad002019-04-24 16:40:57 +0530244 newly discovered ports and devices
245
246 :param port_num:
247 :param type:
248 :return:
249 */
250
251 //This builds a port object which is added to the
252 //appropriate northbound or southbound values
253 if IntfType == "nni" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530254 IntfID := IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
255 nniID := PortNoToIntfID(IntfID, voltha.Port_ETHERNET_NNI)
256 log.Debugf("NniID %v", nniID)
257 return NewNniPort(PortNum, nniID)
Abhilash S.L765ad002019-04-24 16:40:57 +0530258 } else if IntfType == "pon" {
259 // PON ports require a different configuration
260 // intf_id and pon_id are currently equal.
Naga Manjunath7615e552019-10-11 22:35:47 +0530261 IntfID := IntfIDToPortNo(PortNum, voltha.Port_PON_OLT)
262 PONID := PortNoToIntfID(IntfID, voltha.Port_PON_OLT)
263 log.Debugf("PonID %v", PONID)
Abhilash S.L765ad002019-04-24 16:40:57 +0530264 return NewPONPort(PONID, DeviceID, IntfID, PortNum)
265 } else {
266 log.Errorf("Invalid type of interface %s", IntfType)
267 return nil
268 }
269}
270
Naga Manjunath7615e552019-10-11 22:35:47 +0530271// collectNNIMetrics will collect the nni port metrics
272func (StatMgr *OpenOltStatisticsMgr) collectNNIMetrics(nniID uint32) map[string]float32 {
273
274 nnival := make(map[string]float32)
275 mutex.Lock()
276 cm := StatMgr.Device.portStats.NorthBoundPort[nniID]
277 mutex.Unlock()
278 metricName := StatMgr.Device.metrics.GetSubscriberMetrics()
279
280 if metricName != nil && len(metricName) > 0 {
281 for mName := range metricName {
282 switch mName {
283 case "rx_bytes":
284 nnival["RxBytes"] = float32(cm.RxBytes)
285 case "rx_packets":
286 nnival["RxPackets"] = float32(cm.RxPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000287 case "rx_ucast_packets":
288 nnival["RxUcastPackets"] = float32(cm.RxUcastPackets)
Naga Manjunath7615e552019-10-11 22:35:47 +0530289 case "rx_mcast_packets":
290 nnival["RxMcastPackets"] = float32(cm.RxMcastPackets)
291 case "rx_bcast_packets":
292 nnival["RxBcastPackets"] = float32(cm.RxBcastPackets)
293 case "tx_bytes":
294 nnival["TxBytes"] = float32(cm.TxBytes)
295 case "tx_packets":
296 nnival["TxPackets"] = float32(cm.TxPackets)
297 case "tx_mcast_packets":
298 nnival["TxMcastPackets"] = float32(cm.TxMcastPackets)
299 case "tx_bcast_packets":
300 nnival["TxBcastPackets"] = float32(cm.TxBcastPackets)
301 }
302 }
303 }
304 return nnival
305}
306
307// collectPONMetrics will collect the pon port metrics
308func (StatMgr *OpenOltStatisticsMgr) collectPONMetrics(pID uint32) map[string]float32 {
309
310 ponval := make(map[string]float32)
311 mutex.Lock()
312 cm := StatMgr.Device.portStats.SouthBoundPort[pID]
313 mutex.Unlock()
314 metricName := StatMgr.Device.metrics.GetSubscriberMetrics()
315
316 if metricName != nil && len(metricName) > 0 {
317 for mName := range metricName {
318 switch mName {
319 case "rx_bytes":
320 ponval["RxBytes"] = float32(cm.RxBytes)
321 case "rx_packets":
322 ponval["RxPackets"] = float32(cm.RxPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000323 // these are not supported in OpenOlt Agent now
324 // will return zero until supported
325 case "rx_ucast_packets":
326 ponval["RxUcastPackets"] = float32(cm.RxUcastPackets)
Naga Manjunath7615e552019-10-11 22:35:47 +0530327 case "rx_mcast_packets":
328 ponval["RxMcastPackets"] = float32(cm.RxMcastPackets)
329 case "rx_bcast_packets":
330 ponval["RxBcastPackets"] = float32(cm.RxBcastPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000331 // End will return zero until supported
Naga Manjunath7615e552019-10-11 22:35:47 +0530332 case "tx_bytes":
333 ponval["TxBytes"] = float32(cm.TxBytes)
334 case "tx_packets":
335 ponval["TxPackets"] = float32(cm.TxPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000336 // these are not supported in OpenOlt Agent now
337 // will return zero until supported
338 case "tx_ucast_packets":
339 ponval["TxUcastPackets"] = float32(cm.TxUcastPackets)
Naga Manjunath7615e552019-10-11 22:35:47 +0530340 case "tx_mcast_packets":
341 ponval["TxMcastPackets"] = float32(cm.TxMcastPackets)
342 case "tx_bcast_packets":
343 ponval["TxBcastPackets"] = float32(cm.TxBcastPackets)
344 }
345 }
346 }
347 return ponval
348}
349
350// publishMatrics will publish the pon port metrics
351func (StatMgr OpenOltStatisticsMgr) publishMetrics(portType string, val map[string]float32, portnum uint32, context map[string]string, devID string) {
352 log.Debugf("Post-%v %v", portType, val)
353
354 var metricInfo voltha.MetricInformation
355 var ke voltha.KpiEvent2
Esin Karamanccb714b2019-11-29 15:02:06 +0000356 var volthaEventSubCatgry voltha.EventSubCategory_Types
Naga Manjunath7615e552019-10-11 22:35:47 +0530357
358 if portType == "NNIStats" {
359 volthaEventSubCatgry = voltha.EventSubCategory_NNI
360 } else {
361 volthaEventSubCatgry = voltha.EventSubCategory_PON
362 }
363
364 raisedTs := time.Now().UnixNano()
365 mmd := voltha.MetricMetaData{
366 Title: portType,
367 Ts: float64(raisedTs),
368 Context: context,
369 DeviceId: devID,
370 }
371
372 metricInfo.Metadata = &mmd
373 metricInfo.Metrics = val
374
375 ke.SliceData = []*voltha.MetricInformation{&metricInfo}
376 ke.Type = voltha.KpiEventType_slice
377 ke.Ts = float64(time.Now().UnixNano())
378
379 if err := StatMgr.Device.EventProxy.SendKpiEvent("STATS_EVENT", &ke, voltha.EventCategory_EQUIPMENT, volthaEventSubCatgry, raisedTs); err != nil {
380 log.Errorw("Failed to send Pon stats", log.Fields{"err": err})
381 }
382
383}
384
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700385// PortStatisticsIndication handles the port statistics indication
Naga Manjunath7615e552019-10-11 22:35:47 +0530386func (StatMgr *OpenOltStatisticsMgr) PortStatisticsIndication(PortStats *openolt.PortStatistics, NumPonPorts uint32) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530387 log.Debugf("port-stats-collected %v", PortStats)
Naga Manjunath7615e552019-10-11 22:35:47 +0530388 StatMgr.PortsStatisticsKpis(PortStats, NumPonPorts)
389 log.Infow("Received port stats indication", log.Fields{"PortStats": PortStats})
Abhilash S.L765ad002019-04-24 16:40:57 +0530390 // TODO send stats to core topic to the voltha kafka or a different kafka ?
391}
392
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700393// FlowStatisticsIndication to be implemented
Abhilash S.L765ad002019-04-24 16:40:57 +0530394func FlowStatisticsIndication(self, FlowStats *openolt.FlowStatistics) {
395 log.Debugf("flow-stats-collected %v", FlowStats)
396 //TODO send to kafka ?
397}
398
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700399// PortsStatisticsKpis map the port stats values into a dictionary, creates the kpiEvent and then publish to Kafka
Naga Manjunath7615e552019-10-11 22:35:47 +0530400func (StatMgr *OpenOltStatisticsMgr) PortsStatisticsKpis(PortStats *openolt.PortStatistics, NumPonPorts uint32) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530401
402 /*map the port stats values into a dictionary
403 Create a kpoEvent and publish to Kafka
404
405 :param port_stats:
406 :return:
407 */
408 //var err error
409 IntfID := PortStats.IntfId
410
Naga Manjunath7615e552019-10-11 22:35:47 +0530411 if (IntfIDToPortNo(1, voltha.Port_ETHERNET_NNI) < IntfID) &&
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700412 (IntfID < IntfIDToPortNo(4, voltha.Port_ETHERNET_NNI)) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530413 /*
414 for this release we are only interested in the first NNI for
415 Northbound.
416 we are not using the other 3
417 */
418 return
Naga Manjunath7615e552019-10-11 22:35:47 +0530419 } else if IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) == IntfID {
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700420
Naga Manjunath7615e552019-10-11 22:35:47 +0530421 var portNNIStat NniPort
422 portNNIStat.IntfID = IntfID
423 portNNIStat.PortNum = uint32(0)
424 portNNIStat.RxBytes = PortStats.RxBytes
425 portNNIStat.RxPackets = PortStats.RxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000426 portNNIStat.RxUcastPackets = PortStats.RxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530427 portNNIStat.RxMcastPackets = PortStats.RxMcastPackets
428 portNNIStat.RxBcastPackets = PortStats.RxBcastPackets
429 portNNIStat.TxBytes = PortStats.TxBytes
430 portNNIStat.TxPackets = PortStats.TxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000431 portNNIStat.TxUcastPackets = PortStats.TxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530432 portNNIStat.TxMcastPackets = PortStats.TxMcastPackets
433 portNNIStat.TxBcastPackets = PortStats.TxBcastPackets
434 mutex.Lock()
435 StatMgr.NorthBoundPort[0] = &portNNIStat
436 mutex.Unlock()
437 log.Debugf("Received-NNI-Stats: %v", StatMgr.NorthBoundPort)
438 }
439 for i := uint32(0); i < NumPonPorts; i++ {
440
441 if IntfIDToPortNo(i, voltha.Port_PON_OLT) == IntfID {
442 var portPonStat PonPort
443 portPonStat.IntfID = IntfID
444 portPonStat.PortNum = i
445 portPonStat.PONID = i
446 portPonStat.RxBytes = PortStats.RxBytes
447 portPonStat.RxPackets = PortStats.RxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000448 portPonStat.RxUcastPackets = PortStats.RxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530449 portPonStat.RxMcastPackets = PortStats.RxMcastPackets
450 portPonStat.RxBcastPackets = PortStats.RxBcastPackets
451 portPonStat.TxBytes = PortStats.TxBytes
452 portPonStat.TxPackets = PortStats.TxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000453 portPonStat.TxUcastPackets = PortStats.TxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530454 portPonStat.TxMcastPackets = PortStats.TxMcastPackets
455 portPonStat.TxBcastPackets = PortStats.TxBcastPackets
456 mutex.Lock()
457 StatMgr.SouthBoundPort[i] = &portPonStat
458 mutex.Unlock()
459 log.Debugf("Received-PON-Stats-for-Port %v : %v", i, StatMgr.SouthBoundPort[i])
460 }
461 }
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700462
463 /*
464 Based upon the intf_id map to an nni port or a pon port
465 the intf_id is the key to the north or south bound collections
466
467 Based upon the intf_id the port object (nni_port or pon_port) will
468 have its data attr. updated by the current dataset collected.
469
470 For prefixing the rule is currently to use the port number and not the intf_id
471 */
472 //FIXME : Just use first NNI for now
473 /* TODO should the data be marshaled before sending it ?
474 if IntfID == IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) {
475 //NNI port (just the first one)
476 err = UpdatePortObjectKpiData(StatMgr.NorthBoundPorts[PortStats.IntfID], PMData)
477 } else {
478 //PON ports
479 err = UpdatePortObjectKpiData(SouthboundPorts[PortStats.IntfID], PMData)
480 }
481 if (err != nil) {
482 log.Error("Error publishing statistics data")
483 }
484 */
485
Abhilash S.L765ad002019-04-24 16:40:57 +0530486}