* Copyright 2018 Mellanox Technologies, Ltd
*/
+#include <stddef.h>
+#include <string.h>
#include <sys/queue.h>
+#include <rte_errno.h>
#include <rte_malloc.h>
#include <rte_tailq.h>
#include <rte_flow.h>
-#include "rte_eth_bond_private.h"
+#include "eth_bond_private.h"
static struct rte_flow *
bond_flow_alloc(int numa_node, const struct rte_flow_attr *attr,
const struct rte_flow_action *actions)
{
struct rte_flow *flow;
- size_t fdsz;
+ const struct rte_flow_conv_rule rule = {
+ .attr_ro = attr,
+ .pattern_ro = items,
+ .actions_ro = actions,
+ };
+ struct rte_flow_error error;
+ int ret;
- fdsz = rte_flow_copy(NULL, 0, attr, items, actions);
- flow = rte_zmalloc_socket(NULL, sizeof(struct rte_flow) + fdsz,
+ ret = rte_flow_conv(RTE_FLOW_CONV_OP_RULE, NULL, 0, &rule, &error);
+ if (ret < 0) {
+ RTE_BOND_LOG(ERR, "Unable to process flow rule (%s): %s",
+ error.message ? error.message : "unspecified",
+ strerror(rte_errno));
+ return NULL;
+ }
+ flow = rte_zmalloc_socket(NULL, offsetof(struct rte_flow, rule) + ret,
RTE_CACHE_LINE_SIZE, numa_node);
if (unlikely(flow == NULL)) {
RTE_BOND_LOG(ERR, "Could not allocate new flow");
return NULL;
}
- flow->fd = (void *)((uintptr_t)flow + sizeof(*flow));
- if (unlikely(rte_flow_copy(flow->fd, fdsz, attr, items, actions) !=
- fdsz)) {
- RTE_BOND_LOG(ERR, "Failed to copy flow description");
+ ret = rte_flow_conv(RTE_FLOW_CONV_OP_RULE, &flow->rule, ret, &rule,
+ &error);
+ if (ret < 0) {
+ RTE_BOND_LOG(ERR, "Failed to copy flow rule (%s): %s",
+ error.message ? error.message : "unspecified",
+ strerror(rte_errno));
rte_free(flow);
return NULL;
}
/* Destroy all bond flows from its slaves instead of flushing them to
* keep the LACP flow or any other external flows.
*/
- TAILQ_FOREACH_SAFE(flow, &internals->flow_list, next, tmp) {
+ RTE_TAILQ_FOREACH_SAFE(flow, &internals->flow_list, next, tmp) {
lret = bond_flow_destroy(dev, flow, err);
if (unlikely(lret != 0))
ret = lret;
static int
bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
+ const struct rte_flow_action *action,
struct rte_flow_query_count *count,
struct rte_flow_error *err)
{
rte_memcpy(&slave_count, count, sizeof(slave_count));
for (i = 0; i < internals->slave_count; i++) {
ret = rte_flow_query(internals->slaves[i].port_id,
- flow->flows[i], RTE_FLOW_ACTION_TYPE_COUNT,
+ flow->flows[i], action,
&slave_count, err);
if (unlikely(ret != 0)) {
RTE_BOND_LOG(ERR, "Failed to query flow on"
static int
bond_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
- enum rte_flow_action_type type, void *arg,
+ const struct rte_flow_action *action, void *arg,
struct rte_flow_error *err)
{
- switch (type) {
+ switch (action->type) {
case RTE_FLOW_ACTION_TYPE_COUNT:
- return bond_flow_query_count(dev, flow, arg, err);
+ return bond_flow_query_count(dev, flow, action, arg, err);
default:
return rte_flow_error_set(err, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION, arg,