blob: 8342a79143ad2999d7a672b35c3fdc6b3bf04d10 [file] [log] [blame]
kdarapu3248f9a2019-10-03 13:54:52 +05301/*
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
17//Package adaptercore provides the utility for olt devices, flows and statistics
18package adaptercore
19
20import (
Gamze Abakafee36392019-10-03 11:17:24 +000021 "fmt"
kdarapu3248f9a2019-10-03 13:54:52 +053022 "testing"
23
Esin Karamanccb714b2019-11-29 15:02:06 +000024 "github.com/opencord/voltha-protos/v3/go/voltha"
kdarapub26b4502019-10-05 03:02:33 +053025
Esin Karamanccb714b2019-11-29 15:02:06 +000026 "github.com/opencord/voltha-lib-go/v3/pkg/db"
27 fu "github.com/opencord/voltha-lib-go/v3/pkg/flows"
28 "github.com/opencord/voltha-lib-go/v3/pkg/log"
29 tp "github.com/opencord/voltha-lib-go/v3/pkg/techprofile"
kdarapu3248f9a2019-10-03 13:54:52 +053030 "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
kdarapub26b4502019-10-05 03:02:33 +053031 rsrcMgr "github.com/opencord/voltha-openolt-adapter/adaptercore/resourcemanager"
kdarapu3248f9a2019-10-03 13:54:52 +053032 "github.com/opencord/voltha-openolt-adapter/mocks"
Esin Karamanccb714b2019-11-29 15:02:06 +000033 ofp "github.com/opencord/voltha-protos/v3/go/openflow_13"
34 "github.com/opencord/voltha-protos/v3/go/openolt"
35 openoltpb2 "github.com/opencord/voltha-protos/v3/go/openolt"
36 tp_pb "github.com/opencord/voltha-protos/v3/go/tech_profile"
kdarapu3248f9a2019-10-03 13:54:52 +053037)
38
kdarapub26b4502019-10-05 03:02:33 +053039var flowMgr *OpenOltFlowMgr
40
kdarapu3248f9a2019-10-03 13:54:52 +053041func init() {
42 log.SetDefaultLogger(log.JSON, log.DebugLevel, nil)
kdarapub26b4502019-10-05 03:02:33 +053043 flowMgr = newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +053044}
45func newMockResourceMgr() *resourcemanager.OpenOltResourceMgr {
46 ranges := []*openolt.DeviceInfo_DeviceResourceRanges{
47 {IntfIds: []uint32{0, 1, 2}}}
48
49 deviceinfo := &openolt.DeviceInfo{Vendor: "openolt", Model: "openolt", HardwareVersion: "1.0", FirmwareVersion: "1.0",
50 DeviceId: "olt", DeviceSerialNumber: "openolt", PonPorts: 3, Technology: "Default",
51 OnuIdStart: 1, OnuIdEnd: 1, AllocIdStart: 1, AllocIdEnd: 1,
52 GemportIdStart: 1, GemportIdEnd: 1, FlowIdStart: 1, FlowIdEnd: 1,
53 Ranges: ranges,
54 }
55 rsrMgr := resourcemanager.NewResourceMgr("olt", "127.0.0.1:2379", "etcd", "olt", deviceinfo)
kdarapub26b4502019-10-05 03:02:33 +053056 for key := range rsrMgr.ResourceMgrs {
sbarbaria8910ba2019-11-05 10:12:23 -050057 rsrMgr.ResourceMgrs[key].KVStore = &db.Backend{}
kdarapub26b4502019-10-05 03:02:33 +053058 rsrMgr.ResourceMgrs[key].KVStore.Client = &mocks.MockKVClient{}
59 rsrMgr.ResourceMgrs[key].TechProfileMgr = mocks.MockTechProfile{TpID: key}
60 }
kdarapu3248f9a2019-10-03 13:54:52 +053061 return rsrMgr
62}
63
64func newMockFlowmgr() *OpenOltFlowMgr {
Abhilash Laxmeshwarab0bd522019-10-21 15:05:15 +053065 rMgr := newMockResourceMgr()
kdarapu3248f9a2019-10-03 13:54:52 +053066 dh := newMockDeviceHandler()
67
Abhilash Laxmeshwarab0bd522019-10-21 15:05:15 +053068 rMgr.KVStore = &db.Backend{}
69 rMgr.KVStore.Client = &mocks.MockKVClient{}
kdarapu3248f9a2019-10-03 13:54:52 +053070
Abhilash Laxmeshwarab0bd522019-10-21 15:05:15 +053071 dh.resourceMgr = rMgr
72 flwMgr := NewFlowManager(dh, rMgr)
kdarapu3248f9a2019-10-03 13:54:52 +053073
Abhilash Laxmeshwarab0bd522019-10-21 15:05:15 +053074 onuGemInfo1 := make([]rsrcMgr.OnuGemInfo, 2)
75 onuGemInfo2 := make([]rsrcMgr.OnuGemInfo, 2)
76 onuGemInfo1[0] = rsrcMgr.OnuGemInfo{OnuID: 1, SerialNumber: "1", IntfID: 1, GemPorts: []uint32{1}}
77 onuGemInfo2[1] = rsrcMgr.OnuGemInfo{OnuID: 2, SerialNumber: "2", IntfID: 2, GemPorts: []uint32{2}}
78 flwMgr.onuGemInfo[1] = onuGemInfo1
79 flwMgr.onuGemInfo[2] = onuGemInfo2
kdarapu3248f9a2019-10-03 13:54:52 +053080
Abhilash Laxmeshwarab0bd522019-10-21 15:05:15 +053081 packetInGemPort := make(map[rsrcMgr.PacketInInfoKey]uint32)
82 packetInGemPort[rsrcMgr.PacketInInfoKey{IntfID: 1, OnuID: 1, LogicalPort: 1}] = 1
83 packetInGemPort[rsrcMgr.PacketInInfoKey{IntfID: 2, OnuID: 2, LogicalPort: 2}] = 2
kdarapu3248f9a2019-10-03 13:54:52 +053084
85 flwMgr.packetInGemPort = packetInGemPort
Amit Ghoshd4cbe482019-11-21 12:07:14 +000086 tps := make(map[uint32]tp.TechProfileIf)
Abhilash Laxmeshwarab0bd522019-10-21 15:05:15 +053087 for key := range rMgr.ResourceMgrs {
kdarapub26b4502019-10-05 03:02:33 +053088 tps[key] = mocks.MockTechProfile{TpID: key}
kdarapu3248f9a2019-10-03 13:54:52 +053089 }
90 flwMgr.techprofile = tps
Esin Karamanccb714b2019-11-29 15:02:06 +000091
92 interface2mcastQeueuMap := make(map[uint32]*queueInfoBrief)
93 interface2mcastQeueuMap[0] = &queueInfoBrief{
94 gemPortID: 4000,
95 servicePriority: 3,
96 }
97 flwMgr.interfaceToMcastQueueMap = interface2mcastQeueuMap
kdarapu3248f9a2019-10-03 13:54:52 +053098 return flwMgr
99}
kdarapub26b4502019-10-05 03:02:33 +0530100
kdarapu3248f9a2019-10-03 13:54:52 +0530101func TestOpenOltFlowMgr_CreateSchedulerQueues(t *testing.T) {
kdarapub26b4502019-10-05 03:02:33 +0530102 // flowMgr := newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +0530103
104 tprofile := &tp.TechProfile{Name: "tp1", SubscriberIdentifier: "subscriber1",
Girish Gowdra54934262019-11-13 14:19:55 +0530105 ProfileType: "pt1", NumGemPorts: 1, Version: 1,
kdarapu3248f9a2019-10-03 13:54:52 +0530106 InstanceCtrl: tp.InstanceControl{Onu: "1", Uni: "1", MaxGemPayloadSize: "1"},
107 }
108 tprofile.UsScheduler.Direction = "UPSTREAM"
109 tprofile.UsScheduler.AdditionalBw = "AdditionalBW_None"
110 tprofile.UsScheduler.QSchedPolicy = "WRR"
111
112 tprofile2 := tprofile
113 tprofile2.DsScheduler.Direction = "DOWNSTREAM"
114 tprofile2.DsScheduler.AdditionalBw = "AdditionalBW_None"
115 tprofile2.DsScheduler.QSchedPolicy = "WRR"
116 bands := make([]*ofp.OfpMeterBandHeader, 2)
117 bands[0] = &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 1000, BurstSize: 5000, Data: &ofp.OfpMeterBandHeader_Drop{}}
118 bands[1] = &ofp.OfpMeterBandHeader{Type: ofp.OfpMeterBandType_OFPMBT_DROP, Rate: 2000, BurstSize: 5000, Data: &ofp.OfpMeterBandHeader_Drop{}}
119 ofpMeterConfig := &ofp.OfpMeterConfig{Flags: 1, MeterId: 1, Bands: bands}
120 flowmetadata := &voltha.FlowMetadata{
121 Meters: []*ofp.OfpMeterConfig{ofpMeterConfig},
122 }
123 type args struct {
124 Dir tp_pb.Direction
125 IntfID uint32
126 OnuID uint32
127 UniID uint32
128 UniPort uint32
129 TpInst *tp.TechProfile
130 MeterID uint32
131 flowMetadata *voltha.FlowMetadata
132 }
133 tests := []struct {
Gamze Abakafee36392019-10-03 11:17:24 +0000134 name string
135 schedQueue schedQueue
136 wantErr bool
kdarapu3248f9a2019-10-03 13:54:52 +0530137 }{
138 // TODO: Add test cases.
Gamze Abakafee36392019-10-03 11:17:24 +0000139 {"CreateSchedulerQueues-1", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 1, flowmetadata}, false},
140 {"CreateSchedulerQueues-2", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 1, flowmetadata}, false},
141 {"CreateSchedulerQueues-3", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 2, flowmetadata}, true},
142 {"CreateSchedulerQueues-4", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 2, flowmetadata}, true},
143 {"CreateSchedulerQueues-5", schedQueue{tp_pb.Direction_UPSTREAM, 2, 2, 2, 64, 2, tprofile, 2, flowmetadata}, true},
144 {"CreateSchedulerQueues-6", schedQueue{tp_pb.Direction_DOWNSTREAM, 2, 2, 2, 65, 2, tprofile2, 2, flowmetadata}, true},
145 {"CreateSchedulerQueues-13", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 1, flowmetadata}, false},
kdarapu3248f9a2019-10-03 13:54:52 +0530146 //Negative testcases
Gamze Abakafee36392019-10-03 11:17:24 +0000147 {"CreateSchedulerQueues-7", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 1, &voltha.FlowMetadata{}}, true},
148 {"CreateSchedulerQueues-8", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 0, &voltha.FlowMetadata{}}, true},
149 {"CreateSchedulerQueues-9", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 1, &voltha.FlowMetadata{}}, true},
150 {"CreateSchedulerQueues-10", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 2, &voltha.FlowMetadata{}}, true},
151 {"CreateSchedulerQueues-11", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 2, &voltha.FlowMetadata{}}, true},
152 {"CreateSchedulerQueues-12", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 2, nil}, true},
kdarapu3248f9a2019-10-03 13:54:52 +0530153 }
154 for _, tt := range tests {
155 t.Run(tt.name, func(t *testing.T) {
Gamze Abakafee36392019-10-03 11:17:24 +0000156 if err := flowMgr.CreateSchedulerQueues(tt.schedQueue); (err != nil) != tt.wantErr {
kdarapu3248f9a2019-10-03 13:54:52 +0530157 t.Errorf("OpenOltFlowMgr.CreateSchedulerQueues() error = %v, wantErr %v", err, tt.wantErr)
158 }
159 })
160 }
161}
162
163func TestOpenOltFlowMgr_RemoveSchedulerQueues(t *testing.T) {
164
kdarapub26b4502019-10-05 03:02:33 +0530165 // flowMgr := newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +0530166 tprofile := &tp.TechProfile{Name: "tp1", SubscriberIdentifier: "subscriber1",
Girish Gowdra54934262019-11-13 14:19:55 +0530167 ProfileType: "pt1", NumGemPorts: 1, Version: 1,
kdarapu3248f9a2019-10-03 13:54:52 +0530168 InstanceCtrl: tp.InstanceControl{Onu: "1", Uni: "1", MaxGemPayloadSize: "1"},
169 }
170 tprofile.UsScheduler.Direction = "UPSTREAM"
171 tprofile.UsScheduler.AdditionalBw = "AdditionalBW_None"
172 tprofile.UsScheduler.QSchedPolicy = "WRR"
173
174 tprofile2 := tprofile
175 tprofile2.DsScheduler.Direction = "DOWNSTREAM"
176 tprofile2.DsScheduler.AdditionalBw = "AdditionalBW_None"
177 tprofile2.DsScheduler.QSchedPolicy = "WRR"
178 //defTprofile := &tp.DefaultTechProfile{}
179 type args struct {
180 Dir tp_pb.Direction
181 IntfID uint32
182 OnuID uint32
183 UniID uint32
184 UniPort uint32
185 TpInst *tp.TechProfile
186 }
187 tests := []struct {
Gamze Abakafee36392019-10-03 11:17:24 +0000188 name string
189 schedQueue schedQueue
190 wantErr bool
kdarapu3248f9a2019-10-03 13:54:52 +0530191 }{
192 // TODO: Add test cases.
Gamze Abakafee36392019-10-03 11:17:24 +0000193 {"RemoveSchedulerQueues", schedQueue{tp_pb.Direction_UPSTREAM, 1, 1, 1, 64, 1, tprofile, 0, nil}, false},
194 {"RemoveSchedulerQueues", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
kdarapu3248f9a2019-10-03 13:54:52 +0530195 // negative test cases
Gamze Abakafee36392019-10-03 11:17:24 +0000196 {"RemoveSchedulerQueues", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
197 {"RemoveSchedulerQueues", schedQueue{tp_pb.Direction_DOWNSTREAM, 1, 1, 1, 65, 1, tprofile2, 0, nil}, false},
kdarapu3248f9a2019-10-03 13:54:52 +0530198 }
199 for _, tt := range tests {
200 t.Run(tt.name, func(t *testing.T) {
Gamze Abakafee36392019-10-03 11:17:24 +0000201 if err := flowMgr.RemoveSchedulerQueues(tt.schedQueue); (err != nil) != tt.wantErr {
kdarapu3248f9a2019-10-03 13:54:52 +0530202 t.Errorf("OpenOltFlowMgr.RemoveSchedulerQueues() error = %v, wantErr %v", err, tt.wantErr)
203 }
204 })
205 }
kdarapub26b4502019-10-05 03:02:33 +0530206
kdarapu3248f9a2019-10-03 13:54:52 +0530207}
208
209func TestOpenOltFlowMgr_RemoveFlow(t *testing.T) {
kdarapub26b4502019-10-05 03:02:33 +0530210 // flowMgr := newMockFlowmgr()
211 log.Debug("Info Warning Error: Starting RemoveFlow() test")
kdarapu3248f9a2019-10-03 13:54:52 +0530212 fa := &fu.FlowArgs{
213 MatchFields: []*ofp.OfpOxmOfbField{
214 fu.InPort(2),
215 fu.Metadata_ofp(2),
216 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
217 },
218 Actions: []*ofp.OfpAction{
219 fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
220 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
221 fu.Output(1),
222 },
223 }
224 ofpstats := fu.MkFlowStat(fa)
kdarapub26b4502019-10-05 03:02:33 +0530225 ofpstats.Cookie = ofpstats.Id
kdarapub26b4502019-10-05 03:02:33 +0530226 lldpFa := &fu.FlowArgs{
227 KV: fu.OfpFlowModArgs{"priority": 1000, "cookie": 48132224281636694},
228 MatchFields: []*ofp.OfpOxmOfbField{
229 fu.InPort(1),
230 fu.EthType(0x88CC),
231 fu.TunnelId(536870912),
232 },
233 Actions: []*ofp.OfpAction{
234 fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
235 },
236 }
237 lldpofpstats := fu.MkFlowStat(lldpFa)
238 //lldpofpstats.Cookie = lldpofpstats.Id
239
240 dhcpFa := &fu.FlowArgs{
241 KV: fu.OfpFlowModArgs{"priority": 1000, "cookie": 48132224281636694},
242 MatchFields: []*ofp.OfpOxmOfbField{
243 fu.InPort(1),
244 fu.UdpSrc(67),
245 //fu.TunnelId(536870912),
246 fu.IpProto(17),
247 },
248 Actions: []*ofp.OfpAction{
249 fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
250 },
251 }
252 dhcpofpstats := fu.MkFlowStat(dhcpFa)
253 //dhcpofpstats.Cookie = dhcpofpstats.Id
Esin Karamanccb714b2019-11-29 15:02:06 +0000254
255 //multicast flow
256 multicastFa := &fu.FlowArgs{
257 MatchFields: []*ofp.OfpOxmOfbField{
258 fu.InPort(65536),
259 fu.VlanVid(660), //vlan
260 fu.Metadata_ofp(uint64(66)), //inner vlan
261 fu.EthType(0x800), //ipv4
262 fu.Ipv4Dst(3809869825), //227.22.0.1
263 },
264 Actions: []*ofp.OfpAction{
265 fu.Group(1),
266 },
267 }
268 multicastOfpStats := fu.MkFlowStat(multicastFa)
269 multicastOfpStats.Id = 1
270
kdarapu3248f9a2019-10-03 13:54:52 +0530271 type args struct {
272 flow *ofp.OfpFlowStats
273 }
274 tests := []struct {
275 name string
276 args args
277 }{
278 // TODO: Add test cases.
279 {"RemoveFlow", args{flow: ofpstats}},
kdarapub26b4502019-10-05 03:02:33 +0530280 {"RemoveFlow", args{flow: lldpofpstats}},
281 {"RemoveFlow", args{flow: dhcpofpstats}},
Esin Karamanccb714b2019-11-29 15:02:06 +0000282 {"RemoveFlow", args{flow: multicastOfpStats}},
kdarapu3248f9a2019-10-03 13:54:52 +0530283 }
284 for _, tt := range tests {
285 t.Run(tt.name, func(t *testing.T) {
286 flowMgr.RemoveFlow(tt.args.flow)
287 })
288 }
kdarapub26b4502019-10-05 03:02:33 +0530289 // t.Error("=====")
kdarapu3248f9a2019-10-03 13:54:52 +0530290}
291
292func TestOpenOltFlowMgr_AddFlow(t *testing.T) {
kdarapub26b4502019-10-05 03:02:33 +0530293 // flowMgr := newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +0530294 kw := make(map[string]uint64)
295 kw["table_id"] = 1
296 kw["meter_id"] = 1
kdarapub26b4502019-10-05 03:02:33 +0530297 kw["write_metadata"] = 0x4000000000 // Tech-Profile-ID 64
298
299 // Upstream flow
kdarapu3248f9a2019-10-03 13:54:52 +0530300 fa := &fu.FlowArgs{
301 MatchFields: []*ofp.OfpOxmOfbField{
kdarapub26b4502019-10-05 03:02:33 +0530302 fu.InPort(536870912),
303 fu.Metadata_ofp(1),
304 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
305 },
306 Actions: []*ofp.OfpAction{
307 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
308 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
309 fu.Output(65536),
310 fu.PushVlan(0x8100),
311 },
312 KV: kw,
313 }
314
315 // Downstream flow
316 fa3 := &fu.FlowArgs{
317 MatchFields: []*ofp.OfpOxmOfbField{
318 fu.InPort(65536),
319 fu.Metadata_ofp(1),
320 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257),
321 },
322 Actions: []*ofp.OfpAction{
323 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
324 //fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
325 fu.PopVlan(),
326 fu.Output(536870912),
327 },
328 KV: kw,
329 }
330
331 fa2 := &fu.FlowArgs{
332 MatchFields: []*ofp.OfpOxmOfbField{
kdarapu3248f9a2019-10-03 13:54:52 +0530333 fu.InPort(1000),
334 fu.Metadata_ofp(1),
335 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
336 },
337 Actions: []*ofp.OfpAction{
338 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
339 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 101)),
340 fu.Output(65533),
341 },
342 KV: kw,
343 }
344
kdarapub26b4502019-10-05 03:02:33 +0530345 // TODO Add LLDP flow
346 // TODO Add DHCP flow
347
348 // Flows for negative scenarios
349 // Failure in formulateActionInfoFromFlow()
350 fa4 := &fu.FlowArgs{
351 MatchFields: []*ofp.OfpOxmOfbField{
352 fu.InPort(1000),
353 fu.Metadata_ofp(1),
354 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
355 },
356 Actions: []*ofp.OfpAction{
357 fu.Experimenter(257, []byte{1, 2, 3, 4}),
358 },
359 KV: kw,
360 }
361
362 // Invalid Output
363 fa5 := &fu.FlowArgs{
364 MatchFields: []*ofp.OfpOxmOfbField{
365 fu.InPort(1000),
366 fu.Metadata_ofp(1),
367 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
368 },
369 Actions: []*ofp.OfpAction{
370 fu.Output(0),
371 },
372 KV: kw,
373 }
374
375 // Tech-Profile-ID update (not supported)
376 kw6 := make(map[string]uint64)
377 kw6["table_id"] = 1
378 kw6["meter_id"] = 1
379 kw6["write_metadata"] = 0x4100000000 // TpID Other than the stored one
380 fa6 := &fu.FlowArgs{
381 MatchFields: []*ofp.OfpOxmOfbField{
382 fu.InPort(536870912),
383 fu.TunnelId(16),
384 fu.Metadata_ofp(1),
385 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
386 },
387 Actions: []*ofp.OfpAction{
388 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
389 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
390 fu.Output(65535),
391 },
392 KV: kw6,
393 }
394
395 lldpFa := &fu.FlowArgs{
396 KV: fu.OfpFlowModArgs{"priority": 1000, "cookie": 48132224281636694},
397 MatchFields: []*ofp.OfpOxmOfbField{
398 fu.InPort(1),
399 fu.EthType(0x88CC),
400 fu.TunnelId(536870912),
401 },
402 Actions: []*ofp.OfpAction{
403 fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
404 },
405 }
406
407 dhcpFa := &fu.FlowArgs{
408 KV: fu.OfpFlowModArgs{"priority": 1000, "cookie": 48132224281636694},
409 MatchFields: []*ofp.OfpOxmOfbField{
410 fu.InPort(1),
411 fu.UdpSrc(67),
412 //fu.TunnelId(536870912),
413 fu.IpProto(17),
414 },
415 Actions: []*ofp.OfpAction{
416 fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
417 },
418 }
419 igmpFa := &fu.FlowArgs{
420 KV: fu.OfpFlowModArgs{"priority": 1000, "cookie": 48132224281636694},
421 MatchFields: []*ofp.OfpOxmOfbField{
422 fu.InPort(1),
423 fu.UdpSrc(67),
424 //fu.TunnelId(536870912),
425 fu.IpProto(2),
426 },
427 Actions: []*ofp.OfpAction{
428 fu.Output(uint32(ofp.OfpPortNo_OFPP_CONTROLLER)),
429 },
430 }
431
432 fa9 := &fu.FlowArgs{
433 MatchFields: []*ofp.OfpOxmOfbField{
434 fu.InPort(536870912),
435 fu.TunnelId(16),
436 fu.Metadata_ofp(1),
437 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
438 fu.VlanPcp(1000),
439 fu.UdpDst(65535),
440 fu.UdpSrc(536870912),
441 fu.Ipv4Dst(65535),
442 fu.Ipv4Src(536870912),
443 },
444 Actions: []*ofp.OfpAction{
445 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
446 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
447 fu.Output(65535),
448 },
449 KV: kw6,
450 }
451
452 fa10 := &fu.FlowArgs{
453 MatchFields: []*ofp.OfpOxmOfbField{
454 fu.InPort(65533),
455 // fu.TunnelId(16),
456 fu.Metadata_ofp(1),
457 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
458 fu.VlanPcp(1000),
459 fu.UdpDst(65535),
460 fu.UdpSrc(536870912),
461 fu.Ipv4Dst(65535),
462 fu.Ipv4Src(536870912),
463 },
464 Actions: []*ofp.OfpAction{
465 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
466 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
467 fu.Output(65535),
468 },
469 KV: kw6,
470 }
Esin Karamanccb714b2019-11-29 15:02:06 +0000471 //multicast flow
472 fa11 := &fu.FlowArgs{
473 MatchFields: []*ofp.OfpOxmOfbField{
474 fu.InPort(65536),
475 fu.VlanVid(660), //vlan
476 fu.Metadata_ofp(uint64(66)), //inner vlan
477 fu.EthType(0x800), //ipv4
478 fu.Ipv4Dst(3809869825), //227.22.0.1
479 },
480 Actions: []*ofp.OfpAction{
481 fu.Group(1),
482 },
483 KV: kw6,
484 }
kdarapu3248f9a2019-10-03 13:54:52 +0530485 ofpstats := fu.MkFlowStat(fa)
kdarapub26b4502019-10-05 03:02:33 +0530486 ofpstats2 := fu.MkFlowStat(fa2)
487 ofpstats3 := fu.MkFlowStat(fa3)
488 ofpstats4 := fu.MkFlowStat(fa4)
489 ofpstats5 := fu.MkFlowStat(fa5)
490 ofpstats6 := fu.MkFlowStat(fa6)
491 ofpstats7 := fu.MkFlowStat(lldpFa)
492 ofpstats8 := fu.MkFlowStat(dhcpFa)
493 ofpstats9 := fu.MkFlowStat(fa9)
494 ofpstats10 := fu.MkFlowStat(fa10)
495 igmpstats := fu.MkFlowStat(igmpFa)
Esin Karamanccb714b2019-11-29 15:02:06 +0000496 ofpstats11 := fu.MkFlowStat(fa11)
kdarapub26b4502019-10-05 03:02:33 +0530497
Gamze Abakafee36392019-10-03 11:17:24 +0000498 fmt.Println(ofpstats6, ofpstats9, ofpstats10)
499
kdarapu3248f9a2019-10-03 13:54:52 +0530500 ofpMeterConfig := &ofp.OfpMeterConfig{Flags: 1, MeterId: 1}
kdarapu3248f9a2019-10-03 13:54:52 +0530501 flowMetadata := &voltha.FlowMetadata{
502 Meters: []*ofp.OfpMeterConfig{ofpMeterConfig},
503 }
504 type args struct {
505 flow *ofp.OfpFlowStats
506 flowMetadata *voltha.FlowMetadata
507 }
508 tests := []struct {
509 name string
510 args args
511 }{
512 // TODO: Add test cases.
513 {"AddFlow", args{flow: ofpstats, flowMetadata: flowMetadata}},
kdarapub26b4502019-10-05 03:02:33 +0530514 {"AddFlow", args{flow: ofpstats2, flowMetadata: flowMetadata}},
515 {"AddFlow", args{flow: ofpstats3, flowMetadata: flowMetadata}},
516 {"AddFlow", args{flow: ofpstats4, flowMetadata: flowMetadata}},
517 {"AddFlow", args{flow: ofpstats5, flowMetadata: flowMetadata}},
Gamze Abakafee36392019-10-03 11:17:24 +0000518 //{"AddFlow", args{flow: ofpstats6, flowMetadata: flowMetadata}},
kdarapub26b4502019-10-05 03:02:33 +0530519 {"AddFlow", args{flow: ofpstats7, flowMetadata: flowMetadata}},
520 {"AddFlow", args{flow: ofpstats8, flowMetadata: flowMetadata}},
Gamze Abakafee36392019-10-03 11:17:24 +0000521 //{"AddFlow", args{flow: ofpstats9, flowMetadata: flowMetadata}},
kdarapub26b4502019-10-05 03:02:33 +0530522 {"AddFlow", args{flow: igmpstats, flowMetadata: flowMetadata}},
Gamze Abakafee36392019-10-03 11:17:24 +0000523 //{"AddFlow", args{flow: ofpstats10, flowMetadata: flowMetadata}},
kdarapub26b4502019-10-05 03:02:33 +0530524 //ofpstats10
Esin Karamanccb714b2019-11-29 15:02:06 +0000525 {"AddFlow", args{flow: ofpstats11, flowMetadata: flowMetadata}},
kdarapu3248f9a2019-10-03 13:54:52 +0530526 }
527 for _, tt := range tests {
528 t.Run(tt.name, func(t *testing.T) {
529 flowMgr.AddFlow(tt.args.flow, tt.args.flowMetadata)
530 })
531 }
532}
533
534func TestOpenOltFlowMgr_UpdateOnuInfo(t *testing.T) {
kdarapub26b4502019-10-05 03:02:33 +0530535 // flowMgr := newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +0530536 type args struct {
537 intfID uint32
538 onuID uint32
539 serialNum string
540 }
541 tests := []struct {
542 name string
543 args args
544 }{
545 // TODO: Add test cases.
546 {"UpdateOnuInfo", args{1, 1, "onu1"}},
547 {"UpdateOnuInfo", args{2, 3, "onu1"}},
548 }
549 for _, tt := range tests {
550 t.Run(tt.name, func(t *testing.T) {
551
552 flowMgr.UpdateOnuInfo(tt.args.intfID, tt.args.onuID, tt.args.serialNum)
553 })
554 }
555}
556
557func TestOpenOltFlowMgr_GetLogicalPortFromPacketIn(t *testing.T) {
kdarapub26b4502019-10-05 03:02:33 +0530558 // flowMgr := newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +0530559 type args struct {
560 packetIn *openoltpb2.PacketIndication
561 }
562 tests := []struct {
563 name string
564 args args
565 want uint32
566 wantErr bool
567 }{
568 // TODO: Add test cases.
569 {"GetLogicalPortFromPacketIn", args{packetIn: &openoltpb2.PacketIndication{IntfType: "pon", IntfId: 1, GemportId: 1, FlowId: 100, PortNo: 1, Cookie: 100, Pkt: []byte("GetLogicalPortFromPacketIn")}}, 1, false},
Amit Ghoshd4cbe482019-11-21 12:07:14 +0000570 {"GetLogicalPortFromPacketIn", args{packetIn: &openoltpb2.PacketIndication{IntfType: "nni", IntfId: 1, GemportId: 1, FlowId: 100, PortNo: 1, Cookie: 100, Pkt: []byte("GetLogicalPortFromPacketIn")}}, 1048577, false},
kdarapu3248f9a2019-10-03 13:54:52 +0530571 // Negative Test cases.
572 {"GetLogicalPortFromPacketIn", args{packetIn: &openoltpb2.PacketIndication{IntfType: "pon", IntfId: 2, GemportId: 1, FlowId: 100, PortNo: 1, Cookie: 100, Pkt: []byte("GetLogicalPortFromPacketIn")}}, 0, true},
Amit Ghoshd4cbe482019-11-21 12:07:14 +0000573 {"GetLogicalPortFromPacketIn", args{packetIn: &openoltpb2.PacketIndication{IntfType: "pon", IntfId: 1, GemportId: 1, FlowId: 100, PortNo: 0, Cookie: 100, Pkt: []byte("GetLogicalPortFromPacketIn")}}, 4112, false},
kdarapu3248f9a2019-10-03 13:54:52 +0530574 }
575 for _, tt := range tests {
576 t.Run(tt.name, func(t *testing.T) {
577
578 got, err := flowMgr.GetLogicalPortFromPacketIn(tt.args.packetIn)
579 if (err != nil) != tt.wantErr {
580 t.Errorf("OpenOltFlowMgr.GetLogicalPortFromPacketIn() error = %v, wantErr %v", err, tt.wantErr)
581 return
582 }
583 if got != tt.want {
584 t.Errorf("OpenOltFlowMgr.GetLogicalPortFromPacketIn() = %v, want %v", got, tt.want)
585 }
586 })
587 }
588}
589
590func TestOpenOltFlowMgr_GetPacketOutGemPortID(t *testing.T) {
kdarapub26b4502019-10-05 03:02:33 +0530591 // flwMgr := newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +0530592
593 type args struct {
594 intfID uint32
595 onuID uint32
596 portNum uint32
597 }
598 tests := []struct {
599 name string
600 args args
601 want uint32
602 wantErr bool
603 }{
604 // TODO: Add test cases.
605 {"GetPacketOutGemPortID", args{intfID: 1, onuID: 1, portNum: 1}, 1, false},
606 {"GetPacketOutGemPortID", args{intfID: 2, onuID: 2, portNum: 2}, 2, false},
607 {"GetPacketOutGemPortID", args{intfID: 1, onuID: 2, portNum: 2}, 0, true},
608 }
609 for _, tt := range tests {
610 t.Run(tt.name, func(t *testing.T) {
611
kdarapub26b4502019-10-05 03:02:33 +0530612 got, err := flowMgr.GetPacketOutGemPortID(tt.args.intfID, tt.args.onuID, tt.args.portNum)
kdarapu3248f9a2019-10-03 13:54:52 +0530613 if (err != nil) != tt.wantErr {
614 t.Errorf("OpenOltFlowMgr.GetPacketOutGemPortID() error = %v, wantErr %v", err, tt.wantErr)
615 return
616 }
617 if got != tt.want {
618 t.Errorf("OpenOltFlowMgr.GetPacketOutGemPortID() = %v, want %v", got, tt.want)
619 }
620
621 })
622 }
623}
624
625func TestOpenOltFlowMgr_DeleteTechProfileInstance(t *testing.T) {
kdarapub26b4502019-10-05 03:02:33 +0530626 // flwMgr := newMockFlowmgr()
kdarapu3248f9a2019-10-03 13:54:52 +0530627 type args struct {
628 intfID uint32
629 onuID uint32
630 uniID uint32
631 sn string
Gamze Abakafee36392019-10-03 11:17:24 +0000632 tpID uint32
kdarapu3248f9a2019-10-03 13:54:52 +0530633 }
634 tests := []struct {
635 name string
636 args args
637 wantErr bool
638 }{
639 // TODO: Add test cases.
Gamze Abakafee36392019-10-03 11:17:24 +0000640 {"DeleteTechProfileInstance", args{intfID: 0, onuID: 1, uniID: 1, sn: "", tpID: 64}, false},
kdarapu3248f9a2019-10-03 13:54:52 +0530641 }
642 for _, tt := range tests {
643 t.Run(tt.name, func(t *testing.T) {
Gamze Abakafee36392019-10-03 11:17:24 +0000644 if err := flowMgr.DeleteTechProfileInstance(tt.args.intfID, tt.args.onuID, tt.args.uniID, tt.args.sn, tt.args.tpID); (err != nil) != tt.wantErr {
kdarapu3248f9a2019-10-03 13:54:52 +0530645 t.Errorf("OpenOltFlowMgr.DeleteTechProfileInstance() error = %v, wantErr %v", err, tt.wantErr)
646 }
647 })
648 }
649}
kdarapub26b4502019-10-05 03:02:33 +0530650
651func TestOpenOltFlowMgr_checkAndAddFlow(t *testing.T) {
652 // flowMgr := newMockFlowmgr()
653 kw := make(map[string]uint64)
654 kw["table_id"] = 1
655 kw["meter_id"] = 1
656 kw["write_metadata"] = 0x4000000000 // Tech-Profile-ID 64
657
658 // Upstream flow
659 fa := &fu.FlowArgs{
660 MatchFields: []*ofp.OfpOxmOfbField{
661 fu.InPort(536870912),
662 fu.Metadata_ofp(1),
663 fu.IpProto(17), // dhcp
Gamze Abakafee36392019-10-03 11:17:24 +0000664 fu.VlanPcp(0),
kdarapub26b4502019-10-05 03:02:33 +0530665 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
666 },
667 Actions: []*ofp.OfpAction{
668 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
669 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
670 fu.Output(65536),
671 fu.PushVlan(0x8100),
672 },
673 KV: kw,
674 }
675
676 // EAPOL
677 fa2 := &fu.FlowArgs{
678 MatchFields: []*ofp.OfpOxmOfbField{
679 fu.InPort(536870912),
680 fu.Metadata_ofp(1),
681 fu.EthType(0x888E),
682 fu.VlanPcp(1),
683 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257),
684 },
685 Actions: []*ofp.OfpAction{
686 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
687 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 257)),
688 fu.Output(65536),
689 fu.PushVlan(0x8100),
690 },
691 KV: kw,
692 }
693
694 // HSIA
695 fa3 := &fu.FlowArgs{
696 MatchFields: []*ofp.OfpOxmOfbField{
697 fu.InPort(536870912),
698 fu.Metadata_ofp(1),
699 //fu.EthType(0x8100),
700 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
701 },
702 Actions: []*ofp.OfpAction{
703 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
704 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0)),
705 fu.Output(65536),
706 fu.PushVlan(0x8100),
707 },
708 KV: kw,
709 }
710
711 fa4 := &fu.FlowArgs{
712 MatchFields: []*ofp.OfpOxmOfbField{
713 fu.InPort(65535),
714 fu.Metadata_ofp(1),
715 fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
716 fu.VlanPcp(1),
717 },
718 Actions: []*ofp.OfpAction{
719 //fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
720 fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0)),
721 fu.Output(536870912),
722 fu.PopVlan(),
723 },
724 KV: kw,
725 }
726
727 classifierInfo := make(map[string]interface{})
728 actionInfo := make(map[string]interface{})
729 classifierInfo2 := make(map[string]interface{})
730 actionInfo2 := make(map[string]interface{})
731 classifierInfo3 := make(map[string]interface{})
732 actionInfo3 := make(map[string]interface{})
733 classifierInfo4 := make(map[string]interface{})
734 actionInfo4 := make(map[string]interface{})
735 flowState := fu.MkFlowStat(fa)
736 flowState2 := fu.MkFlowStat(fa2)
737 flowState3 := fu.MkFlowStat(fa3)
738 flowState4 := fu.MkFlowStat(fa4)
739 formulateClassifierInfoFromFlow(classifierInfo, flowState)
740 formulateClassifierInfoFromFlow(classifierInfo2, flowState2)
741 formulateClassifierInfoFromFlow(classifierInfo3, flowState3)
742 formulateClassifierInfoFromFlow(classifierInfo4, flowState4)
743
744 err := formulateActionInfoFromFlow(actionInfo, classifierInfo, flowState)
745 if err != nil {
746 // Error logging is already done in the called function
747 // So just return in case of error
748 return
749 }
750
751 err = formulateActionInfoFromFlow(actionInfo2, classifierInfo2, flowState2)
752 if err != nil {
753 // Error logging is already done in the called function
754 // So just return in case of error
755 return
756 }
757
758 err = formulateActionInfoFromFlow(actionInfo3, classifierInfo3, flowState3)
759 if err != nil {
760 // Error logging is already done in the called function
761 // So just return in case of error
762 return
763 }
764
765 err = formulateActionInfoFromFlow(actionInfo4, classifierInfo4, flowState4)
766 if err != nil {
767 // Error logging is already done in the called function
768 // So just return in case of error
769 return
770 }
771
772 //ofpMeterConfig := &ofp.OfpMeterConfig{Flags: 1, MeterId: 1}
773 //flowMetadata := &voltha.FlowMetadata{
774 // Meters: []*ofp.OfpMeterConfig{ofpMeterConfig},
775 //}
776
777 TpInst := &tp.TechProfile{
778 Name: "Test-Tech-Profile",
779 SubscriberIdentifier: "257",
780 ProfileType: "Mock",
781 Version: 1,
782 NumGemPorts: 4,
kdarapub26b4502019-10-05 03:02:33 +0530783 InstanceCtrl: tp.InstanceControl{
784 Onu: "1",
785 Uni: "16",
786 },
787 }
788
789 type fields struct {
Abhilash Laxmeshwarab0bd522019-10-21 15:05:15 +0530790 techprofile []tp.TechProfileIf
791 deviceHandler *DeviceHandler
792 resourceMgr *rsrcMgr.OpenOltResourceMgr
kdarapub26b4502019-10-05 03:02:33 +0530793 }
794 type args struct {
795 args map[string]uint32
796 classifierInfo map[string]interface{}
797 actionInfo map[string]interface{}
798 flow *ofp.OfpFlowStats
799 gemPort uint32
800 intfID uint32
801 onuID uint32
802 uniID uint32
803 portNo uint32
804 TpInst *tp.TechProfile
805 allocID []uint32
806 gemPorts []uint32
807 TpID uint32
808 uni string
809 }
810 tests := []struct {
811 name string
812 fields fields
813 args args
814 }{
815 {
816 name: "checkAndAddFlow-1",
817 args: args{
818 args: nil,
819 classifierInfo: classifierInfo,
820 actionInfo: actionInfo,
821 flow: flowState,
822 gemPort: 1,
823 intfID: 1,
824 onuID: 1,
825 uniID: 16,
826 portNo: 1,
827 TpInst: TpInst,
828 allocID: []uint32{0x8001, 0x8002, 0x8003, 0x8004},
829 gemPorts: []uint32{1, 2, 3, 4},
830 TpID: 64,
831 uni: "16",
832 },
833 },
834 {
835 name: "checkAndAddFlow-2",
836 args: args{
837 args: nil,
838 classifierInfo: classifierInfo2,
839 actionInfo: actionInfo2,
840 flow: flowState2,
841 gemPort: 1,
842 intfID: 1,
843 onuID: 1,
844 uniID: 16,
845 portNo: 1,
846 TpInst: TpInst,
847 allocID: []uint32{0x8001, 0x8002, 0x8003, 0x8004},
848 gemPorts: []uint32{1, 2, 3, 4},
849 TpID: 64,
850 uni: "16",
851 },
852 },
853 {
854 name: "checkAndAddFlow-3",
855 args: args{
856 args: nil,
857 classifierInfo: classifierInfo3,
858 actionInfo: actionInfo3,
859 flow: flowState3,
860 gemPort: 1,
861 intfID: 1,
862 onuID: 1,
863 uniID: 16,
864 portNo: 1,
865 TpInst: TpInst,
866 allocID: []uint32{0x8001, 0x8002, 0x8003, 0x8004},
867 gemPorts: []uint32{1, 2, 3, 4},
868 TpID: 64,
869 uni: "16",
870 },
871 },
872 {
873 name: "checkAndAddFlow-4",
874 args: args{
875 args: nil,
876 classifierInfo: classifierInfo4,
877 actionInfo: actionInfo4,
878 flow: flowState4,
879 gemPort: 1,
880 intfID: 1,
881 onuID: 1,
882 uniID: 16,
883 portNo: 1,
884 TpInst: TpInst,
885 allocID: []uint32{0x8001, 0x8002, 0x8003, 0x8004},
886 gemPorts: []uint32{1, 2, 3, 4},
887 TpID: 64,
888 uni: "16",
889 },
890 },
891 }
892 for _, tt := range tests {
893 t.Run(tt.name, func(t *testing.T) {
Gamze Abakafee36392019-10-03 11:17:24 +0000894 flowMgr.checkAndAddFlow(tt.args.args, tt.args.classifierInfo, tt.args.actionInfo, tt.args.flow,
895 tt.args.TpInst, tt.args.gemPorts, tt.args.TpID, tt.args.uni)
kdarapub26b4502019-10-05 03:02:33 +0530896 })
897 }
898}
Esin Karamanccb714b2019-11-29 15:02:06 +0000899
900func TestOpenOltFlowMgr_TestMulticastFlow(t *testing.T) {
901 //create group
902 group := newGroup(2, []uint32{1})
903 flowMgr.AddGroup(group)
904
905 //create multicast flow
906 multicastFlowArgs := &fu.FlowArgs{
907 MatchFields: []*ofp.OfpOxmOfbField{
908 fu.InPort(65536),
909 fu.VlanVid(660), //vlan
910 fu.Metadata_ofp(uint64(66)), //inner vlan
911 fu.EthType(0x800), //ipv4
912 fu.Ipv4Dst(3809869825), //227.22.0.1
913 },
914 Actions: []*ofp.OfpAction{
915 fu.Group(1),
916 },
917 }
918 ofpStats := fu.MkFlowStat(multicastFlowArgs)
919 flowMgr.AddFlow(ofpStats, &voltha.FlowMetadata{})
920
921 //add bucket to the group
922 group = newGroup(2, []uint32{1, 2})
923
924 flowMgr.ModifyGroup(group)
925}