blob: 7865c7cb1a9e3d14d21b377698d41ad0f8c937d8 [file] [log] [blame]
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301/*
2** Copyright 2017-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*/
16
17#include "bal_stats_hdlr.h"
18
Rajeswara Raob2e441c2017-09-20 16:40:21 +053019#define BAL_STAT_PRES 1
20
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053021/********************************************************************\
22 * Function : asfvolt16_bal_stats_get *
23 * Description : Function to get stats based on *
24 * interface type(NNI/PON/EPON 1G/EPON 10G) *
25 * port number *
26 ********************************************************************/
Rajeswara Rao92e3fd42017-10-26 10:47:03 +053027uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData,
28 BalInterfaceKey *statKey)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053029{
Rajeswara Raob2e441c2017-09-20 16:40:21 +053030 bcmbal_interface_stat interface_stats;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053031
Rajeswara Raob2e441c2017-09-20 16:40:21 +053032 bcmos_errno err = BCM_ERR_OK;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053033
Kim Kempfafa1ab42017-11-13 09:31:47 -080034 ASFVOLT_LOG(ASFVOLT_DEBUG, "Get Stats from OLT intf_type %d",intf_type);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053035
Rajeswara Raob2e441c2017-09-20 16:40:21 +053036 if(intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_NNI && intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_PON &&
37 intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_1G_PATH &&
38 intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_10G_PATH)
39 {
40 return BCM_ERR_PARM;
41 }
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053042
Rajeswara Raob2e441c2017-09-20 16:40:21 +053043 bcmbal_interface_key key = { .intf_id = intf_id, .intf_type = intf_type };
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053044
Rajeswara Raob2e441c2017-09-20 16:40:21 +053045 /* Prepare to retrieve stat on NNI interface 0 */
46 BCMBAL_STAT_INIT(&interface_stats, interface, key);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053047
Rajeswara Raob2e441c2017-09-20 16:40:21 +053048 /* Retrieve the Upstream packet and byte counts */
49 BCMBAL_STAT_PROP_GET(&interface_stats, interface, all_properties);
Kim Kempfafa1ab42017-11-13 09:31:47 -080050 ASFVOLT_LOG(ASFVOLT_DEBUG, "Retrieve the Upstream packet and byte count success");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053051
Rajeswara Raob2e441c2017-09-20 16:40:21 +053052 /* Read the NNI stats.
53 * NOTE: When a CLEAR is specified during a NNI stats GET operation,
54 * all of the NNI stats are cleared, even the ones that are not retrieved.
55 */
56 err = bcmbal_stat_get(DEFAULT_ATERM_ID, &interface_stats.hdr, BCMOS_TRUE);
57
58 if(err == BCM_ERR_OK)
59 {
Rajeswara Rao92e3fd42017-10-26 10:47:03 +053060 /*interface key*/
61 statKey->has_intf_id = BAL_STAT_PRES;
62 statKey->intf_id = interface_stats.key.intf_id;
63 statKey->has_intf_type = BAL_STAT_PRES;
64 statKey->intf_type = interface_stats.key.intf_type;
65
66 /*interface stat data*/
Rajeswara Raob2e441c2017-09-20 16:40:21 +053067 statData->has_rx_bytes = BAL_STAT_PRES;
68 statData->rx_bytes = interface_stats.data.rx_bytes;
69 statData->has_rx_packets = BAL_STAT_PRES;
70 statData->rx_packets = interface_stats.data.rx_packets;
71 statData->has_rx_ucast_packets = BAL_STAT_PRES;
72 statData->rx_ucast_packets = interface_stats.data.rx_ucast_packets;
73 statData->has_rx_mcast_packets = BAL_STAT_PRES;
74 statData->rx_mcast_packets = interface_stats.data.rx_mcast_packets;
75 statData->has_rx_bcast_packets = BAL_STAT_PRES;
76 statData->rx_bcast_packets = interface_stats.data.rx_bcast_packets;
77 statData->has_rx_error_packets = BAL_STAT_PRES;
78 statData->rx_error_packets = interface_stats.data.rx_error_packets;
79 statData->has_rx_unknown_protos = BAL_STAT_PRES;
80 statData->rx_unknown_protos = interface_stats.data.rx_unknown_protos;
81 statData->has_tx_bytes = BAL_STAT_PRES;
82 statData->tx_bytes = interface_stats.data.tx_bytes;
83 statData->has_tx_packets = BAL_STAT_PRES;
84 statData->tx_packets = interface_stats.data.tx_packets;
85 statData->has_tx_ucast_packets = BAL_STAT_PRES;
86 statData->tx_ucast_packets = interface_stats.data.tx_ucast_packets;
87 statData->has_tx_mcast_packets = BAL_STAT_PRES;
88 statData->tx_mcast_packets = interface_stats.data.tx_mcast_packets;
89 statData->has_tx_bcast_packets = BAL_STAT_PRES;
90 statData->tx_bcast_packets = interface_stats.data.tx_bcast_packets;
91 statData->has_tx_error_packets = BAL_STAT_PRES;
92 statData->tx_error_packets = interface_stats.data.tx_error_packets;
93 statData->has_rx_crc_errors = BAL_STAT_PRES;
94 statData->rx_crc_errors = interface_stats.data.rx_crc_errors;
95 statData->has_bip_errors = BAL_STAT_PRES;
96 statData->bip_errors = interface_stats.data.bip_errors;
97 }
98
99 return err;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530100}