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