+static int
+sfc_flow_parse(struct rte_eth_dev *dev,
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_flow *flow,
+ struct rte_flow_error *error)
+{
+ const struct sfc_flow_ops_by_spec *ops;
+ int rc;
+
+ rc = sfc_flow_parse_attr(attr, flow, error);
+ if (rc != 0)
+ return rc;
+
+ ops = sfc_flow_get_ops_by_spec(flow);
+ if (ops == NULL || ops->parse == NULL) {
+ rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "No backend to handle this flow");
+ return -rte_errno;
+ }
+
+ return ops->parse(dev, pattern, actions, flow, error);
+}
+
+static struct rte_flow *
+sfc_flow_zmalloc(struct rte_flow_error *error)
+{
+ struct rte_flow *flow;
+
+ flow = rte_zmalloc("sfc_rte_flow", sizeof(*flow), 0);
+ if (flow == NULL) {
+ rte_flow_error_set(error, ENOMEM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Failed to allocate memory");
+ }
+
+ return flow;
+}
+
+static void
+sfc_flow_free(__rte_unused struct sfc_adapter *sa, struct rte_flow *flow)
+{
+ rte_free(flow);
+}
+
+static int
+sfc_flow_insert(struct sfc_adapter *sa, struct rte_flow *flow,
+ struct rte_flow_error *error)
+{
+ const struct sfc_flow_ops_by_spec *ops;
+ int rc;
+
+ ops = sfc_flow_get_ops_by_spec(flow);
+ if (ops == NULL || ops->insert == NULL) {
+ rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "No backend to handle this flow");
+ return rte_errno;
+ }
+
+ rc = ops->insert(sa, flow);
+ if (rc != 0) {
+ rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Failed to insert the flow rule");
+ }
+
+ return rc;
+}
+
+static int
+sfc_flow_remove(struct sfc_adapter *sa, struct rte_flow *flow,
+ struct rte_flow_error *error)
+{
+ const struct sfc_flow_ops_by_spec *ops;
+ int rc;
+
+ ops = sfc_flow_get_ops_by_spec(flow);
+ if (ops == NULL || ops->remove == NULL) {
+ rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "No backend to handle this flow");
+ return rte_errno;
+ }
+
+ rc = ops->remove(sa, flow);
+ if (rc != 0) {
+ rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Failed to remove the flow rule");
+ }
+
+ return rc;
+}
+