Improve pf layer
[csit.git] / resources / libraries / robot / shared / suite_setup.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 """Keywords used in suite setups."""
15
16 *** Settings ***
17 | Library | resources.libraries.python.DPDK.DPDKTools
18 | Library | resources.libraries.python.InterfaceUtil
19 | Library | resources.libraries.python.NodePath
20 | Library | resources.libraries.python.topology.Topology
21 | Library | resources.libraries.python.TrafficGenerator
22 | Library | resources.tools.wrk.wrk
23 | Variables | resources/libraries/python/Constants.py
24 | Resource | resources/libraries/robot/wrk/wrk_utils.robot
25 |
26 | Documentation | Suite setup keywords.
27
28 *** Keywords ***
29 | Setup suite topology interfaces
30 | | [Documentation]
31 | | ... | Common suite setup for one to multiple link tests.
32 | | ... |
33 | | ... | Compute path for testing on given topology nodes in circular topology
34 | | ... | based on interface model provided as an argument and set
35 | | ... | corresponding suite variables.
36 | |
37 | | ... | _NOTE:_ This KW sets various suite variables based on filtered
38 | | ... | topology. All variables are set with also backward compatibility
39 | | ... | format dut{m}_if{n} (where the value type is string).
40 | | ... | List type allows to access physical interfaces in same way as
41 | | ... | virtual interface (e.g. SRIOV). This keeps abstracted compatibility
42 | | ... | between existing L1 and L2 KWs library and underlaying physical
43 | | ... | topology.
44 | |
45 | | ... | - duts - List of DUT nodes (name as seen in topology file).
46 | | ... | - duts_count - Number of DUT nodes.
47 | | ... | - int - Interfacy type (layer).
48 | | ... | Type: string
49 | | ... | - dut{n} - DUTx node.
50 | | ... | Type: dictionary
51 | | ... | - dut{m}_pf{n} - Nth interface of Mth DUT.
52 | | ... | Type: list
53 | | ... | - dut{m}_pf{n}_mac - Nth interface of Mth DUT - MAC address.
54 | | ... | Type: list
55 | | ... | - dut{m}_pf{n}_vlan - Nth interface of Mth DUT - VLAN id.
56 | | ... | Type: list
57 | | ... | - dut{m}_pf{n}_pci - Nth interface of Mth DUT - PCI address.
58 | | ... | Type: list
59 | | ... | - dut{m}_pf{n}_ip4_addr - Nth interface of Mth DUT - IPv4 address.
60 | | ... | Type: list
61 | | ... | - dut{m}_pf{n}_ip4_prefix - Nth interface of Mth DUT - IPv4 prefix.
62 | | ... | Type: list
63 | |
64 | | ... | *Arguments:*
65 | | ... | - ${actions} - Additional setup action. Type: list
66 | |
67 | | [Arguments] | @{actions}
68 | |
69 | | ${nic_model_list}= | Create list | ${nic_name}
70 | | &{info}= | Compute Circular Topology
71 | | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
72 | | ${variables}= | Get Dictionary Keys | ${info}
73 | | FOR | ${variable} | IN | @{variables}
74 | | | ${value}= | Get From Dictionary | ${info} | ${variable}
75 | | | Set Suite Variable | ${${variable}} | ${value}
76 | | END
77 | | FOR | ${action} | IN | @{actions}
78 | | | Run Keyword | Additional Suite setup Action For ${action}
79 | | END
80
81 | Setup suite single link no tg
82 | | [Documentation]
83 | | ... | Common suite setup for single link tests.
84 | | ... |
85 | | ... | Compute path for testing on two given nodes in circular topology
86 | | ... | based on interface model provided as an argument and set
87 | | ... | corresponding suite variables.
88 | |
89 | | ... | _NOTE:_ This KW sets following suite variables:
90 | | ... | - duts - List of DUT nodes
91 | | ... | - duts_count - Number of DUT nodes.
92 | | ... | - dut{n} - DUTx node
93 | | ... | - dut{n}_if1 - 1st DUT interface.
94 | | ... | - dut{n}_if1_mac - 1st DUT interface MAC address.
95 | | ... | - dut{n}_if2 - 2nd DUT interface.
96 | | ... | - dut{n}_if2_mac - 2nd DUT interface MAC address.
97 | |
98 | | ... | *Arguments:*
99 | | ... | - ${actions} - Additional setup action. Type: list
100 | |
101 | | [Arguments] | @{actions}
102 | |
103 | | ${nic_model_list}= | Create list | ${nic_name}
104 | | ${duts}= | Get Matches | ${nodes} | DUT*
105 | | FOR | ${dut} | IN | @{duts}
106 | | | Append Node | ${nodes['${dut}']} | filter_list=${nic_model_list}
107 | | END
108 | | Append Node | ${nodes['@{duts}[0]']} | filter_list=${nic_model_list}
109 | | Compute Path | always_same_link=${TRUE}
110 | | FOR | ${i} | IN RANGE | 1 | ${DATAPATH_INTERFACES_MAX}
111 | | | ${dutx_if} | ${dutx}= | Next Interface
112 | | | Run Keyword If | '${dutx_if}' == 'None' | EXIT FOR LOOP
113 | | | ${dutx_if_mac}= | Get Interface MAC | ${dutx} | ${dutx_if}
114 | | | ${dutx_if_ip4_addr}= | Get Interface Ip4 | ${dutx} | ${dutx_if}
115 | | | ${dutx_if_ip4_prefix_length}= | Get Interface Ip4 Prefix Length
116 | | | ... | ${dutx} | ${dutx_if}
117 | | | ${dut_str}= | Get Keyname For DUT | ${dutx} | ${duts}
118 | | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
119 | | | ... | Variable Should Exist | ${${dut_str}_if1}
120 | | | ${if_name}= | Set Variable If | '${if1_status}' == 'PASS'
121 | | | ... | if2 | if1
122 | | | Set Suite Variable | ${${dut_str}} | ${dutx}
123 | | | Set Suite Variable | ${${dut_str}_${if_name}} | ${dutx_if}
124 | | | Set Suite Variable | ${${dut_str}_${if_name}_mac} | ${dutx_if_mac}
125 | | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_addr}
126 | | | ... | ${dutx_if_ip4_addr}
127 | | | Set Suite Variable | ${${dut_str}_${if_name}_ip4_prefix}
128 | | | ... | ${dutx_if_ip4_prefix_length}
129 | | END
130 | | Run Keyword If | ${i}>${DATAPATH_INTERFACES_MAX}
131 | | ... | Fatal Error | Datapath length exceeded
132 | | ${duts_count}= | Get Length | ${duts}
133 | | Set Suite Variable | ${duts}
134 | | Set Suite Variable | ${duts_count}
135 | | FOR | ${action} | IN | @{actions}
136 | | | Run Keyword | Additional Suite setup Action For ${action}
137 | | END
138
139 | Additional Suite Setup Action For scapy
140 | | [Documentation]
141 | | ... | Additional Setup for suites which uses scapy as Traffic generator.
142 | |
143 | | FOR | ${dut} | IN | @{duts}
144 | | | Set Suite Variable | ${${dut}_vf1} | ${${dut}_${int}1}
145 | | | Set Suite Variable | ${${dut}_vf2} | ${${dut}_${int}2}
146 | | END
147 | | Set Interface State | ${tg} | ${TG_pf1}[0] | up
148 | | Set Interface State | ${tg} | ${TG_pf2}[0] | up
149
150 | Additional Suite Setup Action For dpdk
151 | | [Documentation]
152 | | ... | Additional Setup for suites which uses dpdk.
153 | |
154 | | FOR | ${dut} | IN | @{duts}
155 | | | Initialize DPDK Environment | ${nodes['${dut}']}
156 | | | ... | ${${dut}_${int}1}[0] | ${${dut}_${int}2}[0]
157 | | END
158
159 | Additional Suite Setup Action For performance vf
160 | | [Documentation]
161 | | ... | Additional Setup for suites which uses performance measurement for
162 | | ... | single DUT (inner loop).
163 | |
164 | | ... | *Arguments:*
165 | | ... | - dut - DUT node. Type: string
166 | |
167 | | ... | *Example:*
168 | |
169 | | ... | \| Additional Suite Setup Action For performance_dut \| DUT1 \|
170 | |
171 | | [Arguments] | ${dut}
172 | |
173 | | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
174 | | | ${_vf}=
175 | | | ... | Run Keyword | Init ${nic_driver} interface
176 | | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | numvfs=${nic_vfs}
177 | | | ... | osi_layer=${osi_layer}
178 | | | ${_mac}=
179 | | | ... | Create List | ${EMPTY}
180 | | | ${_ip4_addr}=
181 | | | ... | Create List | ${EMPTY}
182 | | | ${_ip4_prefix}=
183 | | | ... | Create List | ${EMPTY}
184 | | | ${_pci}=
185 | | | ... | Create List | ${EMPTY}
186 | | | ${_vlan}=
187 | | | ... | Create List | ${EMPTY}
188 | | | Set Suite Variable
189 | | | ... | ${${dut}_prevf${pf}} | ${_vf}
190 | | | Set Suite Variable
191 | | | ... | ${${dut}_prevf${pf}_ip4_addr} | ${_ip4_addr}
192 | | | Set Suite Variable
193 | | | ... | ${${dut}_prevf${pf}_ip4_prefix} | ${_ip4_prefix}
194 | | | Set Suite Variable
195 | | | ... | ${${dut}_prevf${pf}_mac} | ${_mac}
196 | | | Set Suite Variable
197 | | | ... | ${${dut}_prevf${pf}_pci} | ${_pci}
198 | | | Set Suite Variable
199 | | | ... | ${${dut}_prevf${pf}_vlan} | ${_vlan}
200 | | END
201 | | Set Suite Variable
202 | | ... | ${int} | prevf
203
204 | Additional Suite Setup Action For performance
205 | | [Documentation]
206 | | ... | Additional Setup for suites which uses performance measurement.
207 | |
208 | | FOR | ${dut} | IN | @{duts}
209 | | | Run Keyword If | ${nic_vfs} > 0
210 | | | ... | Additional Suite Setup Action For performance vf | ${dut}
211 | | END
212 | | Initialize traffic generator
213 | | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0]
214 | | ... | ${dut1} | ${DUT1_${int}1}[0]
215 | | ... | ${dut${duts_count}} | ${DUT${duts_count}_${int}2}[0]
216 | | ... | ${osi_layer}
217
218 | Additional Suite Setup Action For ipsechw
219 | | [Documentation]
220 | | ... | Additional Setup for suites which uses QAT HW.
221 | |
222 | | ${numvfs}= | Set Variable If
223 | | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
224 | | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
225 | | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
226 | | ... | force_init=${True}
227 | | Configure kernel module on all DUTs | vfio_pci | force_load=${True}
228
229 | Additional Suite Setup Action For wrk
230 | | [Documentation]
231 | | ... | Additional Setup for suites which uses WRK TG.
232 | |
233 | | Verify Program Installed | ${tg} | wrk
234 | | Iface update numa node | ${tg}
235 # Make sure TRex is stopped
236 | | ${running}= | Is TRex running | ${tg}
237 | | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
238 | | ${curr_driver}= | Get PCI dev driver | ${tg}
239 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
240 | | Run keyword if | '${curr_driver}'!='${None}'
241 | | ... | PCI Driver Unbind | ${tg} |
242 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
243 # Bind tg_if1 to driver specified in the topology
244 | | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
245 | | PCI Driver Bind | ${tg}
246 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
247 # Set IP on tg_if1
248 | | ${intf_name}= | Get Linux interface name | ${tg}
249 | | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
250 | | FOR | ${ip_addr} | IN | @{wrk_ip_addrs}
251 | | | ${ip_addr_on_intf}= | Linux interface has IP | ${tg} | ${intf_name}
252 | | | ... | ${ip_addr} | ${wrk_ip_prefix}
253 | | | Run Keyword If | ${ip_addr_on_intf}==${False} | Set Linux interface IP
254 | | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${wrk_ip_prefix}
255 | | END
256 | | Set Linux interface up | ${tg} | ${intf_name}
257 | | Check wrk | ${tg}