+ vlib_log_err (avf_log.class, "%U", format_clib_error, ad->error);
+}
+
+clib_error_t *
+avf_op_program_flow (vlib_main_t *vm, avf_device_t *ad, int is_create,
+ enum virthnl_adv_ops vc_op, u8 *rule, u32 rule_len,
+ u8 *program_status, u32 status_len)
+{
+ virtchnl_ops_t op;
+
+ avf_log_debug (ad, "avf_op_program_flow: vsi_id %u is_create %u", ad->vsi_id,
+ is_create);
+
+ switch (vc_op)
+ {
+ case VIRTCHNL_ADV_OP_ADD_FDIR_FILTER:
+ case VIRTCHNL_ADV_OP_DEL_FDIR_FILTER:
+ op =
+ is_create ? VIRTCHNL_OP_ADD_FDIR_FILTER : VIRTCHNL_OP_DEL_FDIR_FILTER;
+ break;
+ case VIRTCHNL_ADV_OP_ADD_RSS_CFG:
+ case VIRTCHNL_ADV_OP_DEL_RSS_CFG:
+ op = is_create ? VIRTCHNL_OP_ADD_RSS_CFG : VIRTCHNL_OP_DEL_RSS_CFG;
+ break;
+ default:
+ return clib_error_return (0, "invalid virtchnl opcode");
+ ;
+ }
+
+ return avf_send_to_pf (vm, ad, op, rule, rule_len, program_status,
+ status_len);
+}
+
+static void
+avf_process_handle_request (vlib_main_t * vm, avf_process_req_t * req)
+{
+ avf_device_t *ad = avf_get_device (req->dev_instance);
+
+ if (req->type == AVF_PROCESS_REQ_ADD_DEL_ETH_ADDR)
+ req->error = avf_op_add_del_eth_addr (vm, ad, 1, req->eth_addr,
+ req->is_add);
+ else if (req->type == AVF_PROCESS_REQ_CONFIG_PROMISC_MDDE)
+ req->error = avf_op_config_promisc_mode (vm, ad, req->is_enable);
+ else if (req->type == AVF_PROCESS_REQ_PROGRAM_FLOW)
+ req->error = avf_op_program_flow (vm, ad, req->is_add, req->vc_op,
+ req->rule, req->rule_len,
+ req->program_status, req->status_len);
+ else
+ clib_panic ("BUG: unknown avf proceess request type");
+
+ if (req->calling_process_index != avf_process_node.index)
+ vlib_process_signal_event (vm, req->calling_process_index, 0, 0);
+}
+
+static clib_error_t *
+avf_process_request (vlib_main_t * vm, avf_process_req_t * req)
+{
+ uword *event_data = 0;
+ req->calling_process_index = vlib_get_current_process_node_index (vm);
+
+ if (req->calling_process_index != avf_process_node.index)
+ {
+ vlib_process_signal_event_pointer (vm, avf_process_node.index,
+ AVF_PROCESS_EVENT_REQ, req);
+
+ vlib_process_wait_for_event_or_clock (vm, 5.0);
+
+ if (vlib_process_get_events (vm, &event_data) != 0)
+ clib_panic ("avf process node failed to reply in 5 seconds");
+ vec_free (event_data);
+ }
+ else
+ avf_process_handle_request (vm, req);
+
+ return req->error;