khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 17 | package flowdecomposition |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 18 | |
| 19 | import ( |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 20 | "context" |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 21 | "github.com/gogo/protobuf/proto" |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 22 | "github.com/opencord/voltha-go/rw_core/coreif" |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 23 | "github.com/opencord/voltha-go/rw_core/graph" |
serkant.uluderya | 2ae470f | 2020-01-21 11:13:09 -0800 | [diff] [blame] | 24 | fu "github.com/opencord/voltha-lib-go/v3/pkg/flows" |
| 25 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 26 | ofp "github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 27 | "github.com/opencord/voltha-protos/v3/go/voltha" |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 28 | ) |
| 29 | |
| 30 | func init() { |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 31 | _, err := log.AddPackage(log.JSON, log.DebugLevel, nil) |
| 32 | if err != nil { |
| 33 | log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err}) |
| 34 | } |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 35 | } |
| 36 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 37 | // FlowDecomposer represent flow decomposer attribute |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 38 | type FlowDecomposer struct { |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 39 | deviceMgr coreif.DeviceManager |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 40 | } |
| 41 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 42 | // NewFlowDecomposer creates flow decomposer instance |
| 43 | func NewFlowDecomposer(deviceMgr coreif.DeviceManager) *FlowDecomposer { |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 44 | var decomposer FlowDecomposer |
| 45 | decomposer.deviceMgr = deviceMgr |
| 46 | return &decomposer |
| 47 | } |
| 48 | |
| 49 | //DecomposeRules decomposes per-device flows and flow-groups from the flows and groups defined on a logical device |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 50 | func (fd *FlowDecomposer) DecomposeRules(ctx context.Context, agent coreif.LogicalDeviceAgent, flows ofp.Flows, groups ofp.FlowGroups) *fu.DeviceRules { |
khenaidoo | 3306c99 | 2019-05-24 16:57:35 -0400 | [diff] [blame] | 51 | deviceRules := *fu.NewDeviceRules() |
khenaidoo | 2c6a099 | 2019-04-29 13:46:56 -0400 | [diff] [blame] | 52 | devicesToUpdate := make(map[string]string) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 53 | |
| 54 | groupMap := make(map[uint32]*ofp.OfpGroupEntry) |
| 55 | for _, groupEntry := range groups.Items { |
| 56 | groupMap[groupEntry.Desc.GroupId] = groupEntry |
| 57 | } |
| 58 | |
| 59 | var decomposedRules *fu.DeviceRules |
| 60 | for _, flow := range flows.Items { |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 61 | decomposedRules = fd.decomposeFlow(ctx, agent, flow, groupMap) |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 62 | for deviceID, flowAndGroups := range decomposedRules.Rules { |
| 63 | deviceRules.CreateEntryIfNotExist(deviceID) |
| 64 | deviceRules.Rules[deviceID].AddFrom(flowAndGroups) |
| 65 | devicesToUpdate[deviceID] = deviceID |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 66 | } |
| 67 | } |
khenaidoo | 3306c99 | 2019-05-24 16:57:35 -0400 | [diff] [blame] | 68 | return deviceRules.FilterRules(devicesToUpdate) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 69 | } |
| 70 | |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 71 | // Handles special case of any controller-bound flow for a parent device |
| 72 | func (fd *FlowDecomposer) updateOutputPortForControllerBoundFlowForParentDevide(flow *ofp.OfpFlowStats, |
| 73 | dr *fu.DeviceRules) *fu.DeviceRules { |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 74 | EAPOL := fu.EthType(0x888e) |
| 75 | IGMP := fu.IpProto(2) |
| 76 | UDP := fu.IpProto(17) |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 77 | |
| 78 | newDeviceRules := dr.Copy() |
| 79 | // Check whether we are dealing with a parent device |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 80 | for deviceID, fg := range dr.GetRules() { |
| 81 | if root, _ := fd.deviceMgr.IsRootDevice(deviceID); root { |
| 82 | newDeviceRules.ClearFlows(deviceID) |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 83 | for i := 0; i < fg.Flows.Len(); i++ { |
| 84 | f := fg.GetFlow(i) |
| 85 | UpdateOutPortNo := false |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 86 | for _, field := range fu.GetOfbFields(f) { |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 87 | UpdateOutPortNo = (field.String() == EAPOL.String()) |
| 88 | UpdateOutPortNo = UpdateOutPortNo || (field.String() == IGMP.String()) |
| 89 | UpdateOutPortNo = UpdateOutPortNo || (field.String() == UDP.String()) |
| 90 | if UpdateOutPortNo { |
| 91 | break |
| 92 | } |
| 93 | } |
| 94 | if UpdateOutPortNo { |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 95 | f = fu.UpdateOutputPortByActionType(f, uint32(ofp.OfpInstructionType_OFPIT_APPLY_ACTIONS), |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 96 | uint32(ofp.OfpPortNo_OFPP_CONTROLLER)) |
| 97 | } |
| 98 | // Update flow Id as a change in the instruction field will result in a new flow ID |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 99 | f.Id = fu.HashFlowStats(f) |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 100 | newDeviceRules.AddFlow(deviceID, (proto.Clone(f)).(*ofp.OfpFlowStats)) |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | } |
khenaidoo | 2c6a099 | 2019-04-29 13:46:56 -0400 | [diff] [blame] | 104 | |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 105 | return newDeviceRules |
| 106 | } |
| 107 | |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 108 | //processControllerBoundFlow decomposes trap flows |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 109 | func (fd *FlowDecomposer) processControllerBoundFlow(agent coreif.LogicalDeviceAgent, route []graph.RouteHop, |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 110 | inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules { |
| 111 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 112 | log.Debugw("trap-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "flow": flow}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 113 | deviceRules := fu.NewDeviceRules() |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 114 | meterID := fu.GetMeterIdFromFlow(flow) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 115 | metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 116 | |
Matt Jeanneret | b423bad | 2019-10-10 20:42:19 -0400 | [diff] [blame] | 117 | ingressHop := route[0] |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 118 | egressHop := route[1] |
| 119 | |
Humera Kouser | 4ff8901 | 2019-08-25 19:01:51 -0400 | [diff] [blame] | 120 | //case of packet_in from NNI port rule |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 121 | if agent.GetDeviceGraph().IsRootPort(inPortNo) { |
Humera Kouser | 4ff8901 | 2019-08-25 19:01:51 -0400 | [diff] [blame] | 122 | // Trap flow for NNI port |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 123 | log.Debug("trap-nni") |
Humera Kouser | 4ff8901 | 2019-08-25 19:01:51 -0400 | [diff] [blame] | 124 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 125 | fa := &fu.FlowArgs{ |
Humera Kouser | 4ff8901 | 2019-08-25 19:01:51 -0400 | [diff] [blame] | 126 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie}, |
| 127 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 128 | fu.InPort(egressHop.Egress), |
| 129 | }, |
| 130 | Actions: fu.GetActions(flow), |
| 131 | } |
| 132 | // Augment the matchfields with the ofpfields from the flow |
Matt Jeanneret | b423bad | 2019-10-10 20:42:19 -0400 | [diff] [blame] | 133 | fg := fu.NewFlowsAndGroups() |
Humera Kouser | 4ff8901 | 2019-08-25 19:01:51 -0400 | [diff] [blame] | 134 | fa.MatchFields = append(fa.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...) |
| 135 | fg.AddFlow(fu.MkFlowStat(fa)) |
Matt Jeanneret | b423bad | 2019-10-10 20:42:19 -0400 | [diff] [blame] | 136 | deviceRules.AddFlowsAndGroup(egressHop.DeviceID, fg) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 137 | } else { |
| 138 | // Trap flow for UNI port |
| 139 | log.Debug("trap-uni") |
| 140 | |
| 141 | //inPortNo is 0 for wildcard input case, do not include upstream port for 4000 flow in input |
| 142 | var inPorts []uint32 |
| 143 | if inPortNo == 0 { |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 144 | inPorts = agent.GetWildcardInputPorts(egressHop.Egress) // exclude egress_hop.egress_port.port_no |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 145 | } else { |
| 146 | inPorts = []uint32{inPortNo} |
| 147 | } |
| 148 | for _, inputPort := range inPorts { |
Matt Jeanneret | b423bad | 2019-10-10 20:42:19 -0400 | [diff] [blame] | 149 | // Upstream flow on parent (olt) device |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 150 | faParent := &fu.FlowArgs{ |
| 151 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata}, |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 152 | MatchFields: []*ofp.OfpOxmOfbField{ |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 153 | fu.InPort(egressHop.Ingress), |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 154 | fu.TunnelId(uint64(inputPort)), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 155 | }, |
| 156 | Actions: []*ofp.OfpAction{ |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 157 | fu.PushVlan(0x8100), |
| 158 | fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 4000)), |
| 159 | fu.Output(egressHop.Egress), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 160 | }, |
| 161 | } |
| 162 | // Augment the matchfields with the ofpfields from the flow |
Matt Jeanneret | b423bad | 2019-10-10 20:42:19 -0400 | [diff] [blame] | 163 | faParent.MatchFields = append(faParent.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...) |
| 164 | fgParent := fu.NewFlowsAndGroups() |
| 165 | fgParent.AddFlow(fu.MkFlowStat(faParent)) |
| 166 | deviceRules.AddFlowsAndGroup(egressHop.DeviceID, fgParent) |
| 167 | log.Debugw("parent-trap-flow-set", log.Fields{"flow": faParent}) |
| 168 | |
| 169 | // Upstream flow on child (onu) device |
| 170 | var actions []*ofp.OfpAction |
| 171 | setvid := fu.GetVlanVid(flow) |
| 172 | if setvid != nil { |
| 173 | // have this child push the vlan the parent is matching/trapping on above |
| 174 | actions = []*ofp.OfpAction{ |
| 175 | fu.PushVlan(0x8100), |
| 176 | fu.SetField(fu.VlanVid(*setvid)), |
| 177 | fu.Output(ingressHop.Egress), |
| 178 | } |
| 179 | } else { |
| 180 | // otherwise just set the egress port |
| 181 | actions = []*ofp.OfpAction{ |
| 182 | fu.Output(ingressHop.Egress), |
| 183 | } |
| 184 | } |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 185 | faChild := &fu.FlowArgs{ |
| 186 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata}, |
Matt Jeanneret | b423bad | 2019-10-10 20:42:19 -0400 | [diff] [blame] | 187 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 188 | fu.InPort(ingressHop.Ingress), |
| 189 | fu.TunnelId(uint64(inputPort)), |
| 190 | }, |
| 191 | Actions: actions, |
| 192 | } |
| 193 | // Augment the matchfields with the ofpfields from the flow. |
| 194 | // If the parent has a match vid and the child is setting that match vid exclude the the match vlan |
| 195 | // for the child given it will be setting that vlan and the parent will be matching on it |
| 196 | if setvid != nil { |
| 197 | faChild.MatchFields = append(faChild.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT, fu.VLAN_VID)...) |
| 198 | } else { |
| 199 | faChild.MatchFields = append(faChild.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...) |
| 200 | } |
| 201 | fgChild := fu.NewFlowsAndGroups() |
| 202 | fgChild.AddFlow(fu.MkFlowStat(faChild)) |
| 203 | deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fgChild) |
| 204 | log.Debugw("child-trap-flow-set", log.Fields{"flow": faChild}) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 205 | } |
| 206 | } |
khenaidoo | 2c6a099 | 2019-04-29 13:46:56 -0400 | [diff] [blame] | 207 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 208 | return deviceRules |
| 209 | } |
| 210 | |
| 211 | // processUpstreamNonControllerBoundFlow processes non-controller bound flow. We assume that anything that is |
| 212 | // upstream needs to get Q-in-Q treatment and that this is expressed via two flow rules, the first using the |
| 213 | // goto-statement. We also assume that the inner tag is applied at the ONU, while the outer tag is |
| 214 | // applied at the OLT |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 215 | func (fd *FlowDecomposer) processUpstreamNonControllerBoundFlow(agent coreif.LogicalDeviceAgent, |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 216 | route []graph.RouteHop, inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules { |
| 217 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 218 | log.Debugw("upstream-non-controller-bound-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 219 | deviceRules := fu.NewDeviceRules() |
| 220 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 221 | meterID := fu.GetMeterIdFromFlow(flow) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 222 | metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow) |
| 223 | |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 224 | ingressHop := route[0] |
| 225 | egressHop := route[1] |
| 226 | |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 227 | if flow.TableId == 0 && fu.HasNextTable(flow) { |
| 228 | log.Debugw("decomposing-onu-flow-in-upstream-has-next-table", log.Fields{"table_id": flow.TableId}) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 229 | if outPortNo != 0 { |
| 230 | log.Warnw("outPort-should-not-be-specified", log.Fields{"outPortNo": outPortNo}) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 231 | return deviceRules |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 232 | } |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 233 | fa := &fu.FlowArgs{ |
| 234 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata}, |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 235 | MatchFields: []*ofp.OfpOxmOfbField{ |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 236 | fu.InPort(ingressHop.Ingress), |
| 237 | fu.TunnelId(uint64(inPortNo)), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 238 | }, |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 239 | Actions: fu.GetActions(flow), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 240 | } |
| 241 | // Augment the matchfields with the ofpfields from the flow |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 242 | fa.MatchFields = append(fa.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 243 | |
| 244 | // Augment the Actions |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 245 | fa.Actions = append(fa.Actions, fu.Output(ingressHop.Egress)) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 246 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 247 | fg := fu.NewFlowsAndGroups() |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 248 | fg.AddFlow(fu.MkFlowStat(fa)) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 249 | deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fg) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 250 | } else if flow.TableId == 1 && outPortNo != 0 { |
| 251 | log.Debugw("decomposing-olt-flow-in-upstream-has-next-table", log.Fields{"table_id": flow.TableId}) |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 252 | fa := &fu.FlowArgs{ |
| 253 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata}, |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 254 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 255 | fu.InPort(egressHop.Ingress), |
| 256 | fu.TunnelId(uint64(inPortNo)), |
| 257 | }, |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 258 | } |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 259 | // Augment the matchfields with the ofpfields from the flow |
| 260 | fa.MatchFields = append(fa.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 261 | |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 262 | //Augment the actions |
| 263 | filteredAction := fu.GetActions(flow, fu.OUTPUT) |
| 264 | filteredAction = append(filteredAction, fu.Output(egressHop.Egress)) |
| 265 | fa.Actions = filteredAction |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 266 | |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 267 | fg := fu.NewFlowsAndGroups() |
| 268 | fg.AddFlow(fu.MkFlowStat(fa)) |
| 269 | deviceRules.AddFlowsAndGroup(egressHop.DeviceID, fg) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 270 | } |
| 271 | return deviceRules |
| 272 | } |
| 273 | |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 274 | // processDownstreamFlowWithNextTable decomposes downstream flows containing next table ID instructions |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 275 | func (fd *FlowDecomposer) processDownstreamFlowWithNextTable(agent coreif.LogicalDeviceAgent, route []graph.RouteHop, |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 276 | inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules { |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 277 | log.Debugw("decomposing-olt-flow-in-downstream-flow-with-next-table", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 278 | deviceRules := fu.NewDeviceRules() |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 279 | meterID := fu.GetMeterIdFromFlow(flow) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 280 | metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 281 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 282 | if outPortNo != 0 { |
| 283 | log.Warnw("outPort-should-not-be-specified", log.Fields{"outPortNo": outPortNo}) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 284 | return deviceRules |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 285 | } |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 286 | |
| 287 | if flow.TableId != 0 { |
| 288 | log.Warnw("This is not olt pipeline table, so skipping", log.Fields{"tableId": flow.TableId}) |
| 289 | return deviceRules |
| 290 | } |
| 291 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 292 | ingressHop := route[0] |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 293 | egressHop := route[1] |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 294 | if metadataFromwriteMetadata != 0 { |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 295 | log.Debugw("creating-metadata-flow", log.Fields{"flow": flow}) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 296 | portNumber := fu.GetEgressPortNumberFromWriteMetadata(flow) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 297 | if portNumber != 0 { |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 298 | recalculatedRoute := agent.GetRoute(inPortNo, portNumber) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 299 | switch len(recalculatedRoute) { |
| 300 | case 0: |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 301 | log.Errorw("no-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": portNumber, "comment": "deleting-flow", "metadata": metadataFromwriteMetadata}) |
| 302 | //TODO: Delete flow |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 303 | return deviceRules |
| 304 | case 2: |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 305 | log.Debugw("route-found", log.Fields{"ingressHop": ingressHop, "egressHop": egressHop}) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 306 | default: |
| 307 | log.Errorw("invalid-route-length", log.Fields{"routeLen": len(route)}) |
| 308 | return deviceRules |
| 309 | } |
| 310 | ingressHop = recalculatedRoute[0] |
| 311 | } |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 312 | innerTag := fu.GetInnerTagFromMetaData(flow) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 313 | if innerTag == 0 { |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 314 | log.Errorw("no-inner-route-double-tag", log.Fields{"inPortNo": inPortNo, "outPortNo": portNumber, "comment": "deleting-flow", "metadata": metadataFromwriteMetadata}) |
| 315 | //TODO: Delete flow |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 316 | return deviceRules |
| 317 | } |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 318 | fa := &fu.FlowArgs{ |
| 319 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata}, |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 320 | MatchFields: []*ofp.OfpOxmOfbField{ |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 321 | fu.InPort(ingressHop.Ingress), |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 322 | fu.Metadata_ofp(uint64(innerTag)), |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 323 | fu.TunnelId(uint64(portNumber)), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 324 | }, |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 325 | Actions: fu.GetActions(flow), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 326 | } |
| 327 | // Augment the matchfields with the ofpfields from the flow |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 328 | fa.MatchFields = append(fa.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT, fu.METADATA)...) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 329 | |
| 330 | // Augment the Actions |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 331 | fa.Actions = append(fa.Actions, fu.Output(ingressHop.Egress)) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 332 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 333 | fg := fu.NewFlowsAndGroups() |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 334 | fg.AddFlow(fu.MkFlowStat(fa)) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 335 | deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fg) |
| 336 | } else { // Create standard flow |
| 337 | log.Debugw("creating-standard-flow", log.Fields{"flow": flow}) |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 338 | fa := &fu.FlowArgs{ |
| 339 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata}, |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 340 | MatchFields: []*ofp.OfpOxmOfbField{ |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 341 | fu.InPort(ingressHop.Ingress), |
| 342 | fu.TunnelId(uint64(inPortNo)), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 343 | }, |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 344 | Actions: fu.GetActions(flow), |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 345 | } |
| 346 | // Augment the matchfields with the ofpfields from the flow |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 347 | fa.MatchFields = append(fa.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 348 | |
| 349 | // Augment the Actions |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 350 | fa.Actions = append(fa.Actions, fu.Output(ingressHop.Egress)) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 351 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 352 | fg := fu.NewFlowsAndGroups() |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 353 | fg.AddFlow(fu.MkFlowStat(fa)) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 354 | deviceRules.AddFlowsAndGroup(ingressHop.DeviceID, fg) |
| 355 | } |
khenaidoo | 2c6a099 | 2019-04-29 13:46:56 -0400 | [diff] [blame] | 356 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 357 | return deviceRules |
| 358 | } |
| 359 | |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 360 | // processUnicastFlow decomposes unicast flows |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 361 | func (fd *FlowDecomposer) processUnicastFlow(agent coreif.LogicalDeviceAgent, route []graph.RouteHop, |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 362 | inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats) *fu.DeviceRules { |
| 363 | |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 364 | log.Debugw("decomposing-onu-flow-in-downstream-unicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 365 | deviceRules := fu.NewDeviceRules() |
| 366 | |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 367 | egressHop := route[1] |
| 368 | |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 369 | meterID := fu.GetMeterIdFromFlow(flow) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 370 | metadataFromwriteMetadata := fu.GetMetadataFromWriteMetadataAction(flow) |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 371 | fa := &fu.FlowArgs{ |
| 372 | KV: fu.OfpFlowModArgs{"priority": uint64(flow.Priority), "cookie": flow.Cookie, "meter_id": uint64(meterID), "write_metadata": metadataFromwriteMetadata}, |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 373 | MatchFields: []*ofp.OfpOxmOfbField{ |
| 374 | fu.InPort(egressHop.Ingress), |
| 375 | }, |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 376 | } |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 377 | // Augment the matchfields with the ofpfields from the flow |
| 378 | fa.MatchFields = append(fa.MatchFields, fu.GetOfbFields(flow, fu.IN_PORT)...) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 379 | |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 380 | // Augment the Actions |
| 381 | filteredAction := fu.GetActions(flow, fu.OUTPUT) |
| 382 | filteredAction = append(filteredAction, fu.Output(egressHop.Egress)) |
| 383 | fa.Actions = filteredAction |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 384 | |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 385 | fg := fu.NewFlowsAndGroups() |
| 386 | fg.AddFlow(fu.MkFlowStat(fa)) |
| 387 | deviceRules.AddFlowsAndGroup(egressHop.DeviceID, fg) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 388 | return deviceRules |
| 389 | } |
| 390 | |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 391 | // processMulticastFlow decompose multicast flows |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 392 | func (fd *FlowDecomposer) processMulticastFlow(agent coreif.LogicalDeviceAgent, route []graph.RouteHop, |
| 393 | inPortNo uint32, outPortNo uint32, flow *ofp.OfpFlowStats, grpID uint32, |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 394 | groupMap map[uint32]*ofp.OfpGroupEntry) *fu.DeviceRules { |
| 395 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 396 | log.Debugw("multicast-flow", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 397 | deviceRules := fu.NewDeviceRules() |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 398 | |
| 399 | //having no Group yet is the same as having a Group with no buckets |
| 400 | var grp *ofp.OfpGroupEntry |
| 401 | var ok bool |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 402 | if grp, ok = groupMap[grpID]; !ok { |
| 403 | log.Warnw("Group-id-not-present-in-map", log.Fields{"grpId": grpID, "groupMap": groupMap}) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 404 | return deviceRules |
| 405 | } |
| 406 | if grp == nil || grp.Desc == nil { |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 407 | log.Warnw("Group-or-desc-nil", log.Fields{"grpId": grpID, "grp": grp}) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 408 | return deviceRules |
| 409 | } |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 410 | |
Esin Karaman | 09959ae | 2019-11-29 13:59:58 +0000 | [diff] [blame] | 411 | deviceRules.CreateEntryIfNotExist(route[0].DeviceID) |
| 412 | fg := fu.NewFlowsAndGroups() |
| 413 | fg.AddFlow(flow) |
| 414 | //return the multicast flow without decomposing it |
| 415 | deviceRules.AddFlowsAndGroup(route[0].DeviceID, fg) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 416 | return deviceRules |
| 417 | } |
| 418 | |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 419 | // decomposeFlow decomposes a flow for a logical device into flows for each physical device |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 420 | func (fd *FlowDecomposer) decomposeFlow(ctx context.Context, agent coreif.LogicalDeviceAgent, flow *ofp.OfpFlowStats, |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 421 | groupMap map[uint32]*ofp.OfpGroupEntry) *fu.DeviceRules { |
| 422 | |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 423 | inPortNo := fu.GetInPort(flow) |
Esin Karaman | 09959ae | 2019-11-29 13:59:58 +0000 | [diff] [blame] | 424 | if fu.HasGroup(flow) && inPortNo == 0 { |
| 425 | //if no in-port specified for a multicast flow, put NNI port as in-port |
| 426 | //so that a valid route can be found for the flow |
| 427 | nniPorts := agent.GetNNIPorts() |
| 428 | if len(nniPorts) > 0 { |
| 429 | inPortNo = nniPorts[0] |
| 430 | log.Debugw("Assigning NNI port as in-port for the multicast flow", log.Fields{"nni": nniPorts[0], "flow:": flow}) |
| 431 | } |
| 432 | } |
khenaidoo | 68c930b | 2019-05-13 11:46:51 -0400 | [diff] [blame] | 433 | outPortNo := fu.GetOutPort(flow) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 434 | deviceRules := fu.NewDeviceRules() |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 435 | route := agent.GetRoute(inPortNo, outPortNo) |
khenaidoo | 2c6a099 | 2019-04-29 13:46:56 -0400 | [diff] [blame] | 436 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 437 | switch len(route) { |
| 438 | case 0: |
| 439 | log.Errorw("no-route", log.Fields{"inPortNo": inPortNo, "outPortNo": outPortNo, "comment": "deleting-flow"}) |
| 440 | // TODO: Delete flow |
| 441 | return deviceRules |
| 442 | case 2: |
| 443 | log.Debugw("route-found", log.Fields{"ingressHop": route[0], "egressHop": route[1]}) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 444 | default: |
| 445 | log.Errorw("invalid-route-length", log.Fields{"routeLen": len(route)}) |
| 446 | return deviceRules |
| 447 | } |
| 448 | |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 449 | // Process controller bound flow |
| 450 | if outPortNo != 0 && (outPortNo&0x7fffffff) == uint32(ofp.OfpPortNo_OFPP_CONTROLLER) { |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 451 | deviceRules = fd.processControllerBoundFlow(agent, route, inPortNo, outPortNo, flow) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 452 | } else { |
khenaidoo | 297cd25 | 2019-02-07 22:10:23 -0500 | [diff] [blame] | 453 | var ingressDevice *voltha.Device |
| 454 | var err error |
npujar | 467fe75 | 2020-01-16 20:17:45 +0530 | [diff] [blame] | 455 | if ingressDevice, err = fd.deviceMgr.GetDevice(ctx, route[0].DeviceID); err != nil { |
khenaidoo | 297cd25 | 2019-02-07 22:10:23 -0500 | [diff] [blame] | 456 | log.Errorw("ingress-device-not-found", log.Fields{"deviceId": route[0].DeviceID, "flow": flow}) |
| 457 | return deviceRules |
| 458 | } |
| 459 | isUpstream := !ingressDevice.Root |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 460 | if isUpstream { // Unicast OLT and ONU UL |
| 461 | log.Info("processOltAndOnuUpstreamNonControllerBoundUnicastFlows", log.Fields{"flows": flow}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 462 | deviceRules = fd.processUpstreamNonControllerBoundFlow(agent, route, inPortNo, outPortNo, flow) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 463 | } else if fu.HasNextTable(flow) && flow.TableId == 0 { // Unicast OLT flow DL |
| 464 | log.Debugw("processOltDownstreamNonControllerBoundFlowWithNextTable", log.Fields{"flows": flow}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 465 | deviceRules = fd.processDownstreamFlowWithNextTable(agent, route, inPortNo, outPortNo, flow) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 466 | } else if flow.TableId == 1 && outPortNo != 0 { // Unicast ONU flow DL |
| 467 | log.Debugw("processOnuDownstreamUnicastFlow", log.Fields{"flows": flow}) |
khenaidoo | d20a585 | 2018-10-22 22:09:55 -0400 | [diff] [blame] | 468 | deviceRules = fd.processUnicastFlow(agent, route, inPortNo, outPortNo, flow) |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 469 | } else if grpID := fu.GetGroup(flow); grpID != 0 && flow.TableId == 0 { //Multicast |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 470 | log.Debugw("processMulticastFlow", log.Fields{"flows": flow}) |
npujar | 1d86a52 | 2019-11-14 17:11:16 +0530 | [diff] [blame] | 471 | deviceRules = fd.processMulticastFlow(agent, route, inPortNo, outPortNo, flow, grpID, groupMap) |
Manikkaraj k | b1a1092 | 2019-07-29 12:10:34 -0400 | [diff] [blame] | 472 | } else { |
| 473 | log.Errorw("unknown-downstream-flow", log.Fields{"flow": *flow}) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 474 | } |
| 475 | } |
khenaidoo | 19d7b63 | 2018-10-30 10:49:50 -0400 | [diff] [blame] | 476 | deviceRules = fd.updateOutputPortForControllerBoundFlowForParentDevide(flow, deviceRules) |
khenaidoo | 89b0e94 | 2018-10-21 21:11:33 -0400 | [diff] [blame] | 477 | return deviceRules |
| 478 | } |