blob: c42e86b4de1bfd5a1eb1e6d21466106246b1d3f3 [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
17//Package adaptercore provides the utility for olt devices, flows and statistics
Abhilash S.L765ad002019-04-24 16:40:57 +053018package adaptercore
19
20import (
21 "errors"
22 "fmt"
Naga Manjunath7615e552019-10-11 22:35:47 +053023 "sync"
24 "time"
Abhilash S.L765ad002019-04-24 16:40:57 +053025
Scott Baker51290152019-10-24 14:23:20 -070026 "github.com/opencord/voltha-lib-go/v2/pkg/log"
Scott Bakerc6e54cb2019-11-04 09:31:25 -080027 "github.com/opencord/voltha-protos/v2/go/openolt"
28 "github.com/opencord/voltha-protos/v2/go/voltha"
Abhilash S.L765ad002019-04-24 16:40:57 +053029)
30
Naga Manjunath7615e552019-10-11 22:35:47 +053031var mutex = &sync.Mutex{}
32
Girish Gowdru6a80bbd2019-07-02 07:36:09 -070033// PonPort representation
Abhilash S.L765ad002019-04-24 16:40:57 +053034type PonPort struct {
35 /*
36 This is a highly reduced version taken from the adtran pon_port.
37 TODO: Extend for use in the openolt adapter set.
38 */
39 /* MAX_ONUS_SUPPORTED = 256
40 DEFAULT_ENABLED = False
41 MAX_DEPLOYMENT_RANGE = 25000 # Meters (OLT-PB maximum)
42
43 _MCAST_ONU_ID = 253
44 _MCAST_ALLOC_BASE = 0x500
45
46 _SUPPORTED_ACTIVATION_METHODS = ['autodiscovery'] # , 'autoactivate']
47 _SUPPORTED_AUTHENTICATION_METHODS = ['serial-number']
48 */
49 PONID uint32
50 DeviceID string
51 IntfID uint32
52 PortNum uint32
53 PortID uint32
54 Label string
55 ONUs map[uint32]interface{}
56 ONUsByID map[uint32]interface{}
57
58 RxBytes uint64
59 RxPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +000060 RxUcastPackets uint64
Abhilash S.L765ad002019-04-24 16:40:57 +053061 RxMcastPackets uint64
62 RxBcastPackets uint64
63 RxErrorPackets uint64
64 TxBytes uint64
65 TxPackets uint64
66 TxUcastPackets uint64
67 TxMcastPackets uint64
68 TxBcastPackets uint64
69 TxErrorPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +000070 RxCrcErrors uint64
71 BipErrors uint64
Abhilash S.L765ad002019-04-24 16:40:57 +053072}
73
Girish Gowdru6a80bbd2019-07-02 07:36:09 -070074// NewPONPort returns a new instance of PonPort initialized with given PONID, DeviceID, IntfID and PortNum
Abhilash S.L765ad002019-04-24 16:40:57 +053075func NewPONPort(PONID uint32, DeviceID string, IntfID uint32, PortNum uint32) *PonPort {
76
77 var PON PonPort
78
79 PON.PONID = PONID
80 PON.DeviceID = DeviceID
81 PON.IntfID = IntfID
82 PON.PortNum = PortNum
83 PON.PortID = 0
Naga Manjunath7615e552019-10-11 22:35:47 +053084 PON.Label = fmt.Sprintf("%s%d", "pon-", PONID)
Abhilash S.L765ad002019-04-24 16:40:57 +053085
86 PON.ONUs = make(map[uint32]interface{})
87 PON.ONUsByID = make(map[uint32]interface{})
88
89 /*
90 Statistics taken from nni_port
91 self.intf_id = 0 #handled by getter
92 self.port_no = 0 #handled by getter
93 self.port_id = 0 #handled by getter
94
95 Note: In the current implementation of the kpis coming from the BAL the stats are the
96 samne model for NNI and PON.
97
98 TODO: Integrate additional kpis for the PON and other southbound port objecgts.
99
100 */
101
102 PON.RxBytes = 0
103 PON.RxPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000104 PON.RxUcastPackets = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530105 PON.RxMcastPackets = 0
106 PON.RxBcastPackets = 0
107 PON.RxErrorPackets = 0
108 PON.TxBytes = 0
109 PON.TxPackets = 0
110 PON.TxUcastPackets = 0
111 PON.TxMcastPackets = 0
112 PON.TxBcastPackets = 0
113 PON.TxErrorPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000114 PON.RxCrcErrors = 0
115 PON.BipErrors = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530116
117 /* def __str__(self):
118 return "PonPort-{}: Admin: {}, Oper: {}, OLT: {}".format(self._label,
119 self._admin_state,
120 self._oper_status,
121 self.olt)
122 */
123 return &PON
124}
125
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700126// NniPort representation
Abhilash S.L765ad002019-04-24 16:40:57 +0530127type NniPort struct {
128 /*
129 Northbound network port, often Ethernet-based
130
131 This is a highly reduced version taken from the adtran nni_port code set
132 TODO: add functions to allow for port specific values and operations
133 */
134 PortNum uint32
135 Name string
136 LogicalPort uint32
137 IntfID uint32
138
139 RxBytes uint64
140 RxPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000141 RxUcastPackets uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530142 RxMcastPackets uint64
143 RxBcastPackets uint64
144 RxErrorPackets uint64
145 TxBytes uint64
146 TxPackets uint64
147 TxUcastPackets uint64
148 TxMcastPackets uint64
149 TxBcastPackets uint64
150 TxErrorPackets uint64
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000151 RxCrcErrors uint64
152 BipErrors uint64
Abhilash S.L765ad002019-04-24 16:40:57 +0530153}
154
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700155// NewNniPort returns a new instance of NniPort initialized with the given PortNum and IntfID
Abhilash S.L765ad002019-04-24 16:40:57 +0530156func NewNniPort(PortNum uint32, IntfID uint32) *NniPort {
157
158 var NNI NniPort
159
160 NNI.PortNum = PortNum
Naga Manjunath7615e552019-10-11 22:35:47 +0530161 NNI.Name = fmt.Sprintf("%s%d", "nni-", PortNum)
Abhilash S.L765ad002019-04-24 16:40:57 +0530162 NNI.IntfID = IntfID
163
164 NNI.RxBytes = 0
165 NNI.RxPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000166 NNI.RxUcastPackets = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530167 NNI.RxMcastPackets = 0
168 NNI.RxBcastPackets = 0
169 NNI.RxErrorPackets = 0
170 NNI.TxBytes = 0
171 NNI.TxPackets = 0
172 NNI.TxUcastPackets = 0
173 NNI.TxMcastPackets = 0
174 NNI.TxBcastPackets = 0
175 NNI.TxErrorPackets = 0
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000176 NNI.RxCrcErrors = 0
177 NNI.BipErrors = 0
Abhilash S.L765ad002019-04-24 16:40:57 +0530178
179 return &NNI
180}
181
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700182// OpenOltStatisticsMgr structure
Abhilash S.L765ad002019-04-24 16:40:57 +0530183type OpenOltStatisticsMgr struct {
184 Device *DeviceHandler
Naga Manjunath7615e552019-10-11 22:35:47 +0530185 NorthBoundPort map[uint32]*NniPort
186 SouthBoundPort map[uint32]*PonPort
Abhilash S.L765ad002019-04-24 16:40:57 +0530187 // TODO PMMetrics Metrics
188}
189
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700190// NewOpenOltStatsMgr returns a new instance of the OpenOltStatisticsMgr
Abhilash S.L765ad002019-04-24 16:40:57 +0530191func NewOpenOltStatsMgr(Dev *DeviceHandler) *OpenOltStatisticsMgr {
192
193 var StatMgr OpenOltStatisticsMgr
194
195 StatMgr.Device = Dev
196 // TODO call metric PMMetric =
197 // Northbound and Southbound ports
198 // added to initialize the pm_metrics
199 var Ports interface{}
Naga Manjunath7615e552019-10-11 22:35:47 +0530200 Ports, _ = InitPorts("nni", Dev.deviceID, 1)
201 StatMgr.NorthBoundPort, _ = Ports.(map[uint32]*NniPort)
202 NumPonPorts := Dev.resourceMgr.DevInfo.GetPonPorts()
203 Ports, _ = InitPorts("pon", Dev.deviceID, NumPonPorts)
204 StatMgr.SouthBoundPort, _ = Ports.(map[uint32]*PonPort)
Abhilash S.L765ad002019-04-24 16:40:57 +0530205 return &StatMgr
206}
207
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700208// 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 +0530209func InitPorts(Intftype string, DeviceID string, numOfPorts uint32) (interface{}, error) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530210 /*
211 This method collects the port objects: nni and pon that are updated with the
212 current data from the OLT
213
214 Both the northbound (nni) and southbound ports are indexed by the interface id (intf_id)
215 and NOT the port number. When the port object is instantiated it will contain the intf_id and
216 port_no values
217
218 :param type:
219 :return:
220 */
221 var i uint32
222 if Intftype == "nni" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530223 NniPorts := make(map[uint32]*NniPort)
224 for i = 0; i < numOfPorts; i++ {
kdarapu768708d2019-09-16 23:19:15 +0530225 Port := BuildPortObject(i, "nni", DeviceID).(*NniPort)
Naga Manjunath7615e552019-10-11 22:35:47 +0530226 NniPorts[Port.IntfID] = Port
Abhilash S.L765ad002019-04-24 16:40:57 +0530227 }
228 return NniPorts, nil
229 } else if Intftype == "pon" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530230 PONPorts := make(map[uint32]*PonPort)
231 for i = 0; i < numOfPorts; i++ {
kdarapu768708d2019-09-16 23:19:15 +0530232 PONPort := BuildPortObject(i, "pon", DeviceID).(*PonPort)
Naga Manjunath7615e552019-10-11 22:35:47 +0530233 PONPorts[PortNoToIntfID(PONPort.IntfID, voltha.Port_PON_OLT)] = PONPort
Abhilash S.L765ad002019-04-24 16:40:57 +0530234 }
235 return PONPorts, nil
236 } else {
237 log.Errorf("Invalid type of interface %s", Intftype)
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700238 return nil, errors.New("invalid type of interface ")
Abhilash S.L765ad002019-04-24 16:40:57 +0530239 }
240}
241
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700242// BuildPortObject allows for updating north and southbound ports, newly discovered ports, and devices
Abhilash S.L765ad002019-04-24 16:40:57 +0530243func BuildPortObject(PortNum uint32, IntfType string, DeviceID string) interface{} {
244 /*
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700245 Separate method to allow for updating north and southbound ports
Abhilash S.L765ad002019-04-24 16:40:57 +0530246 newly discovered ports and devices
247
248 :param port_num:
249 :param type:
250 :return:
251 */
252
253 //This builds a port object which is added to the
254 //appropriate northbound or southbound values
255 if IntfType == "nni" {
Naga Manjunath7615e552019-10-11 22:35:47 +0530256 IntfID := IntfIDToPortNo(PortNum, voltha.Port_ETHERNET_NNI)
257 nniID := PortNoToIntfID(IntfID, voltha.Port_ETHERNET_NNI)
258 log.Debugf("NniID %v", nniID)
259 return NewNniPort(PortNum, nniID)
Abhilash S.L765ad002019-04-24 16:40:57 +0530260 } else if IntfType == "pon" {
261 // PON ports require a different configuration
262 // intf_id and pon_id are currently equal.
Naga Manjunath7615e552019-10-11 22:35:47 +0530263 IntfID := IntfIDToPortNo(PortNum, voltha.Port_PON_OLT)
264 PONID := PortNoToIntfID(IntfID, voltha.Port_PON_OLT)
265 log.Debugf("PonID %v", PONID)
Abhilash S.L765ad002019-04-24 16:40:57 +0530266 return NewPONPort(PONID, DeviceID, IntfID, PortNum)
267 } else {
268 log.Errorf("Invalid type of interface %s", IntfType)
269 return nil
270 }
271}
272
Naga Manjunath7615e552019-10-11 22:35:47 +0530273// collectNNIMetrics will collect the nni port metrics
274func (StatMgr *OpenOltStatisticsMgr) collectNNIMetrics(nniID uint32) map[string]float32 {
275
276 nnival := make(map[string]float32)
277 mutex.Lock()
278 cm := StatMgr.Device.portStats.NorthBoundPort[nniID]
279 mutex.Unlock()
280 metricName := StatMgr.Device.metrics.GetSubscriberMetrics()
281
282 if metricName != nil && len(metricName) > 0 {
283 for mName := range metricName {
284 switch mName {
285 case "rx_bytes":
286 nnival["RxBytes"] = float32(cm.RxBytes)
287 case "rx_packets":
288 nnival["RxPackets"] = float32(cm.RxPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000289 case "rx_ucast_packets":
290 nnival["RxUcastPackets"] = float32(cm.RxUcastPackets)
Naga Manjunath7615e552019-10-11 22:35:47 +0530291 case "rx_mcast_packets":
292 nnival["RxMcastPackets"] = float32(cm.RxMcastPackets)
293 case "rx_bcast_packets":
294 nnival["RxBcastPackets"] = float32(cm.RxBcastPackets)
295 case "tx_bytes":
296 nnival["TxBytes"] = float32(cm.TxBytes)
297 case "tx_packets":
298 nnival["TxPackets"] = float32(cm.TxPackets)
299 case "tx_mcast_packets":
300 nnival["TxMcastPackets"] = float32(cm.TxMcastPackets)
301 case "tx_bcast_packets":
302 nnival["TxBcastPackets"] = float32(cm.TxBcastPackets)
303 }
304 }
305 }
306 return nnival
307}
308
309// collectPONMetrics will collect the pon port metrics
310func (StatMgr *OpenOltStatisticsMgr) collectPONMetrics(pID uint32) map[string]float32 {
311
312 ponval := make(map[string]float32)
313 mutex.Lock()
314 cm := StatMgr.Device.portStats.SouthBoundPort[pID]
315 mutex.Unlock()
316 metricName := StatMgr.Device.metrics.GetSubscriberMetrics()
317
318 if metricName != nil && len(metricName) > 0 {
319 for mName := range metricName {
320 switch mName {
321 case "rx_bytes":
322 ponval["RxBytes"] = float32(cm.RxBytes)
323 case "rx_packets":
324 ponval["RxPackets"] = float32(cm.RxPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000325 // these are not supported in OpenOlt Agent now
326 // will return zero until supported
327 case "rx_ucast_packets":
328 ponval["RxUcastPackets"] = float32(cm.RxUcastPackets)
Naga Manjunath7615e552019-10-11 22:35:47 +0530329 case "rx_mcast_packets":
330 ponval["RxMcastPackets"] = float32(cm.RxMcastPackets)
331 case "rx_bcast_packets":
332 ponval["RxBcastPackets"] = float32(cm.RxBcastPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000333 // End will return zero until supported
Naga Manjunath7615e552019-10-11 22:35:47 +0530334 case "tx_bytes":
335 ponval["TxBytes"] = float32(cm.TxBytes)
336 case "tx_packets":
337 ponval["TxPackets"] = float32(cm.TxPackets)
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000338 // these are not supported in OpenOlt Agent now
339 // will return zero until supported
340 case "tx_ucast_packets":
341 ponval["TxUcastPackets"] = float32(cm.TxUcastPackets)
Naga Manjunath7615e552019-10-11 22:35:47 +0530342 case "tx_mcast_packets":
343 ponval["TxMcastPackets"] = float32(cm.TxMcastPackets)
344 case "tx_bcast_packets":
345 ponval["TxBcastPackets"] = float32(cm.TxBcastPackets)
346 }
347 }
348 }
349 return ponval
350}
351
352// publishMatrics will publish the pon port metrics
353func (StatMgr OpenOltStatisticsMgr) publishMetrics(portType string, val map[string]float32, portnum uint32, context map[string]string, devID string) {
354 log.Debugf("Post-%v %v", portType, val)
355
356 var metricInfo voltha.MetricInformation
357 var ke voltha.KpiEvent2
358 var volthaEventSubCatgry voltha.EventSubCategory_EventSubCategory
359
360 if portType == "NNIStats" {
361 volthaEventSubCatgry = voltha.EventSubCategory_NNI
362 } else {
363 volthaEventSubCatgry = voltha.EventSubCategory_PON
364 }
365
366 raisedTs := time.Now().UnixNano()
367 mmd := voltha.MetricMetaData{
368 Title: portType,
369 Ts: float64(raisedTs),
370 Context: context,
371 DeviceId: devID,
372 }
373
374 metricInfo.Metadata = &mmd
375 metricInfo.Metrics = val
376
377 ke.SliceData = []*voltha.MetricInformation{&metricInfo}
378 ke.Type = voltha.KpiEventType_slice
379 ke.Ts = float64(time.Now().UnixNano())
380
381 if err := StatMgr.Device.EventProxy.SendKpiEvent("STATS_EVENT", &ke, voltha.EventCategory_EQUIPMENT, volthaEventSubCatgry, raisedTs); err != nil {
382 log.Errorw("Failed to send Pon stats", log.Fields{"err": err})
383 }
384
385}
386
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700387// PortStatisticsIndication handles the port statistics indication
Naga Manjunath7615e552019-10-11 22:35:47 +0530388func (StatMgr *OpenOltStatisticsMgr) PortStatisticsIndication(PortStats *openolt.PortStatistics, NumPonPorts uint32) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530389 log.Debugf("port-stats-collected %v", PortStats)
Naga Manjunath7615e552019-10-11 22:35:47 +0530390 StatMgr.PortsStatisticsKpis(PortStats, NumPonPorts)
391 log.Infow("Received port stats indication", log.Fields{"PortStats": PortStats})
Abhilash S.L765ad002019-04-24 16:40:57 +0530392 // TODO send stats to core topic to the voltha kafka or a different kafka ?
393}
394
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700395// FlowStatisticsIndication to be implemented
Abhilash S.L765ad002019-04-24 16:40:57 +0530396func FlowStatisticsIndication(self, FlowStats *openolt.FlowStatistics) {
397 log.Debugf("flow-stats-collected %v", FlowStats)
398 //TODO send to kafka ?
399}
400
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700401// PortsStatisticsKpis map the port stats values into a dictionary, creates the kpiEvent and then publish to Kafka
Naga Manjunath7615e552019-10-11 22:35:47 +0530402func (StatMgr *OpenOltStatisticsMgr) PortsStatisticsKpis(PortStats *openolt.PortStatistics, NumPonPorts uint32) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530403
404 /*map the port stats values into a dictionary
405 Create a kpoEvent and publish to Kafka
406
407 :param port_stats:
408 :return:
409 */
410 //var err error
411 IntfID := PortStats.IntfId
412
Naga Manjunath7615e552019-10-11 22:35:47 +0530413 if (IntfIDToPortNo(1, voltha.Port_ETHERNET_NNI) < IntfID) &&
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700414 (IntfID < IntfIDToPortNo(4, voltha.Port_ETHERNET_NNI)) {
Abhilash S.L765ad002019-04-24 16:40:57 +0530415 /*
416 for this release we are only interested in the first NNI for
417 Northbound.
418 we are not using the other 3
419 */
420 return
Naga Manjunath7615e552019-10-11 22:35:47 +0530421 } else if IntfIDToPortNo(0, voltha.Port_ETHERNET_NNI) == IntfID {
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700422
Naga Manjunath7615e552019-10-11 22:35:47 +0530423 var portNNIStat NniPort
424 portNNIStat.IntfID = IntfID
425 portNNIStat.PortNum = uint32(0)
426 portNNIStat.RxBytes = PortStats.RxBytes
427 portNNIStat.RxPackets = PortStats.RxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000428 portNNIStat.RxUcastPackets = PortStats.RxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530429 portNNIStat.RxMcastPackets = PortStats.RxMcastPackets
430 portNNIStat.RxBcastPackets = PortStats.RxBcastPackets
431 portNNIStat.TxBytes = PortStats.TxBytes
432 portNNIStat.TxPackets = PortStats.TxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000433 portNNIStat.TxUcastPackets = PortStats.TxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530434 portNNIStat.TxMcastPackets = PortStats.TxMcastPackets
435 portNNIStat.TxBcastPackets = PortStats.TxBcastPackets
436 mutex.Lock()
437 StatMgr.NorthBoundPort[0] = &portNNIStat
438 mutex.Unlock()
439 log.Debugf("Received-NNI-Stats: %v", StatMgr.NorthBoundPort)
440 }
441 for i := uint32(0); i < NumPonPorts; i++ {
442
443 if IntfIDToPortNo(i, voltha.Port_PON_OLT) == IntfID {
444 var portPonStat PonPort
445 portPonStat.IntfID = IntfID
446 portPonStat.PortNum = i
447 portPonStat.PONID = i
448 portPonStat.RxBytes = PortStats.RxBytes
449 portPonStat.RxPackets = PortStats.RxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000450 portPonStat.RxUcastPackets = PortStats.RxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530451 portPonStat.RxMcastPackets = PortStats.RxMcastPackets
452 portPonStat.RxBcastPackets = PortStats.RxBcastPackets
453 portPonStat.TxBytes = PortStats.TxBytes
454 portPonStat.TxPackets = PortStats.TxPackets
Dileep Kuchhangi52cfbe12020-01-15 20:16:21 +0000455 portPonStat.TxUcastPackets = PortStats.TxUcastPackets
Naga Manjunath7615e552019-10-11 22:35:47 +0530456 portPonStat.TxMcastPackets = PortStats.TxMcastPackets
457 portPonStat.TxBcastPackets = PortStats.TxBcastPackets
458 mutex.Lock()
459 StatMgr.SouthBoundPort[i] = &portPonStat
460 mutex.Unlock()
461 log.Debugf("Received-PON-Stats-for-Port %v : %v", i, StatMgr.SouthBoundPort[i])
462 }
463 }
Girish Gowdru6a80bbd2019-07-02 07:36:09 -0700464
465 /*
466 Based upon the intf_id map to an nni port or a pon port
467 the intf_id is the key to the north or south bound collections
468
469 Based upon the intf_id the port object (nni_port or pon_port) will
470 have its data attr. updated by the current dataset collected.
471
472 For prefixing the rule is currently to use the port number and not the intf_id
473 */
474 //FIXME : Just use first NNI for now
475 /* TODO should the data be marshaled before sending it ?
476 if IntfID == IntfIdToPortNo(0, voltha.Port_ETHERNET_NNI) {
477 //NNI port (just the first one)
478 err = UpdatePortObjectKpiData(StatMgr.NorthBoundPorts[PortStats.IntfID], PMData)
479 } else {
480 //PON ports
481 err = UpdatePortObjectKpiData(SouthboundPorts[PortStats.IntfID], PMData)
482 }
483 if (err != nil) {
484 log.Error("Error publishing statistics data")
485 }
486 */
487
Abhilash S.L765ad002019-04-24 16:40:57 +0530488}