blob: b1c49d21ab1130cc32a0af2b4a31c1d88c635632 [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
19/********************************************************************\
20 * Function : asfvolt16_bal_stats_get *
21 * Description : Function to get stats based on *
22 * interface type(NNI/PON/EPON 1G/EPON 10G) *
23 * port number *
24 ********************************************************************/
25uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData)
26{
27 bcmbal_interface_stat interface_stats;
28
29 bcmos_errno err = BCM_ERR_OK;
30
31 if(intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_NNI || intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_PON||
32 intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_1G_PATH ||
33 intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_10G_PATH)
34 {
35 err = BCM_ERR_PARM;
36 }
37
38 if(err == BCM_ERR_OK)
39 {
40 bcmbal_interface_key key = { .intf_id = intf_id,
41 .intf_type = intf_type };
42
43 /* Prepare to retrieve stat on NNI interface 0 */
44 BCMBAL_STAT_INIT(&interface_stats, interface, key);
45
46 /* Retrieve the Upstream packet and byte counts */
47 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_bytes);
48 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_packets);
49 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_ucast_packets);
50 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_mcast_packets);
51 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_bcast_packets);
52 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_error_packets);
53 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_unknown_protos);
54 BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_bytes);
55 BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_packets);
56 BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_ucast_packets);
57 BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_mcast_packets);
58 BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_bcast_packets);
59 BCMBAL_STAT_PROP_GET(&interface_stats, interface, tx_error_packets);
60 BCMBAL_STAT_PROP_GET(&interface_stats, interface, rx_crc_errors);
61 BCMBAL_STAT_PROP_GET(&interface_stats, interface, bip_errors);
62
63 /* Read the NNI stats.
64 * NOTE: When a CLEAR is specified during a NNI stats GET operation,
65 * all of the NNI stats are cleared, even the ones that are not retrieved.
66 */
67 err = bcmbal_stat_get(DEFAULT_ATERM_ID, &interface_stats.hdr, BCMOS_TRUE);
68
69 if(err == BCM_ERR_OK)
70 {
71 statData->rx_bytes = interface_stats.data.rx_bytes;
72 statData->rx_packets = interface_stats.data.rx_packets;
73 statData->rx_ucast_packets = interface_stats.data.rx_ucast_packets;
74 statData->rx_mcast_packets = interface_stats.data.rx_mcast_packets;
75 statData->rx_bcast_packets = interface_stats.data.rx_bcast_packets;
76 statData->rx_error_packets = interface_stats.data.rx_error_packets;
77 statData->rx_unknown_protos = interface_stats.data.rx_unknown_protos;
78 statData->tx_bytes = interface_stats.data.tx_bytes;
79 statData->tx_packets = interface_stats.data.tx_packets;
80 statData->tx_ucast_packets = interface_stats.data.tx_ucast_packets;
81 statData->tx_mcast_packets = interface_stats.data.tx_mcast_packets;
82 statData->tx_bcast_packets = interface_stats.data.tx_bcast_packets;
83 statData->tx_error_packets = interface_stats.data.tx_error_packets;
84 statData->rx_crc_errors = interface_stats.data.rx_crc_errors;
85 statData->bip_errors = interface_stats.data.bip_errors;
86 }
87 }
88
89 return err;
90}