From patchwork Tue Aug 1 16:54:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 27357 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 10DCAA30F; Tue, 1 Aug 2017 18:56:33 +0200 (CEST) Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 4FCF3A1DE for ; Tue, 1 Aug 2017 18:55:55 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id v105so9281774wrb.0 for ; Tue, 01 Aug 2017 09:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=FcFy4zp+s2g+cPEUPMShIo2rQNg7ewNszAXjxzd6rcs=; b=2Aqn3WuJ1sYmbbHBT/p/z4+pmx59Mt+6aFQKi+NusqpvGghZK6xt4XKAiEWfzsdge2 aNY3frSlfErpXAeOgVgSz9csvNhZ6gxMBB87XTAsyjRUeE9INhrgux1W5dpQoS5OsA/b FQ/kRZ1u9VxLrjpqrUwv0eFcamJpZ+YbvztKqQA9Dvk15AbLwG/u9G6a4eTJsEU95/63 PzQxRNxWaU6R3tlgARMWmOdr7nuThD3ZD2GFd2VnlMeu2viHr4TSI/eOa0lcJOle7ULA 1cbM7NlTcn14vXKFjOfnPXRHkrvr1O3FFrn0YxmcwPcI+fRNM6XtQGed2nyS3N/RuBH9 JIMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=FcFy4zp+s2g+cPEUPMShIo2rQNg7ewNszAXjxzd6rcs=; b=MbFkAkjwd8pOOtWuXXMcITePQ/o9XZ3sxjllzDuZkCUCMeyAmEs+7c6pNAEbJlTkF4 sWHpRrSSm5UAZS+aAN0tMnevDais6a7Tw/u3m/w8Ez0qcXm+cNwpgluJ7q5IStR/2jD0 fde95lo9TXgsy8KL9RzycTsT6FUesK8saW/fRPK9y+MpTY1Wwc/wnnHVaKD8E+VXBqLF fiNIQGOd17P4h/n+ad3NlXwO+MaiEO36T5Mxj3QfaasArmck1gupDnxZdKdVHPovTFty 6tvXTvp/DWFWByTqxWapXjOP3ZjTb6x2BFW+azcuobn0/hknCq+VBTCaOo3UzMHTGMIL rIMg== X-Gm-Message-State: AIVw112CWCPxfBze8ZXjc/YAnWs35zxRYQrznFdN2x0bNGZFP50leIZE cVBuNyzvPApwUboRjVI= X-Received: by 10.223.164.154 with SMTP id g26mr14767799wrb.230.1501606554787; Tue, 01 Aug 2017 09:55:54 -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 e5sm12283409wre.24.2017.08.01.09.55.53 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 01 Aug 2017 09:55:54 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 1 Aug 2017 18:54:32 +0200 Message-Id: <494935cff17600efd89871a28adcd6f7afca1034.1501598384.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 45/48] net/mlx4: group flow API handlers in common file 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" Only the common filter control operation callback needs to be exposed. No impact on functionality. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 48 +------------------------- drivers/net/mlx4/mlx4_flow.c | 72 ++++++++++++++++++++++++++++++++++++--- drivers/net/mlx4/mlx4_flow.h | 39 +++++---------------- 3 files changed, 76 insertions(+), 83 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index b54a569..6424d8b 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -356,51 +355,6 @@ mlx4_dev_close(struct rte_eth_dev *dev) memset(priv, 0, sizeof(*priv)); } -const struct rte_flow_ops mlx4_flow_ops = { - .validate = mlx4_flow_validate, - .create = mlx4_flow_create, - .destroy = mlx4_flow_destroy, - .flush = mlx4_flow_flush, - .query = NULL, - .isolate = mlx4_flow_isolate, -}; - -/** - * Manage filter operations. - * - * @param dev - * Pointer to Ethernet device structure. - * @param filter_type - * Filter type. - * @param filter_op - * Operation to perform. - * @param arg - * Pointer to operation-specific structure. - * - * @return - * 0 on success, negative errno value otherwise and rte_errno is set. - */ -static int -mlx4_dev_filter_ctrl(struct rte_eth_dev *dev, - enum rte_filter_type filter_type, - enum rte_filter_op filter_op, - void *arg) -{ - switch (filter_type) { - case RTE_ETH_FILTER_GENERIC: - if (filter_op != RTE_ETH_FILTER_GET) - break; - *(const void **)arg = &mlx4_flow_ops; - return 0; - default: - ERROR("%p: filter type (%d) not supported", - (void *)dev, filter_type); - break; - } - rte_errno = ENOTSUP; - return -rte_errno; -} - static const struct eth_dev_ops mlx4_dev_ops = { .dev_configure = mlx4_dev_configure, .dev_start = mlx4_dev_start, @@ -419,7 +373,7 @@ static const struct eth_dev_ops mlx4_dev_ops = { .flow_ctrl_get = mlx4_flow_ctrl_get, .flow_ctrl_set = mlx4_flow_ctrl_set, .mtu_set = mlx4_mtu_set, - .filter_ctrl = mlx4_dev_filter_ctrl, + .filter_ctrl = mlx4_filter_ctrl, .rx_queue_intr_enable = mlx4_rx_intr_enable, .rx_queue_intr_disable = mlx4_rx_intr_disable, }; diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c index 61455ce..6401a83 100644 --- a/drivers/net/mlx4/mlx4_flow.c +++ b/drivers/net/mlx4/mlx4_flow.c @@ -31,8 +31,26 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include +#include +#include +#include +#include +#include +/* Verbs headers do not support -pedantic. */ +#ifdef PEDANTIC +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +#include +#ifdef PEDANTIC +#pragma GCC diagnostic error "-Wpedantic" +#endif + +#include +#include +#include #include #include #include @@ -697,7 +715,7 @@ priv_flow_validate(struct priv *priv, * @see rte_flow_validate() * @see rte_flow_ops */ -int +static int mlx4_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], @@ -844,7 +862,7 @@ priv_flow_create_action_queue(struct priv *priv, * @see rte_flow_create() * @see rte_flow_ops */ -struct rte_flow * +static struct rte_flow * mlx4_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], @@ -927,7 +945,7 @@ mlx4_flow_create(struct rte_eth_dev *dev, * @return * 0 on success, a negative value on error. */ -int +static int mlx4_flow_isolate(struct rte_eth_dev *dev, int enable, struct rte_flow_error *error) @@ -951,7 +969,7 @@ mlx4_flow_isolate(struct rte_eth_dev *dev, * @see rte_flow_destroy() * @see rte_flow_ops */ -int +static int mlx4_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error) @@ -973,7 +991,7 @@ mlx4_flow_destroy(struct rte_eth_dev *dev, * @see rte_flow_flush() * @see rte_flow_ops */ -int +static int mlx4_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error) { @@ -1044,3 +1062,47 @@ mlx4_priv_flow_start(struct priv *priv) } return 0; } + +static const struct rte_flow_ops mlx4_flow_ops = { + .validate = mlx4_flow_validate, + .create = mlx4_flow_create, + .destroy = mlx4_flow_destroy, + .flush = mlx4_flow_flush, + .isolate = mlx4_flow_isolate, +}; + +/** + * Manage filter operations. + * + * @param dev + * Pointer to Ethernet device structure. + * @param filter_type + * Filter type. + * @param filter_op + * Operation to perform. + * @param arg + * Pointer to operation-specific structure. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +int +mlx4_filter_ctrl(struct rte_eth_dev *dev, + enum rte_filter_type filter_type, + enum rte_filter_op filter_op, + void *arg) +{ + switch (filter_type) { + case RTE_ETH_FILTER_GENERIC: + if (filter_op != RTE_ETH_FILTER_GET) + break; + *(const void **)arg = &mlx4_flow_ops; + return 0; + default: + ERROR("%p: filter type (%d) not supported", + (void *)dev, filter_type); + break; + } + rte_errno = ENOTSUP; + return -rte_errno; +} diff --git a/drivers/net/mlx4/mlx4_flow.h b/drivers/net/mlx4/mlx4_flow.h index 17e5f6e..8bd659c 100644 --- a/drivers/net/mlx4/mlx4_flow.h +++ b/drivers/net/mlx4/mlx4_flow.h @@ -34,7 +34,6 @@ #ifndef RTE_PMD_MLX4_FLOW_H_ #define RTE_PMD_MLX4_FLOW_H_ -#include #include #include @@ -48,12 +47,12 @@ #pragma GCC diagnostic error "-Wpedantic" #endif +#include +#include #include #include #include -#include "mlx4.h" - struct rte_flow { LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */ struct ibv_flow *ibv_flow; /**< Verbs flow. */ @@ -61,47 +60,25 @@ struct rte_flow { struct ibv_qp *qp; /**< Verbs queue pair. */ }; -int -mlx4_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); - -struct rte_flow * -mlx4_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); - -int -mlx4_flow_destroy(struct rte_eth_dev *dev, - struct rte_flow *flow, - struct rte_flow_error *error); - -int -mlx4_flow_flush(struct rte_eth_dev *dev, - struct rte_flow_error *error); - /** Structure to pass to the conversion function. */ struct mlx4_flow { struct ibv_flow_attr *ibv_attr; /**< Verbs attribute. */ unsigned int offset; /**< Offset in bytes in the ibv_attr buffer. */ }; -int -mlx4_flow_isolate(struct rte_eth_dev *dev, - int enable, - struct rte_flow_error *error); - struct mlx4_flow_action { uint32_t drop:1; /**< Target is a drop queue. */ uint32_t queue:1; /**< Target is a receive queue. */ uint32_t queue_id; /**< Identifier of the queue. */ }; +/* mlx4_flow.c */ + int mlx4_priv_flow_start(struct priv *priv); void mlx4_priv_flow_stop(struct priv *priv); +int mlx4_filter_ctrl(struct rte_eth_dev *dev, + enum rte_filter_type filter_type, + enum rte_filter_op filter_op, + void *arg); #endif /* RTE_PMD_MLX4_FLOW_H_ */