+static int
+sfc_mae_rule_parse_action(const struct rte_flow_action *action,
+ __rte_unused efx_mae_actions_t *spec,
+ struct rte_flow_error *error)
+{
+ switch (action->type) {
+ default:
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+ "Unsupported action");
+ }
+
+ return 0;
+}
+
+int
+sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
+ const struct rte_flow_action actions[],
+ struct sfc_mae_action_set **action_setp,
+ struct rte_flow_error *error)
+{
+ const struct rte_flow_action *action;
+ efx_mae_actions_t *spec;
+ int rc;
+
+ if (actions == NULL) {
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION_NUM, NULL,
+ "NULL actions");
+ }
+
+ rc = efx_mae_action_set_spec_init(sa->nic, &spec);
+ if (rc != 0)
+ goto fail_action_set_spec_init;
+
+ for (action = actions;
+ action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
+ rc = sfc_mae_rule_parse_action(action, spec, error);
+ if (rc != 0)
+ goto fail_rule_parse_action;
+ }
+
+ *action_setp = sfc_mae_action_set_attach(sa, spec);
+ if (*action_setp != NULL) {
+ efx_mae_action_set_spec_fini(sa->nic, spec);
+ return 0;
+ }
+
+ rc = sfc_mae_action_set_add(sa, spec, action_setp);
+ if (rc != 0)
+ goto fail_action_set_add;
+
+ return 0;
+
+fail_action_set_add:
+fail_rule_parse_action:
+ efx_mae_action_set_spec_fini(sa->nic, spec);
+
+fail_action_set_spec_init:
+ if (rc > 0) {
+ rc = rte_flow_error_set(error, rc,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Failed to process the action");
+ }
+ return rc;
+}
+