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_access_terminal_hdlr.h" |
| 24 | |
| 25 | |
| 26 | /********************************************************************\ |
| 27 | * Function : bal_access_terminal_cfg_set * |
| 28 | * Description : Configures the OLT device * |
| 29 | ********************************************************************/ |
| 30 | |
| 31 | uint32_t bal_access_terminal_cfg_set(BalAccessTerminalCfg *access_term_cfg) |
| 32 | { |
| 33 | bcmos_errno err = BCM_ERR_OK; |
| 34 | bcmbal_access_terminal_cfg acc_term_obj; /**< declare main API struct */ |
| 35 | bcmbal_access_terminal_key key = { }; /**< declare key */ |
| 36 | |
| 37 | key.access_term_id = access_term_cfg->key->access_term_id; |
| 38 | |
| 39 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Configuration of OLT starts\n"); |
| 40 | |
| 41 | /* init the API struct */ |
| 42 | BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key); |
| 43 | |
| 44 | /* decode API parameters from CLI */ |
| 45 | ASFVOLT_CFG_PROP_SET(acc_term_obj, access_terminal, admin_state, BCMOS_TRUE, BCMBAL_STATE_UP); |
| 46 | |
| 47 | err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr)); |
| 48 | |
| 49 | if(BCM_ERR_OK != err) |
| 50 | { |
| 51 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the access-terminal(OLT) to ADMIN-UP\n"); |
| 52 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 53 | } |
| 54 | |
| 55 | ASFVOLT_LOG(ASFVOLT_INFO, "Access Terminal UP configuration sent to OLT\n"); |
| 56 | return BAL_ERRNO__BAL_ERR_OK; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | /********************************************************************\ |
| 61 | * Function : bal_access_term_indication_cb * |
| 62 | * Description : Call back function registered with BAL to handle * |
| 63 | * event related to access terminal * |
| 64 | ********************************************************************/ |
| 65 | bcmos_errno bal_access_term_indication_cb(bcmbal_obj *obj) |
| 66 | { |
| 67 | /*bcmos_errno result = BCM_ERR_OK;*/ |
| 68 | ASFVOLT_LOG(ASFVOLT_INFO, "Processing API \'%s\' IND callback (status is %s)\n", |
| 69 | bcmbal_objtype_str(obj->obj_type), |
| 70 | bcmos_strerror(obj->status)); |
| 71 | |
| 72 | return BAL_ERRNO__BAL_ERR_OK; |
| 73 | } |
| 74 | |
| 75 | |
| 76 | /********************************************************************\ |
| 77 | * Function : bal_access_terminal_cfg_clear * |
| 78 | * Description : Handles the clear/Delete of access terminal * |
| 79 | ********************************************************************/ |
| 80 | uint32_t bal_access_terminal_cfg_clear(BalAccessTerminalKey *access_term_key) |
| 81 | { |
| 82 | bcmos_errno err = BCM_ERR_OK; |
| 83 | bcmbal_access_terminal_cfg cfg_clear; /**< declare main API struct */ |
| 84 | bcmbal_access_terminal_key key = { }; /**< declare key */ |
| 85 | |
| 86 | ASFVOLT_LOG(ASFVOLT_INFO, "processing the clear request on access terminal\n"); |
| 87 | |
| 88 | key.access_term_id = access_term_key->access_term_id; |
| 89 | |
| 90 | /* init the API struct */ |
| 91 | BCMBAL_CFG_INIT(&cfg_clear, access_terminal, key); |
| 92 | |
| 93 | |
| 94 | /* call API */ |
| 95 | err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg_clear.hdr); |
| 96 | |
| 97 | if( err != BCM_ERR_OK) |
| 98 | { |
| 99 | ASFVOLT_LOG(ASFVOLT_INFO, "Failed to clear the access terminal\n"); |
| 100 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 101 | } |
| 102 | |
| 103 | ASFVOLT_LOG(ASFVOLT_INFO, "Successfully cleared the access terminal\n"); |
| 104 | return BAL_ERRNO__BAL_ERR_OK; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | /********************************************************************\ |
| 109 | * Function : bal_access_terminal_cfg_get * |
| 110 | * Description : Handles the clear/Delete of access terminal * |
| 111 | ********************************************************************/ |
| 112 | uint32_t bal_access_terminal_cfg_get (BalAccessTerminalKey *access_term_key, |
| 113 | BalAccessTerminalCfg *access_term_cfg) |
| 114 | { |
| 115 | bcmos_errno err = BCM_ERR_OK; |
| 116 | bcmbal_access_terminal_cfg cfg; /**< declare main API struct */ |
| 117 | bcmbal_access_terminal_key key = { }; /**< declare key */ |
| 118 | |
| 119 | ASFVOLT_LOG(ASFVOLT_INFO, "processing the get request on access terminal\n"); |
| 120 | /* init the API struct */ |
| 121 | BCMBAL_CFG_INIT(&cfg, access_terminal, key); |
| 122 | |
| 123 | BCMBAL_CFG_PROP_GET(&cfg, access_terminal, all_properties); |
| 124 | |
| 125 | /* call API */ |
| 126 | err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &cfg.hdr); |
| 127 | if (err != BCM_ERR_OK) |
| 128 | { |
| 129 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get access terminal configuration\n"); |
| 130 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 131 | } |
| 132 | |
| 133 | ASFVOLT_LOG(ASFVOLT_INFO, |
| 134 | "To-Do. Send access terminal details to Adapter\n"); |
| 135 | |
| 136 | return BAL_ERRNO__BAL_ERR_OK; |
| 137 | } |