blob: 153fcf9bb68a1cf575870982901c6f2f0a77738a [file] [log] [blame]
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301/*
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
31uint32_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 Kempfafa1ab42017-11-13 09:31:47 -080039 ASFVOLT_LOG(ASFVOLT_DEBUG, "Configuration of OLT starts");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053040
41 /* init the API struct */
42 BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
43
44 /* decode API parameters from CLI */
Suhas Gururaj07da86a2018-05-11 14:37:03 +053045 ASFVOLT_CFG_PROP_SET(acc_term_obj, access_terminal, admin_state, BCMOS_TRUE,
46 access_term_cfg->data->admin_state);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053047
48 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
49
50 if(BCM_ERR_OK != err)
51 {
Kim Kempfafa1ab42017-11-13 09:31:47 -080052 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the access-terminal(OLT) to ADMIN-UP");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053053 return BAL_ERRNO__BAL_ERR_INTERNAL;
54 }
55
Suhas Gururaj07da86a2018-05-11 14:37:03 +053056 ASFVOLT_LOG(ASFVOLT_INFO, "Access Terminal %d sent to OLT", access_term_cfg->data->admin_state);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053057 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 ********************************************************************/
66bcmos_errno bal_access_term_indication_cb(bcmbal_obj *obj)
67{
68 /*bcmos_errno result = BCM_ERR_OK;*/
Kim Kempfafa1ab42017-11-13 09:31:47 -080069 ASFVOLT_LOG(ASFVOLT_INFO, "Processing API \'%s\' IND callback (status is %s)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053070 bcmbal_objtype_str(obj->obj_type),
71 bcmos_strerror(obj->status));
Kim Kempfafa1ab42017-11-13 09:31:47 -080072
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053073 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 ********************************************************************/
81uint32_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 Kempfafa1ab42017-11-13 09:31:47 -080087 ASFVOLT_LOG(ASFVOLT_INFO, "processing the clear request on access terminal");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053088
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 Kempfafa1ab42017-11-13 09:31:47 -0800100 ASFVOLT_LOG(ASFVOLT_INFO, "Failed to clear the access terminal");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530101 return BAL_ERRNO__BAL_ERR_INTERNAL;
102 }
103
Kim Kempfafa1ab42017-11-13 09:31:47 -0800104 ASFVOLT_LOG(ASFVOLT_INFO, "Successfully cleared the access terminal");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530105 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 ********************************************************************/
113uint32_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 Kempfafa1ab42017-11-13 09:31:47 -0800120 ASFVOLT_LOG(ASFVOLT_INFO, "processing the get request on access terminal");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530121 /* 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 Kempfafa1ab42017-11-13 09:31:47 -0800130 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get access terminal configuration");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530131 return BAL_ERRNO__BAL_ERR_INTERNAL;
132 }
133
Kim Kempfafa1ab42017-11-13 09:31:47 -0800134 ASFVOLT_LOG(ASFVOLT_INFO,
135 "To-Do. Send access terminal details to Adapter");
136
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530137 return BAL_ERRNO__BAL_ERR_OK;
138}