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