blob: c7730c0ea48a27ebe3ed67dd9d3ae3a196ccc44b [file] [log] [blame]
Shad Ansarib7b0ced2018-05-11 21:53:32 +00001/*
Nicolas Palpacuerb78def42018-06-07 12:55:26 -04002 Copyright (C) 2018 Open Networking Foundation
Shad Ansarib7b0ced2018-05-11 21:53:32 +00003
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <iostream>
19#include <memory>
20#include <string>
21
22#include "Queue.h"
23#include <iostream>
24#include <sstream>
Nicolas Palpacuer9c352082018-08-14 16:37:14 -040025#include <chrono>
26#include <thread>
Shad Ansarib7b0ced2018-05-11 21:53:32 +000027
Craig Lutgen88a22ad2018-10-04 12:30:46 -050028#include "device.h"
Shad Ansarib7b0ced2018-05-11 21:53:32 +000029#include "core.h"
30#include "indications.h"
Nicolas Palpacuer0f19b1a2018-06-07 17:29:31 -040031#include "stats_collection.h"
Nicolas Palpacuer73222e02018-07-16 12:20:26 -040032#include "error_format.h"
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -040033#include "state.h"
Craig Lutgen88a22ad2018-10-04 12:30:46 -050034#include "utils.h"
Shad Ansarib7b0ced2018-05-11 21:53:32 +000035
36extern "C"
37{
38#include <bcmos_system.h>
39#include <bal_api.h>
40#include <bal_api_end.h>
Nicolas Palpacuerf0b02492018-09-10 10:21:29 -040041// FIXME : dependency problem
42// #include <bcm_common_gpon.h>
Nicolas Palpacuer967438f2018-09-07 14:41:54 -040043// #include <bcm_dev_log_task.h>
Shad Ansarib7b0ced2018-05-11 21:53:32 +000044}
Craig Lutgen19512312018-11-02 10:14:46 -050045// These need patched into bal_model_types.h directly. But, with above extern "C", it cannot be done
46inline bcmbal_action_cmd_id& operator|=(bcmbal_action_cmd_id& a, bcmbal_action_cmd_id b) {return a = static_cast<bcmbal_action_cmd_id>(static_cast<int>(a) | static_cast<int>(b));}
47inline bcmbal_action_id& operator|=(bcmbal_action_id& a, bcmbal_action_id b) {return a = static_cast<bcmbal_action_id>(static_cast<int>(a) | static_cast<int>(b));}
48inline bcmbal_classifier_id& operator|=(bcmbal_classifier_id& a, bcmbal_classifier_id b) {return a = static_cast<bcmbal_classifier_id>(static_cast<int>(a) | static_cast<int>(b));}
49inline bcmbal_tm_sched_owner_agg_port_id& operator|=(bcmbal_tm_sched_owner_agg_port_id& a, bcmbal_tm_sched_owner_agg_port_id b) {return a = static_cast<bcmbal_tm_sched_owner_agg_port_id>(static_cast<int>(a) | static_cast<int>(b));}
50inline bcmbal_tm_sched_parent_id& operator|=(bcmbal_tm_sched_parent_id& a, bcmbal_tm_sched_parent_id b) {return a = static_cast<bcmbal_tm_sched_parent_id>(static_cast<int>(a) | static_cast<int>(b));}
51inline bcmbal_tm_shaping_id& operator|=(bcmbal_tm_shaping_id& a, bcmbal_tm_shaping_id b) {return a = static_cast<bcmbal_tm_shaping_id>(static_cast<int>(a) | static_cast<int>(b));}
Shad Ansarib7b0ced2018-05-11 21:53:32 +000052
Nicolas Palpacuer967438f2018-09-07 14:41:54 -040053dev_log_id openolt_log_id = bcm_dev_log_id_register("OPENOLT", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
54dev_log_id omci_log_id = bcm_dev_log_id_register("OMCI", DEV_LOG_LEVEL_INFO, DEV_LOG_ID_TYPE_BOTH);
55
Craig Lutgen88a22ad2018-10-04 12:30:46 -050056#define MAX_SUPPORTED_INTF 16
57#define BAL_RSC_MANAGER_BASE_TM_SCHED_ID 16384
Nicolas Palpacuer967438f2018-09-07 14:41:54 -040058
Craig Lutgen88a22ad2018-10-04 12:30:46 -050059static unsigned int num_of_nni_ports = 0;
60static unsigned int num_of_pon_ports = 0;
Craig Lutgenb2601f02018-10-23 13:04:31 -050061static std::string intf_technologies[MAX_SUPPORTED_INTF];
Craig Lutgen88a22ad2018-10-04 12:30:46 -050062static const std::string UNKNOWN_TECH("unknown");
Craig Lutgenb2601f02018-10-23 13:04:31 -050063static const std::string MIXED_TECH("mixed");
64static std::string board_technology(UNKNOWN_TECH);
Craig Lutgen88a22ad2018-10-04 12:30:46 -050065
66static std::string firmware_version = "Openolt.2018.10.04";
Nicolas Palpacuerdff96792018-09-06 14:59:32 -040067
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -070068const uint32_t tm_upstream_sched_id_start = 18432;
69const uint32_t tm_downstream_sched_id_start = 16384;
70const uint32_t tm_queue_id_start = 4; //0 to 3 are default queues. Lets not use them.
71const std::string upstream = "upstream";
72const std::string downstream = "downstream";
73
Shad Ansariedef2132018-08-10 22:14:50 +000074State state;
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -040075
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -070076Status SchedAdd_(std::string direction, uint32_t access_intf_id, uint32_t onu_id,
77 uint32_t alloc_id, openolt::AdditionalBW additional_bw, uint32_t weight, uint32_t priority,
78 openolt::SchedulingPolicy sched_policy);
79static Status SchedRemove_(std::string direction, int intf_id, int onu_id, int alloc_id);
Shad Ansari627b5782018-08-13 22:49:32 +000080
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -070081static inline int mk_sched_id(int intf_id, int onu_id, std::string direction) {
82 if (direction.compare(upstream) == 0) {
83 return tm_upstream_sched_id_start + intf_id;
84 } else if (direction.compare(downstream) == 0) {
85 return tm_downstream_sched_id_start + intf_id;
86 }
87 else {
88 BCM_LOG(ERROR, openolt_log_id, "invalid direction - %s\n", direction.c_str());
89 return 0;
90 }
91}
92
93static inline int mk_queue_id(int pon_intf_id, int onu_id) {
94 return tm_queue_id_start + pon_intf_id * 32 + onu_id;
Shad Ansari627b5782018-08-13 22:49:32 +000095}
96
Nicolas Palpacuer8ebaa262018-08-16 14:56:47 -040097static inline int mk_agg_port_id(int intf_id, int onu_id) {
Craig Lutgenb2601f02018-10-23 13:04:31 -050098 if (board_technology == "gpon") return 511 + intf_id * 32 + onu_id;
Shad Ansari0c6fa3e2018-09-26 17:43:21 +000099 return 1023 + intf_id * 32 + onu_id;
Shad Ansari627b5782018-08-13 22:49:32 +0000100}
101
Nicolas Palpacuerdff96792018-09-06 14:59:32 -0400102Status GetDeviceInfo_(openolt::DeviceInfo* device_info) {
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500103 device_info->set_vendor(VENDOR_ID);
104 device_info->set_model(MODEL_ID);
Nicolas Palpacuerdff96792018-09-06 14:59:32 -0400105 device_info->set_hardware_version("");
106 device_info->set_firmware_version(firmware_version);
Craig Lutgenb2601f02018-10-23 13:04:31 -0500107 device_info->set_technology(board_technology);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500108 device_info->set_pon_ports(num_of_pon_ports);
Craig Lutgenb2601f02018-10-23 13:04:31 -0500109
110 // Legacy, device-wide ranges. To be deprecated when adapter
111 // is upgraded to support per-interface ranges
112 if (board_technology == "xgspon") {
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500113 device_info->set_onu_id_start(1);
114 device_info->set_onu_id_end(255);
115 device_info->set_alloc_id_start(1024);
116 device_info->set_alloc_id_end(16383);
117 device_info->set_gemport_id_start(1024);
118 device_info->set_gemport_id_end(65535);
Craig Lutgenb2601f02018-10-23 13:04:31 -0500119 device_info->set_flow_id_start(1);
120 device_info->set_flow_id_end(16383);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500121 }
Craig Lutgenb2601f02018-10-23 13:04:31 -0500122 else if (board_technology == "gpon") {
123 device_info->set_onu_id_start(1);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500124 device_info->set_onu_id_end(127);
125 device_info->set_alloc_id_start(256);
126 device_info->set_alloc_id_end(767);
Craig Lutgenb2601f02018-10-23 13:04:31 -0500127 device_info->set_gemport_id_start(256);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500128 device_info->set_gemport_id_end(4095);
Craig Lutgenb2601f02018-10-23 13:04:31 -0500129 device_info->set_flow_id_start(1);
130 device_info->set_flow_id_end(16383);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500131 }
Craig Lutgenb2601f02018-10-23 13:04:31 -0500132
133 std::map<std::string, openolt::DeviceInfo::DeviceResourceRanges*> ranges;
134 for (uint32_t intf_id = 0; intf_id < num_of_pon_ports; ++intf_id) {
135 std::string intf_technology = intf_technologies[intf_id];
136 openolt::DeviceInfo::DeviceResourceRanges *range = ranges[intf_technology];
137 if(range == nullptr) {
138 range = device_info->add_ranges();
139 ranges[intf_technology] = range;
140 range->set_technology(intf_technology);
141
142 if (intf_technology == "xgspon") {
143 openolt::DeviceInfo::DeviceResourceRanges::Pool* pool;
144
145 pool = range->add_pools();
146 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::ONU_ID);
147 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::DEDICATED_PER_INTF);
148 pool->set_start(1);
149 pool->set_end(255);
150
151 pool = range->add_pools();
152 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::ALLOC_ID);
153 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::SHARED_BY_ALL_INTF_SAME_TECH);
154 pool->set_start(1024);
155 pool->set_end(16383);
156
157 pool = range->add_pools();
158 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::GEMPORT_ID);
159 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::SHARED_BY_ALL_INTF_ALL_TECH);
160 pool->set_start(1024);
161 pool->set_end(65535);
162
163 pool = range->add_pools();
164 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::FLOW_ID);
165 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::SHARED_BY_ALL_INTF_ALL_TECH);
166 pool->set_start(1);
167 pool->set_end(16383);
168 }
169 else if (intf_technology == "gpon") {
170 openolt::DeviceInfo::DeviceResourceRanges::Pool* pool;
171
172 pool = range->add_pools();
173 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::ONU_ID);
174 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::DEDICATED_PER_INTF);
175 pool->set_start(1);
176 pool->set_end(127);
177
178 pool = range->add_pools();
179 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::ALLOC_ID);
180 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::SHARED_BY_ALL_INTF_SAME_TECH);
181 pool->set_start(256);
182 pool->set_end(757);
183
184 pool = range->add_pools();
185 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::GEMPORT_ID);
186 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::SHARED_BY_ALL_INTF_ALL_TECH);
187 pool->set_start(256);
188 pool->set_end(4095);
189
190 pool = range->add_pools();
191 pool->set_type(openolt::DeviceInfo::DeviceResourceRanges::Pool::FLOW_ID);
192 pool->set_sharing(openolt::DeviceInfo::DeviceResourceRanges::Pool::SHARED_BY_ALL_INTF_ALL_TECH);
193 pool->set_start(1);
194 pool->set_end(16383);
195 }
196 }
197
198 range->add_intf_ids(intf_id);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500199 }
Nicolas Palpacuerf0b02492018-09-10 10:21:29 -0400200
201 // FIXME: Once dependency problem is fixed
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500202 // device_info->set_pon_ports(num_of_pon_ports);
Nicolas Palpacuerf0b02492018-09-10 10:21:29 -0400203 // device_info->set_onu_id_end(XGPON_NUM_OF_ONUS - 1);
204 // device_info->set_alloc_id_start(1024);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500205 // device_info->set_alloc_id_end(XGPON_NUM_OF_ALLOC_IDS * num_of_pon_ports ? - 1);
Nicolas Palpacuerf0b02492018-09-10 10:21:29 -0400206 // device_info->set_gemport_id_start(XGPON_MIN_BASE_SERVICE_PORT_ID);
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500207 // device_info->set_gemport_id_end(XGPON_NUM_OF_GEM_PORT_IDS_PER_PON * num_of_pon_ports ? - 1);
208 // device_info->set_pon_ports(num_of_pon_ports);
Nicolas Palpacuerdff96792018-09-06 14:59:32 -0400209
210 return Status::OK;
211}
212
Shad Ansari627b5782018-08-13 22:49:32 +0000213Status Enable_(int argc, char *argv[]) {
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000214 bcmbal_access_terminal_cfg acc_term_obj;
215 bcmbal_access_terminal_key key = { };
216
Shad Ansariedef2132018-08-10 22:14:50 +0000217 if (!state.is_activated()) {
Shad Ansari627b5782018-08-13 22:49:32 +0000218
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500219 vendor_init();
Shad Ansari627b5782018-08-13 22:49:32 +0000220 bcmbal_init(argc, argv, NULL);
221
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500222 BCM_LOG(INFO, openolt_log_id, "Enable OLT - %s-%s\n", VENDOR_ID, MODEL_ID);
223
Shad Ansari627b5782018-08-13 22:49:32 +0000224 Status status = SubscribeIndication();
225 if (!status.ok()) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400226 BCM_LOG(ERROR, openolt_log_id, "SubscribeIndication failed - %s : %s\n",
227 grpc_status_code_to_string(status.error_code()).c_str(),
228 status.error_message().c_str());
229
Shad Ansari627b5782018-08-13 22:49:32 +0000230 return status;
231 }
232
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000233 key.access_term_id = DEFAULT_ATERM_ID;
234 BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
235 BCMBAL_CFG_PROP_SET(&acc_term_obj, access_terminal, admin_state, BCMBAL_STATE_UP);
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400236 bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
237 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400238 BCM_LOG(ERROR, openolt_log_id, "Failed to enable OLT\n");
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400239 return bcm_to_grpc_err(err, "Failed to enable OLT");
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000240 }
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500241
Shad Ansariedef2132018-08-10 22:14:50 +0000242 init_stats();
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000243 }
Shad Ansariedef2132018-08-10 22:14:50 +0000244
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400245 //If already enabled, generate an extra indication ????
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000246 return Status::OK;
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400247}
248
249Status Disable_() {
250 // bcmbal_access_terminal_cfg acc_term_obj;
251 // bcmbal_access_terminal_key key = { };
252 //
253 // if (state::is_activated) {
254 // std::cout << "Disable OLT" << std::endl;
255 // key.access_term_id = DEFAULT_ATERM_ID;
256 // BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
257 // BCMBAL_CFG_PROP_SET(&acc_term_obj, access_terminal, admin_state, BCMBAL_STATE_DOWN);
258 // bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
259 // if (err) {
260 // std::cout << "ERROR: Failed to disable OLT" << std::endl;
261 // return bcm_to_grpc_err(err, "Failed to disable OLT");
262 // }
263 // }
264 // //If already disabled, generate an extra indication ????
265 // return Status::OK;
266 //This fails with Operation Not Supported, bug ???
267
268 //TEMPORARY WORK AROUND
269 Status status = DisableUplinkIf_(0);
270 if (status.ok()) {
Shad Ansariedef2132018-08-10 22:14:50 +0000271 state.deactivate();
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400272 openolt::Indication ind;
273 openolt::OltIndication* olt_ind = new openolt::OltIndication;
274 olt_ind->set_oper_state("down");
275 ind.set_allocated_olt_ind(olt_ind);
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400276 BCM_LOG(INFO, openolt_log_id, "Disable OLT, add an extra indication\n");
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400277 oltIndQ.push(ind);
278 }
279 return status;
280
281}
282
283Status Reenable_() {
284 Status status = EnableUplinkIf_(0);
285 if (status.ok()) {
Shad Ansariedef2132018-08-10 22:14:50 +0000286 state.activate();
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400287 openolt::Indication ind;
288 openolt::OltIndication* olt_ind = new openolt::OltIndication;
289 olt_ind->set_oper_state("up");
290 ind.set_allocated_olt_ind(olt_ind);
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400291 BCM_LOG(INFO, openolt_log_id, "Reenable OLT, add an extra indication\n");
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400292 oltIndQ.push(ind);
293 }
294 return status;
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000295}
296
297Status EnablePonIf_(uint32_t intf_id) {
298 bcmbal_interface_cfg interface_obj;
299 bcmbal_interface_key interface_key;
300
301 interface_key.intf_id = intf_id;
302 interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
303
304 BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500305
306 BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
307 bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
308 if (err == BCM_ERR_OK && interface_obj.data.admin_state == BCMBAL_STATE_UP) {
309 BCM_LOG(DEBUG, openolt_log_id, "PON interface: %d already enabled\n", intf_id);
310 return Status::OK;
311 }
312
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000313 BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_UP);
314
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500315 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400316 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400317 BCM_LOG(ERROR, openolt_log_id, "Failed to enable PON interface: %d\n", intf_id);
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400318 return bcm_to_grpc_err(err, "Failed to enable PON interface");
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000319 }
320
321 return Status::OK;
322}
323
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400324Status DisableUplinkIf_(uint32_t intf_id) {
325 bcmbal_interface_cfg interface_obj;
326 bcmbal_interface_key interface_key;
327
328 interface_key.intf_id = intf_id;
329 interface_key.intf_type = BCMBAL_INTF_TYPE_NNI;
330
331 BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
332 BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_DOWN);
333
334 bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
335 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400336 BCM_LOG(ERROR, openolt_log_id, "Failed to disable Uplink interface: %d\n", intf_id);
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400337 return bcm_to_grpc_err(err, "Failed to disable Uplink interface");
338 }
339
340 return Status::OK;
341}
342
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500343Status ProbeDeviceCapabilities_() {
344 bcmbal_access_terminal_cfg acc_term_obj;
345 bcmbal_access_terminal_key key = { };
346
347 key.access_term_id = DEFAULT_ATERM_ID;
348 BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
349 BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, admin_state);
350 BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, oper_status);
351 BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, topology);
352 BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, sw_version);
353 BCMBAL_CFG_PROP_GET(&acc_term_obj, access_terminal, conn_id);
354 bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
355 if (err) {
356 BCM_LOG(ERROR, openolt_log_id, "Failed to query OLT\n");
357 return bcm_to_grpc_err(err, "Failed to query OLT");
358 }
359
360 BCM_LOG(INFO, openolt_log_id, "OLT capabilitites, admin_state: %s oper_state: %s\n",
361 acc_term_obj.data.admin_state == BCMBAL_STATE_UP ? "up" : "down",
362 acc_term_obj.data.oper_status == BCMBAL_STATUS_UP ? "up" : "down");
363
364 std::string bal_version;
365 bal_version += std::to_string(acc_term_obj.data.sw_version.major_rev)
366 + "." + std::to_string(acc_term_obj.data.sw_version.minor_rev)
367 + "." + std::to_string(acc_term_obj.data.sw_version.release_rev);
368 firmware_version = "BAL." + bal_version + "__" + firmware_version;
369
370 BCM_LOG(INFO, openolt_log_id, "--------------- version %s object model: %d\n", bal_version.c_str(),
371 acc_term_obj.data.sw_version.om_version);
372
373 BCM_LOG(INFO, openolt_log_id, "--------------- topology nni:%d pon:%d dev:%d ppd:%d family: %d:%d\n",
374 acc_term_obj.data.topology.num_of_nni_ports,
375 acc_term_obj.data.topology.num_of_pon_ports,
376 acc_term_obj.data.topology.num_of_mac_devs,
377 acc_term_obj.data.topology.num_of_pons_per_mac_dev,
378 acc_term_obj.data.topology.pon_family,
379 acc_term_obj.data.topology.pon_sub_family
380 );
381
382 switch(acc_term_obj.data.topology.pon_sub_family)
383 {
Craig Lutgenb2601f02018-10-23 13:04:31 -0500384 case BCMBAL_PON_SUB_FAMILY_GPON: board_technology = "gpon"; break;
385 case BCMBAL_PON_SUB_FAMILY_XGS: board_technology = "xgspon"; break;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500386 }
387
388 num_of_nni_ports = acc_term_obj.data.topology.num_of_nni_ports;
389 num_of_pon_ports = acc_term_obj.data.topology.num_of_pon_ports;
390
Craig Lutgenb2601f02018-10-23 13:04:31 -0500391 BCM_LOG(INFO, openolt_log_id, "PON num_intfs: %d global board_technology: %s\n", num_of_pon_ports, board_technology.c_str());
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500392
393 return Status::OK;
394}
395
396Status ProbePonIfTechnology_() {
397 // Probe maximum extent possible as configured into BAL driver to determine
398 // which are active in the current BAL topology. And for those
399 // that are active, determine each port's access technology, i.e. "gpon" or "xgspon".
400 for (uint32_t intf_id = 0; intf_id < num_of_pon_ports; ++intf_id) {
401 bcmbal_interface_cfg interface_obj;
402 bcmbal_interface_key interface_key;
403
404 interface_key.intf_id = intf_id;
405 interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
406
407 BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
408 BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
409 BCMBAL_CFG_PROP_GET(&interface_obj, interface, transceiver_type);
410
411 bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
412 if (err != BCM_ERR_OK) {
Craig Lutgenb2601f02018-10-23 13:04:31 -0500413 intf_technologies[intf_id] = UNKNOWN_TECH;
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500414 if(err != BCM_ERR_RANGE) BCM_LOG(ERROR, openolt_log_id, "Failed to get PON config: %d\n", intf_id);
415 }
416 else {
417 switch(interface_obj.data.transceiver_type) {
418 case BCMBAL_TRX_TYPE_GPON_SPS_43_48:
419 case BCMBAL_TRX_TYPE_GPON_SPS_SOG_4321:
420 case BCMBAL_TRX_TYPE_GPON_LTE_3680_M:
421 case BCMBAL_TRX_TYPE_GPON_SOURCE_PHOTONICS:
422 case BCMBAL_TRX_TYPE_GPON_LTE_3680_P:
Craig Lutgenb2601f02018-10-23 13:04:31 -0500423 intf_technologies[intf_id] = "gpon";
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500424 break;
425 default:
Craig Lutgenb2601f02018-10-23 13:04:31 -0500426 intf_technologies[intf_id] = "xgspon";
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500427 break;
428 }
Craig Lutgenb2601f02018-10-23 13:04:31 -0500429 BCM_LOG(INFO, openolt_log_id, "PON intf_id: %d intf_technologies: %d:%s\n", intf_id,
430 interface_obj.data.transceiver_type, intf_technologies[intf_id].c_str());
431
432 if (board_technology != UNKNOWN_TECH) {
433 board_technology = intf_technologies[intf_id];
434 } else if (board_technology != MIXED_TECH && board_technology != intf_technologies[intf_id]) {
435 intf_technologies[intf_id] = MIXED_TECH;
436 }
437
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500438 }
439 }
440
441 return Status::OK;
442}
443
444unsigned NumNniIf_() {return num_of_nni_ports;}
445unsigned NumPonIf_() {return num_of_pon_ports;}
446
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400447Status EnableUplinkIf_(uint32_t intf_id) {
448 bcmbal_interface_cfg interface_obj;
449 bcmbal_interface_key interface_key;
450
451 interface_key.intf_id = intf_id;
452 interface_key.intf_type = BCMBAL_INTF_TYPE_NNI;
453
454 BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500455
456 BCMBAL_CFG_PROP_GET(&interface_obj, interface, admin_state);
457 bcmos_errno err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
458 if (err == BCM_ERR_OK && interface_obj.data.admin_state == BCMBAL_STATE_UP) {
459 BCM_LOG(DEBUG, openolt_log_id, "Uplink interface: %d already enabled\n", intf_id);
460 return Status::OK;
461 }
462
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400463 BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_UP);
464
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500465 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400466 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400467 BCM_LOG(ERROR, openolt_log_id, "Failed to enable Uplink interface: %d\n", intf_id);
Nicolas Palpacuere3fc0d22018-08-02 16:51:05 -0400468 return bcm_to_grpc_err(err, "Failed to enable Uplink interface");
469 }
470
471 return Status::OK;
472}
473
Nicolas Palpacuer05ea0ea2018-07-06 11:47:21 -0400474Status DisablePonIf_(uint32_t intf_id) {
475 bcmbal_interface_cfg interface_obj;
476 bcmbal_interface_key interface_key;
477
478 interface_key.intf_id = intf_id;
479 interface_key.intf_type = BCMBAL_INTF_TYPE_PON;
480
481 BCMBAL_CFG_INIT(&interface_obj, interface, interface_key);
482 BCMBAL_CFG_PROP_SET(&interface_obj, interface, admin_state, BCMBAL_STATE_DOWN);
483
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400484 bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
485 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400486 BCM_LOG(ERROR, openolt_log_id, "Failed to disable PON interface: %d\n", intf_id);
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400487 return bcm_to_grpc_err(err, "Failed to disable PON interface");
Nicolas Palpacuer05ea0ea2018-07-06 11:47:21 -0400488 }
489
490 return Status::OK;
491}
492
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000493Status ActivateOnu_(uint32_t intf_id, uint32_t onu_id,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700494 const char *vendor_id, const char *vendor_specific, uint32_t pir) {
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000495
496 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
497 bcmbal_subscriber_terminal_key subs_terminal_key;
498 bcmbal_serial_number serial_num = {};
499 bcmbal_registration_id registration_id = {};
500
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700501 BCM_LOG(INFO, openolt_log_id, "Enabling ONU %d on PON %d : vendor id %s, vendor specific %s, pir %d\n",
502 onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str(), pir);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000503
504 subs_terminal_key.sub_term_id = onu_id;
505 subs_terminal_key.intf_id = intf_id;
506 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, subs_terminal_key);
507
508 memcpy(serial_num.vendor_id, vendor_id, 4);
509 memcpy(serial_num.vendor_specific, vendor_specific, 4);
510 BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, serial_number, serial_num);
511
Shad Ansaricb004c52018-05-30 18:07:23 +0000512#if 0
513 // Commenting out as this is causing issues with onu activation
514 // with BAL 2.6 (Broadcom CS5248819).
515
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000516 // FIXME - Use a default (all zeros) registration id.
517 memset(registration_id.arr, 0, sizeof(registration_id.arr));
518 BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, registration_id, registration_id);
Shad Ansaricb004c52018-05-30 18:07:23 +0000519#endif
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000520
521 BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, admin_state, BCMBAL_STATE_UP);
522
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400523 bcmos_errno err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(sub_term_obj.hdr));
524 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400525 BCM_LOG(ERROR, openolt_log_id, "Failed to enable ONU %d on PON %d\n", onu_id, intf_id);
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400526 return bcm_to_grpc_err(err, "Failed to enable ONU");
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000527 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700528 return Status::OK;
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000529}
530
Jonathan Davis70c21812018-07-19 15:32:10 -0400531Status DeactivateOnu_(uint32_t intf_id, uint32_t onu_id,
532 const char *vendor_id, const char *vendor_specific) {
533
Jonathan Davis70c21812018-07-19 15:32:10 -0400534 bcmbal_subscriber_terminal_cfg sub_term_obj = {};
535 bcmbal_subscriber_terminal_key subs_terminal_key;
536
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400537 BCM_LOG(INFO, openolt_log_id, "Deactivating ONU %d on PON %d : vendor id %s, vendor specific %s\n",
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500538 onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str());
Jonathan Davis70c21812018-07-19 15:32:10 -0400539
540 subs_terminal_key.sub_term_id = onu_id;
541 subs_terminal_key.intf_id = intf_id;
542 BCMBAL_CFG_INIT(&sub_term_obj, subscriber_terminal, subs_terminal_key);
543
544 BCMBAL_CFG_PROP_SET(&sub_term_obj, subscriber_terminal, admin_state, BCMBAL_STATE_DOWN);
545
546 if (bcmbal_cfg_set(DEFAULT_ATERM_ID, &(sub_term_obj.hdr))) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400547 BCM_LOG(ERROR, openolt_log_id, "Failed to deactivate ONU %d on PON %d\n", onu_id, intf_id);
Jonathan Davis70c21812018-07-19 15:32:10 -0400548 return Status(grpc::StatusCode::INTERNAL, "Failed to deactivate ONU");
549 }
550
551 return Status::OK;
552}
553
554Status DeleteOnu_(uint32_t intf_id, uint32_t onu_id,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700555 const char *vendor_id, const char *vendor_specific) {
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400556
Craig Lutgend0bae9b2018-10-18 18:02:07 -0500557 BCM_LOG(INFO, openolt_log_id, "DeleteOnu ONU %d on PON %d : vendor id %s, vendor specific %s\n",
558 onu_id, intf_id, vendor_id, vendor_specific_to_str(vendor_specific).c_str());
559
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400560 // Need to deactivate before removing it (BAL rules)
561
562 DeactivateOnu_(intf_id, onu_id, vendor_id, vendor_specific);
563 // Sleep to allow the state to propagate
564 // We need the subscriber terminal object to be admin down before removal
565 // Without sleep the race condition is lost by ~ 20 ms
566 std::this_thread::sleep_for(std::chrono::milliseconds(100));
567
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700568 // TODO: Delete the schedulers and queues.
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400569
Jonathan Davis70c21812018-07-19 15:32:10 -0400570 bcmos_errno err = BCM_ERR_OK;
571 bcmbal_subscriber_terminal_cfg cfg;
572 bcmbal_subscriber_terminal_key key = { };
573
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400574 BCM_LOG(INFO, openolt_log_id, "Processing subscriber terminal cfg clear for sub_term_id %d and intf_id %d\n",
575 onu_id, intf_id);
Jonathan Davis70c21812018-07-19 15:32:10 -0400576
577 key.sub_term_id = onu_id ;
578 key.intf_id = intf_id ;
579
580 if (0 == key.sub_term_id)
581 {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400582 BCM_LOG(INFO, openolt_log_id,"Invalid Key to handle subscriber terminal clear subscriber_terminal_id %d, Interface ID %d\n",
583 onu_id, intf_id);
Jonathan Davis70c21812018-07-19 15:32:10 -0400584 return Status(grpc::StatusCode::INTERNAL, "Failed to delete ONU");
585 }
586
587 BCMBAL_CFG_INIT(&cfg, subscriber_terminal, key);
588
589 err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
590 if (err != BCM_ERR_OK)
591 {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400592 BCM_LOG(ERROR, openolt_log_id, "Failed to clear information for BAL subscriber_terminal_id %d, Interface ID %d\n",
593 onu_id, intf_id);
Jonathan Davis70c21812018-07-19 15:32:10 -0400594 return Status(grpc::StatusCode::INTERNAL, "Failed to delete ONU");
595 }
596
597 return Status::OK;;
598}
599
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000600#define MAX_CHAR_LENGTH 20
601#define MAX_OMCI_MSG_LENGTH 44
602Status OmciMsgOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt) {
603 bcmbal_u8_list_u32_max_2048 buf; /* A structure with a msg pointer and length value */
604 bcmos_errno err = BCM_ERR_OK;
605
606 /* The destination of the OMCI packet is a registered ONU on the OLT PON interface */
607 bcmbal_dest proxy_pkt_dest;
608
609 proxy_pkt_dest.type = BCMBAL_DEST_TYPE_ITU_OMCI_CHANNEL;
610 proxy_pkt_dest.u.itu_omci_channel.sub_term_id = onu_id;
611 proxy_pkt_dest.u.itu_omci_channel.intf_id = intf_id;
612
613 // ???
614 if ((pkt.size()/2) > MAX_OMCI_MSG_LENGTH) {
615 buf.len = MAX_OMCI_MSG_LENGTH;
616 } else {
617 buf.len = pkt.size()/2;
618 }
619
620 /* Send the OMCI packet using the BAL remote proxy API */
621 uint16_t idx1 = 0;
622 uint16_t idx2 = 0;
623 uint8_t arraySend[buf.len];
624 char str1[MAX_CHAR_LENGTH];
625 char str2[MAX_CHAR_LENGTH];
626 memset(&arraySend, 0, buf.len);
627
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000628 for (idx1=0,idx2=0; idx1<((buf.len)*2); idx1++,idx2++) {
629 sprintf(str1,"%c", pkt[idx1]);
630 sprintf(str2,"%c", pkt[++idx1]);
631 strcat(str1,str2);
632 arraySend[idx2] = strtol(str1, NULL, 16);
633 }
634
635 buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
636 memcpy(buf.val, (uint8_t *)arraySend, buf.len);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000637
638 err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
639
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400640 if (err) {
641 BCM_LOG(ERROR, omci_log_id, "Error sending OMCI message to ONU %d on PON %d\n", onu_id, intf_id);
642 } else {
643 BCM_LOG(DEBUG, omci_log_id, "OMCI request msg of length %d sent to ONU %d on PON %d : %s\n",
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500644 buf.len, onu_id, intf_id, pkt.c_str());
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400645 }
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000646
647 free(buf.val);
648
649 return Status::OK;
650}
651
652Status OnuPacketOut_(uint32_t intf_id, uint32_t onu_id, const std::string pkt) {
653 bcmos_errno err = BCM_ERR_OK;
654 bcmbal_dest proxy_pkt_dest;
655 bcmbal_u8_list_u32_max_2048 buf;
656
657 proxy_pkt_dest.type = BCMBAL_DEST_TYPE_SUB_TERM,
658 proxy_pkt_dest.u.sub_term.sub_term_id = onu_id;
659 proxy_pkt_dest.u.sub_term.intf_id = intf_id;
660
661 buf.len = pkt.size();
662 buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
663 memcpy(buf.val, (uint8_t *)pkt.data(), buf.len);
664
665 err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
666
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400667 BCM_LOG(INFO, openolt_log_id, "Packet out of length %d sent to ONU %d on PON %d\n",
668 buf.len, onu_id, intf_id);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000669
670 free(buf.val);
671
672 return Status::OK;
673}
674
Nicolas Palpacuerb78def42018-06-07 12:55:26 -0400675Status UplinkPacketOut_(uint32_t intf_id, const std::string pkt) {
676 bcmos_errno err = BCM_ERR_OK;
677 bcmbal_dest proxy_pkt_dest;
678 bcmbal_u8_list_u32_max_2048 buf;
679
680 proxy_pkt_dest.type = BCMBAL_DEST_TYPE_NNI,
681 proxy_pkt_dest.u.nni.intf_id = intf_id;
682
683 buf.len = pkt.size();
684 buf.val = (uint8_t *)malloc((buf.len)*sizeof(uint8_t));
685 memcpy(buf.val, (uint8_t *)pkt.data(), buf.len);
686
687 err = bcmbal_pkt_send(0, proxy_pkt_dest, (const char *)(buf.val), buf.len);
688
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400689 BCM_LOG(INFO, openolt_log_id, "Packet out of length %d sent through uplink port %d\n",
690 buf.len, intf_id);
Nicolas Palpacuerb78def42018-06-07 12:55:26 -0400691
692 free(buf.val);
693
694 return Status::OK;
695}
696
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700697Status FlowAdd_(int32_t access_intf_id, int32_t onu_id,
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000698 uint32_t flow_id, const std::string flow_type,
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700699 int32_t alloc_id, int32_t network_intf_id,
700 int32_t gemport_id, const ::openolt::Classifier& classifier,
701 const ::openolt::Action& action, int32_t priority_value) {
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000702 bcmos_errno err;
703 bcmbal_flow_cfg cfg;
704 bcmbal_flow_key key = { };
705
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700706 BCM_LOG(INFO, openolt_log_id, "flow add - intf_id %d, onu_id %d, flow_id %d, flow_type %s, gemport_id %d, network_intf_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400707 access_intf_id, onu_id, flow_id, flow_type.c_str(), gemport_id, network_intf_id);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000708
709 key.flow_id = flow_id;
710 if (flow_type.compare("upstream") == 0 ) {
711 key.flow_type = BCMBAL_FLOW_TYPE_UPSTREAM;
712 } else if (flow_type.compare("downstream") == 0) {
713 key.flow_type = BCMBAL_FLOW_TYPE_DOWNSTREAM;
714 } else {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400715 BCM_LOG(WARNING, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400716 return bcm_to_grpc_err(BCM_ERR_PARM, "Invalid flow type");
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000717 }
718
719 BCMBAL_CFG_INIT(&cfg, flow, key);
720
721 BCMBAL_CFG_PROP_SET(&cfg, flow, admin_state, BCMBAL_STATE_UP);
Shad Ansari39739bc2018-09-13 21:38:37 +0000722 if (access_intf_id >= 0) {
723 BCMBAL_CFG_PROP_SET(&cfg, flow, access_int_id, access_intf_id);
724 }
725 if (network_intf_id >= 0) {
726 BCMBAL_CFG_PROP_SET(&cfg, flow, network_int_id, network_intf_id);
727 }
728 if (onu_id >= 0) {
729 BCMBAL_CFG_PROP_SET(&cfg, flow, sub_term_id, onu_id);
730 }
731 if (gemport_id >= 0) {
732 BCMBAL_CFG_PROP_SET(&cfg, flow, svc_port_id, gemport_id);
733 }
734 if (priority_value >= 0) {
735 BCMBAL_CFG_PROP_SET(&cfg, flow, priority, priority_value);
736 }
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000737
738 {
739 bcmbal_classifier val = { };
740
741 if (classifier.o_tpid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500742 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, o_tpid, classifier.o_tpid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000743 }
744
745 if (classifier.o_vid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500746 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, o_vid, classifier.o_vid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000747 }
748
749 if (classifier.i_tpid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500750 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, i_tpid, classifier.i_tpid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000751 }
752
753 if (classifier.i_vid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500754 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, i_vid, classifier.i_vid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000755 }
756
757 if (classifier.o_pbits()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500758 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, o_pbits, classifier.o_pbits());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000759 }
760
761 if (classifier.i_pbits()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500762 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, i_pbits, classifier.i_pbits());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000763 }
764
765 if (classifier.eth_type()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500766 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, ether_type, classifier.eth_type());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000767 }
768
769 /*
770 if (classifier.dst_mac()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500771 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, dst_mac, classifier.dst_mac());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000772 }
773
774 if (classifier.src_mac()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500775 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, src_mac, classifier.src_mac());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000776 }
777 */
778
779 if (classifier.ip_proto()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500780 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, ip_proto, classifier.ip_proto());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000781 }
782
783 /*
784 if (classifier.dst_ip()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500785 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, dst_ip, classifier.dst_ip());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000786 }
787
788 if (classifier.src_ip()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500789 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, src_ip, classifier.src_ip());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000790 }
791 */
792
793 if (classifier.src_port()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500794 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, src_port, classifier.src_port());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000795 }
796
797 if (classifier.dst_port()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500798 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, dst_port, classifier.dst_port());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000799 }
800
801 if (!classifier.pkt_tag_type().empty()) {
802 if (classifier.pkt_tag_type().compare("untagged") == 0) {
Craig Lutgen19512312018-11-02 10:14:46 -0500803 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, pkt_tag_type, BCMBAL_PKT_TAG_TYPE_UNTAGGED);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000804 } else if (classifier.pkt_tag_type().compare("single_tag") == 0) {
Craig Lutgen19512312018-11-02 10:14:46 -0500805 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, pkt_tag_type, BCMBAL_PKT_TAG_TYPE_SINGLE_TAG);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000806 } else if (classifier.pkt_tag_type().compare("double_tag") == 0) {
Craig Lutgen19512312018-11-02 10:14:46 -0500807 BCMBAL_ATTRIBUTE_PROP_SET(&val, classifier, pkt_tag_type, BCMBAL_PKT_TAG_TYPE_DOUBLE_TAG);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000808 }
809 }
810
811 BCMBAL_CFG_PROP_SET(&cfg, flow, classifier, val);
812 }
813
814 {
815 bcmbal_action val = { };
816
817 const ::openolt::ActionCmd& cmd = action.cmd();
818
819 if (cmd.add_outer_tag()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500820 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, cmds_bitmask, BCMBAL_ACTION_CMD_ID_ADD_OUTER_TAG);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000821 }
822
823 if (cmd.remove_outer_tag()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500824 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, cmds_bitmask, BCMBAL_ACTION_CMD_ID_REMOVE_OUTER_TAG);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000825 }
826
827 if (cmd.trap_to_host()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500828 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, cmds_bitmask, BCMBAL_ACTION_CMD_ID_TRAP_TO_HOST);
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000829 }
830
831 if (action.o_vid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500832 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, o_vid, action.o_vid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000833 }
834
835 if (action.o_pbits()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500836 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, o_pbits, action.o_pbits());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000837 }
838
839 if (action.o_tpid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500840 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, o_tpid, action.o_tpid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000841 }
842
843 if (action.i_vid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500844 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, i_vid, action.i_vid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000845 }
846
847 if (action.i_pbits()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500848 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, i_pbits, action.i_pbits());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000849 }
850
851 if (action.i_tpid()) {
Craig Lutgen19512312018-11-02 10:14:46 -0500852 BCMBAL_ATTRIBUTE_PROP_SET(&val, action, i_tpid, action.i_tpid());
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000853 }
854
855 BCMBAL_CFG_PROP_SET(&cfg, flow, action, val);
856 }
857
Shad Ansari39739bc2018-09-13 21:38:37 +0000858 if ((access_intf_id >= 0) && (onu_id >= 0)) {
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000859
Shad Ansari39739bc2018-09-13 21:38:37 +0000860 if (key.flow_type == BCMBAL_FLOW_TYPE_DOWNSTREAM) {
861 bcmbal_tm_queue_ref val = { };
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700862 val.sched_id = mk_sched_id(access_intf_id, onu_id, "downstream");
863 val.queue_id = mk_queue_id(access_intf_id, onu_id);
Shad Ansari39739bc2018-09-13 21:38:37 +0000864 BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700865 } else if (key.flow_type == BCMBAL_FLOW_TYPE_UPSTREAM) {
866 bcmbal_tm_sched_id val1;
867 if (alloc_id != 0) {
868 val1 = alloc_id;
869 } else {
870 BCM_LOG(ERROR, openolt_log_id, "alloc_id not present");
871 }
872 BCMBAL_CFG_PROP_SET(&cfg, flow, dba_tm_sched_id, val1);
873
874 bcmbal_tm_queue_ref val2 = { };
875 val2.sched_id = mk_sched_id(network_intf_id, onu_id, "upstream");
876 BCMBAL_CFG_PROP_SET(&cfg, flow, queue, val2);
Shad Ansari39739bc2018-09-13 21:38:37 +0000877 }
Shad Ansari06101952018-07-25 00:22:09 +0000878 }
879
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400880 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));
881 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400882 BCM_LOG(ERROR, openolt_log_id, "Flow add failed\n");
Nicolas Palpacuer73222e02018-07-16 12:20:26 -0400883 return bcm_to_grpc_err(err, "flow add failed");
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000884 }
885
Nicolas Palpacuer6a63ea92018-09-05 17:21:37 -0400886 // register_new_flow(key);
Nicolas Palpacuer0f19b1a2018-06-07 17:29:31 -0400887
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000888 return Status::OK;
889}
890
Nicolas Palpacueredfaa0c2018-07-05 15:05:27 -0400891Status FlowRemove_(uint32_t flow_id, const std::string flow_type) {
892
893 bcmbal_flow_cfg cfg;
894 bcmbal_flow_key key = { };
895
896 key.flow_id = (bcmbal_flow_id) flow_id;
897 key.flow_id = flow_id;
898 if (flow_type.compare("upstream") == 0 ) {
899 key.flow_type = BCMBAL_FLOW_TYPE_UPSTREAM;
900 } else if (flow_type.compare("downstream") == 0) {
901 key.flow_type = BCMBAL_FLOW_TYPE_DOWNSTREAM;
902 } else {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400903 BCM_LOG(WARNING, openolt_log_id, "Invalid flow type %s\n", flow_type.c_str());
Nicolas Palpacueredfaa0c2018-07-05 15:05:27 -0400904 return bcm_to_grpc_err(BCM_ERR_PARM, "Invalid flow type");
905 }
906
907 BCMBAL_CFG_INIT(&cfg, flow, key);
908
909
910 bcmos_errno err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
911 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400912 BCM_LOG(ERROR, openolt_log_id, "Error %d while removing flow %d, %s\n",
913 err, flow_id, flow_type.c_str());
Nicolas Palpacueredfaa0c2018-07-05 15:05:27 -0400914 return Status(grpc::StatusCode::INTERNAL, "Failed to remove flow");
915 }
916
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400917 BCM_LOG(INFO, openolt_log_id, "Flow %d, %s removed\n", flow_id, flow_type.c_str());
Nicolas Palpacueredfaa0c2018-07-05 15:05:27 -0400918 return Status::OK;
919}
920
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700921Status SchedAdd_(std::string direction, uint32_t intf_id, uint32_t onu_id,
922 uint32_t alloc_id, openolt::AdditionalBW additional_bw, uint32_t weight, uint32_t priority,
923 openolt::SchedulingPolicy sched_policy) {
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400924
925 bcmos_errno err;
926
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700927 if (direction == "downstream") {
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400928 bcmbal_tm_queue_cfg cfg;
929 bcmbal_tm_queue_key key = { };
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700930 // Note: We use the default scheduler available in the DL.
931 key.sched_id = mk_sched_id(intf_id, onu_id, direction);
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400932 key.sched_dir = BCMBAL_TM_SCHED_DIR_DS;
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700933 key.id = mk_queue_id(intf_id, onu_id);
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400934
935 BCMBAL_CFG_INIT(&cfg, tm_queue, key);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700936 //Queue must be set with either weight or priority, not both,
937 // as its scheduler' sched_type is sp_wfq
938 BCMBAL_CFG_PROP_SET(&cfg, tm_queue, priority, priority);
939 //BCMBAL_CFG_PROP_SET(&cfg, tm_queue, weight, weight);
940 //BCMBAL_CFG_PROP_SET(&cfg, tm_queue, creation_mode, BCMBAL_TM_CREATION_MODE_MANUAL);
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400941 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &cfg.hdr);
942
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700943 // TODO: Shaping parameters will be available after meter bands are supported.
944 // TODO: The shaping parameters will be applied on the downstream queue on the PON default scheduler.
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400945 if (err) {
Nicolas Palpacuer967438f2018-09-07 14:41:54 -0400946 BCM_LOG(ERROR, openolt_log_id, "Failed to create subscriber downstream tm queue, id %d, sched_id %d, intf_id %d, onu_id %d\n",
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700947 key.id, key.sched_id, intf_id, onu_id);
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400948 return bcm_to_grpc_err(err, "Failed to create subscriber downstream tm queue");
949 }
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700950 } else { //"upstream"
951 bcmbal_tm_sched_cfg cfg;
952 bcmbal_tm_sched_key key = { };
953 bcmbal_tm_sched_type sched_type;
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400954
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700955 key.id = alloc_id;
956 key.dir = BCMBAL_TM_SCHED_DIR_US;
957
958 BCMBAL_CFG_INIT(&cfg, tm_sched, key);
959
960 {
961 bcmbal_tm_sched_owner val = { };
962
963 val.type = BCMBAL_TM_SCHED_OWNER_TYPE_AGG_PORT;
964 BCMBAL_ATTRIBUTE_PROP_SET(&val.u.agg_port, tm_sched_owner_agg_port, intf_id, (bcmbal_intf_id) intf_id);
965 BCMBAL_ATTRIBUTE_PROP_SET(&val.u.agg_port, tm_sched_owner_agg_port, sub_term_id, (bcmbal_sub_id) onu_id);
966 BCMBAL_ATTRIBUTE_PROP_SET(&val.u.agg_port, tm_sched_owner_agg_port, agg_port_id, (bcmbal_aggregation_port_id) alloc_id);
967
968 BCMBAL_CFG_PROP_SET(&cfg, tm_sched, owner, val);
969
970 }
971 // TODO: Shaping parameters will be available after meter bands are supported.
972 // TODO: The shaping parameters will be applied on the upstream DBA scheduler.
973
974 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(cfg.hdr));
975 if (err) {
976 BCM_LOG(ERROR, openolt_log_id, "Failed to create upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
977 key.id, intf_id, onu_id);
978 return bcm_to_grpc_err(err, "Failed to create upstream DBA sched");
979 }
980 BCM_LOG(INFO, openolt_log_id, "Create upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
981 key.id,intf_id,onu_id);
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400982 }
983
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700984 return Status::OK;
Nicolas Palpacuer9c352082018-08-14 16:37:14 -0400985
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700986}
Shad Ansarib7b0ced2018-05-11 21:53:32 +0000987
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -0700988Status CreateTconts_(const openolt::Tconts *tconts) {
989 uint32_t intf_id = tconts->intf_id();
990 uint32_t onu_id = tconts->onu_id();
991 std::string direction;
992 unsigned int alloc_id;
993 openolt::Scheduler scheduler;
994 openolt::AdditionalBW additional_bw;
995 uint32_t priority;
996 uint32_t weight;
997 openolt::SchedulingPolicy sched_policy;
998
999 for (int i = 0; i < tconts->tconts_size(); i++) {
1000 openolt::Tcont tcont = tconts->tconts(i);
1001 if (tcont.direction() == openolt::Direction::UPSTREAM) {
1002 direction = "upstream";
1003 } else if (tcont.direction() == openolt::Direction::DOWNSTREAM) {
1004 direction = "downstream";
1005 }
1006 else {
1007 BCM_LOG(ERROR, openolt_log_id, "direction-not-supported %d", tcont.direction());
1008 return Status::CANCELLED;
1009 }
1010 alloc_id = tcont.alloc_id();
1011 scheduler = tcont.scheduler();
1012 additional_bw = scheduler.additional_bw();
1013 priority = scheduler.priority();
1014 weight = scheduler.weight();
1015 sched_policy = scheduler.sched_policy();
1016 // TODO: TrafficShapingInfo is not supported for now as meter band support is not there
1017 SchedAdd_(direction, intf_id, onu_id, alloc_id, additional_bw, weight, priority, sched_policy);
Girish Gowdru1cdf6ce2018-08-27 02:43:02 -07001018 }
Shad Ansarib7b0ced2018-05-11 21:53:32 +00001019 return Status::OK;
Shad Ansarib7b0ced2018-05-11 21:53:32 +00001020}
Jonathan Davis70c21812018-07-19 15:32:10 -04001021
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001022Status RemoveTconts_(const openolt::Tconts *tconts) {
1023 uint32_t intf_id = tconts->intf_id();
1024 uint32_t onu_id = tconts->onu_id();
1025 std::string direction;
1026 unsigned int alloc_id;
1027
1028 for (int i = 0; i < tconts->tconts_size(); i++) {
1029 openolt::Tcont tcont = tconts->tconts(i);
1030 if (tcont.direction() == openolt::Direction::UPSTREAM) {
1031 direction = "upstream";
1032 } else if (tcont.direction() == openolt::Direction::DOWNSTREAM) {
1033 direction = "downstream";
1034 }
1035 else {
1036 BCM_LOG(ERROR, openolt_log_id, "direction-not-supported %d", tcont.direction());
1037 return Status::CANCELLED;
1038 }
1039 alloc_id = tcont.alloc_id();
1040 SchedRemove_(direction, intf_id, onu_id, alloc_id);
1041 }
1042 return Status::OK;
1043}
1044
1045Status SchedRemove_(std::string direction, int intf_id, int onu_id, int alloc_id) {
Jonathan Davis70c21812018-07-19 15:32:10 -04001046
Nicolas Palpacuer9c352082018-08-14 16:37:14 -04001047 bcmos_errno err;
Jonathan Davis70c21812018-07-19 15:32:10 -04001048
Jonathan Davis70c21812018-07-19 15:32:10 -04001049
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001050 if (direction == "upstream") {
1051 // DBA sched
1052 bcmbal_tm_sched_cfg tm_cfg_us;
1053 bcmbal_tm_sched_key tm_key_us = { };
Nicolas Palpacuer9c352082018-08-14 16:37:14 -04001054
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001055 tm_key_us.id = alloc_id;
1056 tm_key_us.dir = BCMBAL_TM_SCHED_DIR_US;
Nicolas Palpacuer9c352082018-08-14 16:37:14 -04001057
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001058 BCMBAL_CFG_INIT(&tm_cfg_us, tm_sched, tm_key_us);
Nicolas Palpacuer9c352082018-08-14 16:37:14 -04001059
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001060 err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &(tm_cfg_us.hdr));
1061 if (err) {
1062 BCM_LOG(ERROR, openolt_log_id, "Failed to remove upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
1063 tm_key_us.id, intf_id, onu_id);
1064 return Status(grpc::StatusCode::INTERNAL, "Failed to remove upstream DBA sched");
1065 }
1066
1067 BCM_LOG(INFO, openolt_log_id, "Remove upstream DBA sched, id %d, intf_id %d, onu_id %d\n",
Nicolas Palpacuer967438f2018-09-07 14:41:54 -04001068 tm_key_us.id, intf_id, onu_id);
Girish Gowdru7c4ec2d2018-10-25 00:29:54 -07001069
1070 } else if (direction == "downstream") {
1071 // Queue
1072
1073 bcmbal_tm_queue_cfg queue_cfg;
1074 bcmbal_tm_queue_key queue_key = { };
1075 queue_key.sched_id = mk_sched_id(intf_id, onu_id, "downstream");
1076 queue_key.sched_dir = BCMBAL_TM_SCHED_DIR_DS;
1077 queue_key.id = mk_queue_id(intf_id, onu_id);;
1078
1079 BCMBAL_CFG_INIT(&queue_cfg, tm_queue, queue_key);
1080
1081 err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &(queue_cfg.hdr));
1082 if (err) {
1083 BCM_LOG(ERROR, openolt_log_id, "Failed to remove downstream tm queue, id %d, sched_id %d, intf_id %d, onu_id %d\n",
1084 queue_key.id, queue_key.sched_id, intf_id, onu_id);
1085 return Status(grpc::StatusCode::INTERNAL, "Failed to remove downstream tm queue");
1086 }
1087
1088 BCM_LOG(INFO, openolt_log_id, "Remove upstream DBA sched, id %d, sched_id %d, intf_id %d, onu_id %d\n",
1089 queue_key.id, queue_key.sched_id, intf_id, onu_id);
Jonathan Davis70c21812018-07-19 15:32:10 -04001090 }
1091
Jonathan Davis70c21812018-07-19 15:32:10 -04001092 return Status::OK;
Jonathan Davis70c21812018-07-19 15:32:10 -04001093}