Improve pf layer
[csit.git] / resources / libraries / robot / l2 / l2_xconnect.robot
1 # Copyright (c) 2020 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.L2Util
16 | Library | resources.libraries.python.InterfaceUtil
17
18 *** Keywords ***
19 | Configure L2XC
20 | | [Documentation]
21 | | ... | Setup Bidirectional Cross Connect on DUTs
22 | |
23 | | ... | *Arguments:*
24 | | ... | - dut - DUT node. Type: string
25 | | ... | - if1 - First interface. Type: string
26 | | ... | - if2 - Second interface. Type: string
27 | |
28 | | ... | *Example:*
29 | |
30 | | ... | \| Initialize L2 cross connect on node \| DUT1 \| 1 \|
31 | |
32 | | [Arguments] | ${dut} | ${if1} | ${if2}
33 | |
34 | | Set Interface State | ${dut} | ${if1} | up
35 | | Set Interface State | ${dut} | ${if2} | up
36 | | Vpp Setup Bidirectional Cross Connect | ${dut} | ${if1} | ${if2}
37
38 | Initialize L2 cross connect on node
39 | | [Documentation]
40 | | ... | Setup L2 cross connect topology by connecting RX/TX of two interfaces
41 | | ... | on each DUT. Interfaces are brought up.
42 | |
43 | | ... | *Arguments:*
44 | | ... | - dut - DUT node. Type: string
45 | | ... | - count - Number of interfaces pairs to connect. Type: integer
46 | |
47 | | ... | *Example:*
48 | |
49 | | ... | \| Initialize L2 cross connect on node \| DUT1 \| 1 \|
50 | |
51 | | [Arguments] | ${dut} | ${count}=${1}
52 | |
53 | | FOR | ${id} | IN RANGE | 1 | ${count} + 1
54 | | | VPP Setup Bidirectional Cross Connect | ${nodes['${dut}']}
55 | | | ... | ${${dut}_${int}1_${id}}[0] | ${${dut}_${int}2_${id}}[0]
56 | | END
57
58 | Initialize L2 cross connect
59 | | [Documentation]
60 | | ... | Setup L2 cross connect topology by connecting RX/TX of two interfaces
61 | | ... | on each DUT. Interfaces are brought up.
62 | |
63 | | ... | *Arguments:*
64 | | ... | - count - Number of interfaces pairs to connect. Type: integer
65 | |
66 | | ... | *Example:*
67 | |
68 | | ... | \| Initialize L2 cross connect \| 1 \|
69 | |
70 | | [Arguments] | ${count}=${1}
71 | |
72 | | FOR | ${dut} | IN | @{duts}
73 | | | Initialize L2 cross connect on node | ${dut} | count=${count}
74 | | END
75
76 | Initialize L2 xconnect with VXLANoIPv4 in 3-node circular topology
77 | | [Documentation]
78 | | ... | Setup L2 xconnect topology with VXLANoIPv4 by cross connecting
79 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
80 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
81 | | ... | between DUTs. VXLAN sub-interfaces has same IPv4 address as
82 | | ... | interfaces.
83 | |
84 | | Set interfaces in path up
85 | | VPP Interface Set IP Address
86 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 172.16.0.1 | 24
87 | | VPP Interface Set IP Address
88 | | ... | ${dut2} | ${DUT2_${int}1}[0] | 172.16.0.2 | 24
89 | | VPP Add IP Neighbor
90 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 172.16.0.2 | ${DUT2_${int}1_mac}[0]
91 | | VPP Add IP Neighbor
92 | | ... | ${dut2} | ${DUT2_${int}1}[0] | 172.16.0.1 | ${DUT1_${int}2_mac}[0]
93 | | ${dut1s_vxlan}= | Create VXLAN interface
94 | | ... | ${dut1} | 24 | 172.16.0.1 | 172.16.0.2
95 | | Configure L2XC
96 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${dut1s_vxlan}
97 | | ${dut2s_vxlan}= | Create VXLAN interface
98 | | ... | ${dut2} | 24 | 172.16.0.2 | 172.16.0.1
99 | | Configure L2XC
100 | | ... | ${dut2} | ${DUT2_${int}2}[0] | ${dut2s_vxlan}
101
102 | Initialize L2 xconnect with Vhost-User on node
103 | | [Documentation]
104 | | ... | Create pairs of Vhost-User interfaces for defined number of VMs on
105 | | ... | defined VPP node. Add each Vhost-User interface into L2 cross-connect
106 | | ... | with with physical inteface or Vhost-User interface of another VM.
107 | |
108 | | ... | *Arguments:*
109 | | ... | - dut - DUT node. Type: string
110 | | ... | - nf_nodes - VM count. Type: integer
111 | |
112 | | ... | *Note:*
113 | | ... | Socket paths for VM are defined in following format:
114 | | ... | - /tmp/sock-\${VM_ID}-1
115 | | ... | - /tmp/sock-\${VM_ID}-2
116 | |
117 | | ... | *Example:*
118 | |
119 | | ... | \| Initialize L2 xconnect with Vhost-User on node \| DUT1 \| 1 \|
120 | |
121 | | [Arguments] | ${dut} | ${nf_nodes}=${1}
122 | |
123 | | FOR | ${number} | IN RANGE | 1 | ${nf_nodes}+1
124 | | | ${sock1}= | Set Variable | /run/vpp/sock-${number}-1
125 | | | ${sock2}= | Set Variable | /run/vpp/sock-${number}-2
126 | | | ${prev_index}= | Evaluate | ${number}-1
127 | | | Configure vhost interfaces | ${nodes['${dut}']}
128 | | | ... | ${sock1} | ${sock2} | ${dut}-vhost-${number}-if1
129 | | | ... | ${dut}-vhost-${number}-if2
130 | | | ${dut_xconnect_if1}= | Set Variable If | ${number}==1
131 | | | ... | ${${dut}_${int}1}[0]
132 | | | ... | ${${dut}-vhost-${prev_index}-if2}
133 | | | Configure L2XC | ${nodes['${dut}']} | ${dut_xconnect_if1}
134 | | | ... | ${${dut}-vhost-${number}-if1}
135 | | | Run Keyword If | ${number}==${nf_nodes} | Configure L2XC
136 | | | ... | ${nodes['${dut}']} | ${${dut}-vhost-${number}-if2}
137 | | | ... | ${${dut}_${int}2}[0]
138 | | END
139
140 | Initialize L2 xconnect with Vhost-User
141 | | [Documentation]
142 | | ... | Create pairs of Vhost-User interfaces for defined number of VMs on
143 | | ... | all VPP nodes. Add each Vhost-User interface into L2 cross-connect
144 | | ... | with with physical inteface or Vhost-User interface of another VM.
145 | |
146 | | ... | *Arguments:*
147 | | ... | - nf_nodes - VM count. Type: integer
148 | |
149 | | ... | *Example:*
150 | |
151 | | ... | \| Initialize L2 xconnect with Vhost-User \| 1 \|
152 | |
153 | | [Arguments] | ${nf_nodes}=${1}
154 | |
155 | | FOR | ${dut} | IN | @{duts}
156 | | | Initialize L2 xconnect with Vhost-User on node | ${dut}
157 | | | ... | nf_nodes=${nf_nodes}
158 | | END
159
160 | Initialize L2 xconnect with Vhost-User and VLAN in circular topology
161 | | [Documentation]
162 | | ... | Create two Vhost-User interfaces on all defined VPP nodes. Cross
163 | | ... | connect each Vhost interface with one physical interface.
164 | | ... | Setup VLAN between DUTs. All interfaces are brought up.
165 | |
166 | | ... | *Arguments:*
167 | | ... | - subid - ID of the sub-interface to be created. Type: string
168 | | ... | - tag_rewrite - Method of tag rewrite. Type: string
169 | |
170 | | ... | *Example:*
171 | |
172 | | ... | \| L2 xconnect with Vhost-User and VLAN initialized in a 3-node\
173 | | ... | circular topology \| 10 \| pop-1 \|
174 | |
175 | | [Arguments] | ${subid} | ${tag_rewrite}
176 | |
177 | | ${dut2_status} | ${value}= | Run Keyword And Ignore Error
178 | | ... | Variable Should Exist | ${dut2}
179 | |
180 | | Set interfaces in path up
181 | |
182 | | Run Keyword If | '${dut2_status}' == 'PASS'
183 | | ... | Initialize VLAN dot1q sub-interfaces in circular topology
184 | | ... | ${dut1} | ${DUT1_${int}2}[0]
185 | | ... | ${dut2} | ${DUT2_${int}1}[0] | SUB_ID=${subid}
186 | | ... | ELSE | Initialize VLAN dot1q sub-interfaces in circular topology
187 | | ... | ${dut1} | ${DUT1_${int}2}[0] | SUB_ID=${subid}
188 | | Run Keyword If | '${dut2_status}' == 'PASS'
189 | | ... | Configure L2 tag rewrite method on interfaces
190 | | ... | ${dut1} | ${subif_index_1}
191 | | ... | ${dut2} | ${subif_index_2} | TAG_REWRITE_METHOD=${tag_rewrite}
192 | | ... | ELSE | Configure L2 tag rewrite method on interfaces
193 | | ... | ${dut1} | ${subif_index_1} | TAG_REWRITE_METHOD=${tag_rewrite}
194 | | Configure vhost interfaces
195 | | ... | ${dut1} | /run/vpp/sock-1-1 | /run/vpp/sock-1-2
196 | | Configure L2XC
197 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${vhost_if1}
198 | | Configure L2XC
199 | | ... | ${dut1} | ${subif_index_1} | ${vhost_if2}
200 | | Run Keyword If | '${dut2_status}' == 'PASS'
201 | | ... | Configure vhost interfaces
202 | | ... | ${dut2} | /run/vpp/sock-1-1 | /run/vpp/sock-1-2
203 | | Run Keyword If | '${dut2_status}' == 'PASS'
204 | | ... | Configure L2XC | ${dut2} | ${subif_index_2} | ${vhost_if1}
205 | | Run Keyword If | '${dut2_status}' == 'PASS'
206 | | ... | Configure L2XC | ${dut2} | ${DUT2_${int}2}[0] | ${vhost_if2}
207
208 | Initialize L2 xconnect with Vhost-User and VLAN with VPP link bonding in 3-node circular topology
209 | | [Documentation]
210 | | ... | Create two Vhost-User interfaces on all defined VPP nodes. Create one
211 | | ... | link bonding (BondEthernet) interface on both VPP nodes. Enslave one
212 | | ... | physical interface towards next DUT by BondEthernet interface. Setup
213 | | ... | VLAN on BondEthernet interfaces between DUTs. Cross connect one Vhost
214 | | ... | interface with physical interface towards TG and other Vhost interface
215 | | ... | with VLAN sub-interface. All interfaces are brought up.
216 | |
217 | | ... | *Arguments:*
218 | | ... | - subid - ID of the sub-interface to be created. Type: string
219 | | ... | - tag_rewrite - Method of tag rewrite. Type: string
220 | | ... | - bond_mode - Link bonding mode. Type: string
221 | | ... | - lb_mode - Load balance mode. Type: string
222 | |
223 | | ... | *Example:*
224 | |
225 | | ... | \| Initialize L2 xconnect with Vhost-User and VLAN with VPP link\
226 | | ... | bonding in 3-node circular topology \| 10 \| pop-1 \| xor \| l34 \|
227 | |
228 | | [Arguments] | ${subid} | ${tag_rewrite} | ${bond_mode} | ${lb_mode}
229 | |
230 | | Set interfaces in path up
231 | | ${dut1_eth_bond_if1}= | VPP Create Bond Interface
232 | | ... | ${dut1} | ${bond_mode} | ${lb_mode}
233 | | Set Interface State | ${dut1} | ${dut1_eth_bond_if1} | up
234 | | VPP Set interface MTU | ${dut1} | ${dut1_eth_bond_if1}
235 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
236 | | | ${_even}= | Evaluate | ${pf} % 2
237 | | | Run Keyword Unless | ${even}
238 | | | ... | VPP Enslave Physical Interface
239 | | | ... | ${dut1} | ${DUT1_${int}${pf}}[0] | ${dut1_eth_bond_if1}
240 | | END
241 | | ${dut2_eth_bond_if1}= | VPP Create Bond Interface
242 | | ... | ${dut2} | ${bond_mode} | ${lb_mode}
243 | | Set Interface State | ${dut2} | ${dut2_eth_bond_if1} | up
244 | | VPP Set interface MTU | ${dut2} | ${dut2_eth_bond_if1}
245 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
246 | | | ${_even}= | Evaluate | ${pf} % 2
247 | | | Run Keyword If | ${even}
248 | | | ... | VPP Enslave Physical Interface
249 | | | ... | ${dut2} | ${DUT2_${int}${pf}}[0] | ${dut2_eth_bond_if1}
250 | | END
251 | | VPP Show Bond Data On All Nodes | ${nodes} | verbose=${TRUE}
252 | | Initialize VLAN dot1q sub-interfaces in circular topology
253 | | ... | ${dut1} | ${dut1_eth_bond_if1}
254 | | ... | ${dut2} | ${dut2_eth_bond_if1} | ${subid}
255 | | Configure L2 tag rewrite method on interfaces
256 | | ... | ${dut1} | ${subif_index_1}
257 | | ... | ${dut2} | ${subif_index_2} | ${tag_rewrite}
258 | | Configure vhost interfaces
259 | | ... | ${dut1} | /run/vpp/sock-1-1 | /run/vpp/sock-1-2
260 | | Configure L2XC
261 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${vhost_if1}
262 | | Configure L2XC
263 | | ... | ${dut1} | ${subif_index_1} | ${vhost_if2}
264 | | Configure vhost interfaces
265 | | ... | ${dut2} | /run/vpp/sock-1-1 | /run/vpp/sock-1-2
266 | | Configure L2XC
267 | | ... | ${dut2} | ${subif_index_2} | ${vhost_if1}
268 | | Configure L2XC
269 | | ... | ${dut2} | ${DUT2_${int}2}[0] | ${vhost_if2}
270
271 | Initialize L2 xconnect with memif pairs on DUT node
272 | | [Documentation]
273 | | ... | Create pairs of Memif interfaces on DUT node. Cross connect each Memif
274 | | ... | interface with one physical interface or virtual interface to create
275 | | ... | a chain accross DUT node.
276 | |
277 | | ... | *Arguments:*
278 | | ... | - dut - DUT node. Type: dictionary
279 | | ... | - count - Number of memif pairs (containers). Type: integer
280 | |
281 | | ... | *Note:*
282 | | ... | Socket paths for Memif are defined in following format:
283 | | ... | - /tmp/memif-\${dut}_CNF\${number}-\${sid}
284 | |
285 | | ... | KW uses test variable \${rxq_count_int} set by KW Add worker threads
286 | | ... | and rxqueues to all DUTs
287 | |
288 | | ... | *Example:*
289 | |
290 | | ... | \| Initialize L2 xconnect with memif pairs on DUT node \| ${dut} \
291 | | ... | \| ${1} \|
292 | |
293 | | [Arguments] | ${dut} | ${count}
294 | |
295 | | FOR | ${number} | IN RANGE | 1 | ${count}+1
296 | | | ${sock1}= | Set Variable | memif-${dut}_CNF
297 | | | ${sock2}= | Set Variable | memif-${dut}_CNF
298 | | | ${prev_index}= | Evaluate | ${number}-1
299 | | | Set up memif interfaces on DUT node | ${nodes['${dut}']}
300 | | | ... | ${sock1} | ${sock2} | ${number} | ${dut}-memif-${number}-if1
301 | | | ... | ${dut}-memif-${number}-if2 | ${rxq_count_int} | ${rxq_count_int}
302 | | | ${xconnect_if1}= | Set Variable If | ${number}==1
303 | | | ... | ${${dut}_${int}1}[0] | ${${dut}-memif-${prev_index}-if2}
304 | | | Configure L2XC | ${nodes['${dut}']} | ${xconnect_if1}
305 | | | ... | ${${dut}-memif-${number}-if1}
306 | | | Run Keyword If | ${number}==${count} | Configure L2XC
307 | | | ... | ${nodes['${dut}']} | ${${dut}-memif-${number}-if2}
308 | | | ... | ${${dut}_${int}2}[0]
309 | | END
310
311 | Initialize L2 xconnect with memif pairs
312 | | [Documentation]
313 | | ... | Create pairs of Memif interfaces on all defined VPP nodes. Cross
314 | | ... | connect each Memif interface with one physical interface or virtual
315 | | ... | interface to create a chain accross DUT node.
316 | |
317 | | ... | *Arguments:*
318 | | ... | - count - Number of memif pairs (containers). Type: integer
319 | |
320 | | ... | *Example:*
321 | |
322 | | ... | \| Initialize L2 xconnect with memif pairs \| ${1} \|
323 | |
324 | | [Arguments] | ${count}=${1}
325 | |
326 | | FOR | ${dut} | IN | @{duts}
327 | | | Initialize L2 xconnect with memif pairs on DUT node | ${dut} | ${count}
328 | | END
329 | | Set interfaces in path up
330 | | Show Memif on all DUTs | ${nodes}
331 | | VPP round robin RX placement on all DUTs | ${nodes} | prefix=memif