MCPcopy Create free account
hub / github.com/F-Stack/f-stack / meters_handler

Function meters_handler

dpdk/app/test-flow-perf/main.c:1200–1258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1198}
1199
1200static void
1201meters_handler(int port_id, uint8_t core_id, uint8_t ops)
1202{
1203 uint64_t start_batch;
1204 double cpu_time_used, insertion_rate;
1205 int rules_count_per_core, rules_batch_idx;
1206 uint32_t counter, start_counter = 0, end_counter;
1207 double cpu_time_per_batch[MAX_BATCHES_COUNT] = { 0 };
1208
1209 rules_count_per_core = rules_count / mc_pool.cores_count;
1210
1211 if (core_id)
1212 start_counter = core_id * rules_count_per_core;
1213 end_counter = (core_id + 1) * rules_count_per_core;
1214
1215 cpu_time_used = 0;
1216 start_batch = rte_get_timer_cycles();
1217 for (counter = start_counter; counter < end_counter; counter++) {
1218 if (ops == METER_CREATE)
1219 create_meter_rule(port_id, counter);
1220 else
1221 destroy_meter_rule(port_id, counter);
1222 /*
1223 * Save the insertion rate for rules batch.
1224 * Check if the insertion reached the rules
1225 * patch counter, then save the insertion rate
1226 * for this batch.
1227 */
1228 if (!((counter + 1) % rules_batch)) {
1229 rules_batch_idx = ((counter + 1) / rules_batch) - 1;
1230 cpu_time_per_batch[rules_batch_idx] =
1231 ((double)(rte_get_timer_cycles() - start_batch))
1232 / rte_get_timer_hz();
1233 cpu_time_used += cpu_time_per_batch[rules_batch_idx];
1234 start_batch = rte_get_timer_cycles();
1235 }
1236 }
1237
1238 /* Print insertion rates for all batches */
1239 if (dump_iterations)
1240 print_rules_batches(cpu_time_per_batch);
1241
1242 insertion_rate =
1243 ((double) (rules_count_per_core / cpu_time_used) / 1000);
1244
1245 /* Insertion rate for all rules in one core */
1246 printf(":: Port %d :: Core %d Meter %s :: start @[%d] - end @[%d],"
1247 " use:%.02fs, rate:%.02fk Rule/Sec\n",
1248 port_id, core_id, ops == METER_CREATE ? "create" : "delete",
1249 start_counter, end_counter - 1,
1250 cpu_time_used, insertion_rate);
1251
1252 if (ops == METER_CREATE)
1253 mc_pool.meters_record.insertion[port_id][core_id]
1254 = cpu_time_used;
1255 else
1256 mc_pool.meters_record.deletion[port_id][core_id]
1257 = cpu_time_used;

Callers 1

flows_handlerFunction · 0.85

Calls 4

create_meter_ruleFunction · 0.85
destroy_meter_ruleFunction · 0.85
print_rules_batchesFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected