759ee5c28f2620de9f0d104dccc4a76710e10c4b
[csit.git] / resources / libraries / robot / performance / performance_limits.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
14 *** Settings ***
15 | Documentation | Performance suite keywords - Handling NIC and TG limits.
16 | Library | Collections
17 | Variables | ${CURDIR}/../../python/Constants.py
18
19 *** Keywords ***
20 | Get Average Frame Size
21 | | [Documentation]
22 | | ... | Framesize can be either integer in case of a single packet
23 | | ... | in stream, or set of packets in case of IMIX type or simmilar.
24 | | ...
25 | | ... | *Arguments:*
26 | | ... | - frame_size - Framesize. Type: integer or string
27 | | ...
28 | | ... | *Returns:*
29 | | ... | Average frame size. Type: float
30 | | ...
31 | | ... | *Example:*
32 | | ...
33 | | ... | \| Get Average Frame Size \| IMIX_v4_1 \|
34 | | ...
35 | | [Arguments] | ${frame_size}
36 | | ...
37 | | Return From Keyword If | '${frame_size}' == 'IMIX_v4_1' | ${353.83333}
38 | | ${frame_size} = | Convert To Number | ${frame_size}
39 | | Return From Keyword | ${frame_size}
40
41 | Set Max Rate And Jumbo
42 | | [Documentation]
43 | | ... | Input framesize can be either integer in case of a single packet
44 | | ... | in stream, or IMIX string defining mix of packets.
45 | | ... | For jumbo frames detection, the maximal packet size is relevant.
46 | | ... | For maximal transmit rate, the average packet size is relevant.
47 | | ... | In both cases, encapsulation overhead (if any) has effect.
48 | | ... | The maximal rate is computed from NIC name.
49 | | ... | The implementation works by mapping from exact
50 | | ... | whitelisted NIC names.
51 | | ... | The mapping is hardcoded in nic_limits.yaml
52 | | ... | TODO: Make the mapping from NIC names case insensistive.
53 | | ...
54 | | ... | TODO: Make pps limit also definable per NIC.
55 | | ...
56 | | ... | This keyword computes maximal unidirectional transmit rate
57 | | ... | and jumbo boolean (some suites need that for configuration decisions).
58 | | ... | To streamline suite autogeneration, both input and output values
59 | | ... | are communicated as test (or broader scope) variables,
60 | | ... | instead of explicit arguments and return values.
61 | | ...
62 | | ... | *Test (or broader scope) variables read:*
63 | | ... |   - nic_name - Name of bottleneck NIC. Type: string
64 | | ... |   - overhead - Overhead in bytes. Default: 0. Type: integer
65 | | ... |   - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
66 | | ...
67 | | ... | *Test variables set:*
68 | | ... |   - max_rate - Calculated unidirectional maximal transmit rate [pps].
69 | | ... |     Type: float
70 | | ... |   - jumbo - Jumbo boolean, true if jumbo packet support
71 | | ... |     has to be enabled. Type: boolean
72 | | ...
73 | | ... | *Example:*
74 | | ...
75 | | ... | \| Set test Variable \| \${frame_size} \| IMIX_v4_1 \|
76 | | ... | \| Set Max Rate And Jumbo \|
77 | | ...
78 | | ${pps_limit} = | Set Variable | ${18750000.0}
79 | | ${bps_limit} = | Get From Dictionary | ${NIC_NAME_TO_LIMIT} | ${nic_name}
80 | | ${avg_size} = | Get Average Frame Size | ${frame_size}
81 | | ${max_size} = | Set Variable If | '${frame_size}' == 'IMIX_v4_1'
82 | | ... | ${1518} | ${frame_size}
83 | | # swo := size_with_overhead
84 | | ${avg_swo} = | Evaluate | ${avg_size} + ${overhead}
85 | | ${max_swo} = | Evaluate | ${max_size} + ${overhead}
86 | | ${jumbo} = | Set Variable If | ${max_swo} < 1522
87 | | ... | ${False} | ${True}
88 | | ${rate} = | Evaluate | ${bps_limit} / ((${avg_swo} + 20.0) * 8)
89 | | ${max_rate} = | Set Variable If | ${rate} > ${pps_limit}
90 | | ... | ${pps_limit} | ${rate}
91 | | Set Test Variable | \${jumbo}
92 | | Set Test Variable | \${max_rate}
93
94 | Set Max Rate And Jumbo And Handle Multi Seg
95 | | [Documentation]
96 | | ... | This keyword starts with Get Max Rate And Jumbo keyword,
97 | | ... | then adds correct multi seg VPP configuration.
98 | | ...
99 | | ... | See Documentation of Set Max Rate And Jumbo for more details.
100 | | ...
101 | | ... | *Test (or broader scope) variables read:*
102 | | ... |   - nic_name - Name of bottleneck NIC. Type: string
103 | | ... |   - overhead - Overhead in bytes. Default: 0. Type: integer
104 | | ... |   - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
105 | | ...
106 | | ... | *Test variables set:*
107 | | ... |   - max_rate - Calculated unidirectional maximal transmit rate [pps].
108 | | ... |     Type: float
109 | | ... |   - jumbo - Jumbo boolean, true if jumbo packet support
110 | | ... |     has to be enabled. Type: boolean
111 | | ...
112 | | ... | *Example:*
113 | | ...
114 | | ... | \| Set Max Rate And Jumbo And Handle Multi Seg \|
115 | | ...
116 | | Set Max Rate And Jumbo
117 | | Run Keyword If | not ${jumbo} | Add no multi seg to all DUTs