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