332ed9368b2de9b1fe8b74ccdac5a6b4c2659bdc
[csit.git] / resources / libraries / robot / performance / performance_limits.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 | 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 | | ... | - overhead - Overhead in bytes; default value: ${0}. Type: integer
28 | |
29 | | ... | *Returns:*
30 | | ... | Average frame size including overhead. Type: float
31 | |
32 | | ... | *Example:*
33 | |
34 | | ... | \| Get Average Frame Size \| IMIX_v4_1 \|
35 | |
36 | | [Arguments] | ${frame_size} | ${overhead}=${0}
37 | |
38 | | ${frame_size} = | Run Keyword If | '${frame_size}' == 'IMIX_v4_1'
39 | | ... | Set Variable | ${353.83333}
40 | | ... | ELSE
41 | | ... | Convert To Number | ${frame_size}
42 | | ${avg_frame_size} = | Evaluate | ${frame_size} + ${overhead}
43 | | Return From Keyword | ${avg_frame_size}
44
45 | Get Maximum Frame Size
46 | | [Documentation]
47 | | ... | Framesize can be either integer in case of a single packet
48 | | ... | in stream, or set of packets in case of IMIX type or simmilar.
49 | |
50 | | ... | *Arguments:*
51 | | ... | - frame_size - Framesize. Type: integer or string
52 | | ... | - overhead - Overhead in bytes; default value: ${0}. Type: integer
53 | |
54 | | ... | *Returns:*
55 | | ... | Maximum frame size including overhead. Type: float
56 | |
57 | | ... | *Example:*
58 | |
59 | | ... | \| Get Maximum Frame Size \| IMIX_v4_1 \|
60 | |
61 | | [Arguments] | ${frame_size} | ${overhead}=${0}
62 | |
63 | | ${frame_size} = | Run Keyword If | '${frame_size}' == 'IMIX_v4_1'
64 | | ... | Set Variable | ${1518}
65 | | ... | ELSE
66 | | ... | Convert To Number | ${frame_size}
67 | | ${max_frame_size} = | Evaluate | ${frame_size} + ${overhead}
68 | | Return From Keyword | ${max_frame_size}
69
70 | Set Max Rate And Jumbo
71 | | [Documentation]
72 | | ... | Input framesize can be either integer in case of a single packet
73 | | ... | in stream, or IMIX string defining mix of packets.
74 | | ... | For jumbo frames detection, the maximal packet size is relevant.
75 | | ... | For maximal transmit rate, the average packet size is relevant.
76 | | ... | In both cases, encapsulation overhead (if any) has effect.
77 | | ... | The maximal rate is computed from NIC name.
78 | | ... | The implementation works by mapping from exact
79 | | ... | whitelisted NIC names.
80 | | ... | The mapping is hardcoded in nic_limits.yaml
81 | | ... | TODO: Make the mapping from NIC names case insensistive.
82 | |
83 | | ... | TODO: Make pps limit also definable per NIC.
84 | |
85 | | ... | This keyword computes maximal unidirectional transmit rate
86 | | ... | and jumbo boolean (some suites need that for configuration decisions).
87 | | ... | To streamline suite autogeneration, both input and output values
88 | | ... | are communicated as test (or broader scope) variables,
89 | | ... | instead of explicit arguments and return values.
90 | |
91 | | ... | *Test (or broader scope) variables read:*
92 | | ... | - nic_name - Name of bottleneck NIC. Type: string
93 | | ... | - overhead - Overhead in bytes; default value: 0. Type: integer
94 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: integer or
95 | | ... | string
96 | |
97 | | ... | *Test variables set:*
98 | | ... | - max_rate - Calculated unidirectional maximal transmit rate [pps].
99 | | ... | Type: float
100 | | ... | - jumbo - Jumbo boolean, true if jumbo packet support has to be
101 | | ... | enabled. Type: boolean
102 | |
103 | | ... | *Example:*
104 | |
105 | | ... | \| Set Test Variable \| \${frame_size} \| IMIX_v4_1 \|
106 | | ... | \| Set Max Rate And Jumbo \|
107 | |
108 | | # Negative overhead is possible, if DUT-DUT traffic is less encapsulated
109 | | # than TG-DUT traffic.
110 | | # TODO: Re-check overhead values in suites with both traffics encapsulated.
111 | | # TODO: Improve layered setup to detect encap/decap and update overhead.
112 | | ${overhead} = | Set Variable If | ${overhead} >= 0 | ${overhead} | ${0}
113 | | ${pps_limit} = | Get From Dictionary
114 | | ... | ${NIC_NAME_TO_PPS_LIMIT} | ${nic_name}
115 | | ${bps_limit} = | Get From Dictionary
116 | | ... | ${NIC_NAME_TO_BPS_LIMIT} | ${nic_name}
117 | | # swo := size_with_overhead
118 | | ${avg_swo} = | Get Average Frame Size | ${frame_size} | ${overhead}
119 | | ${rate} = | Evaluate | ${bps_limit} / ((${avg_swo} + 20.0) * 8)
120 | | ${max_rate} = | Set Variable If | ${rate} > ${pps_limit}
121 | | ... | ${pps_limit} | ${rate}
122 | | Set Test Variable | \${max_rate}
123 | | Set Jumbo
124
125 | Set Jumbo
126 | | [Documentation]
127 | | ... | For jumbo frames detection, the maximal packet size is relevant,
128 | | ... | encapsulation overhead (if any) has effect.
129 | |
130 | | ... | This keyword computes jumbo boolean (some suites need that for
131 | | ... | configuration decisions).
132 | | ... | To streamline suite autogeneration, both input and output values
133 | | ... | are communicated as test (or broader scope) variables,
134 | | ... | instead of explicit arguments and return values.
135 | |
136 | | ... | *Test (or broader scope) variables read:*
137 | | ... | - overhead - Overhead in bytes; default value: 0. Type: integer
138 | | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: integer or
139 | | ... | string
140 | |
141 | | ... | *Test variables set:*
142 | | ... | - jumbo - Jumbo boolean, true if jumbo packet support has to be
143 | | ... | enabled. Type: boolean
144 | |
145 | | ... | *Example:*
146 | |
147 | | ... | \| Set Jumnbo \|
148 | |
149 | | ${overhead} = | Set Variable If | ${overhead} >= 0 | ${overhead} | ${0}
150 | | ${max_swo} = | Get Maximum Frame Size | ${frame_size} | ${overhead}
151 | | ${jumbo} = | Set Variable If | ${max_swo} < 1522
152 | | ... | ${False} | ${True}
153 | | Set Test Variable | \${jumbo}