Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1 | /* |
| 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 Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 19 | #define BAL_STAT_PRES 1 |
| 20 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 21 | /********************************************************************\ |
| 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 Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 27 | uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData, |
| 28 | BalInterfaceKey *statKey) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 29 | { |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 30 | bcmbal_interface_stat interface_stats; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 31 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 32 | bcmos_errno err = BCM_ERR_OK; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 33 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame^] | 34 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Get Stats from OLT intf_type %d",intf_type); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 35 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 36 | 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 Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 42 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 43 | bcmbal_interface_key key = { .intf_id = intf_id, .intf_type = intf_type }; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 44 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 45 | /* Prepare to retrieve stat on NNI interface 0 */ |
| 46 | BCMBAL_STAT_INIT(&interface_stats, interface, key); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 47 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 48 | /* Retrieve the Upstream packet and byte counts */ |
| 49 | BCMBAL_STAT_PROP_GET(&interface_stats, interface, all_properties); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame^] | 50 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Retrieve the Upstream packet and byte count success"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 51 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 52 | /* 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 Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 60 | /*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 Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 67 | 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 Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 100 | } |