VPPD: Dot1Q
[csit.git] / resources / libraries / robot / shared / interfaces.robot
1 # Copyright (c) 2019 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 *** Settings ***
14 | Library | resources.libraries.python.InterfaceUtil
15 | Library | resources.libraries.python.NodePath
16 | Library | resources.libraries.python.VatExecutor
17
18 *** Keywords ***
19 | VPP reports interfaces through VAT on '${node}'
20 | | Execute Script | dump_interfaces.vat | ${node}
21 | | Script Should Have Passed
22
23 | Configure MTU on TG based on MTU on DUT
24 | | [Documentation] | Type of the tg_node must be TG and dut_node must be DUT
25 | | [Arguments] | ${tg_node} | ${dut_node}
26 | | Append Nodes | ${tg_node} | ${dut_node}
27 | | Compute Path
28 | | ${tg_port} | ${tg_node}= | First Interface
29 | | ${dut_port} | ${dut_node}= | Last Interface
30 | | # get physical layer MTU (max. size of Ethernet frame)
31 | | ${mtu}= | Get Interface MTU | ${dut_node} | ${dut_port}
32 | | # Ethernet MTU is physical layer MTU minus size of Ethernet header and FCS
33 | | ${eth_mtu}= | Evaluate | ${mtu} - 14 - 4
34 | | Set Interface Ethernet MTU | ${tg_node} | ${tg_port} | ${eth_mtu}
35
36 | Get Vhost dump
37 | | [Documentation] | Get vhost-user dump.
38 | | ...
39 | | ... | *Arguments:*
40 | | ... | - node - DUT node data. Type: dictionary
41 | | ...
42 | | [Arguments] | ${dut_node}
43 | | ...
44 | | [Return] | ${vhost_dump}
45 | | ...
46 | | ${vhost_dump}= | Vhost User Dump | ${dut_node}
47
48 | Initialize layer interface on node
49 | | [Documentation]
50 | | ... | Baseline interfaces variables to be created.
51 | | ...
52 | | ... | *Arguments:*
53 | | ... | - dut - DUT node. Type: string
54 | | ... | - count - Number of baseline interface variables. Type: integer
55 | | ...
56 | | ... | *Example:*
57 | | ...
58 | | ... | \| Initialize layer interface on node \| DUT1 \| 1 \|
59 | | ...
60 | | [Arguments] | ${dut} | ${count}=${1}
61 | | ...
62 | | ${dut_str}= | Convert To Lowercase | ${dut}
63 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
64 | | | Set Test Variable | ${${dut_str}_if_${id}_1} | ${${dut_str}_if1}
65 | | | Set Test Variable | ${${dut_str}_if_${id}_2} | ${${dut_str}_if2}
66
67 | Initialize layer interface
68 | | [Documentation]
69 | | ... | Physical interfaces variables to be created on all DUTs.
70 | | ...
71 | | ... | *Arguments:*
72 | | ... | - count - Number of untagged interfaces variables. Type: integer
73 | | ...
74 | | ... | *Example:*
75 | | ...
76 | | ... | \| Initialize layer interface \| 1 \|
77 | | ...
78 | | [Arguments] | ${count}=${1}
79 | | ...
80 | | :FOR | ${dut} | IN | @{duts}
81 | | | Initialize layer interface on node | ${dut} | count=${count}
82 | | Set Test Variable | ${prev_layer} | if
83 | | Set interfaces in path up
84
85 | Initialize layer avf on node
86 | | [Documentation]
87 | | ... | Initialize AVF interfaces on DUT. Interfaces are brought up.
88 | | ...
89 | | ... | *Arguments:*
90 | | ... | - dut - DUT node. Type: string
91 | | ...
92 | | ... | *Example:*
93 | | ...
94 | | ... | \| Initialize layer avf on node \| DUT1 \|
95 | | ...
96 | | [Arguments] | ${dut}
97 | | ...
98 | | ${dut_str}= | Convert To Lowercase | ${dut}
99 | | ${if1_vlan}= | Get Interface Vlan | ${nodes['${dut}']} | ${${dut}_if1}
100 | | ${if2_vlan}= | Get Interface Vlan | ${nodes['${dut}']} | ${${dut}_if2}
101 | | Set Test Variable | ${${dut_str}_vlan1} | ${if1_vlan}
102 | | Set Test Variable | ${${dut_str}_vlan2} | ${if2_vlan}
103 | | ${if1_pci}= | Get Interface PCI Addr | ${nodes['${dut}']}
104 | | ... | ${${dut}_if1_vf0}
105 | | ${if2_pci}= | Get Interface PCI Addr | ${nodes['${dut}']}
106 | | ... | ${${dut}_if2_vf0}
107 | | ${dut_eth_vf_if1}= | VPP Create AVF Interface | ${nodes['${dut}']}
108 | | ... | ${if1_pci} | ${rxq_count_int}
109 | | ${dut_eth_vf_if2}= | VPP Create AVF Interface | ${nodes['${dut}']}
110 | | ... | ${if2_pci} | ${rxq_count_int}
111 | | Set Test Variable | ${${dut_str}_if1} | ${dut_eth_vf_if1}
112 | | Set Test Variable | ${${dut_str}_if2} | ${dut_eth_vf_if2}
113
114 | Initialize AVF interfaces
115 | | [Documentation]
116 | | ... | Initialize AVF interfaces on each DUT. Interfaces are brought up.
117 | | ...
118 | | :FOR | ${dut} | IN | @{duts}
119 | | | Initialize layer avf on node | ${dut}
120 | | Set Test Variable | ${prev_layer} | vf
121 | | Set interfaces in path up
122
123 | Initialize layer bonding on node
124 | | [Documentation]
125 | | ... | Bonded interface and variables to be created on across east and
126 | | ... | west DUT's node interfaces.
127 | | ...
128 | | ... | *Arguments:*
129 | | ... | - dut - DUT node. Type: string
130 | | ... | - bond_mode - Link bonding mode. Type: string
131 | | ... | - lb_mode - Load balance mode. Type: string
132 | | ... | - count - Number of bond interface variables. Type: integer
133 | | ...
134 | | ... | *Example:*
135 | | ...
136 | | ... | \| Initialize layer bonding on node \| DUT1 \| xor \| l34 \| 1 \|
137 | | ...
138 | | [Arguments] | ${dut} | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
139 | | ...
140 | | ${dut_str}= | Convert To Lowercase | ${dut}
141 | | ${if_index}= | VPP Create Bond Interface
142 | | ... | ${nodes['${dut}']} | ${bond_mode} | load_balance=${lb_mode}
143 | | ... | mac=00:00:00:01:01:01
144 | | Set Interface State | ${nodes['${dut}']} | ${if_index} | up
145 | | VPP Enslave Physical Interface
146 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1} | ${if_index}
147 | | VPP Enslave Physical Interface
148 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2} | ${if_index}
149 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
150 | | | Set Test Variable | ${${dut_str}_bond_${id}_1} | ${if_index}
151 | | | Set Test Variable | ${${dut_str}_bond_${id}_2} | ${if_index}
152
153 | Initialize layer bonding
154 | | [Documentation]
155 | | ... | Bonded interfaces and variables to be created on all DUT's interfaces.
156 | | ...
157 | | ... | *Arguments:*
158 | | ... | - bond_mode - Link bonding mode. Type: string
159 | | ... | - lb_mode - Load balance mode. Type: string
160 | | ... | - count - Number of bond interface variables. Type: integer
161 | | ...
162 | | ... | *Example:*
163 | | ...
164 | | ... | \| Initialize layer bonding \| xor \| l34 \| 1 \|
165 | | ...
166 | | [Arguments] | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
167 | | ...
168 | | :FOR | ${dut} | IN | @{duts}
169 | | | Initialize layer bonding on node
170 | | | ... | ${dut} | bond_mode=${bond_mode} | lb_mode=${lb_mode}
171 | | | ... | count=${count}
172 | | Set Test Variable | ${prev_layer} | bond
173
174 | Initialize layer dot1q on node
175 | | [Documentation]
176 | | ... | Dot1q interfaces and variables to be created on all DUT's node
177 | | ... | interfaces.
178 | | ...
179 | | ... | *Arguments:*
180 | | ... | - dut - DUT node. Type: string
181 | | ... | - count - Number of tagged interfaces. Type: integer
182 | | ... | - create - Whether to create vlan subinterface for each chain.
183 | | ... |     Type: boolean
184 | | ...
185 | | ... | *Example:*
186 | | ...
187 | | ... | \| Initialize layer dot1q on node \| DUT1 \| 1 \| True \|
188 | | ...
189 | | [Arguments] | ${dut} | ${count}=${1} | ${create}=${True}
190 | | ...
191 | | ${dut_str}= | Convert To Lowercase | ${dut}
192 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
193 | | | ${if1_vlan}= | Run Keyword If | ${${dut_str}_vlan1}
194 | | | ... | Set Variable | ${${dut_str}_vlan1}
195 | | | ... | ELSE
196 | | | ... | Evaluate | ${100} + ${id} - ${1}
197 | | | ${if2_vlan}= | Run Keyword If | ${${dut_str}_vlan2}
198 | | | ... | Set Variable | ${${dut_str}_vlan2}
199 | | | ... | ELSE
200 | | | ... | Evaluate | ${200} + ${id} - ${1}
201 | | | ${if1_name} | ${if1_index}= | Run Keyword If
202 | | | ... | ${create} or ${id} == ${1}
203 | | | ... | Create Vlan Subinterface
204 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
205 | | | ... | ${if1_vlan}
206 | | | ${if2_name} | ${if2_index}= | Run Keyword If
207 | | | ... | ${create} or ${id} == ${1}
208 | | | ... | Create Vlan Subinterface
209 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
210 | | | ... | ${if2_vlan}
211 | | | Run Keyword If | ${create} or ${id} == ${1}
212 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
213 | | | Run Keyword If | ${create} or ${id} == ${1}
214 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
215 | | | Run Keyword If | ${create} or ${id} == ${1}
216 | | | ... | Configure L2 tag rewrite method on interfaces
217 | | | ... | ${nodes['${dut}']} | ${if1_index} | TAG_REWRITE_METHOD=pop-1
218 | | | Run Keyword If | ${create} or ${id} == ${1}
219 | | | ... | Configure L2 tag rewrite method on interfaces
220 | | | ... | ${nodes['${dut}']} | ${if2_index} | TAG_REWRITE_METHOD=pop-1
221 | | | ${if1_index}= | Set Variable If | '${if1_index}' == '${NONE}'
222 | | | ... | ${${dut_str}_dot1q_1_1} | ${if1_index}
223 | | | ${if2_index}= | Set Variable If | '${if2_index}' == '${NONE}'
224 | | | ... | ${${dut_str}_dot1q_1_2} | ${if2_index}
225 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_1} | ${if1_index}
226 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_2} | ${if2_index}
227
228 | Initialize layer dot1q
229 | | [Documentation]
230 | | ... | Dot1q interfaces and variables to be created on all DUT's interfaces.
231 | | ...
232 | | ... | *Arguments:*
233 | | ... | - count - Number of tagged interfaces. Type: integer
234 | | ... | - create - Whether to create vlan for each chain. Type: boolean
235 | | ...
236 | | ... | \| Initialize layer dot1q \| 1 \| True \|
237 | | ...
238 | | [Arguments] | ${count}=${1} | ${create}=${True}
239 | | ...
240 | | :FOR | ${dut} | IN | @{duts}
241 | | | Initialize layer dot1q on node | ${dut} | count=${count}
242 | | | ... | create=${create}
243 | | Set Test Variable | ${prev_layer} | dot1q
244
245 | Initialize layer ip4vxlan on node
246 | | [Documentation]
247 | | ... | Setup VXLANoIPv4 between TG and DUTs and DUT to DUT by connecting
248 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
249 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
250 | | ... | towards TG. VXLAN sub-interfaces has same IPv4 address as interfaces.
251 | | ...
252 | | ... | *Arguments:*
253 | | ... | - dut - DUT node. Type: string
254 | | ... | - count - Number of vxlan interfaces. Type: integer
255 | | ...
256 | | ... | *Example:*
257 | | ...
258 | | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 1 \|
259 | | ...
260 | | [Arguments] | ${dut} | ${count}=${1}
261 | | ...
262 | | ${dut_str}= | Convert To Lowercase | ${dut}
263 | | Configure IP addresses on interfaces
264 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1}
265 | | ... | 172.16.0.1 | 24
266 | | Configure IP addresses on interfaces
267 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2}
268 | | ... | 172.26.0.1 | 24
269 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
270 | | | ${subnet}= | Evaluate | ${id} - 1
271 | | | ${vni}= | Evaluate | ${id} - 1
272 | | | ${ip4vxlan_1}= | Create VXLAN interface
273 | | | ... | ${nodes['${dut}']} | ${vni} | 172.16.0.1 | 172.17.${subnet}.2
274 | | | ${ip4vxlan_2}= | Create VXLAN interface
275 | | | ... | ${nodes['${dut}']} | ${vni} | 172.26.0.1 | 172.27.${subnet}.2
276 | | | ${prev_mac}= | Set Variable If | '${dut}' == 'DUT1'
277 | | | ... | ${tg_if1_mac} | ${dut1_if2_mac}
278 | | | ${next_mac}= | Set Variable If | '${dut}' == 'DUT1' and ${duts_count} == 2
279 | | | ... | ${dut2_if1_mac} | ${tg_if2_mac}
280 | | | VPP Add IP Neighbor
281 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
282 | | | ... | 172.16.${subnet}.2 | ${prev_mac}
283 | | | VPP Add IP Neighbor
284 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
285 | | | ... | 172.26.${subnet}.2 | ${next_mac}
286 | | | VPP Route Add
287 | | | ... | ${nodes['${dut}']} | 172.17.${subnet}.0 | 24
288 | | | ... | gateway=172.16.${subnet}.2
289 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_1}
290 | | | VPP Route Add
291 | | | ... | ${nodes['${dut}']} | 172.27.${subnet}.0 | 24
292 | | | ... | gateway=172.26.${subnet}.2
293 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_2}
294 | | | Set VXLAN Bypass
295 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
296 | | | Set VXLAN Bypass
297 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
298 | | | Set Test Variable
299 | | | ... | ${${dut_str}_ip4vxlan_${id}_1} | ${ip4vxlan_1}
300 | | | Set Test Variable
301 | | | ... | ${${dut_str}_ip4vxlan_${id}_2} | ${ip4vxlan_2}
302
303 | Initialize layer ip4vxlan
304 | | [Documentation]
305 | | ... | VXLAN interfaces and variables to be created on all DUT's interfaces.
306 | | ...
307 | | ... | *Arguments:*
308 | | ... | - count - Number of vxlan interfaces. Type: integer
309 | | ...
310 | | ... | \| Initialize layer ip4vxlan \| 1 \|
311 | | ...
312 | | [Arguments] | ${count}=${1}
313 | | ...
314 | | :FOR | ${dut} | IN | @{duts}
315 | | | Initialize layer ip4vxlan on node | ${dut} | count=${count}
316 | | Set Test Variable | ${prev_layer} | ip4vxlan