Query a flow rule. */
| 3786 | |
| 3787 | /** Query a flow rule. */ |
| 3788 | int |
| 3789 | port_flow_query(portid_t port_id, uint64_t rule, |
| 3790 | const struct rte_flow_action *action, bool is_user_id) |
| 3791 | { |
| 3792 | struct rte_flow_error error; |
| 3793 | struct rte_port *port; |
| 3794 | struct port_flow *pf; |
| 3795 | const char *name; |
| 3796 | union { |
| 3797 | struct rte_flow_query_count count; |
| 3798 | struct rte_flow_action_rss rss_conf; |
| 3799 | struct rte_flow_query_age age; |
| 3800 | } query; |
| 3801 | int ret; |
| 3802 | |
| 3803 | if (port_id_is_invalid(port_id, ENABLED_WARN) || |
| 3804 | port_id == (portid_t)RTE_PORT_ALL) |
| 3805 | return -EINVAL; |
| 3806 | port = &ports[port_id]; |
| 3807 | for (pf = port->flow_list; pf; pf = pf->next) |
| 3808 | if ((is_user_id ? pf->user_id : pf->id) == rule) |
| 3809 | break; |
| 3810 | if (!pf) { |
| 3811 | fprintf(stderr, "Flow rule #%"PRIu64" not found\n", rule); |
| 3812 | return -ENOENT; |
| 3813 | } |
| 3814 | ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTION_NAME_PTR, |
| 3815 | &name, sizeof(name), |
| 3816 | (void *)(uintptr_t)action->type, &error); |
| 3817 | if (ret < 0) |
| 3818 | return port_flow_complain(&error); |
| 3819 | switch (action->type) { |
| 3820 | case RTE_FLOW_ACTION_TYPE_COUNT: |
| 3821 | case RTE_FLOW_ACTION_TYPE_RSS: |
| 3822 | case RTE_FLOW_ACTION_TYPE_AGE: |
| 3823 | break; |
| 3824 | default: |
| 3825 | fprintf(stderr, "Cannot query action type %d (%s)\n", |
| 3826 | action->type, name); |
| 3827 | return -ENOTSUP; |
| 3828 | } |
| 3829 | /* Poisoning to make sure PMDs update it in case of error. */ |
| 3830 | memset(&error, 0x55, sizeof(error)); |
| 3831 | memset(&query, 0, sizeof(query)); |
| 3832 | if (rte_flow_query(port_id, pf->flow, action, &query, &error)) |
| 3833 | return port_flow_complain(&error); |
| 3834 | switch (action->type) { |
| 3835 | case RTE_FLOW_ACTION_TYPE_COUNT: |
| 3836 | printf("%s:\n" |
| 3837 | " hits_set: %u\n" |
| 3838 | " bytes_set: %u\n" |
| 3839 | " hits: %" PRIu64 "\n" |
| 3840 | " bytes: %" PRIu64 "\n", |
| 3841 | name, |
| 3842 | query.count.hits_set, |
| 3843 | query.count.bytes_set, |
| 3844 | query.count.hits, |
| 3845 | query.count.bytes); |
no test coverage detected