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 | |
| 64 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_miss_mode, |
| 65 | interface_cfg->data->has_ds_miss_mode, |
| 66 | interface_cfg->data->ds_miss_mode); |
| 67 | |
| 68 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, mtu, |
| 69 | interface_cfg->data->has_mtu, |
| 70 | interface_cfg->data->mtu); |
| 71 | |
| 72 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, flow_control, |
| 73 | interface_cfg->data->has_flow_control, |
| 74 | interface_cfg->data->flow_control); |
| 75 | |
| 76 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_tm, |
| 77 | interface_cfg->data->has_ds_tm, |
| 78 | interface_cfg->data->ds_tm); |
| 79 | |
| 80 | ASFVOLT_CFG_PROP_SET(interface_obj, interface, us_tm, |
| 81 | interface_cfg->data->has_us_tm, |
| 82 | interface_cfg->data->us_tm); |
| 83 | |
| 84 | ASFVOLT_LOG(ASFVOLT_INFO, "Bringing up the interface No: %d", intf_key.intf_id); |
| 85 | |
| 86 | err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr)); |
| 87 | |
| 88 | if(BCM_ERR_OK != err) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 89 | { |
Suhas Gururaj | 07da86a | 2018-05-11 14:37:03 +0530 | [diff] [blame^] | 90 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the interface object to ADMIN-UP"); |
| 91 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 92 | } |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 93 | 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] | 94 | intf_key.intf_id, intf_key.intf_type); |
| 95 | return BAL_ERRNO__BAL_ERR_OK; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | /********************************************************************\ |
| 100 | * Function : bal_interface_cfg_get * |
| 101 | * Description : get the PON and NNI interfaces * |
| 102 | * of OLT Device * |
| 103 | ********************************************************************/ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 104 | uint32_t bal_interface_cfg_get(BalInterfaceKey *interface_cfg_key, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 105 | BalInterfaceCfg *interface_cfg) |
| 106 | { |
| 107 | bcmos_errno err = BCM_ERR_OK; |
| 108 | bcmbal_interface_cfg interface_obj; |
| 109 | bcmbal_interface_key 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 | if((interface_cfg_key->has_intf_id) && (interface_cfg_key->has_intf_type)) |
| 112 | { |
| 113 | intf_key.intf_id = interface_cfg_key->intf_id; |
| 114 | intf_key.intf_type = interface_cfg_key->intf_type; |
| 115 | } |
| 116 | else |
| 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): Missing Key values " |
| 119 | "Received key values intf-id(%d), intf-type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 120 | interface_cfg_key->intf_id, interface_cfg_key->intf_type); |
| 121 | return BAL_ERRNO__BAL_ERR_NOENT; |
| 122 | } |
| 123 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 124 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Get interface cfg(for OLT) starts"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 125 | /* |
| 126 | * Set the key in the interface object and initialize the object itself |
| 127 | */ |
| 128 | BCMBAL_CFG_INIT(&interface_obj, interface, intf_key); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 129 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 130 | /* request all properties, include everything */ |
| 131 | BCMBAL_CFG_PROP_GET(&interface_obj, interface, all_properties); |
| 132 | |
| 133 | err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &interface_obj.hdr); |
| 134 | |
| 135 | if(BCM_ERR_OK != err) |
| 136 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 137 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the interface Cfg(OLT)"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 138 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 139 | } |
| 140 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 141 | ASFVOLT_LOG(ASFVOLT_INFO, "Get Interface cfg sent to OLT. " |
| 142 | "Interface ID(%d) Interface Type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 143 | intf_key.intf_id, intf_key.intf_type); |
| 144 | /* TODO - Add code to call grpc */ |
| 145 | |
| 146 | return BAL_ERRNO__BAL_ERR_OK; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | /********************************************************************\ |
| 151 | * Function : bal_interface_cfg_clear * |
| 152 | * Description : Clears the PON and NNI interfaces * |
| 153 | * of OLT Device * |
| 154 | ********************************************************************/ |
| 155 | uint32_t bal_interface_cfg_clear(BalInterfaceKey *interface_cfg_key) |
| 156 | { |
| 157 | bcmos_errno err = BCM_ERR_OK; |
| 158 | bcmbal_interface_cfg interface_obj; |
| 159 | bcmbal_interface_key intf_key; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 160 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 161 | if((interface_cfg_key->has_intf_id) && (interface_cfg_key->has_intf_type)) |
| 162 | { |
| 163 | intf_key.intf_id = interface_cfg_key->intf_id; |
| 164 | intf_key.intf_type = interface_cfg_key->intf_type; |
| 165 | } |
| 166 | else |
| 167 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 168 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface cfg(OLT): Missing Key values " |
| 169 | "Received key values intf-id(%d), intf-type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 170 | interface_cfg_key->intf_id, interface_cfg_key->intf_type); |
| 171 | return BAL_ERRNO__BAL_ERR_NOENT; |
| 172 | } |
| 173 | |
| 174 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 175 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Clearing of OLT(interface cfg) starts"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 176 | /* |
| 177 | * Set the key in the interface object and initialize the object itself |
| 178 | */ |
| 179 | BCMBAL_CFG_INIT(&interface_obj, interface, intf_key); |
| 180 | |
| 181 | err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &interface_obj.hdr); |
| 182 | |
| 183 | if(BCM_ERR_OK != err) |
| 184 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 185 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface Cfg(OLT)"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 186 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 187 | } |
| 188 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 189 | ASFVOLT_LOG(ASFVOLT_INFO, "Clear Interface cfg sent to OLT. " |
| 190 | "Interface ID(%d) Interface Type(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 191 | intf_key.intf_id, intf_key.intf_type); |
| 192 | return BAL_ERRNO__BAL_ERR_OK; |
| 193 | } |