From patchwork Wed Dec 21 15:19:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?N=C3=A9lio_Laranjeiro?= X-Patchwork-Id: 18408 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B369C10CB3; Wed, 21 Dec 2016 16:20:22 +0100 (CET) Received: from mail-wj0-f180.google.com (mail-wj0-f180.google.com [209.85.210.180]) by dpdk.org (Postfix) with ESMTP id F0C0110C89 for ; Wed, 21 Dec 2016 16:20:05 +0100 (CET) Received: by mail-wj0-f180.google.com with SMTP id v7so205588436wjy.2 for ; Wed, 21 Dec 2016 07:20:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=cQh2abcrN2eQduMaCYzfE4N3BosavN9+vvW1O/OrXdA=; b=I0fSf6vWyHwv1549vwOQqM7JIf1Hv8Ieaj2uYVMbmWDbU5/pN0JTzXq+TQ+LBLi1Bb 3lnemnl4Au6DhnqdQXw8m4k/GTiQRzsDrclXjNarmqlVPAgqSUSfJhWQ5SiOM8aXQEga EDeLmq0pNDNCXzYJHaiG1/kA+zjFSNnADepxIiyzS/AZCPxWPwczFx2QdEyaGK6rm5Wm PobQaZLiBgDQTOzEro2+n4leU8JzrSqTo+dhw4B53fnXot2K1N4Mi2ms1IjikRxKoFxp nZF7JjfAtu51Wdf25aefFVSN0AeELAesjEFEA3qxtgKUOs+uyq345mGLvPd6/TXndo2b oafQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=cQh2abcrN2eQduMaCYzfE4N3BosavN9+vvW1O/OrXdA=; b=bsL8+cRgEYj85QMRfOau9tffBLBxmiQuAezcdcWM5Dhp2IzHEkcXfjqphKkK8fqyyJ tr8mgHiwxzAqfnDL5nQOXa8zZ4ycV8YewuDbNoZ8AZ1V59vUCF+MIxgcdxl9zroxzIR/ Ne65VPWfCW8PMJjViy9adRC0cB8d+bRVgEJ6UVgno/9sm9DQeCsHaOaQy9DsCFnrAa1C 636RHk2kyk1SwVdndTkgzAB/UBNXwAJQdgErwv6x+tbR0X/rClKNsuTWnMc5OnwlE5n9 ZeMYLNRoGthRfp0/W53gOt/cqJ2P6HCYGZ8EkL6SK81IUeuUOhxK6cbE0183NzaOS6PS fs5A== X-Gm-Message-State: AIkVDXKiYK8akFuqMkRQCMhRT8Eft8uFttAVDRPj3mtQiziTvkEEZGNs+oY9AB5hlESidBfJ X-Received: by 10.194.54.99 with SMTP id i3mr4898824wjp.86.1482333605535; Wed, 21 Dec 2016 07:20:05 -0800 (PST) Received: from ping.vm.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id gk6sm30984584wjc.46.2016.12.21.07.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Dec 2016 07:20:05 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil Date: Wed, 21 Dec 2016 16:19:44 +0100 Message-Id: <8c2e80baa1fa0639898e4c30361ae80b93ee330b.1482331954.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 1/4] net/mlx5: add preliminary support for rte_flow 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/Makefile | 1 + drivers/net/mlx5/mlx5.h | 16 ++++++ drivers/net/mlx5/mlx5_fdir.c | 15 ++++++ drivers/net/mlx5/mlx5_flow.c | 122 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_flow.c diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index cf87f0b..6d1338a 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -48,6 +48,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_stats.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rss.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_fdir.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mr.c +SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c # Dependencies. DEPDIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += lib/librte_ether diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 79b7a60..04f4eaa 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -59,6 +59,7 @@ #include #include #include +#include #ifdef PEDANTIC #pragma GCC diagnostic error "-Wpedantic" #endif @@ -268,4 +269,19 @@ void priv_fdir_enable(struct priv *); int mlx5_dev_filter_ctrl(struct rte_eth_dev *, enum rte_filter_type, enum rte_filter_op, void *); +/* mlx5_flow.c */ + +int mlx5_flow_validate(struct rte_eth_dev *, const struct rte_flow_attr *, + const struct rte_flow_item [], + const struct rte_flow_action [], + struct rte_flow_error *); +struct rte_flow *mlx5_flow_create(struct rte_eth_dev *, + const struct rte_flow_attr *, + const struct rte_flow_item [], + const struct rte_flow_action [], + struct rte_flow_error *); +int mlx5_flow_destroy(struct rte_eth_dev *, struct rte_flow *, + struct rte_flow_error *); +int mlx5_flow_flush(struct rte_eth_dev *, struct rte_flow_error *); + #endif /* RTE_PMD_MLX5_H_ */ diff --git a/drivers/net/mlx5/mlx5_fdir.c b/drivers/net/mlx5/mlx5_fdir.c index 1acf682..f80c58b 100644 --- a/drivers/net/mlx5/mlx5_fdir.c +++ b/drivers/net/mlx5/mlx5_fdir.c @@ -55,6 +55,8 @@ #include #include #include +#include +#include #ifdef PEDANTIC #pragma GCC diagnostic error "-Wpedantic" #endif @@ -1042,6 +1044,14 @@ priv_fdir_ctrl_func(struct priv *priv, enum rte_filter_op filter_op, void *arg) return ret; } +static const struct rte_flow_ops mlx5_flow_ops = { + .validate = mlx5_flow_validate, + .create = mlx5_flow_create, + .destroy = mlx5_flow_destroy, + .flush = mlx5_flow_flush, + .query = NULL, +}; + /** * Manage filter operations. * @@ -1067,6 +1077,11 @@ mlx5_dev_filter_ctrl(struct rte_eth_dev *dev, struct priv *priv = dev->data->dev_private; switch (filter_type) { + case RTE_ETH_FILTER_GENERIC: + if (filter_op != RTE_ETH_FILTER_GET) + return -EINVAL; + *(const void **)arg = &mlx5_flow_ops; + return 0; case RTE_ETH_FILTER_FDIR: priv_lock(priv); ret = priv_fdir_ctrl_func(priv, filter_op, arg); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c new file mode 100644 index 0000000..a514dff --- /dev/null +++ b/drivers/net/mlx5/mlx5_flow.c @@ -0,0 +1,122 @@ +/*- + * BSD LICENSE + * + * Copyright 2016 6WIND S.A. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of 6WIND S.A. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include "mlx5.h" + +/** + * Validate a flow supported by the NIC. + * + * @see rte_flow_validate() + * @see rte_flow_ops + */ +int +mlx5_flow_validate(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + (void)dev; + (void)attr; + (void)items; + (void)actions; + (void)error; + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_NONE, + NULL, "not implemented yet"); + return -rte_errno; +} + +/** + * Create a flow. + * + * @see rte_flow_create() + * @see rte_flow_ops + */ +struct rte_flow * +mlx5_flow_create(struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_flow_item items[], + const struct rte_flow_action actions[], + struct rte_flow_error *error) +{ + (void)dev; + (void)attr; + (void)items; + (void)actions; + (void)error; + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_NONE, + NULL, "not implemented yet"); + return NULL; +} + +/** + * Destroy a flow. + * + * @see rte_flow_destroy() + * @see rte_flow_ops + */ +int +mlx5_flow_destroy(struct rte_eth_dev *dev, + struct rte_flow *flow, + struct rte_flow_error *error) +{ + (void)dev; + (void)flow; + (void)error; + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_NONE, + NULL, "not implemented yet"); + return -rte_errno; +} + +/** + * Destroy all flows. + * + * @see rte_flow_flush() + * @see rte_flow_ops + */ +int +mlx5_flow_flush(struct rte_eth_dev *dev, + struct rte_flow_error *error) +{ + (void)dev; + (void)error; + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_NONE, + NULL, "not implemented yet"); + return -rte_errno; +}