Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [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 | |
macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 17 | import logging
|
| 18 | import oftest.base_tests as base_tests
|
| 19 | from oftest import config
|
| 20 | from oftest.testutils import *
|
| 21 | from util import *
|
| 22 | from accton_util import convertIP4toStr as toIpV4Str
|
| 23 | from accton_util import convertMACtoStr as toMacStr
|
| 24 |
|
| 25 | """
|
| 26 | Not Verify yet, need to think how to verify meter
|
| 27 | """
|
| 28 |
|
| 29 | class wred(base_tests.SimpleDataPlane):
|
| 30 | """
|
| 31 | [WRED]
|
| 32 | WRED (DCTCP)
|
| 33 |
|
| 34 | Inject eth 1/1 untag, SA000000112233, DA000000000111, TCP ECN 01 [100%]
|
| 35 | Output eth 1/5 ECN 11
|
| 36 |
|
| 37 | [CLI] interface eth 1/1 => switch priority default 1
|
| 38 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20005 group=any,port=any,weight=0 output=5
|
| 39 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1000/0xfff apply:set_field=vlan_vid=2 goto:20
|
| 40 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1000/0xfff apply:set_field=vlan_vid=2 goto:20
|
| 41 | dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 in_port=3 write:group=0x20005
|
| 42 | dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=1 write:group=0x20005
|
| 43 | dpctl tcp:192.168.1.1:6633 queue-mod type=wred,port=5,queue=0 min=1,max=60,ecn=100,drop=100
|
| 44 | """
|
| 45 | def runTest(self):
|
| 46 | delete_all_flows(self.controller)
|
| 47 | delete_all_groups(self.controller)
|
| 48 |
|
| 49 | test_ports = sorted(config["port_map"].keys())
|
| 50 |
|
| 51 | input_port = test_ports[0]
|
| 52 | input_port2 = test_ports[1]
|
| 53 | output_port = test_ports[2]
|
| 54 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 55 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 56 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 57 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1000/0xfff apply:set_field=vlan_vid=2 goto:20")
|
| 58 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port2)+",vlan_vid=0x1000/0xfff apply:set_field=vlan_vid=2 goto:20")
|
| 59 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 in_port="+str(input_port2)+" write:group=0x2000"+str(output_port))
|
| 60 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x2000"+str(output_port))
|
| 61 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28")
|
| 62 | apply_dpctl_mod(self, config, "queue-mod type=wred,port="+str(output_port)+",queue=0 min=1,max=60,ecn=100,drop=100")
|
| 63 |
|
| 64 | # TCP ecn = 01
|
| 65 | input_pkt = simple_packet(
|
| 66 | '70 72 cf 7c f3 a3 00 00 00 11 22 33 81 00 00 02 '
|
| 67 | '08 00 45 01 00 4e 04 d2 00 00 7f 06 b2 7b c0 a8 '
|
| 68 | '01 0a c0 a8 02 02 00 03 00 06 00 01 f7 fa 00 00 '
|
| 69 | '00 00 50 00 04 00 2f 5d 00 00 00 00 00 00 00 00 '
|
| 70 | '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
|
| 71 | '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
|
| 72 |
|
| 73 | # TCP ecn = 00
|
| 74 | input_pkt2 = simple_packet(
|
| 75 | '70 72 cf 7c f3 a3 00 00 00 11 22 33 81 00 00 02 '
|
| 76 | '08 00 45 00 00 4e 04 d2 00 00 7f 06 b2 7b c0 a8 '
|
| 77 | '01 0a c0 a8 02 02 00 03 00 06 00 01 f7 fa 00 00 '
|
| 78 | '00 00 50 00 04 00 2f 5d 00 00 00 00 00 00 00 00 '
|
| 79 | '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
|
| 80 | '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
|
| 81 |
|
| 82 | # TCP ecn = 11
|
| 83 | output_pkt = simple_packet(
|
| 84 | '70 72 cf 7c f3 a3 00 00 00 11 22 33 81 00 00 02 '
|
| 85 | '08 00 45 11 00 4e 04 d2 00 00 7f 06 b2 7b c0 a8 '
|
| 86 | '01 0a c0 a8 02 02 00 03 00 06 00 01 f7 fa 00 00 '
|
| 87 | '00 00 50 00 04 00 2f 5d 00 00 00 00 00 00 00 00 '
|
| 88 | '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
|
| 89 | '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
|
| 90 |
|
| 91 | self.dataplane.send(input_port, str(input_pkt))
|
| 92 | self.dataplane.send(input_port2, str(input_pkt2))
|
| 93 | verify_packet(self, str(output_pkt), output_port)
|
| 94 |
|