app/flow-perf: add random priority option

Added support to create flows with priority attribute set
randomly between 0 and a user supplied maximum value. This
is useful to measure performance on NICs which may have to
rearrange flows to honor flow priority.

Removed the lower limit of 100000 flows per batch.

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>
This commit is contained in:
Satheesh Paul 2021-11-02 16:20:41 +05:30 committed by Thomas Monjalon
parent f66898ebd0
commit fda3750de6
4 changed files with 47 additions and 20 deletions

View File

@ -18,7 +18,7 @@
static void
fill_attributes(struct rte_flow_attr *attr,
uint64_t *flow_attrs, uint16_t group)
uint64_t *flow_attrs, uint16_t group, uint8_t max_priority)
{
uint8_t i;
for (i = 0; i < MAX_ATTRS_NUM; i++) {
@ -32,6 +32,7 @@ fill_attributes(struct rte_flow_attr *attr,
attr->transfer = 1;
}
attr->group = group;
attr->priority = rte_rand_max(max_priority);
}
struct rte_flow *
@ -49,6 +50,7 @@ generate_flow(uint16_t port_id,
uint8_t core_idx,
uint8_t rx_queues_count,
bool unique_data,
uint8_t max_priority,
struct rte_flow_error *error)
{
struct rte_flow_attr attr;
@ -60,7 +62,7 @@ generate_flow(uint16_t port_id,
memset(actions, 0, sizeof(actions));
memset(&attr, 0, sizeof(struct rte_flow_attr));
fill_attributes(&attr, flow_attrs, group);
fill_attributes(&attr, flow_attrs, group, max_priority);
fill_actions(actions, flow_actions,
outer_ip_src, next_table, hairpinq,

View File

@ -38,6 +38,7 @@ generate_flow(uint16_t port_id,
uint8_t core_idx,
uint8_t rx_queues_count,
bool unique_data,
uint8_t max_priority,
struct rte_flow_error *error);
#endif /* FLOW_PERF_FLOW_GEN */

View File

@ -78,6 +78,8 @@ static uint32_t rules_count;
static uint32_t rules_batch;
static uint32_t hairpin_queues_num; /* total hairpin q number - default: 0 */
static uint32_t nb_lcores;
static uint8_t max_priority;
static uint32_t rand_seed;
#define MAX_PKT_BURST 32
#define LCORE_MODE_PKT 1
@ -141,6 +143,9 @@ usage(char *progname)
printf(" --enable-fwd: To enable packets forwarding"
" after insertion\n");
printf(" --portmask=N: hexadecimal bitmask of ports used\n");
printf(" --random-priority=N,S: use random priority levels "
"from 0 to (N - 1) for flows "
"and S as seed for pseudo-random number generator\n");
printf(" --unique-data: flag to set using unique data for all"
" actions that support data, such as header modify and encap actions\n");
@ -239,8 +244,9 @@ usage(char *progname)
static void
args_parse(int argc, char **argv)
{
uint64_t pm;
uint64_t pm, seed;
char **argvopt;
uint32_t prio;
char *token;
char *end;
int n, opt;
@ -590,6 +596,7 @@ args_parse(int argc, char **argv)
{ "unique-data", 0, 0, 0 },
{ "portmask", 1, 0, 0 },
{ "cores", 1, 0, 0 },
{ "random-priority", 1, 0, 0 },
{ "meter-profile-alg", 1, 0, 0 },
{ "rxq", 1, 0, 0 },
{ "txq", 1, 0, 0 },
@ -771,25 +778,26 @@ args_parse(int argc, char **argv)
/* Control */
if (strcmp(lgopts[opt_idx].name,
"rules-batch") == 0) {
n = atoi(optarg);
if (n >= DEFAULT_RULES_BATCH)
rules_batch = n;
else {
rte_exit(EXIT_FAILURE,
"rules_batch should be >= %d\n",
DEFAULT_RULES_BATCH);
}
rules_batch = atoi(optarg);
}
if (strcmp(lgopts[opt_idx].name,
"rules-count") == 0) {
n = atoi(optarg);
if (n >= (int) rules_batch)
rules_count = n;
else {
rules_count = atoi(optarg);
}
if (strcmp(lgopts[opt_idx].name, "random-priority") ==
0) {
end = NULL;
prio = strtol(optarg, &end, 10);
if ((optarg[0] == '\0') || (end == NULL))
rte_exit(EXIT_FAILURE,
"rules_count should be >= %d\n",
rules_batch);
}
"Invalid value for random-priority\n");
max_priority = prio;
token = end + 1;
seed = strtoll(token, &end, 10);
if ((token[0] == '\0') || (*end != '\0'))
rte_exit(EXIT_FAILURE,
"Invalid value for random-priority\n");
rand_seed = seed;
}
if (strcmp(lgopts[opt_idx].name,
"dump-iterations") == 0)
@ -877,6 +885,16 @@ args_parse(int argc, char **argv)
break;
}
}
if (rules_count % rules_batch != 0) {
rte_exit(EXIT_FAILURE,
"rules_count %% rules_batch should be 0\n");
}
if (rules_count / rules_batch > MAX_BATCHES_COUNT) {
rte_exit(EXIT_FAILURE,
"rules_count / rules_batch should be <= %d\n",
MAX_BATCHES_COUNT);
}
printf("end_flow\n");
}
@ -1242,7 +1260,7 @@ insert_flows(int port_id, uint8_t core_id, uint16_t dst_port_id)
flow = generate_flow(port_id, 0, flow_attrs,
global_items, global_actions,
flow_group, 0, 0, 0, 0, dst_port_id, core_id,
rx_queues_count, unique_data, &error);
rx_queues_count, unique_data, max_priority, &error);
if (flow == NULL) {
print_flow_error(error);
@ -1259,7 +1277,7 @@ insert_flows(int port_id, uint8_t core_id, uint16_t dst_port_id)
hairpin_queues_num, encap_data,
decap_data, dst_port_id,
core_id, rx_queues_count,
unique_data, &error);
unique_data, max_priority, &error);
if (!counter) {
first_flow_latency = (double) (rte_get_timer_cycles() - start_batch);
@ -1992,6 +2010,8 @@ main(int argc, char **argv)
printf(":: Flows Count per port: %d\n\n", rules_count);
rte_srand(rand_seed);
if (has_meter())
create_meter_profile();
rte_eal_mp_remote_launch(run_rte_flow_handler_cores, NULL, CALL_MAIN);

View File

@ -100,6 +100,10 @@ The command line options are:
Set the number of needed cores to insert/delete rte_flow rules.
Default cores count is 1.
* ``--random-priority=N,S``
Create flows with the priority attribute set randomly between 0 to N - 1
and use S as seed for the pseudo-random number generator.
* ``--meter-profile-alg``
Set the traffic metering algorithm.
Example: meter-profile-alg=srtcmp, default algorithm is srtcm_rfc2697