blob: f59be37391375b9a7a84bf8e5c05bc0750b5da06 [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_interface_hdlr.h"
24
25/********************************************************************\
Kim Kempfafa1ab42017-11-13 09:31:47 -080026 * Function : bal_interface_cfg_set *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053027 * Description : Configures the PON and NNI interfaces *
28 * of OLT Device *
29 ********************************************************************/
30uint32_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 Gururaj07da86a2018-05-11 14:37:03 +053039 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 Raof6b4e6c2017-08-31 17:26:27 +053042
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 Gururaj07da86a2018-05-11 14:37:03 +053048 ASFVOLT_CFG_PROP_SET(interface_obj, interface, admin_state, BCMOS_TRUE,
49 interface_cfg->data->admin_state);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053050
Suhas Gururaj07da86a2018-05-11 14:37:03 +053051 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 Raof6b4e6c2017-08-31 17:26:27 +053089 {
Suhas Gururaj07da86a2018-05-11 14:37:03 +053090 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the interface object to ADMIN-UP");
91 return BAL_ERRNO__BAL_ERR_INTERNAL;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053092 }
Kim Kempfafa1ab42017-11-13 09:31:47 -080093 ASFVOLT_LOG(ASFVOLT_DEBUG, "Set Interface configuration sent to OLT.Interface ID(%d) Interface Type(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053094 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 Kempfafa1ab42017-11-13 09:31:47 -0800104uint32_t bal_interface_cfg_get(BalInterfaceKey *interface_cfg_key,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530105 BalInterfaceCfg *interface_cfg)
106{
107 bcmos_errno err = BCM_ERR_OK;
108 bcmbal_interface_cfg interface_obj;
109 bcmbal_interface_key intf_key;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800110
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530111 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 Kempfafa1ab42017-11-13 09:31:47 -0800118 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 Raof6b4e6c2017-08-31 17:26:27 +0530120 interface_cfg_key->intf_id, interface_cfg_key->intf_type);
121 return BAL_ERRNO__BAL_ERR_NOENT;
122 }
123
Kim Kempfafa1ab42017-11-13 09:31:47 -0800124 ASFVOLT_LOG(ASFVOLT_DEBUG, "Get interface cfg(for OLT) starts");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530125 /*
126 * Set the key in the interface object and initialize the object itself
127 */
128 BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800129
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530130 /* 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 Kempfafa1ab42017-11-13 09:31:47 -0800137 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the interface Cfg(OLT)");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530138 return BAL_ERRNO__BAL_ERR_INTERNAL;
139 }
140
Kim Kempfafa1ab42017-11-13 09:31:47 -0800141 ASFVOLT_LOG(ASFVOLT_INFO, "Get Interface cfg sent to OLT. "
142 "Interface ID(%d) Interface Type(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530143 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 ********************************************************************/
155uint32_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 Kempfafa1ab42017-11-13 09:31:47 -0800160
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530161 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 Kempfafa1ab42017-11-13 09:31:47 -0800168 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 Raof6b4e6c2017-08-31 17:26:27 +0530170 interface_cfg_key->intf_id, interface_cfg_key->intf_type);
171 return BAL_ERRNO__BAL_ERR_NOENT;
172 }
173
174
Kim Kempfafa1ab42017-11-13 09:31:47 -0800175 ASFVOLT_LOG(ASFVOLT_DEBUG, "Clearing of OLT(interface cfg) starts");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530176 /*
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 Kempfafa1ab42017-11-13 09:31:47 -0800185 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface Cfg(OLT)");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530186 return BAL_ERRNO__BAL_ERR_INTERNAL;
187 }
188
Kim Kempfafa1ab42017-11-13 09:31:47 -0800189 ASFVOLT_LOG(ASFVOLT_INFO, "Clear Interface cfg sent to OLT. "
190 "Interface ID(%d) Interface Type(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530191 intf_key.intf_id, intf_key.intf_type);
192 return BAL_ERRNO__BAL_ERR_OK;
193}