Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1 | /* |
| 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 31 | static uint32_t bal_fill_queue_cfg(BalTmQueueRef *tmp_que, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 32 | bcmbal_tm_queue_ref *que_val) |
| 33 | { |
| 34 | if(tmp_que->has_sched_id) |
| 35 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 36 | que_val->sched_id = tmp_que->sched_id; |
| 37 | ASFVOLT_LOG(ASFVOLT_DEBUG, "que_val->sched_id = %d", que_val->sched_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | if(tmp_que->has_queue_id) |
| 41 | { |
| 42 | que_val->queue_id = tmp_que->queue_id; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 43 | ASFVOLT_LOG(ASFVOLT_DEBUG, "que_val->queue_id = %d", que_val->queue_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | return BAL_ERRNO__BAL_ERR_OK; |
| 47 | } |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 48 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 49 | |
| 50 | /********************************************************************\ |
| 51 | * Function : bal_fill_action_cfg * |
| 52 | * Description : copy action information from proto structure to * |
| 53 | * BAL structure * |
| 54 | ********************************************************************/ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 55 | static uint32_t bal_fill_action_cfg(BalAction *tmp_action, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 56 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 65 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->cmds_bitmask = %x", action_val->cmds_bitmask); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | if (action_val->presence_mask & BCMBAL_ACTION_ID_O_VID) |
| 69 | { |
| 70 | action_val->o_vid = tmp_action->o_vid; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 71 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_vid = %d", action_val->o_vid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | if (action_val->presence_mask & BCMBAL_ACTION_ID_O_PBITS) |
| 75 | { |
| 76 | action_val->o_pbits = tmp_action->o_pbits; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 77 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_pbits = %d", action_val->o_pbits); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | if (action_val->presence_mask & BCMBAL_ACTION_ID_O_TPID) |
| 81 | { |
| 82 | action_val->o_tpid = tmp_action->o_tpid; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 83 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->o_tpid = %d", action_val->o_tpid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | if (action_val->presence_mask & BCMBAL_ACTION_ID_I_VID) |
| 87 | { |
| 88 | action_val->i_vid = tmp_action->i_vid; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 89 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_vid = %d", action_val->i_vid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | if (action_val->presence_mask & BCMBAL_ACTION_ID_I_PBITS) |
| 93 | { |
| 94 | action_val->i_pbits = tmp_action->i_pbits; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 95 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_pbits = %d", action_val->i_pbits); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | if (action_val->presence_mask & BCMBAL_ACTION_ID_I_TPID) |
| 99 | { |
| 100 | action_val->i_tpid = tmp_action->i_tpid; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 101 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->i_tpid = %d", action_val->i_tpid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 102 | } |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 103 | ASFVOLT_LOG(ASFVOLT_DEBUG, "action_val->presence_mask = %x", action_val->presence_mask); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 104 | } |
| 105 | else |
| 106 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 107 | ASFVOLT_LOG(ASFVOLT_ERROR, "Action is not present in the flow"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 108 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 120 | uint32_t bal_fill_classifier_cfg(BalClassifier *tmp_classifier, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 121 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 130 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_tpid = %d", classifier_val->o_tpid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_VID) |
| 134 | { |
| 135 | classifier_val->o_vid = tmp_classifier->o_vid; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 136 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_vid = %d", classifier_val->o_vid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_TPID) |
| 140 | { |
| 141 | classifier_val->i_tpid = tmp_classifier->i_tpid; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 142 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_tpid = %d", classifier_val->i_tpid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_VID) |
| 146 | { |
| 147 | classifier_val->i_vid = tmp_classifier->i_vid; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 148 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_vid = %d", classifier_val->i_vid); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_O_PBITS) |
| 152 | { |
| 153 | classifier_val->o_pbits = tmp_classifier->o_pbits; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 154 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->o_pbits = %d", classifier_val->o_pbits); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_I_PBITS) |
| 158 | { |
| 159 | classifier_val->i_pbits = tmp_classifier->i_pbits; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 160 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->i_pbits = %d", classifier_val->i_pbits); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_ETHER_TYPE) |
| 164 | { |
| 165 | classifier_val->ether_type = tmp_classifier->ether_type; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 166 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->ether_type = %x", classifier_val->ether_type); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 167 | } |
| 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 173 | memcpy(classifier_val->dst_mac.u8, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 174 | tmp_classifier->dst_mac.data, tmp_classifier->dst_mac.len); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 175 | /*ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_mac= %d", classifier_val->dst_mac);*/ |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 176 | } |
| 177 | else |
| 178 | { |
| 179 | ASFVOLT_LOG(ASFVOLT_ERROR, "dst_mac should not be more than 6 bytes." |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 180 | "actual bytes %lu", tmp_classifier->dst_mac.len); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 181 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 189 | memcpy(classifier_val->src_mac.u8, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 190 | tmp_classifier->src_mac.data, tmp_classifier->src_mac.len); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 191 | /*ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_mac= %x", classifier_val->src_mac);*/ |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 192 | } |
| 193 | else |
| 194 | { |
| 195 | ASFVOLT_LOG(ASFVOLT_ERROR, "src_mac should not be more than 6 bytes." |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 196 | "actual bytes %lu", tmp_classifier->src_mac.len); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 197 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 205 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->ip_proto = %x", classifier_val->ip_proto); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_IP) |
| 209 | { |
| 210 | classifier_val->dst_ip.u32 = tmp_classifier->dst_ip; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 211 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_ip = %x", classifier_val->dst_ip.u32); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_IP) |
| 215 | { |
| 216 | classifier_val->src_ip.u32 = tmp_classifier->src_ip; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 217 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_ip = %x", classifier_val->src_ip.u32); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_SRC_PORT) |
| 221 | { |
| 222 | classifier_val->src_port = tmp_classifier->src_port; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 223 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->src_port = %d", classifier_val->src_port); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | if (classifier_val->presence_mask & BCMBAL_CLASSIFIER_ID_DST_PORT) |
| 227 | { |
| 228 | classifier_val->dst_port = tmp_classifier->dst_port; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 229 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->dst_port = %d", classifier_val->dst_port); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 230 | } |
| 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 235 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->pkt_tag_type = %x", classifier_val->pkt_tag_type); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 236 | } |
| 237 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 238 | ASFVOLT_LOG(ASFVOLT_DEBUG, "classifier_val->presence_mask = %x", classifier_val->presence_mask); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 239 | } |
| 240 | else |
| 241 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 242 | ASFVOLT_LOG(ASFVOLT_ERROR, "Classifier is not present in the flow"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 243 | 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 | ********************************************************************/ |
| 254 | uint32_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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 271 | ASFVOLT_LOG(ASFVOLT_ERROR, "Invalid Flow Id (%d)", flow_cfg->key->flow_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 272 | return BAL_ERRNO__BAL_ERR_PARM; |
| 273 | } |
| 274 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 275 | if (flow_cfg->data->admin_state == BAL_STATE__BAL_STATE_UP ) |
| 276 | { |
| 277 | ASFVOLT_LOG(ASFVOLT_INFO, "Adding the flow to OLT. FlowID(%d)", flow_cfg->key->flow_id); |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | ASFVOLT_LOG(ASFVOLT_INFO, "Deleting the flow at OLT. FlowID(%d)", flow_cfg->key->flow_id); |
| 282 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 283 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 284 | if (!flow_cfg->key->has_flow_type && |
| 285 | ((flow_cfg->key->flow_type < BAL_FLOW_TYPE__BAL_FLOW_TYPE_UPSTREAM) || |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 286 | flow_cfg->key->flow_type > BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST )) |
| 287 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 288 | ASFVOLT_LOG(ASFVOLT_ERROR, "Flow type is not supported (%d)", flow_cfg->key->flow_type); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 289 | return BAL_ERRNO__BAL_ERR_PARM; |
| 290 | } |
| 291 | else |
| 292 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 293 | ASFVOLT_LOG(ASFVOLT_DEBUG, "flow_type = %d", flow_cfg->key->flow_type); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 294 | key.flow_type = (bcmbal_flow_type) flow_cfg->key->flow_type; |
| 295 | } |
| 296 | |
| 297 | /* init the API struct */ |
| 298 | BCMBAL_CFG_INIT(&cfg, flow, key); |
| 299 | |
| 300 | /* decode API parameters from grpc-c */ |
| 301 | /* Admin State */ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 302 | ASFVOLT_CFG_PROP_SET(cfg, flow, admin_state, |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 303 | BCMOS_TRUE, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 304 | flow_cfg->data->admin_state); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 305 | ASFVOLT_LOG(ASFVOLT_DEBUG, "admin state = %d", flow_cfg->data->admin_state); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 306 | |
| 307 | /* Operational status */ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 308 | ASFVOLT_CFG_PROP_SET(cfg, flow, oper_status, |
| 309 | flow_cfg->data->has_oper_status, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 310 | flow_cfg->data->oper_status); |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 311 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Oper.status = %d", flow_cfg->data->oper_status); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 312 | |
| 313 | /* Access Side interface ID */ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 314 | ASFVOLT_CFG_PROP_SET(cfg, flow, access_int_id, |
| 315 | BCMOS_TRUE, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 316 | flow_cfg->data->access_int_id); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 317 | ASFVOLT_LOG(ASFVOLT_DEBUG, "access_int_id = %d", flow_cfg->data->access_int_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 318 | |
| 319 | /* Network interface ID */ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 320 | ASFVOLT_CFG_PROP_SET(cfg, flow, network_int_id, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 321 | BCMOS_TRUE, |
| 322 | flow_cfg->data->network_int_id); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 323 | ASFVOLT_LOG(ASFVOLT_DEBUG, "network_int_id = %d", flow_cfg->data->network_int_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 324 | |
| 325 | /* ONU ID */ |
| 326 | if(BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST != flow_cfg->key->flow_type) |
| 327 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 328 | ASFVOLT_CFG_PROP_SET(cfg, flow, sub_term_id, |
| 329 | flow_cfg->data->has_sub_term_id, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 330 | flow_cfg->data->sub_term_id); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 331 | ASFVOLT_LOG(ASFVOLT_DEBUG, "sub_term_id = %d", flow_cfg->data->sub_term_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 332 | } |
| 333 | else if (BAL_FLOW_TYPE__BAL_FLOW_TYPE_MULTICAST == flow_cfg->key->flow_type) |
| 334 | { |
| 335 | /* In case of Multicast the flow belongs to particular group */ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 336 | ASFVOLT_CFG_PROP_SET(cfg, flow, group_id, |
| 337 | flow_cfg->data->has_group_id, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 338 | flow_cfg->data->group_id); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 339 | ASFVOLT_LOG(ASFVOLT_DEBUG, "group_id = %d", flow_cfg->data->group_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 340 | } |
| 341 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 342 | /*Resolve MAC*/ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 343 | ASFVOLT_CFG_PROP_SET(cfg, flow, resolve_mac, |
| 344 | flow_cfg->data->has_resolve_mac, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 345 | flow_cfg->data->resolve_mac); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 346 | ASFVOLT_LOG(ASFVOLT_DEBUG, "resolve_mac = %d", flow_cfg->data->resolve_mac); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 347 | |
| 348 | /*Gem port*/ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 349 | ASFVOLT_CFG_PROP_SET(cfg, flow, svc_port_id, |
| 350 | flow_cfg->data->has_svc_port_id, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 351 | flow_cfg->data->svc_port_id); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 352 | ASFVOLT_LOG(ASFVOLT_DEBUG, "svc_port_id = %d", flow_cfg->data->svc_port_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 353 | |
| 354 | /*priority*/ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 355 | ASFVOLT_CFG_PROP_SET(cfg, flow, priority, |
| 356 | flow_cfg->data->has_priority, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 357 | flow_cfg->data->priority); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 358 | ASFVOLT_LOG(ASFVOLT_DEBUG, "priority = %d",flow_cfg->data->priority); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 359 | |
| 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 368 | ASFVOLT_LOG(ASFVOLT_ERROR, |
| 369 | "Addition of flow %d failed while processing classifier", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 370 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 378 | ASFVOLT_LOG(ASFVOLT_DEBUG, "No Classifier for flow"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 379 | } |
| 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 389 | ASFVOLT_LOG(ASFVOLT_ERROR, |
| 390 | "Addition of flow %d failed while processing action", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 391 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 398 | ASFVOLT_LOG(ASFVOLT_DEBUG, "No Action for flow"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | /*cookie*/ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 402 | ASFVOLT_CFG_PROP_SET(cfg, flow, cookie, |
| 403 | flow_cfg->data->has_cookie, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 404 | flow_cfg->data->cookie); |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 405 | ASFVOLT_LOG(ASFVOLT_DEBUG, "cookie = %lx",flow_cfg->data->cookie); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 406 | |
| 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 416 | ASFVOLT_LOG(ASFVOLT_ERROR, |
| 417 | "Addition of flow %d failed while processing queue", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 418 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 428 | ASFVOLT_CFG_PROP_SET(cfg, flow, dba_tm_sched_id, |
| 429 | flow_cfg->data->has_dba_tm_sched_id, |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 430 | flow_cfg->data->dba_tm_sched_id); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 431 | ASFVOLT_LOG(ASFVOLT_DEBUG, "tm_sched used for dba = %d",flow_cfg->data->dba_tm_sched_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 432 | |
| 433 | err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &cfg.hdr); |
| 434 | if(err != BCM_ERR_OK) |
| 435 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 436 | ASFVOLT_LOG(ASFVOLT_ERROR, |
| 437 | "Failed to configure the flow. FlowId(%d)", key.flow_id); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 438 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 446 | * Description : Deletes/Clears the OLT DEVICE with flow * |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 447 | * information using BAL Apis * |
| 448 | ********************************************************************/ |
| 449 | uint32_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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 462 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Invalid Flow Parameters to clear FlowId(%d), FlowType(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 463 | key.flow_id, key.flow_type); |
| 464 | return BAL_ERRNO__BAL_ERR_PARM; |
| 465 | } |
| 466 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 467 | ASFVOLT_LOG(ASFVOLT_DEBUG, "FlowId(%d), FlowType(%d)", key.flow_id, key.flow_type); |
| 468 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 469 | /* 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 476 | ASFVOLT_LOG(ASFVOLT_INFO, |
| 477 | "Failed to clear the Flow. FlowID(%d) FlowType(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 478 | key.flow_id, key.flow_type); |
| 479 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 480 | } |
| 481 | return BAL_ERRNO__BAL_ERR_OK; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 482 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 483 | |
| 484 | |
| 485 | /********************************************************************\ |
| 486 | * Function : bal_flow_cfg_get * |
| 487 | * Description : Get flow information from BAL. * |
| 488 | ********************************************************************/ |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 489 | uint32_t bal_flow_cfg_get(BalFlowCfg *flow_cfg) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 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 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 496 | if (flow_cfg->key->has_flow_id && flow_cfg->key->has_flow_type) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 497 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 498 | key.flow_id = flow_cfg->key->flow_id; |
| 499 | key.flow_type = flow_cfg->key->flow_type; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 500 | } |
| 501 | else |
| 502 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 503 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Invalid Flow Parameters to get cfg FlowId(%d), FlowType(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 504 | 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 Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 517 | ASFVOLT_LOG(ASFVOLT_INFO, |
| 518 | "Failed to get Flow Info. FlowID(%d) FlowType(%d)", |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 519 | key.flow_id, key.flow_type); |
| 520 | return BAL_ERRNO__BAL_ERR_INTERNAL; |
| 521 | } |
| 522 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 523 | ASFVOLT_LOG(ASFVOLT_INFO, "Get Group cfg sent to OLT for Flow Id(%d)", |
| 524 | key.flow_id); |
| 525 | |
| 526 | memcpy(flow_cfg->key, &key, sizeof(BalFlowKey)); |
| 527 | memcpy(flow_cfg->data, &cfg, sizeof(BalFlowCfgData)); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 528 | |
| 529 | return BAL_ERRNO__BAL_ERR_OK; |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 530 | } |