net/bonding: switch to flow API object conversion function
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Fri, 31 Aug 2018 09:01:09 +0000 (11:01 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 11 Oct 2018 16:53:49 +0000 (18:53 +0200)
This patch replaces rte_flow_copy() with rte_flow_conv().

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
drivers/net/bonding/Makefile
drivers/net/bonding/meson.build
drivers/net/bonding/rte_eth_bond_api.c
drivers/net/bonding/rte_eth_bond_flow.c
drivers/net/bonding/rte_eth_bond_private.h

index acad16a..1893e3c 100644 (file)
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 LIB = librte_pmd_bond.a
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
index 602d288..00374ed 100644 (file)
@@ -3,6 +3,7 @@
 
 name = 'bond' #, james bond :-)
 version = 2
+allow_experimental_apis = true
 sources = files('rte_eth_bond_api.c', 'rte_eth_bond_pmd.c', 'rte_eth_bond_flow.c',
        'rte_eth_bond_args.c', 'rte_eth_bond_8023ad.c', 'rte_eth_bond_alb.c')
 
index 9e039e7..21bcd50 100644 (file)
@@ -245,9 +245,9 @@ slave_rte_flow_prepare(uint16_t slave_id, struct bond_dev_private *internals)
        }
        TAILQ_FOREACH(flow, &internals->flow_list, next) {
                flow->flows[slave_id] = rte_flow_create(slave_port_id,
-                                                       &flow->fd->attr,
-                                                       flow->fd->items,
-                                                       flow->fd->actions,
+                                                       flow->rule.attr,
+                                                       flow->rule.pattern,
+                                                       flow->rule.actions,
                                                        &ferror);
                if (flow->flows[slave_id] == NULL) {
                        RTE_BOND_LOG(ERR, "Cannot create flow for slave"
index 31e4bca..f94d46c 100644 (file)
@@ -2,8 +2,11 @@
  * 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>
@@ -16,19 +19,33 @@ 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;
        }
index c81baa0..3ea5d68 100644 (file)
@@ -5,9 +5,11 @@
 #ifndef _RTE_ETH_BOND_PRIVATE_H_
 #define _RTE_ETH_BOND_PRIVATE_H_
 
+#include <stdint.h>
 #include <sys/queue.h>
 
 #include <rte_ethdev_driver.h>
+#include <rte_flow.h>
 #include <rte_spinlock.h>
 #include <rte_bitmap.h>
 #include <rte_flow_driver.h>
@@ -93,7 +95,8 @@ struct rte_flow {
        /* Slaves flows */
        struct rte_flow *flows[RTE_MAX_ETHPORTS];
        /* Flow description for synchronization */
-       struct rte_flow_desc *fd;
+       struct rte_flow_conv_rule rule;
+       uint8_t rule_data[];
 };
 
 typedef void (*burst_xmit_hash_t)(struct rte_mbuf **buf, uint16_t nb_pkts,