+ return 0;
+ return 0;
+}
+
+static int
+adjust_flow_attr(const struct rte_flow_attr *attrs,
+ struct rte_flow_attr *vf_attrs,
+ struct rte_flow_error *error)
+{
+ if (!attrs) {
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ATTR,
+ NULL, "no attribute specified");
+ }
+ /*
+ * Swap ingress and egress as the firmware view of direction
+ * is the opposite of the representor.
+ */
+ *vf_attrs = *attrs;
+ if (attrs->ingress && !attrs->egress) {
+ vf_attrs->ingress = 0;
+ vf_attrs->egress = 1;
+ return 0;
+ }
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
+ "representor only supports ingress");
+}
+
+static int
+enic_vf_flow_validate(struct rte_eth_dev *dev,
+ const struct rte_flow_attr *attrs,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_flow_error *error)
+{
+ struct rte_flow_attr vf_attrs;
+ int ret;
+
+ ret = adjust_flow_attr(attrs, &vf_attrs, error);
+ if (ret)
+ return ret;
+ attrs = &vf_attrs;
+ return enic_fm_flow_ops.validate(dev, attrs, pattern, actions, error);
+}
+
+static struct rte_flow *
+enic_vf_flow_create(struct rte_eth_dev *dev,
+ const struct rte_flow_attr *attrs,
+ const struct rte_flow_item pattern[],
+ const struct rte_flow_action actions[],
+ struct rte_flow_error *error)
+{
+ struct rte_flow_attr vf_attrs;
+
+ if (adjust_flow_attr(attrs, &vf_attrs, error))
+ return NULL;
+ attrs = &vf_attrs;
+ return enic_fm_flow_ops.create(dev, attrs, pattern, actions, error);
+}
+
+static int
+enic_vf_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
+ struct rte_flow_error *error)
+{
+ return enic_fm_flow_ops.destroy(dev, flow, error);
+}
+
+static int
+enic_vf_flow_query(struct rte_eth_dev *dev,
+ struct rte_flow *flow,
+ const struct rte_flow_action *actions,
+ void *data,
+ struct rte_flow_error *error)
+{
+ return enic_fm_flow_ops.query(dev, flow, actions, data, error);
+}
+
+static int
+enic_vf_flow_flush(struct rte_eth_dev *dev,
+ struct rte_flow_error *error)
+{
+ return enic_fm_flow_ops.flush(dev, error);
+}
+
+static const struct rte_flow_ops enic_vf_flow_ops = {
+ .validate = enic_vf_flow_validate,
+ .create = enic_vf_flow_create,
+ .destroy = enic_vf_flow_destroy,
+ .flush = enic_vf_flow_flush,
+ .query = enic_vf_flow_query,
+};
+
+static int
+enic_vf_flow_ops_get(struct rte_eth_dev *eth_dev,
+ const struct rte_flow_ops **ops)
+{
+ struct enic_vf_representor *vf;
+
+ ENICPMD_FUNC_TRACE();
+ vf = eth_dev->data->dev_private;
+ if (vf->enic.flow_filter_mode != FILTER_FLOWMAN) {
+ ENICPMD_LOG(WARNING,
+ "VF representors require flowman support for rte_flow API");
+ return -EINVAL;
+ }
+
+ *ops = &enic_vf_flow_ops;
+ return 0;