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 <stdio.h> |
| 18 | #include <bal_api.h> |
| 19 | |
| 20 | #undef _SYS_QUEUE_H_ |
| 21 | |
| 22 | #include "asfvolt16_driver.h" |
| 23 | #include "bal_interface_hdlr.h" |
| 24 | |
| 25 | /********************************************************************\ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 26 | * Function : bal_interface_cfg_set * |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 27 | * Description : Configures the PON and NNI interfaces * |
| 28 | * of OLT Device * |
| 29 | ********************************************************************/ |
| 30 | uint32_t bal_interface_cfg_set(BalInterfaceCfg *interface_cfg) |
| 31 | { |
| 32 | bcmos_errno err = BCM_ERR_OK; |
| 33 | bcmbal_interface_cfg interface_obj; |
| 34 | bcmbal_interface_key intf_key; |
| 35 | |
| 36 | intf_key.intf_id = interface_cfg->key->intf_id; |
| 37 | intf_key.intf_type = interface_cfg->key->intf_type; |
| 38 | |
Suhas Gururaj | 07da86a | 2018-05-11 14:37:03 +0530 | [diff] [blame] | 39 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Setting Interface ID(%d) Interface Type(%d) to Admin state(%d)", |
| 40 | intf_key.intf_id, intf_key.intf_type, |
| 41 | interface_cfg->data->admin_state); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 42 | |
| 43 | /* |
| 44 | * Set the key in the interface object and initialize the object itself |
| 45 | */ |
| 46 | BCMBAL_CFG_INIT(&interface_obj, interface, intf_key); |
| 47 | |
Suhas Gururaj | 07da86a | 2018-05-11 14:37:03 +0530 | [diff] [blame] | 48 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, admin_state, BCMOS_TRUE, |
| 49 | interface_cfg->data->admin_state); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 50 | |
Suhas Gururaj | 07da86a | 2018-05-11 14:37:03 +0530 | [diff] [blame] | 51 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_agg_port_id, |
| 52 | interface_cfg->data->has_min_data_svc_port_id, |
| 53 | interface_cfg->data->min_data_agg_port_id); |
| 54 | |
| 55 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_svc_port_id, |
| 56 | interface_cfg->data->has_min_data_svc_port_id, |
| 57 | interface_cfg->data->min_data_svc_port_id); |
| 58 | |
| 59 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, transceiver_type, |
| 60 | BCMOS_TRUE, |
| 61 | interface_cfg->data->transceiver_type); |
| 62 | ASFVOLT_LOG(ASFVOLT_INFO, "Setting transceiver_type to : %d", interface_cfg->data->transceiver_type); |
| 63 | |
Suhas Gururaj | 07da86a | 2018-05-11 14:37:03 +0530 | [diff] [blame] | 64 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, mtu, |
| 65 | interface_cfg->data->has_mtu, |
| 66 | interface_cfg->data->mtu); |
| 67 | |
Suhas Gururaj | 07da86a | 2018-05-11 14:37:03 +0530 | [diff] [blame] | 68 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_tm, |
| 69 | interface_cfg->data->has_ds_tm, |
| 70 | interface_cfg->data->ds_tm); |
| 71 | |
| 72 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, us_tm, |
| 73 | interface_cfg->data->has_us_tm, |
| 74 | interface_cfg->data->us_tm); |
| 75 | |
| 76 | ASFVOLT_LOG(ASFVOLT_INFO, "Bringing up the interface No: %d", intf_key.intf_id); |
| 77 | |
| 78 | err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr)); |
| 79 | |
| 80 | if(BCM_ERR_OK != err) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 81 | { |
Suhas Gururaj | 07da86a | 2018-05-11 14:37:03 +0530 | [diff] [blame] | 82 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the interface object to ADMIN-UP"); |
| 83 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 84 | } |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 85 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Set Interface configuration sent to OLT.Interface ID(%d) Interface Type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 86 | intf_key.intf_id, intf_key.intf_type); |
| 87 | return BAL_ERRNO__BAL_ERR_OK; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | /********************************************************************\ |
| 92 | * Function : bal_interface_cfg_get * |
| 93 | * Description : get the PON and NNI interfaces * |
| 94 | * of OLT Device * |
| 95 | ********************************************************************/ |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 96 | uint32_t bal_interface_cfg_get(BalInterfaceCfg *interface_cfg) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 97 | { |
| 98 | bcmos_errno err = BCM_ERR_OK; |
| 99 | bcmbal_interface_cfg interface_obj; |
| 100 | bcmbal_interface_key intf_key; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 101 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 102 | intf_key.intf_id = interface_cfg->key->intf_id; |
| 103 | intf_key.intf_type = interface_cfg->key->intf_type; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 104 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 105 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Get interface cfg(for OLT) starts"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 106 | /* |
| 107 | * Set the key in the interface object and initialize the object itself |
| 108 | */ |
| 109 | BCMBAL_CFG_INIT(&interface_obj, interface, intf_key); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 110 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 111 | /* request all properties, include everything */ |
| 112 | BCMBAL_CFG_PROP_GET(&interface_obj, interface, all_properties); |
| 113 | |
| 114 | err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &interface_obj.hdr); |
| 115 | |
| 116 | if(BCM_ERR_OK != err) |
| 117 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 118 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the interface Cfg(OLT)"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 119 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 120 | } |
| 121 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 122 | ASFVOLT_LOG(ASFVOLT_INFO, "Get Interface cfg sent to OLT. " |
| 123 | "Interface ID(%d) Interface Type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 124 | intf_key.intf_id, intf_key.intf_type); |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 125 | |
| 126 | memcpy(interface_cfg->data, &interface_obj, sizeof(bcmbal_interface_cfg_data)); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 127 | |
| 128 | return BAL_ERRNO__BAL_ERR_OK; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | /********************************************************************\ |
| 133 | * Function : bal_interface_cfg_clear * |
| 134 | * Description : Clears the PON and NNI interfaces * |
| 135 | * of OLT Device * |
| 136 | ********************************************************************/ |
| 137 | uint32_t bal_interface_cfg_clear(BalInterfaceKey *interface_cfg_key) |
| 138 | { |
| 139 | bcmos_errno err = BCM_ERR_OK; |
| 140 | bcmbal_interface_cfg interface_obj; |
| 141 | bcmbal_interface_key intf_key; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 142 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 143 | if((interface_cfg_key->has_intf_id) && (interface_cfg_key->has_intf_type)) |
| 144 | { |
| 145 | intf_key.intf_id = interface_cfg_key->intf_id; |
| 146 | intf_key.intf_type = interface_cfg_key->intf_type; |
| 147 | } |
| 148 | else |
| 149 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 150 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface cfg(OLT): Missing Key values " |
| 151 | "Received key values intf-id(%d), intf-type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 152 | interface_cfg_key->intf_id, interface_cfg_key->intf_type); |
| 153 | return BAL_ERRNO__BAL_ERR_NOENT; |
| 154 | } |
| 155 | |
| 156 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 157 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Clearing of OLT(interface cfg) starts"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 158 | /* |
| 159 | * Set the key in the interface object and initialize the object itself |
| 160 | */ |
| 161 | BCMBAL_CFG_INIT(&interface_obj, interface, intf_key); |
| 162 | |
| 163 | err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &interface_obj.hdr); |
| 164 | |
| 165 | if(BCM_ERR_OK != err) |
| 166 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 167 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface Cfg(OLT)"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 168 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 169 | } |
| 170 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 171 | ASFVOLT_LOG(ASFVOLT_INFO, "Clear Interface cfg sent to OLT. " |
| 172 | "Interface ID(%d) Interface Type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 173 | intf_key.intf_id, intf_key.intf_type); |
| 174 | return BAL_ERRNO__BAL_ERR_OK; |
| 175 | } |