blob: ea70c089e5976d2b6d9b72084e6336babce754f8 [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
Suhas Gururaj07da86a2018-05-11 14:37:03 +053064 ASFVOLT_CFG_PROP_SET(interface_obj, interface, mtu,
65 interface_cfg->data->has_mtu,
66 interface_cfg->data->mtu);
67
Suhas Gururaj07da86a2018-05-11 14:37:03 +053068 ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_tm,
69 interface_cfg->data->has_ds_tm,
70 interface_cfg->data->ds_tm);
71
72 ASFVOLT_CFG_PROP_SET(interface_obj, interface, us_tm,
73 interface_cfg->data->has_us_tm,
74 interface_cfg->data->us_tm);
75
76 ASFVOLT_LOG(ASFVOLT_INFO, "Bringing up the interface No: %d", intf_key.intf_id);
77
78 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
79
80 if(BCM_ERR_OK != err)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053081 {
Suhas Gururaj07da86a2018-05-11 14:37:03 +053082 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the interface object to ADMIN-UP");
83 return BAL_ERRNO__BAL_ERR_INTERNAL;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053084 }
Kim Kempfafa1ab42017-11-13 09:31:47 -080085 ASFVOLT_LOG(ASFVOLT_DEBUG, "Set Interface configuration sent to OLT.Interface ID(%d) Interface Type(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053086 intf_key.intf_id, intf_key.intf_type);
87 return BAL_ERRNO__BAL_ERR_OK;
88}
89
90
91/********************************************************************\
92 * Function : bal_interface_cfg_get *
93 * Description : get the PON and NNI interfaces *
94 * of OLT Device *
95 ********************************************************************/
Girish Gowdru9ebd8b22018-09-26 03:21:03 -070096uint32_t bal_interface_cfg_get(BalInterfaceCfg *interface_cfg)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053097{
98 bcmos_errno err = BCM_ERR_OK;
99 bcmbal_interface_cfg interface_obj;
100 bcmbal_interface_key intf_key;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800101
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700102 intf_key.intf_id = interface_cfg->key->intf_id;
103 intf_key.intf_type = interface_cfg->key->intf_type;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530104
Kim Kempfafa1ab42017-11-13 09:31:47 -0800105 ASFVOLT_LOG(ASFVOLT_DEBUG, "Get interface cfg(for OLT) starts");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530106 /*
107 * Set the key in the interface object and initialize the object itself
108 */
109 BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800110
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530111 /* request all properties, include everything */
112 BCMBAL_CFG_PROP_GET(&interface_obj, interface, all_properties);
113
114 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &interface_obj.hdr);
115
116 if(BCM_ERR_OK != err)
117 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800118 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to get the interface Cfg(OLT)");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530119 return BAL_ERRNO__BAL_ERR_INTERNAL;
120 }
121
Kim Kempfafa1ab42017-11-13 09:31:47 -0800122 ASFVOLT_LOG(ASFVOLT_INFO, "Get Interface cfg sent to OLT. "
123 "Interface ID(%d) Interface Type(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530124 intf_key.intf_id, intf_key.intf_type);
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700125
126 memcpy(interface_cfg->data, &interface_obj, sizeof(bcmbal_interface_cfg_data));
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530127
128 return BAL_ERRNO__BAL_ERR_OK;
129}
130
131
132/********************************************************************\
133 * Function : bal_interface_cfg_clear *
134 * Description : Clears the PON and NNI interfaces *
135 * of OLT Device *
136 ********************************************************************/
137uint32_t bal_interface_cfg_clear(BalInterfaceKey *interface_cfg_key)
138{
139 bcmos_errno err = BCM_ERR_OK;
140 bcmbal_interface_cfg interface_obj;
141 bcmbal_interface_key intf_key;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800142
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530143 if((interface_cfg_key->has_intf_id) && (interface_cfg_key->has_intf_type))
144 {
145 intf_key.intf_id = interface_cfg_key->intf_id;
146 intf_key.intf_type = interface_cfg_key->intf_type;
147 }
148 else
149 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800150 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface cfg(OLT): Missing Key values "
151 "Received key values intf-id(%d), intf-type(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530152 interface_cfg_key->intf_id, interface_cfg_key->intf_type);
153 return BAL_ERRNO__BAL_ERR_NOENT;
154 }
155
156
Kim Kempfafa1ab42017-11-13 09:31:47 -0800157 ASFVOLT_LOG(ASFVOLT_DEBUG, "Clearing of OLT(interface cfg) starts");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530158 /*
159 * Set the key in the interface object and initialize the object itself
160 */
161 BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
162
163 err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &interface_obj.hdr);
164
165 if(BCM_ERR_OK != err)
166 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800167 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to clear the interface Cfg(OLT)");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530168 return BAL_ERRNO__BAL_ERR_INTERNAL;
169 }
170
Kim Kempfafa1ab42017-11-13 09:31:47 -0800171 ASFVOLT_LOG(ASFVOLT_INFO, "Clear Interface cfg sent to OLT. "
172 "Interface ID(%d) Interface Type(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530173 intf_key.intf_id, intf_key.intf_type);
174 return BAL_ERRNO__BAL_ERR_OK;
175}