From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id EFEB34C88 for ; Fri, 31 Aug 2018 11:01:23 +0200 (CEST) Received: by mail-wm0-f46.google.com with SMTP id b19-v6so4475406wme.3 for ; Fri, 31 Aug 2018 02:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PtvSO8AnfduGqjsbwqMjjOWkPQJnQbptU1MYVAkL/8g=; b=QXGp5c9e2vNk7V3sdgDfynfT9yvLPdaqEy/12/Zk6ju+U7kJSRbRq/tgFkzAcHQtUS dGf7nVKWJXjTsWp7m7ChlPjyeaVpr+WZqEfVpIiM45eHbif5/H4rVV4QkIPPNZAFnwrP /iBTna04Byp1QIYJXHcybI/rcl1p/Yh2x5rX3MOOk/l4Wko1sSn4yBtiAvhJR2mAU1s3 BB5uqaVVs7hZQIGb57d7KsFx7MViNrg7sM/raNbHLM+Kdn+SS0qfY3+lTYYzxCx5bF6W ZDVtZxC4F5y1cefUjareBObszLfYIVjjmF47EA4Y6h9ijOAmGJfrSte+RaWAXyFCJNYv hAow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PtvSO8AnfduGqjsbwqMjjOWkPQJnQbptU1MYVAkL/8g=; b=Zt2C4PbHOUAFOLplkQ0XWuXHq316ly9q58hhdAJaN2N5SE50kvGZbq6pqR8mhyAhOw +Vv6+cfxNm319GgduGcITH9P/TpZ47+bYdBloa0S+Hu18M8MS7jpKURq+TlzjsV0SQrC IKDgHHxulRO4elsLqERMoMuQsgmP/V1fhs/GSaE5UTg79Kg5oLLUmDav+toYCyCH+rUu iWUutY4dtyHvVZCNsThA/tCSej5+hFxEEeeA9TBUcK8FDuzq7cwI54R4aRHLXkoyzgQt ZQa6AGWSLUaOijl2QdunmwMfkDBJHEKDha0PZnBNCCAPsgyN6S+IONZwlBp9GhZNyjfM Hv8Q== X-Gm-Message-State: APzg51BkS7LwqFUNSyHDvtVbtrrtOuAPCbu4wk5R0MSOouKzcjVBZFGX dzI7KMtjT5eJ1xXt9nEwZKIaQw== X-Google-Smtp-Source: ANB0Vdb1tpe3cleUo2Sbvg71Mjqn9JhzppTWUFh0xSndrSRpyfIR3i6hHKBFs8r4ssSyfERSPI2Waw== X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr4212903wmb.14.1535706083688; Fri, 31 Aug 2018 02:01:23 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id b124-v6sm3385141wmh.17.2018.08.31.02.01.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 02:01:22 -0700 (PDT) Date: Fri, 31 Aug 2018 11:01:07 +0200 From: Adrien Mazarguil To: Ferruh Yigit Cc: dev@dpdk.org, Gaetan Rivet Message-ID: <20180831085337.21419-5-adrien.mazarguil@6wind.com> References: <20180803132032.29038-1-adrien.mazarguil@6wind.com> <20180831085337.21419-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180831085337.21419-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v3 4/7] net/failsafe: switch to flow API object conversion function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2018 09:01:24 -0000 This patch replaces rte_flow_copy() with rte_flow_conv(). Signed-off-by: Adrien Mazarguil Cc: Gaetan Rivet -- v2 changes: - Patch was split from "ethdev: add flow API object converter". --- drivers/net/failsafe/failsafe_ether.c | 6 +++--- drivers/net/failsafe/failsafe_flow.c | 31 +++++++++++++++++++++------- drivers/net/failsafe/failsafe_private.h | 5 ++++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 5b5cb3b49..8bce368f3 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -230,9 +230,9 @@ fs_eth_dev_conf_apply(struct rte_eth_dev *dev, DEBUG("Creating flow #%" PRIu32, i++); flow->flows[SUB_ID(sdev)] = rte_flow_create(PORT_ID(sdev), - &flow->fd->attr, - flow->fd->items, - flow->fd->actions, + flow->rule.attr, + flow->rule.pattern, + flow->rule.actions, &ferror); ret = rte_errno; if (ret) diff --git a/drivers/net/failsafe/failsafe_flow.c b/drivers/net/failsafe/failsafe_flow.c index bfe42fcee..5e2b5f7c6 100644 --- a/drivers/net/failsafe/failsafe_flow.c +++ b/drivers/net/failsafe/failsafe_flow.c @@ -3,8 +3,11 @@ * Copyright 2017 Mellanox Technologies, Ltd */ +#include +#include #include +#include #include #include #include @@ -18,19 +21,33 @@ fs_flow_allocate(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(NULL, - sizeof(struct rte_flow) + fdsz, + ret = rte_flow_conv(RTE_FLOW_CONV_OP_RULE, NULL, 0, &rule, &error); + if (ret < 0) { + ERROR("Unable to process flow rule (%s): %s", + error.message ? error.message : "unspecified", + strerror(rte_errno)); + return NULL; + } + flow = rte_zmalloc(NULL, offsetof(struct rte_flow, rule) + ret, RTE_CACHE_LINE_SIZE); if (flow == NULL) { ERROR("Could not allocate new flow"); return NULL; } - flow->fd = (void *)((uintptr_t)flow + sizeof(*flow)); - if (rte_flow_copy(flow->fd, fdsz, attr, items, actions) != fdsz) { - ERROR("Failed to copy flow description"); + ret = rte_flow_conv(RTE_FLOW_CONV_OP_RULE, &flow->rule, ret, &rule, + &error); + if (ret < 0) { + ERROR("Failed to copy flow rule (%s): %s", + error.message ? error.message : "unspecified", + strerror(rte_errno)); rte_free(flow); return NULL; } diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 886af8616..cc1f0343d 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -6,6 +6,7 @@ #ifndef _RTE_ETH_FAILSAFE_PRIVATE_H_ #define _RTE_ETH_FAILSAFE_PRIVATE_H_ +#include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include #define FAILSAFE_DRIVER_NAME "Fail-safe PMD" @@ -81,7 +83,8 @@ struct rte_flow { /* sub_flows */ struct rte_flow *flows[FAILSAFE_MAX_ETHPORTS]; /* flow description for synchronization */ - struct rte_flow_desc *fd; + struct rte_flow_conv_rule rule; + uint8_t rule_data[]; }; enum dev_state { -- 2.11.0