Enqueue update flow rule operation. */
| 2903 | |
| 2904 | /** Enqueue update flow rule operation. */ |
| 2905 | int |
| 2906 | port_queue_flow_update(portid_t port_id, queueid_t queue_id, |
| 2907 | bool postpone, uint32_t rule_idx, uint32_t actions_idx, |
| 2908 | const struct rte_flow_action *actions) |
| 2909 | { |
| 2910 | struct rte_flow_op_attr op_attr = { .postpone = postpone }; |
| 2911 | struct rte_port *port; |
| 2912 | struct port_flow *pf, *uf; |
| 2913 | struct port_flow **tmp; |
| 2914 | struct port_table *pt; |
| 2915 | bool found; |
| 2916 | struct rte_flow_error error = { RTE_FLOW_ERROR_TYPE_NONE, NULL, NULL }; |
| 2917 | struct rte_flow_action_age *age = age_action_get(actions); |
| 2918 | struct queue_job *job; |
| 2919 | |
| 2920 | if (port_id_is_invalid(port_id, ENABLED_WARN) || |
| 2921 | port_id == (portid_t)RTE_PORT_ALL) |
| 2922 | return -EINVAL; |
| 2923 | port = &ports[port_id]; |
| 2924 | |
| 2925 | if (queue_id >= port->queue_nb) { |
| 2926 | printf("Queue #%u is invalid\n", queue_id); |
| 2927 | return -EINVAL; |
| 2928 | } |
| 2929 | |
| 2930 | found = false; |
| 2931 | tmp = &port->flow_list; |
| 2932 | while (*tmp) { |
| 2933 | pf = *tmp; |
| 2934 | if (rule_idx == pf->id) { |
| 2935 | found = true; |
| 2936 | break; |
| 2937 | } |
| 2938 | tmp = &(*tmp)->next; |
| 2939 | } |
| 2940 | if (!found) { |
| 2941 | printf("Flow rule #%u is invalid\n", rule_idx); |
| 2942 | return -EINVAL; |
| 2943 | } |
| 2944 | |
| 2945 | pt = pf->table; |
| 2946 | if (actions_idx >= pt->nb_actions_templates) { |
| 2947 | printf("Actions template index #%u is invalid," |
| 2948 | " %u templates present in the table\n", |
| 2949 | actions_idx, pt->nb_actions_templates); |
| 2950 | return -EINVAL; |
| 2951 | } |
| 2952 | |
| 2953 | job = calloc(1, sizeof(*job)); |
| 2954 | if (!job) { |
| 2955 | printf("Queue flow create job allocate failed\n"); |
| 2956 | return -ENOMEM; |
| 2957 | } |
| 2958 | job->type = QUEUE_JOB_TYPE_FLOW_UPDATE; |
| 2959 | |
| 2960 | uf = port_flow_new(&pt->flow_attr, pf->rule.pattern_ro, actions, &error); |
| 2961 | if (!uf) { |
| 2962 | free(job); |
no test coverage detected