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 | |
| 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 | ********************************************************************/ |
Rajeswara Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 25 | uint32_t asfvolt16_bal_stats_get(BalIntfType intf_type, uint32_t intf_id, BalInterfaceStatData *statData, |
| 26 | BalInterfaceKey *statKey) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 27 | { |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 28 | bcmbal_interface_stat interface_stats; |
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 | bcmos_errno err = BCM_ERR_OK; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 31 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 32 | 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] | 33 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 34 | if(intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_NNI && intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_PON && |
| 35 | intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_1G_PATH && |
| 36 | intf_type!=BAL_INTF_TYPE__BAL_INTF_TYPE_EPON_10G_PATH) |
| 37 | { |
| 38 | return BCM_ERR_PARM; |
| 39 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 40 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 41 | bcmbal_interface_key key = { .intf_id = intf_id, .intf_type = intf_type }; |
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 | /* Prepare to retrieve stat on NNI interface 0 */ |
| 44 | BCMBAL_STAT_INIT(&interface_stats, interface, key); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 45 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 46 | /* Retrieve the Upstream packet and byte counts */ |
| 47 | BCMBAL_STAT_PROP_GET(&interface_stats, interface, all_properties); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 48 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Retrieve the Upstream packet and byte count success"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 49 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 50 | /* Read the NNI stats. |
| 51 | * NOTE: When a CLEAR is specified during a NNI stats GET operation, |
| 52 | * all of the NNI stats are cleared, even the ones that are not retrieved. |
| 53 | */ |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 54 | err = bcmbal_stat_get(DEFAULT_ATERM_ID, &interface_stats.hdr, BCMOS_FALSE); |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 55 | |
| 56 | if(err == BCM_ERR_OK) |
| 57 | { |
Rajeswara Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 58 | /*interface key*/ |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 59 | statKey->has_intf_id = BAL_ELEMENT_PRES; |
Rajeswara Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 60 | statKey->intf_id = interface_stats.key.intf_id; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 61 | statKey->has_intf_type = BAL_ELEMENT_PRES; |
Rajeswara Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 62 | statKey->intf_type = interface_stats.key.intf_type; |
| 63 | |
| 64 | /*interface stat data*/ |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 65 | statData->has_rx_bytes = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 66 | statData->rx_bytes = interface_stats.data.rx_bytes; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 67 | statData->has_rx_packets = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 68 | statData->rx_packets = interface_stats.data.rx_packets; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 69 | statData->has_rx_data_bytes = BAL_ELEMENT_PRES; |
| 70 | statData->rx_data_bytes = interface_stats.data.rx_data_bytes; |
| 71 | statData->has_rx_ucast_packets = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 72 | statData->rx_ucast_packets = interface_stats.data.rx_ucast_packets; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 73 | statData->has_rx_mcast_packets = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 74 | statData->rx_mcast_packets = interface_stats.data.rx_mcast_packets; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 75 | statData->has_rx_bcast_packets = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 76 | statData->rx_bcast_packets = interface_stats.data.rx_bcast_packets; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 77 | statData->rx_64_packets = BAL_ELEMENT_PRES; |
| 78 | statData->rx_64_packets = interface_stats.data.rx_64_packets; |
| 79 | statData->has_rx_65_127_packets = BAL_ELEMENT_PRES; |
| 80 | statData->rx_65_127_packets = interface_stats.data.rx_65_127_packets; |
| 81 | statData->has_rx_128_255_packets = BAL_ELEMENT_PRES; |
| 82 | statData->rx_128_255_packets = interface_stats.data.rx_128_255_packets; |
| 83 | statData->has_rx_256_511_packets = BAL_ELEMENT_PRES; |
| 84 | statData->rx_256_511_packets = interface_stats.data.rx_256_511_packets; |
| 85 | statData->has_rx_512_1023_packets = BAL_ELEMENT_PRES; |
| 86 | statData->rx_512_1023_packets = interface_stats.data.rx_512_1023_packets; |
| 87 | statData->has_rx_1024_1518_packets = BAL_ELEMENT_PRES; |
| 88 | statData->rx_1024_1518_packets = interface_stats.data.rx_1024_1518_packets; |
| 89 | statData->has_rx_1519_2047_packets = BAL_ELEMENT_PRES; |
| 90 | statData->rx_1519_2047_packets = interface_stats.data.rx_1519_2047_packets; |
| 91 | statData->has_rx_2048_4095_packets = BAL_ELEMENT_PRES; |
| 92 | statData->rx_2048_4095_packets = interface_stats.data.rx_2048_4095_packets; |
| 93 | statData->has_rx_4096_9216_packets = BAL_ELEMENT_PRES; |
| 94 | statData->rx_4096_9216_packets = interface_stats.data.rx_4096_9216_packets; |
| 95 | statData->has_rx_9217_16383_packets = BAL_ELEMENT_PRES; |
| 96 | statData->rx_9217_16383_packets = interface_stats.data.rx_9217_16383_packets; |
| 97 | statData->has_rx_error_packets = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 98 | statData->rx_error_packets = interface_stats.data.rx_error_packets; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 99 | statData->has_rx_unknown_protos = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 100 | statData->rx_unknown_protos = interface_stats.data.rx_unknown_protos; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 101 | statData->has_rx_crc_errors = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 102 | statData->rx_crc_errors = interface_stats.data.rx_crc_errors; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 103 | statData->has_bip_errors = BAL_ELEMENT_PRES; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 104 | statData->bip_errors = interface_stats.data.bip_errors; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 105 | statData->has_rx_mpcp = BAL_ELEMENT_PRES; |
| 106 | statData->rx_mpcp = interface_stats.data.rx_mpcp; |
| 107 | statData->has_rx_report = BAL_ELEMENT_PRES; |
| 108 | statData->rx_report = interface_stats.data.rx_report; |
| 109 | statData->has_rx_oam_bytes = BAL_ELEMENT_PRES; |
| 110 | statData->rx_oam_bytes = interface_stats.data.rx_oam_bytes; |
| 111 | statData->has_rx_oam_packets = BAL_ELEMENT_PRES; |
| 112 | statData->rx_oam_packets = interface_stats.data.rx_oam_packets; |
| 113 | statData->has_tx_bytes = BAL_ELEMENT_PRES; |
| 114 | statData->tx_bytes = interface_stats.data.tx_bytes; |
| 115 | statData->has_tx_packets = BAL_ELEMENT_PRES; |
| 116 | statData->tx_packets = interface_stats.data.tx_packets; |
| 117 | statData->has_tx_data_bytes = BAL_ELEMENT_PRES; |
| 118 | statData->tx_data_bytes = interface_stats.data.tx_data_bytes; |
| 119 | statData->has_tx_ucast_packets = BAL_ELEMENT_PRES; |
| 120 | statData->tx_ucast_packets = interface_stats.data.tx_ucast_packets; |
| 121 | statData->has_tx_mcast_packets = BAL_ELEMENT_PRES; |
| 122 | statData->tx_mcast_packets = interface_stats.data.tx_mcast_packets; |
| 123 | statData->has_tx_bcast_packets = BAL_ELEMENT_PRES; |
| 124 | statData->tx_bcast_packets = interface_stats.data.tx_bcast_packets; |
| 125 | statData->has_tx_64_packets = BAL_ELEMENT_PRES; |
| 126 | statData->tx_64_packets = interface_stats.data.tx_64_packets; |
| 127 | statData->has_tx_65_127_packets = BAL_ELEMENT_PRES; |
| 128 | statData->tx_65_127_packets = interface_stats.data.tx_65_127_packets; |
| 129 | statData->has_tx_128_255_packets = BAL_ELEMENT_PRES; |
| 130 | statData->tx_128_255_packets = interface_stats.data.tx_128_255_packets; |
| 131 | statData->has_tx_256_511_packets = BAL_ELEMENT_PRES; |
| 132 | statData->tx_256_511_packets = interface_stats.data.tx_256_511_packets; |
| 133 | statData->has_tx_512_1023_packets = BAL_ELEMENT_PRES; |
| 134 | statData->tx_512_1023_packets = interface_stats.data.tx_512_1023_packets; |
| 135 | statData->has_tx_1024_1518_packets = BAL_ELEMENT_PRES; |
| 136 | statData->tx_1024_1518_packets = interface_stats.data.tx_1024_1518_packets; |
| 137 | statData->has_tx_1519_2047_packets = BAL_ELEMENT_PRES; |
| 138 | statData->tx_1519_2047_packets = interface_stats.data.tx_1519_2047_packets; |
| 139 | statData->has_tx_2048_4095_packets = BAL_ELEMENT_PRES; |
| 140 | statData->tx_2048_4095_packets = interface_stats.data.tx_2048_4095_packets; |
| 141 | statData->has_tx_4096_9216_packets = BAL_ELEMENT_PRES; |
| 142 | statData->tx_4096_9216_packets = interface_stats.data.tx_4096_9216_packets; |
| 143 | statData->has_tx_9217_16383_packets = BAL_ELEMENT_PRES; |
| 144 | statData->tx_9217_16383_packets = interface_stats.data.tx_9217_16383_packets; |
| 145 | statData->has_tx_error_packets = BAL_ELEMENT_PRES; |
| 146 | statData->tx_error_packets = interface_stats.data.tx_error_packets; |
| 147 | statData->has_tx_mpcp = BAL_ELEMENT_PRES; |
| 148 | statData->tx_mpcp = interface_stats.data.tx_mpcp; |
| 149 | statData->has_tx_gate = BAL_ELEMENT_PRES; |
| 150 | statData->tx_gate = interface_stats.data.tx_gate; |
| 151 | statData->has_tx_oam_bytes = BAL_ELEMENT_PRES; |
| 152 | statData->tx_oam_bytes = interface_stats.data.tx_oam_bytes; |
| 153 | statData->has_tx_oam_packets = BAL_ELEMENT_PRES; |
| 154 | statData->tx_oam_packets = interface_stats.data.tx_oam_packets; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | return err; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 158 | } |