blob: 0c0de39f3529a61c64e93b66361426e4e095a778 [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 ********************************************************************/
27uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData)
28{
Rajeswara Raob2e441c2017-09-20 16:40:21 +053029 bcmbal_interface_stat interface_stats;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053030
Rajeswara Raob2e441c2017-09-20 16:40:21 +053031 bcmos_errno err = BCM_ERR_OK;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053032
Rajeswara Raob2e441c2017-09-20 16:40:21 +053033 ASFVOLT_LOG(ASFVOLT_DEBUG, "Get Stats from OLT intf_type %d\n",intf_type);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053034
Rajeswara Raob2e441c2017-09-20 16:40:21 +053035 if(intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_NNI && intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_PON &&
36 intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_1G_PATH &&
37 intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_10G_PATH)
38 {
39 return BCM_ERR_PARM;
40 }
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053041
Rajeswara Raob2e441c2017-09-20 16:40:21 +053042 bcmbal_interface_key key = { .intf_id = intf_id, .intf_type = intf_type };
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053043
Rajeswara Raob2e441c2017-09-20 16:40:21 +053044 /* Prepare to retrieve stat on NNI interface 0 */
45 BCMBAL_STAT_INIT(&interface_stats, interface, key);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053046
Rajeswara Raob2e441c2017-09-20 16:40:21 +053047 /* Retrieve the Upstream packet and byte counts */
48 BCMBAL_STAT_PROP_GET(&interface_stats, interface, all_properties);
49 ASFVOLT_LOG(ASFVOLT_DEBUG, "Retrieve the Upstream packet and byte count success\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053050
Rajeswara Raob2e441c2017-09-20 16:40:21 +053051 /* Read the NNI stats.
52 * NOTE: When a CLEAR is specified during a NNI stats GET operation,
53 * all of the NNI stats are cleared, even the ones that are not retrieved.
54 */
55 err = bcmbal_stat_get(DEFAULT_ATERM_ID, &interface_stats.hdr, BCMOS_TRUE);
56
57 if(err == BCM_ERR_OK)
58 {
59 statData->has_rx_bytes = BAL_STAT_PRES;
60 statData->rx_bytes = interface_stats.data.rx_bytes;
61 statData->has_rx_packets = BAL_STAT_PRES;
62 statData->rx_packets = interface_stats.data.rx_packets;
63 statData->has_rx_ucast_packets = BAL_STAT_PRES;
64 statData->rx_ucast_packets = interface_stats.data.rx_ucast_packets;
65 statData->has_rx_mcast_packets = BAL_STAT_PRES;
66 statData->rx_mcast_packets = interface_stats.data.rx_mcast_packets;
67 statData->has_rx_bcast_packets = BAL_STAT_PRES;
68 statData->rx_bcast_packets = interface_stats.data.rx_bcast_packets;
69 statData->has_rx_error_packets = BAL_STAT_PRES;
70 statData->rx_error_packets = interface_stats.data.rx_error_packets;
71 statData->has_rx_unknown_protos = BAL_STAT_PRES;
72 statData->rx_unknown_protos = interface_stats.data.rx_unknown_protos;
73 statData->has_tx_bytes = BAL_STAT_PRES;
74 statData->tx_bytes = interface_stats.data.tx_bytes;
75 statData->has_tx_packets = BAL_STAT_PRES;
76 statData->tx_packets = interface_stats.data.tx_packets;
77 statData->has_tx_ucast_packets = BAL_STAT_PRES;
78 statData->tx_ucast_packets = interface_stats.data.tx_ucast_packets;
79 statData->has_tx_mcast_packets = BAL_STAT_PRES;
80 statData->tx_mcast_packets = interface_stats.data.tx_mcast_packets;
81 statData->has_tx_bcast_packets = BAL_STAT_PRES;
82 statData->tx_bcast_packets = interface_stats.data.tx_bcast_packets;
83 statData->has_tx_error_packets = BAL_STAT_PRES;
84 statData->tx_error_packets = interface_stats.data.tx_error_packets;
85 statData->has_rx_crc_errors = BAL_STAT_PRES;
86 statData->rx_crc_errors = interface_stats.data.rx_crc_errors;
87 statData->has_bip_errors = BAL_STAT_PRES;
88 statData->bip_errors = interface_stats.data.bip_errors;
89 }
90
91 return err;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053092}