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 <bcmos_system.h> |
| 19 | #include <bal_api.h> |
| 20 | |
| 21 | #undef _SYS_QUEUE_H_ |
| 22 | |
| 23 | #include "asfvolt16_driver.h" |
| 24 | #include "bal_access_terminal_hdlr.h" |
| 25 | #include "bal_subscriber_terminal_hdlr.h" |
| 26 | #include "bal_flow_hdlr.h" |
| 27 | #include "bal_group_hdlr.h" |
| 28 | #include "bal_interface_hdlr.h" |
| 29 | #include "bal_tmqueue_hdlr.h" |
| 30 | #include "bal_tmsched_hdlr.h" |
| 31 | #include "bal_packet_hdlr.h" |
| 32 | #include "bal_indications_hdlr.h" |
| 33 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 34 | #if 0 |
| 35 | #include "bal_api_end.h" /* Use when BAL -Wsign-compare is cleaned up */ |
| 36 | #else |
| 37 | extern bcmos_errno bcmbal_apiend_init_all(int argc, char *argv[], void *, int); |
| 38 | extern bcmos_errno bcmbal_apiend_finish(void); |
| 39 | #endif |
| 40 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 41 | bcmbal_access_term_id access_term_id = DEFAULT_ATERM_ID; |
| 42 | |
| 43 | /********************************************************************\ |
| 44 | * Function : bal_register_indication_cbs * |
| 45 | * Description : Registering the Call back function to handle the * |
| 46 | * indciations from BAL * |
| 47 | ********************************************************************/ |
| 48 | uint32_t bal_register_indication_cbs() |
| 49 | { |
| 50 | bcmos_errno err = BCM_ERR_OK; |
| 51 | bcmbal_cb_cfg cb_cfg = {}; |
| 52 | uint16_t ind_subgroup; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 53 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Subscription for other messages"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 54 | |
| 55 | cb_cfg.module = BCMOS_MODULE_ID_NONE; |
| 56 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 57 | /* Access Terminal Operational State Change */ |
| 58 | cb_cfg.obj_type = BCMBAL_OBJ_ID_ACCESS_TERMINAL; |
| 59 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_acc_term_osc_indication_cb; |
| 60 | ind_subgroup = bcmbal_access_terminal_auto_id_oper_status_change; |
| 61 | cb_cfg.p_subgroup = &ind_subgroup; |
| 62 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 63 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 64 | /* Register to get indications for interface objects |
| 65 | */ |
| 66 | cb_cfg.obj_type = BCMBAL_OBJ_ID_INTERFACE; |
| 67 | |
| 68 | /* Interface los */ |
| 69 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_interface_los_indication_cb; |
| 70 | ind_subgroup = bcmbal_interface_auto_id_los; |
| 71 | cb_cfg.p_subgroup = &ind_subgroup; |
| 72 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 73 | |
| 74 | /* Interface Indication */ |
| 75 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_interface_indication_cb; |
| 76 | ind_subgroup = bcmbal_interface_auto_id_ind; |
| 77 | cb_cfg.p_subgroup = &ind_subgroup; |
| 78 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 79 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 80 | /* Interface Operational State Change */ |
| 81 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_interface_osc_indication_cb; |
| 82 | ind_subgroup = bcmbal_interface_auto_id_oper_status_change; |
| 83 | cb_cfg.p_subgroup = &ind_subgroup; |
| 84 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 85 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 86 | /* Register to get indications for subscriber terminal objects |
| 87 | */ |
| 88 | cb_cfg.obj_type = BCMBAL_OBJ_ID_SUBSCRIBER_TERMINAL; |
| 89 | |
| 90 | /* Subscriber Terminal Alarm */ |
| 91 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_alarm_indication_cb; |
| 92 | ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_alarm; |
| 93 | cb_cfg.p_subgroup = &ind_subgroup; |
| 94 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 95 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 96 | /* Subscriber Terminal dgi */ |
| 97 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_dgi_indication_cb; |
| 98 | ind_subgroup = bcmbal_subscriber_terminal_auto_id_dgi; |
| 99 | cb_cfg.p_subgroup = &ind_subgroup; |
| 100 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 101 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 102 | /* Subscriber Terminal Discovery */ |
| 103 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_disc_indication_cb; |
| 104 | ind_subgroup = bcmbal_subscriber_terminal_auto_id_sub_term_disc; |
| 105 | cb_cfg.p_subgroup = &ind_subgroup; |
| 106 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 107 | |
| 108 | /* Subscriber Terminal Indication */ |
| 109 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_indication_cb; |
| 110 | ind_subgroup = bcmbal_subscriber_terminal_auto_id_ind; |
| 111 | cb_cfg.p_subgroup = &ind_subgroup; |
| 112 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 113 | |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 114 | /* Subscriber Terminal Operational State Change */ |
| 115 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_sub_term_osc_indication_cb; |
| 116 | ind_subgroup = bcmbal_subscriber_terminal_auto_id_oper_status_change; |
| 117 | cb_cfg.p_subgroup = &ind_subgroup; |
| 118 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 119 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 120 | /* Register to get indication callbacks for OMCI objects |
| 121 | */ |
| 122 | cb_cfg.obj_type = BCMBAL_OBJ_ID_PACKET; |
| 123 | |
| 124 | ind_subgroup = BCMBAL_IND_SUBGROUP(packet, itu_omci_channel_rx); |
| 125 | cb_cfg.p_object_key_info = NULL; |
| 126 | cb_cfg.p_subgroup = &ind_subgroup; |
| 127 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler )bal_omci_data_indication_cb; |
| 128 | bcmbal_subscribe_ind(0, &cb_cfg); |
| 129 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 130 | /* Bearer Channel Data */ |
| 131 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_packet_data_indication_cb; |
| 132 | ind_subgroup = bcmbal_packet_auto_id_bearer_channel_rx; |
| 133 | cb_cfg.p_subgroup = &ind_subgroup; |
| 134 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 135 | #if 0 |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 136 | /* OAM Channel Data - oam response indication */ |
| 137 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_oam_data_indication_cb; |
| 138 | ind_subgroup = bcmbal_packet_auto_id_ieee_oam_channel_rx; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 139 | cb_cfg.p_subgroup = &ind_subgroup; |
| 140 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 141 | #endif |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 142 | /* Register to get indication callbacks for flow objects |
| 143 | */ |
| 144 | cb_cfg.obj_type = BCMBAL_OBJ_ID_FLOW; |
| 145 | |
| 146 | /* Flow Operational State Change */ |
| 147 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_flow_osc_indication_cb; |
| 148 | ind_subgroup = bcmbal_flow_auto_id_oper_status_change; |
| 149 | cb_cfg.p_subgroup = &ind_subgroup; |
| 150 | err = bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 151 | |
| 152 | /* Flow Indication */ |
| 153 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_flow_indication_cb; |
| 154 | ind_subgroup = bcmbal_flow_auto_id_ind; |
| 155 | cb_cfg.p_subgroup = &ind_subgroup; |
| 156 | err = bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 157 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 158 | /* Register to get indication callbacks for tm queue objects |
| 159 | */ |
| 160 | cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_QUEUE; |
| 161 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_tm_queue_indication_cb; |
| 162 | ind_subgroup = bcmbal_tm_queue_auto_id_ind; |
| 163 | cb_cfg.p_subgroup = &ind_subgroup; |
| 164 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 165 | |
| 166 | /* Register to get indication callbacks for tm sched objects |
| 167 | */ |
| 168 | cb_cfg.obj_type = BCMBAL_OBJ_ID_TM_SCHED; |
| 169 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_tm_sched_indication_cb; |
| 170 | ind_subgroup = bcmbal_tm_sched_auto_id_ind; |
| 171 | cb_cfg.p_subgroup = &ind_subgroup; |
| 172 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 173 | |
| 174 | /* Register to get indication callbacks for group objects |
| 175 | */ |
| 176 | cb_cfg.obj_type = BCMBAL_OBJ_ID_GROUP; |
| 177 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_group_indication_cb; |
| 178 | ind_subgroup = bcmbal_group_auto_id_ind; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 179 | cb_cfg.p_subgroup = &ind_subgroup; |
| 180 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 181 | return err; |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /******************************************************************** |
| 186 | * * |
| 187 | * gRPC service RPC function implementation * |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 188 | * * |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 189 | ********************************************************************/ |
| 190 | |
| 191 | /********************************************************************\ |
| 192 | * Function : asfvolt16_bal_init * |
| 193 | * Description : This function will initialize the BAL module * |
| 194 | ********************************************************************/ |
| 195 | uint32_t asfvolt16_bal_init(BalInit *bal_init, balCoreIpInfo *coreInfo) |
| 196 | |
| 197 | { |
| 198 | bcmos_errno err = BCM_ERR_OK; |
| 199 | |
| 200 | char *ip_and_port = NULL; |
| 201 | if (NULL == bal_init) |
| 202 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 203 | ASFVOLT_LOG(ASFVOLT_ERROR, "Received NULL balInit Structure from VOLTHA"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 204 | return BAL_ERRNO__BAL_ERR_PERM; |
| 205 | } |
| 206 | else |
| 207 | { |
| 208 | ip_and_port = bal_init->voltha_adapter_ip_port; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 209 | ASFVOLT_LOG(ASFVOLT_DEBUG,"Received Adapter IP and Port from VOLTHA is %s",ip_and_port); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 210 | } |
| 211 | char *argv[6]; |
| 212 | /* Initialize BAL */ |
| 213 | argv[1] = coreInfo->bal_core_arg1; |
| 214 | argv[2] = coreInfo->bal_core_ip_port; |
| 215 | argv[3] = coreInfo->bal_core_arg2; |
| 216 | argv[4] = coreInfo->bal_shared_lib_ip_port; |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 217 | int argc = 5; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 218 | client = grpc_c_client_init(ip_and_port, "bal_client", NULL); |
| 219 | |
| 220 | /* Init BAL */ |
| 221 | err = bcmbal_apiend_init_all(argc, argv, NULL,3); |
| 222 | if(err != BCM_ERR_OK) |
| 223 | { |
| 224 | printf("\n Failed in bcmbal_init \n"); |
| 225 | } |
| 226 | |
| 227 | #if 0 |
| 228 | err = (err != BCM_ERR_OK) ? err : bcmbal_autostart(); /* Execute bal_autostart.ini script if any */ |
| 229 | |
| 230 | if (err) |
| 231 | { |
| 232 | /* Let logger task have enough time to drain its message queue. */ |
| 233 | usleep(1000000); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 234 | ASFVOLT_LOG(ASFVOLT_ERROR, "failed to Initialize the BAL"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 235 | return err; |
| 236 | } |
| 237 | #endif |
| 238 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 239 | /* Register the call back functions to handle any |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 240 | * indications from the BAL */ |
| 241 | bcmbal_cb_cfg cb_cfg = {}; |
| 242 | uint16_t ind_subgroup; |
| 243 | |
| 244 | cb_cfg.module = BCMOS_MODULE_ID_NONE; |
| 245 | /* Register to get indications for access terminal objects |
| 246 | */ |
| 247 | cb_cfg.obj_type = BCMBAL_OBJ_ID_ACCESS_TERMINAL; |
| 248 | |
| 249 | /* Access Terminal Indication */ |
| 250 | cb_cfg.ind_cb_hdlr = (f_bcmbal_ind_handler)bal_acc_term_indication_cb; |
| 251 | ind_subgroup = bcmbal_access_terminal_auto_id_ind; |
| 252 | cb_cfg.p_subgroup = &ind_subgroup; |
| 253 | err = err ? err : bcmbal_subscribe_ind(access_term_id, &cb_cfg); |
| 254 | |
| 255 | if (err) |
| 256 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 257 | ASFVOLT_LOG(ASFVOLT_ERROR, "failed to register call back functions to BAL"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | return err; |
| 261 | } |
| 262 | |
| 263 | /********************************************************************\ |
| 264 | * Function : asfvolt16_bal_finish * |
| 265 | * Description : This function will Un-initialize the BAL module * |
| 266 | ********************************************************************/ |
| 267 | uint32_t asfvolt16_bal_finish(void) |
| 268 | { |
| 269 | bcmos_errno err = BCM_ERR_OK; |
| 270 | |
| 271 | /* Un-Initialize the BAL function */ |
| 272 | bcmbal_apiend_finish(); |
| 273 | |
| 274 | return err; |
| 275 | } |
| 276 | |
| 277 | |
| 278 | /********************************************************************\ |
| 279 | * Function : asfvolt16_bal_cfg_set * |
| 280 | * Description : Handles below configuration * |
| 281 | * 1) Access Terminal Cfg * |
| 282 | * 2) Interface(PON & NNI) Cfg * |
| 283 | * 3) Subscriber Terminal (ONU) cfg * |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 284 | * 4) Flow Cfg * |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 285 | * 5) Group Cfg (In case of Multicast) * |
| 286 | ********************************************************************/ |
| 287 | uint32_t asfvolt16_bal_cfg_set(BalCfg *cfg) |
| 288 | { |
| 289 | bcmos_errno err = BCM_ERR_OK; |
| 290 | memset(&voltha_device_id, 0, ASFVOLT_MAX_DEVICE_ID_SIZE); |
| 291 | strcpy(voltha_device_id,cfg->device_id); |
| 292 | |
| 293 | switch(cfg->hdr->obj_type) |
| 294 | { |
| 295 | case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL: |
| 296 | { |
| 297 | err = bal_access_terminal_cfg_set(cfg->cfg); |
| 298 | break; |
| 299 | } |
| 300 | case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE: |
| 301 | { |
| 302 | err = bal_interface_cfg_set(cfg->interface); |
| 303 | break; |
| 304 | } |
| 305 | case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL: |
| 306 | { |
| 307 | err = bal_subscriber_terminal_cfg_set(cfg->terminal); |
| 308 | break; |
| 309 | } |
| 310 | case BAL_OBJ_ID__BAL_OBJ_ID_FLOW: |
| 311 | { |
| 312 | err = bal_flow_cfg_set(cfg->flow); |
| 313 | break; |
| 314 | } |
| 315 | case BAL_OBJ_ID__BAL_OBJ_ID_GROUP: |
| 316 | { |
| 317 | err = bal_group_cfg_set(cfg->group); |
| 318 | break; |
| 319 | } |
| 320 | case BAL_OBJ_ID__BAL_OBJ_ID_TM_QUEUE: |
| 321 | { |
| 322 | err = bal_tm_queue_cfg_set(cfg->tm_queue_cfg); |
| 323 | break; |
| 324 | } |
| 325 | case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED: |
| 326 | { |
| 327 | err = bal_tm_sched_cfg_set(cfg->tm_sched_cfg); |
| 328 | break; |
| 329 | } |
| 330 | case BAL_OBJ_ID__BAL_OBJ_ID_PACKET: |
| 331 | { |
| 332 | err = bal_packet_cfg_req(cfg->packet); |
| 333 | break; |
| 334 | } |
| 335 | default: |
| 336 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 337 | ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid object type for configuration"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 338 | err = BAL_ERRNO__BAL_ERR_INVALID_OP; |
| 339 | break; |
| 340 | } |
| 341 | } |
| 342 | return err; |
| 343 | } |
| 344 | |
| 345 | /********************************************************************\ |
| 346 | * Function : asfvolt16_bal_cfg_clear * |
| 347 | * Description : Clears the configuration related to below objects * |
| 348 | * 1) Access Terminal Cfg * |
| 349 | * 2) Interface(PON & NNI) Cfg * |
| 350 | * 3) Subscriber Terminal (ONU) cfg * |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 351 | * 4) Flow Cfg * |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 352 | * 5) Group Cfg (In case of Multicast) * |
| 353 | ********************************************************************/ |
| 354 | uint32_t asfvolt16_bal_cfg_clear(BalKey *key) |
| 355 | { |
| 356 | bcmos_errno err = BCM_ERR_OK; |
| 357 | |
| 358 | if(!key->hdr->has_obj_type) |
| 359 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 360 | ASFVOLT_LOG(ASFVOLT_ERROR, "object type is not present for clear"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 361 | return BAL_ERRNO__BAL_ERR_INVALID_OP; |
| 362 | } |
| 363 | |
| 364 | switch(key->hdr->obj_type) |
| 365 | { |
| 366 | case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL: |
| 367 | { |
| 368 | err = bal_access_terminal_cfg_clear(key->access_term_key); |
| 369 | break; |
| 370 | } |
| 371 | case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE: |
| 372 | { |
| 373 | err = bal_interface_cfg_clear(key->interface_key); |
| 374 | break; |
| 375 | } |
| 376 | case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL: |
| 377 | { |
| 378 | err = bal_subscriber_terminal_cfg_clear(key->terminal_key); |
| 379 | break; |
| 380 | } |
| 381 | case BAL_OBJ_ID__BAL_OBJ_ID_FLOW: |
| 382 | { |
| 383 | err = bal_flow_cfg_clear(key->flow_key); |
| 384 | break; |
| 385 | } |
| 386 | case BAL_OBJ_ID__BAL_OBJ_ID_GROUP: |
| 387 | { |
| 388 | break; |
| 389 | } |
| 390 | case BAL_OBJ_ID__BAL_OBJ_ID_TM_QUEUE: |
| 391 | { |
| 392 | err = bal_tm_queue_cfg_clear(key->tm_queue_key); |
| 393 | break; |
| 394 | } |
| 395 | case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED: |
| 396 | { |
| 397 | err = bal_tm_sched_cfg_clear(key->tm_sched_key); |
| 398 | break; |
| 399 | } |
| 400 | /*case BAL_KEY__OBJ_PACKET_KEY: |
| 401 | { |
| 402 | break; |
| 403 | }*/ |
| 404 | default: |
| 405 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 406 | ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid object type to handle clear"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 407 | err = BAL_ERRNO__BAL_ERR_INVALID_OP; |
| 408 | break; |
| 409 | } |
| 410 | } |
| 411 | return err; |
| 412 | } |
| 413 | |
| 414 | |
| 415 | /********************************************************************\ |
| 416 | * Function : asfvolt16_bal_cfg_get * |
| 417 | * Description : Get the configuration related to below objects * |
| 418 | * 1) Access Terminal Cfg * |
| 419 | * 2) Interface(PON & NNI) Cfg * |
| 420 | * 3) Subscriber Terminal (ONU) cfg * |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 421 | * 4) Flow Cfg * |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 422 | * 5) Group Cfg (In case of Multicast) * |
| 423 | ********************************************************************/ |
| 424 | uint32_t asfvolt16_bal_cfg_get(BalKey *key, BalCfg *cfg) |
| 425 | { |
| 426 | bcmos_errno err = BCM_ERR_OK; |
| 427 | |
| 428 | if(!key->hdr->has_obj_type) |
| 429 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 430 | ASFVOLT_LOG(ASFVOLT_ERROR, "object type is not present for get"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 431 | return BAL_ERRNO__BAL_ERR_INVALID_OP; |
| 432 | } |
| 433 | |
| 434 | switch(key->hdr->obj_type) |
| 435 | { |
| 436 | case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL: |
| 437 | { |
| 438 | err = bal_access_terminal_cfg_get(key->access_term_key, cfg->cfg ); |
| 439 | break; |
| 440 | } |
| 441 | case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE: |
| 442 | { |
| 443 | err = bal_interface_cfg_get(key->interface_key, cfg->interface); |
| 444 | break; |
| 445 | } |
| 446 | case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL: |
| 447 | { |
| 448 | err = bal_subscriber_terminal_cfg_get(key->terminal_key, cfg->terminal); |
| 449 | break; |
| 450 | } |
| 451 | case BAL_OBJ_ID__BAL_OBJ_ID_FLOW: |
| 452 | { |
| 453 | err = bal_flow_cfg_get(key->flow_key, cfg->flow); |
| 454 | break; |
| 455 | } |
| 456 | case BAL_OBJ_ID__BAL_OBJ_ID_GROUP: |
| 457 | { |
| 458 | err = bal_group_cfg_get(key->group_key, cfg->group); |
| 459 | break; |
| 460 | } |
| 461 | case BAL_OBJ_ID__BAL_OBJ_ID_TM_QUEUE: |
| 462 | { |
| 463 | err = bal_tm_queue_cfg_get(key->tm_queue_key, cfg->tm_queue_cfg); |
| 464 | break; |
| 465 | } |
| 466 | case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED: |
| 467 | { |
| 468 | err = bal_tm_sched_cfg_get(key->tm_sched_key, cfg->tm_sched_cfg); |
| 469 | break; |
| 470 | } |
| 471 | case BAL_OBJ_ID__BAL_OBJ_ID_PACKET: |
| 472 | { |
| 473 | break; |
| 474 | } |
| 475 | default: |
| 476 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 477 | ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid object type to handle Get"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 478 | err = BAL_ERRNO__BAL_ERR_INVALID_OP; |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | return err; |
| 483 | } |
| 484 | |
| 485 | |