List simply and destroy all aged flows per queue. */
| 3396 | |
| 3397 | /** List simply and destroy all aged flows per queue. */ |
| 3398 | void |
| 3399 | port_queue_flow_aged(portid_t port_id, uint32_t queue_id, uint8_t destroy) |
| 3400 | { |
| 3401 | void **contexts; |
| 3402 | int nb_context, total = 0, idx; |
| 3403 | uint64_t *rules = NULL; |
| 3404 | struct rte_port *port; |
| 3405 | struct rte_flow_error error; |
| 3406 | enum age_action_context_type *type; |
| 3407 | union { |
| 3408 | struct port_flow *pf; |
| 3409 | struct port_indirect_action *pia; |
| 3410 | } ctx; |
| 3411 | |
| 3412 | if (port_id_is_invalid(port_id, ENABLED_WARN) || |
| 3413 | port_id == (portid_t)RTE_PORT_ALL) |
| 3414 | return; |
| 3415 | port = &ports[port_id]; |
| 3416 | if (queue_id >= port->queue_nb) { |
| 3417 | printf("Error: queue #%u is invalid\n", queue_id); |
| 3418 | return; |
| 3419 | } |
| 3420 | total = rte_flow_get_q_aged_flows(port_id, queue_id, NULL, 0, &error); |
| 3421 | if (total < 0) { |
| 3422 | port_flow_complain(&error); |
| 3423 | return; |
| 3424 | } |
| 3425 | printf("Port %u queue %u total aged flows: %d\n", |
| 3426 | port_id, queue_id, total); |
| 3427 | if (total == 0) |
| 3428 | return; |
| 3429 | contexts = calloc(total, sizeof(void *)); |
| 3430 | if (contexts == NULL) { |
| 3431 | printf("Cannot allocate contexts for aged flow\n"); |
| 3432 | return; |
| 3433 | } |
| 3434 | printf("%-20s\tID\tGroup\tPrio\tAttr\n", "Type"); |
| 3435 | nb_context = rte_flow_get_q_aged_flows(port_id, queue_id, contexts, |
| 3436 | total, &error); |
| 3437 | if (nb_context > total) { |
| 3438 | printf("Port %u queue %u get aged flows count(%d) > total(%d)\n", |
| 3439 | port_id, queue_id, nb_context, total); |
| 3440 | free(contexts); |
| 3441 | return; |
| 3442 | } |
| 3443 | if (destroy) { |
| 3444 | rules = malloc(sizeof(uint32_t) * nb_context); |
| 3445 | if (rules == NULL) |
| 3446 | printf("Cannot allocate memory for destroy aged flow\n"); |
| 3447 | } |
| 3448 | total = 0; |
| 3449 | for (idx = 0; idx < nb_context; idx++) { |
| 3450 | if (!contexts[idx]) { |
| 3451 | printf("Error: get Null context in port %u queue %u\n", |
| 3452 | port_id, queue_id); |
| 3453 | continue; |
| 3454 | } |
| 3455 | type = (enum age_action_context_type *)contexts[idx]; |
no test coverage detected