blob: 700eba4ca386ec093d979638911245610102bb63 [file] [log] [blame]
Sreeju Sreedhare3fefd92019-04-02 15:57:15 -07001
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
17import logging
18import oftest.base_tests as base_tests
19from oftest import config
20from oftest.testutils import *
21from util import *
22from accton_util import convertIP4toStr as toIpV4Str
23from accton_util import convertMACtoStr as toMacStr
24
25"""
26Not verify yet, need to think how to verify meter
27"""
28
29class dscp(base_tests.SimpleDataPlane):
30 """
31 [DSCP meter]
32 DSCP meter
33
34 Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100* 10 pkt/sec]
35 Output eth 1/1 [10] no change
36
37 Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 10 burst]
38 Output eth 1/1 [8] no change; [2] dscp 2
39
40 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
41 ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x06,meter=1 dscp_remark:rate=5,prec_level=2,burst=5
42 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
43 ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 meter:1
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 output_port = test_ports[1]
53
54 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
55 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
56 apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x06,meter=1 dscp_remark:rate=5,prec_level=2,burst=5")
57 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))
58 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" meter:1")
59
60 input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
61 eth_src="00:00:00:11:22:33",
62 ip_src=toIpV4Str(0xc0a80164),
63 ip_dst=toIpV4Str(0xc0a80202),
64 dl_vlan_enable=True,
65 vlan_vid=2)
66
67 output_pkt = input_pkt
68
69 self.dataplane.send(input_port, str(input_pkt))
70 verify_packet(self, str(output_pkt), output_port)
71
72
73class drop(base_tests.SimpleDataPlane):
74 """
75 [Drop meter]
76 Drop meter
77
78 Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 10 pkt/sec]
79 Output eth 1/1 [8] output
80
81 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
82 ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x01,meter=1 drop:rate=8
83 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
84 ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 meter:1
85 """
86 def runTest(self):
87 delete_all_flows(self.controller)
88 delete_all_groups(self.controller)
89
90 test_ports = sorted(config["port_map"].keys())
91
92 input_port = test_ports[0]
93 output_port = test_ports[1]
94
95 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
96 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
97 apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x01,meter=1 drop:rate=8")
98 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))
99 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" meter:1")
100
101 input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
102 eth_src="00:00:00:11:22:33",
103 ip_src=toIpV4Str(0xc0a80164),
104 ip_dst=toIpV4Str(0xc0a80202),
105 dl_vlan_enable=True,
106 vlan_vid=2)
107
108 output_pkt = input_pkt
109
110 self.dataplane.send(input_port, str(input_pkt))
111 verify_packet(self, str(output_pkt), output_port)
112
113
114class trtcm(base_tests.SimpleDataPlane):
115 """
116 [TrTCM meter]
117 TrTCM meter
118
119 Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 50 pkt/sec]
120 Output eth 1/1 [16] vlan pcp 1 + [14] vlan pcp 3 + [20] vlan pcp 5
121
122 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
123 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
124 ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=2
125 ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1
126 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5
127 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3
128 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1
129 """
130 def runTest(self):
131 delete_all_flows(self.controller)
132 delete_all_groups(self.controller)
133
134 test_ports = sorted(config["port_map"].keys())
135
136 input_port = test_ports[0]
137 output_port = test_ports[1]
138
139 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
140 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
141 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))
142 apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=2")
143 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1")
144 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5")
145 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3")
146 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1")
147
148 input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
149 eth_src="00:00:00:11:22:33",
150 ip_src=toIpV4Str(0xc0a80164),
151 ip_dst=toIpV4Str(0xc0a80202),
152 dl_vlan_enable=True,
153 vlan_vid=2,
154 vlan_pcp=0)
155
156 output_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
157 eth_src="00:00:00:11:22:33",
158 ip_src=toIpV4Str(0xc0a80164),
159 ip_dst=toIpV4Str(0xc0a80202),
160 dl_vlan_enable=True,
161 vlan_vid=2,
162 vlan_pcp=1)
163
164 self.dataplane.send(input_port, str(input_pkt))
165 verify_packet(self, str(output_pkt), output_port)
166
167
168class srtcm(base_tests.SimpleDataPlane):
169 """
170 [SrTCM meter]
171 SrTCM meter
172
173 Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 50 pkt/sec]
174 Output eth 1/1 [15] vlan pcp 1 + [15] vlan pcp 3 + [20] vlan pcp 5
175
176 Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 30 pkt/sec]
177 Output eth 1/1 [15] vlan pcp 1 + [15] vlan pcp 3
178
179 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
180 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
181 ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=1,burst=10 set_color:rate=20,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=2,burst=20
182 ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1
183 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5
184 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3
185 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1
186 """
187 def runTest(self):
188 delete_all_flows(self.controller)
189 delete_all_groups(self.controller)
190
191 test_ports = sorted(config["port_map"].keys())
192
193 input_port = test_ports[0]
194 output_port = test_ports[1]
195
196 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
197 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
198 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))
199 apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=1,burst=10 set_color:rate=20,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=2,burst=20")
200 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1")
201 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5")
202 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3")
203 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1")
204
205 input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
206 eth_src="00:00:00:11:22:33",
207 ip_src=toIpV4Str(0xc0a80164),
208 ip_dst=toIpV4Str(0xc0a80202),
209 dl_vlan_enable=True,
210 vlan_vid=2,
211 vlan_pcp=0)
212
213 output_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
214 eth_src="00:00:00:11:22:33",
215 ip_src=toIpV4Str(0xc0a80164),
216 ip_dst=toIpV4Str(0xc0a80202),
217 dl_vlan_enable=True,
218 vlan_vid=2,
219 vlan_pcp=1)
220
221 self.dataplane.send(input_port, str(input_pkt))
222 verify_packet(self, str(output_pkt), output_port)
223
224
225class mod_trtcm(base_tests.SimpleDataPlane):
226 """
227 [Mod TrTCM meter]
228 Mod TrTCM meter
229
230 Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 50 pkt/sec]
231 Output eth 1/1 [15] vlan pcp 1 + [28] vlan pcp 3 + [7] vlan pcp 5
232
233 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
234 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
235 ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=2
236 ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1
237 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5
238 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3
239 ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1
240 """
241 def runTest(self):
242 delete_all_flows(self.controller)
243 delete_all_groups(self.controller)
244
245 test_ports = sorted(config["port_map"].keys())
246
247 input_port = test_ports[0]
248 output_port = test_ports[1]
249
250 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
251 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
252 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))
253 apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=2")
254 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1")
255 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5")
256 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3")
257 apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1")
258
259 input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
260 eth_src="00:00:00:11:22:33",
261 ip_src=toIpV4Str(0xc0a80164),
262 ip_dst=toIpV4Str(0xc0a80202),
263 dl_vlan_enable=True,
264 vlan_vid=2,
265 vlan_pcp=0)
266
267 output_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
268 eth_src="00:00:00:11:22:33",
269 ip_src=toIpV4Str(0xc0a80164),
270 ip_dst=toIpV4Str(0xc0a80202),
271 dl_vlan_enable=True,
272 vlan_vid=2,
273 vlan_pcp=1)
274
275 self.dataplane.send(input_port, str(input_pkt))
276 verify_packet(self, str(output_pkt), output_port)
277
278
279