blob: adaba1a92cec94a608f3051fb116522e9cccda02 [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_flow_hdlr.h"
24
25
26/********************************************************************\
27 * Function : bal_fill_queue_cfg *
28 * Description : copy queue information from proto structure to *
29 * BAL structure *
30 ********************************************************************/
Kim Kempfafa1ab42017-11-13 09:31:47 -080031static uint32_t bal_fill_queue_cfg(BalTmQueueRef *tmp_que,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053032 bcmbal_tm_queue_ref *que_val)
33{
34 if(tmp_que->has_sched_id)
35 {
Kim Kempfafa1ab42017-11-13 09:31:47 -080036 que_val->sched_id = tmp_que->sched_id;
37 ASFVOLT_LOG(ASFVOLT_DEBUG, "que_val->sched_id = %d", que_val->sched_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053038 }
39
40 if(tmp_que->has_queue_id)
41 {
42 que_val->queue_id = tmp_que->queue_id;
Kim Kempfafa1ab42017-11-13 09:31:47 -080043 ASFVOLT_LOG(ASFVOLT_DEBUG, "que_val->queue_id = %d", que_val->queue_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053044 }
45
46 return BAL_ERRNO__BAL_ERR_OK;
47}
Kim Kempfafa1ab42017-11-13 09:31:47 -080048
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053049
50/********************************************************************\
51 * Function : bal_fill_action_cfg *
52 * Description : copy action information from proto structure to *
53 * BAL structure *
54 ********************************************************************/
Kim Kempfafa1ab42017-11-13 09:31:47 -080055static uint32_t bal_fill_action_cfg(BalAction *tmp_action,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053056 bcmbal_action *action_val)
57{
58
59 if(tmp_action->has_presence_mask)
60 {
61 action_val->presence_mask = tmp_action->presence_mask;
62 if (action_val->presence_mask & BCMBAL_ACTION_ID_CMDS_BITMASK)
63 {
64 action_val->cmds_bitmask = tmp_action->cmds_bitmask;
Kim Kempfafa1ab42017-11-13 09:31:47 -080065 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->cmds_bitmask = %x", action_val->cmds_bitmask);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053066 }
67
68 if (action_val->presence_mask & BCMBAL_ACTION_ID_O_VID)
69 {
70 action_val->o_vid = tmp_action->o_vid;
Kim Kempfafa1ab42017-11-13 09:31:47 -080071 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_vid = %d", action_val->o_vid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053072 }
73
74 if (action_val->presence_mask & BCMBAL_ACTION_ID_O_PBITS)
75 {
76 action_val->o_pbits = tmp_action->o_pbits;
Kim Kempfafa1ab42017-11-13 09:31:47 -080077 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_pbits = %d", action_val->o_pbits);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053078 }
79
80 if (action_val->presence_mask & BCMBAL_ACTION_ID_O_TPID)
81 {
82 action_val->o_tpid = tmp_action->o_tpid;
Kim Kempfafa1ab42017-11-13 09:31:47 -080083 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_tpid = %d", action_val->o_tpid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053084 }
85
86 if (action_val->presence_mask & BCMBAL_ACTION_ID_I_VID)
87 {
88 action_val->i_vid = tmp_action->i_vid;
Kim Kempfafa1ab42017-11-13 09:31:47 -080089 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_vid = %d", action_val->i_vid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053090 }
91
92 if (action_val->presence_mask & BCMBAL_ACTION_ID_I_PBITS)
93 {
94 action_val->i_pbits = tmp_action->i_pbits;
Kim Kempfafa1ab42017-11-13 09:31:47 -080095 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_pbits = %d", action_val->i_pbits);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053096 }
97
98 if (action_val->presence_mask & BCMBAL_ACTION_ID_I_TPID)
99 {
100 action_val->i_tpid = tmp_action->i_tpid;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800101 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_tpid = %d", action_val->i_tpid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530102 }
Kim Kempfafa1ab42017-11-13 09:31:47 -0800103 ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->presence_mask = %x", action_val->presence_mask);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530104 }
105 else
106 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800107 ASFVOLT_LOG(ASFVOLT_ERROR, "Action is not present in the flow");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530108 return BAL_ERRNO__BAL_ERR_PARM;
109 }
110
111 return BAL_ERRNO__BAL_ERR_OK;
112}
113
114
115/********************************************************************\
116 * Function : bal_fill_classifier_cfg *
117 * Description : copy classifier information from proto structure to*
118 * BAL structure
119 ********************************************************************/
Kim Kempfafa1ab42017-11-13 09:31:47 -0800120uint32_t bal_fill_classifier_cfg(BalClassifier *tmp_classifier,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530121 bcmbal_classifier *classifier_val)
122{
123
124 if(tmp_classifier->has_presence_mask)
125 {
126 classifier_val->presence_mask = tmp_classifier->presence_mask;
127 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_TPID)
128 {
129 classifier_val->o_tpid = tmp_classifier->o_tpid;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800130 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_tpid = %d", classifier_val->o_tpid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530131 }
132
133 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_VID)
134 {
135 classifier_val->o_vid = tmp_classifier->o_vid;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800136 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_vid = %d", classifier_val->o_vid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530137 }
138
139 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_TPID)
140 {
141 classifier_val->i_tpid = tmp_classifier->i_tpid;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800142 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_tpid = %d", classifier_val->i_tpid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530143 }
144
145 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_VID)
146 {
147 classifier_val->i_vid = tmp_classifier->i_vid;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800148 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_vid = %d", classifier_val->i_vid);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530149 }
150
151 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_PBITS)
152 {
153 classifier_val->o_pbits = tmp_classifier->o_pbits;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800154 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_pbits = %d", classifier_val->o_pbits);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530155 }
156
157 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_PBITS)
158 {
159 classifier_val->i_pbits = tmp_classifier->i_pbits;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800160 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_pbits = %d", classifier_val->i_pbits);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530161 }
162
163 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_ETHER_TYPE)
164 {
165 classifier_val->ether_type = tmp_classifier->ether_type;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800166 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->ether_type = %x", classifier_val->ether_type);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530167 }
168
169 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_MAC)
170 {
171 if(tmp_classifier->dst_mac.len > BCMOS_ETH_ALEN)
172 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800173 memcpy(classifier_val->dst_mac.u8,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530174 tmp_classifier->dst_mac.data, tmp_classifier->dst_mac.len);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800175 /*ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_mac= %d", classifier_val->dst_mac);*/
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530176 }
177 else
178 {
179 ASFVOLT_LOG(ASFVOLT_ERROR, "dst_mac should not be more than 6 bytes."
Kim Kempfafa1ab42017-11-13 09:31:47 -0800180 "actual bytes %lu", tmp_classifier->dst_mac.len);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530181 return BAL_ERRNO__BAL_ERR_PARM;
182 }
183 }
184
185 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_MAC)
186 {
187 if(tmp_classifier->src_mac.len > BCMOS_ETH_ALEN)
188 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800189 memcpy(classifier_val->src_mac.u8,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530190 tmp_classifier->src_mac.data, tmp_classifier->src_mac.len);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800191 /*ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_mac= %x", classifier_val->src_mac);*/
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530192 }
193 else
194 {
195 ASFVOLT_LOG(ASFVOLT_ERROR, "src_mac should not be more than 6 bytes."
Kim Kempfafa1ab42017-11-13 09:31:47 -0800196 "actual bytes %lu", tmp_classifier->src_mac.len);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530197 return BAL_ERRNO__BAL_ERR_PARM;
198 }
199
200 }
201
202 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_IP_PROTO)
203 {
204 classifier_val->ip_proto = tmp_classifier->ip_proto;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800205 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->ip_proto = %x", classifier_val->ip_proto);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530206 }
207
208 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_IP)
209 {
210 classifier_val->dst_ip.u32 = tmp_classifier->dst_ip;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800211 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_ip = %x", classifier_val->dst_ip.u32);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530212 }
213
214 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_IP)
215 {
216 classifier_val->src_ip.u32 = tmp_classifier->src_ip;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800217 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_ip = %x", classifier_val->src_ip.u32);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530218 }
219
220 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_PORT)
221 {
222 classifier_val->src_port = tmp_classifier->src_port;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800223 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_port = %d", classifier_val->src_port);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530224 }
225
226 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_PORT)
227 {
228 classifier_val->dst_port = tmp_classifier->dst_port;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800229 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_port = %d", classifier_val->dst_port);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530230 }
231
232 if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_PKT_TAG_TYPE)
233 {
234 classifier_val->pkt_tag_type = tmp_classifier->pkt_tag_type;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800235 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->pkt_tag_type = %x", classifier_val->pkt_tag_type);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530236 }
237
Kim Kempfafa1ab42017-11-13 09:31:47 -0800238 ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->presence_mask = %x", classifier_val->presence_mask);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530239 }
240 else
241 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800242 ASFVOLT_LOG(ASFVOLT_ERROR, "Classifier is not present in the flow");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530243 return BAL_ERRNO__BAL_ERR_PARM;
244 }
245
246 return BAL_ERRNO__BAL_ERR_OK;
247}
248
249/********************************************************************\
250 * Function : bal_flow_cfg_req *
251 * Description : Configure the the OLT DEVICE with flow information *
252 * using BAL Apis *
253 ********************************************************************/
254uint32_t bal_flow_cfg_set(BalFlowCfg *flow_cfg)
255{
256 bcmos_errno err = BCM_ERR_OK;
257 BalErrno bal_err = BAL_ERRNO__BAL_ERR_OK;
258 bcmbal_flow_cfg cfg; /**< declare main API struct */
259 bcmbal_flow_key key = { 0, 0}; /**< declare key */
260 bcmbal_classifier classifier_value = {};
261 bcmbal_action action_value = {};
262 bcmbal_tm_queue_ref queue_value = {};
263
264 /* build key from CLI parameters */
265 if(flow_cfg->key->has_flow_id)
266 {
267 key.flow_id = (bcmbal_flow_id) flow_cfg->key->flow_id;
268 }
269 else
270 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800271 ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid Flow Id (%d)", flow_cfg->key->flow_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530272 return BAL_ERRNO__BAL_ERR_PARM;
273 }
274
275
Kim Kempfafa1ab42017-11-13 09:31:47 -0800276 ASFVOLT_LOG(ASFVOLT_INFO, "Adding the flow to OLT. FlowID(%d)", flow_cfg->key->flow_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530277
Kim Kempfafa1ab42017-11-13 09:31:47 -0800278 if (!flow_cfg->key->has_flow_type &&
279 ((flow_cfg->key->flow_type < BAL_FLOW_TYPE__BAL_FLOW_TYPE_UPSTREAM) ||
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530280 flow_cfg->key->flow_type > BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST ))
281 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800282 ASFVOLT_LOG(ASFVOLT_ERROR, "Flow type is not supported (%d)", flow_cfg->key->flow_type);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530283 return BAL_ERRNO__BAL_ERR_PARM;
284 }
285 else
286 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800287 ASFVOLT_LOG(ASFVOLT_DEBUG, "flow_type = %d", flow_cfg->key->flow_type);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530288 key.flow_type = (bcmbal_flow_type) flow_cfg->key->flow_type;
289 }
290
291 /* init the API struct */
292 BCMBAL_CFG_INIT(&cfg, flow, key);
293
294 /* decode API parameters from grpc-c */
295 /* Admin State */
Kim Kempfafa1ab42017-11-13 09:31:47 -0800296 ASFVOLT_CFG_PROP_SET(cfg, flow, admin_state,
297 flow_cfg->data->has_admin_state,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530298 flow_cfg->data->admin_state);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800299 ASFVOLT_LOG(ASFVOLT_DEBUG, "admin state = %d", flow_cfg->data->admin_state);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530300
301 /* Operational status */
Kim Kempfafa1ab42017-11-13 09:31:47 -0800302 ASFVOLT_CFG_PROP_SET(cfg, flow, oper_status,
303 flow_cfg->data->has_oper_status,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530304 flow_cfg->data->oper_status);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800305 ASFVOLT_LOG(ASFVOLT_DEBUG, "Oper. status = %d", flow_cfg->data->oper_status);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530306
307 /* Access Side interface ID */
Kim Kempfafa1ab42017-11-13 09:31:47 -0800308 ASFVOLT_CFG_PROP_SET(cfg, flow, access_int_id,
309 BCMOS_TRUE,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530310 flow_cfg->data->access_int_id);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800311 ASFVOLT_LOG(ASFVOLT_DEBUG, "access_int_id = %d", flow_cfg->data->access_int_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530312
313 /* Network interface ID */
Kim Kempfafa1ab42017-11-13 09:31:47 -0800314 ASFVOLT_CFG_PROP_SET(cfg, flow, network_int_id,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530315 BCMOS_TRUE,
316 flow_cfg->data->network_int_id);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800317 ASFVOLT_LOG(ASFVOLT_DEBUG, "network_int_id = %d", flow_cfg->data->network_int_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530318
319 /* ONU ID */
320 if(BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST != flow_cfg->key->flow_type)
321 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800322 ASFVOLT_CFG_PROP_SET(cfg, flow, sub_term_id,
323 flow_cfg->data->has_sub_term_id,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530324 flow_cfg->data->sub_term_id);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800325 ASFVOLT_LOG(ASFVOLT_DEBUG, "sub_term_id = %d", flow_cfg->data->sub_term_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530326 }
327 else if (BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST == flow_cfg->key->flow_type)
328 {
329 /* In case of Multicast the flow belongs to particular group */
Kim Kempfafa1ab42017-11-13 09:31:47 -0800330 ASFVOLT_CFG_PROP_SET(cfg, flow, group_id,
331 flow_cfg->data->has_group_id,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530332 flow_cfg->data->group_id);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800333 ASFVOLT_LOG(ASFVOLT_DEBUG, "group_id = %d", flow_cfg->data->group_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530334 }
335
336 /*Subscriber Terminal UNI index*/
Kim Kempfafa1ab42017-11-13 09:31:47 -0800337 ASFVOLT_CFG_PROP_SET(cfg, flow, sub_term_uni_idx,
338 flow_cfg->data->has_sub_term_uni_idx,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530339 flow_cfg->data->sub_term_uni_idx);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800340 ASFVOLT_LOG(ASFVOLT_DEBUG, "sub_term_uni_idx = %d", flow_cfg->data->sub_term_uni_idx);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530341
342 /*Resolve MAC*/
Kim Kempfafa1ab42017-11-13 09:31:47 -0800343 ASFVOLT_CFG_PROP_SET(cfg, flow, resolve_mac,
344 flow_cfg->data->has_resolve_mac,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530345 flow_cfg->data->resolve_mac);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800346 ASFVOLT_LOG(ASFVOLT_DEBUG, "resolve_mac = %d", flow_cfg->data->resolve_mac);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530347
348 /*Gem port*/
Kim Kempfafa1ab42017-11-13 09:31:47 -0800349 ASFVOLT_CFG_PROP_SET(cfg, flow, svc_port_id,
350 flow_cfg->data->has_svc_port_id,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530351 flow_cfg->data->svc_port_id);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800352 ASFVOLT_LOG(ASFVOLT_DEBUG, "svc_port_id = %d", flow_cfg->data->svc_port_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530353
354 /*priority*/
Kim Kempfafa1ab42017-11-13 09:31:47 -0800355 ASFVOLT_CFG_PROP_SET(cfg, flow, priority,
356 flow_cfg->data->has_priority,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530357 flow_cfg->data->priority);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800358 ASFVOLT_LOG(ASFVOLT_DEBUG, "priority = %d",flow_cfg->data->priority);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530359
360 BalClassifier *tmp_classifier = (BalClassifier*)(flow_cfg->data->classifier);
361
362 if (tmp_classifier != NULL)
363 {
364 bal_err = bal_fill_classifier_cfg(tmp_classifier, &classifier_value);
365
366 if(bal_err != BAL_ERRNO__BAL_ERR_OK)
367 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800368 ASFVOLT_LOG(ASFVOLT_ERROR,
369 "Addition of flow %d failed while processing classifier",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530370 flow_cfg->key->flow_id);
371 return bal_err;
372 }
373
374 ASFVOLT_CFG_PROP_SET(cfg, flow, classifier, BCMOS_TRUE, classifier_value);
375 }
376 else
377 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800378 ASFVOLT_LOG(ASFVOLT_DEBUG, "No Classifier for flow");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530379 }
380
381 BalAction *tmp_action = (BalAction*)(flow_cfg->data->action);
382
383 if (tmp_action != NULL)
384 {
385 bal_err = bal_fill_action_cfg(tmp_action, &action_value);
386
387 if(bal_err != BAL_ERRNO__BAL_ERR_OK)
388 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800389 ASFVOLT_LOG(ASFVOLT_ERROR,
390 "Addition of flow %d failed while processing action",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530391 flow_cfg->key->flow_id);
392 return bal_err;
393 }
394 ASFVOLT_CFG_PROP_SET(cfg, flow, action, BCMOS_TRUE, action_value);
395 }
396 else
397 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800398 ASFVOLT_LOG(ASFVOLT_DEBUG, "No Action for flow");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530399 }
400
401 /*cookie*/
Kim Kempfafa1ab42017-11-13 09:31:47 -0800402 ASFVOLT_CFG_PROP_SET(cfg, flow, cookie,
403 flow_cfg->data->has_cookie,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530404 flow_cfg->data->cookie);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800405 ASFVOLT_LOG(ASFVOLT_DEBUG, "priority = %lx",flow_cfg->data->cookie);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530406
407 /*Egress queue*/
408 BalTmQueueRef *tmp_que = (BalTmQueueRef*)(flow_cfg->data->queue);
409
410 if (tmp_que != NULL)
411 {
412 bal_err = bal_fill_queue_cfg(tmp_que, &queue_value);
413
414 if(bal_err != BAL_ERRNO__BAL_ERR_OK)
415 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800416 ASFVOLT_LOG(ASFVOLT_ERROR,
417 "Addition of flow %d failed while processing queue",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530418 flow_cfg->key->flow_id);
419 return bal_err;
420 }
421 ASFVOLT_CFG_PROP_SET(cfg, flow, queue, BCMOS_TRUE, queue_value);
422 }
423 else
424 {
425 ASFVOLT_LOG(ASFVOLT_DEBUG, "No queue Information for flow");
426 }
427 /*dba_tm_sched_id*/
Kim Kempfafa1ab42017-11-13 09:31:47 -0800428 ASFVOLT_CFG_PROP_SET(cfg, flow, dba_tm_sched_id,
429 flow_cfg->data->has_dba_tm_sched_id,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530430 flow_cfg->data->dba_tm_sched_id);
Kim Kempfafa1ab42017-11-13 09:31:47 -0800431 ASFVOLT_LOG(ASFVOLT_DEBUG, "tm_sched used for dba = %d",flow_cfg->data->dba_tm_sched_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530432
433 err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &cfg.hdr);
434 if(err != BCM_ERR_OK)
435 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800436 ASFVOLT_LOG(ASFVOLT_ERROR,
437 "Failed to configure the flow. FlowId(%d)", key.flow_id);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530438 return BAL_ERRNO__BAL_ERR_INTERNAL;
439 }
440 return BAL_ERRNO__BAL_ERR_OK;
441}
442
443
444/********************************************************************\
445 * Function : bal_flow_cfg_clear *
Kim Kempfafa1ab42017-11-13 09:31:47 -0800446 * Description : Deletes/Clears the OLT DEVICE with flow *
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530447 * information using BAL Apis *
448 ********************************************************************/
449uint32_t bal_flow_cfg_clear(BalFlowKey *flow_key)
450{
451 bcmos_errno err = BCM_ERR_OK;
452 bcmbal_flow_cfg cfg; /**< declare main API struct */
453 bcmbal_flow_key key = { }; /**< declare key */
454
455 if (flow_key->has_flow_id && flow_key->has_flow_type)
456 {
457 key.flow_id = flow_key->flow_id;
458 key.flow_type = flow_key->flow_type;
459 }
460 else
461 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800462 ASFVOLT_LOG(ASFVOLT_DEBUG, "Invalid Flow Parameters to clear FlowId(%d), FlowType(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530463 key.flow_id, key.flow_type);
464 return BAL_ERRNO__BAL_ERR_PARM;
465 }
466
Kim Kempfafa1ab42017-11-13 09:31:47 -0800467 ASFVOLT_LOG(ASFVOLT_DEBUG, "FlowId(%d), FlowType(%d)", key.flow_id, key.flow_type);
468
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530469 /* init the API struct */
470 BCMBAL_CFG_INIT(&cfg, flow, key);
471
472 /* call API */
473 err = bcmbal_cfg_clear(DEFAULT_ATERM_ID, &cfg.hdr);
474 if( err != BCM_ERR_OK)
475 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800476 ASFVOLT_LOG(ASFVOLT_INFO,
477 "Failed to clear the Flow. FlowID(%d) FlowType(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530478 key.flow_id, key.flow_type);
479 return BAL_ERRNO__BAL_ERR_INTERNAL;
480 }
481 return BAL_ERRNO__BAL_ERR_OK;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800482}
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530483
484
485/********************************************************************\
486 * Function : bal_flow_cfg_get *
487 * Description : Get flow information from BAL. *
488 ********************************************************************/
489uint32_t bal_flow_cfg_get(BalFlowKey *flow_key, BalFlowCfg *flow_cfg)
490{
491
492 bcmos_errno err = BCM_ERR_OK;
493 bcmbal_flow_cfg cfg; /**< declare main API struct */
494 bcmbal_flow_key key = { }; /**< declare key */
495
496 if (flow_key->has_flow_id && flow_key->has_flow_type)
497 {
498 key.flow_id = flow_key->flow_id;
499 key.flow_type = flow_key->flow_type;
500 }
501 else
502 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800503 ASFVOLT_LOG(ASFVOLT_DEBUG, "Invalid Flow Parameters to get cfg FlowId(%d), FlowType(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530504 key.flow_id, key.flow_type);
505 return BAL_ERRNO__BAL_ERR_PARM;
506 }
507
508 /* init the API struct */
509 BCMBAL_CFG_INIT(&cfg, flow, key);
510
511 BCMBAL_CFG_PROP_GET(&cfg, flow, all_properties);
512
513 /* call API */
514 err = bcmbal_cfg_get(DEFAULT_ATERM_ID, &cfg.hdr);
515 if( err != BCM_ERR_OK)
516 {
Kim Kempfafa1ab42017-11-13 09:31:47 -0800517 ASFVOLT_LOG(ASFVOLT_INFO,
518 "Failed to get Flow Info. FlowID(%d) FlowType(%d)",
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530519 key.flow_id, key.flow_type);
520 return BAL_ERRNO__BAL_ERR_INTERNAL;
521 }
522
Kim Kempfafa1ab42017-11-13 09:31:47 -0800523 ASFVOLT_LOG(ASFVOLT_INFO,
524 "To-Do. Send Flow details to Adapter");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530525
526 return BAL_ERRNO__BAL_ERR_OK;
Kim Kempfafa1ab42017-11-13 09:31:47 -0800527}