From patchwork Mon Oct 26 16:37:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bing Zhao X-Patchwork-Id: 82208 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CA14AA04DD; Mon, 26 Oct 2020 17:39:59 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F1B22E1E; Mon, 26 Oct 2020 17:38:42 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 4E9B52BDB for ; Mon, 26 Oct 2020 17:38:37 +0100 (CET) From: Bing Zhao To: viacheslavo@mellanox.com, matan@mellanox.com Cc: dev@dpdk.org, orika@nvidia.com, rasland@nvidia.com Date: Tue, 27 Oct 2020 00:37:45 +0800 Message-Id: <1603730267-267228-6-git-send-email-bingz@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603730267-267228-1-git-send-email-bingz@nvidia.com> References: <1602166620-46303-1-git-send-email-bingz@nvidia.com> <1603730267-267228-1-git-send-email-bingz@nvidia.com> Subject: [dpdk-dev] [PATCH v3 5/7] net/mlx5: change hairpin ingress flow validation 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" In the current implementation of the single port hairpin, there is an implicit splitting process for actions. When inserting a hairpin flow, all the actions will be included with the ingress attribute. The flow engine will check and decide which actions should be moved into the TX flow part, e.g., encapsulation, VLAN push. In some NICs, some actions can only be done in one direction. Since the hairpin flow will be split into two parts, such validation will be skipped. With the hairpin explicit TX flow mode, no splitting is needed any more. The hairpin flow may have no big difference from a standard flow (except the queue). The application should take full charge of the actions and the flow engine should validate the hairpin flow in the same way as other flows. In the meanwhile, a new internal API is added to get the hairpin configuration. This will bypass the useless atomic operation to save the CPU cycles. Signed-off-by: Bing Zhao Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_dv.c | 17 ++++++++++++++--- drivers/net/mlx5/mlx5_rxq.c | 27 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.h | 2 ++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 504d842..62e1d19 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -5310,6 +5310,7 @@ struct field_modify_info modify_tcp[] = { .transfer = !!attr->transfer, .fdb_def_rule = !!priv->fdb_def_rule, }; + const struct rte_eth_hairpin_conf *conf; if (items == NULL) return -1; @@ -6155,11 +6156,18 @@ struct field_modify_info modify_tcp[] = { actions, "no fate action is found"); } - /* Continue validation for Xcap and VLAN actions.*/ + /* + * Continue validation for Xcap and VLAN actions. + * If hairpin is working in explicit TX rule mode, there is no actions + * splitting and the validation of hairpin ingress flow should be the + * same as other standard flows. + */ if ((action_flags & (MLX5_FLOW_XCAP_ACTIONS | MLX5_FLOW_VLAN_ACTIONS)) && (queue_index == 0xFFFF || - mlx5_rxq_get_type(dev, queue_index) != MLX5_RXQ_TYPE_HAIRPIN)) { + mlx5_rxq_get_type(dev, queue_index) != MLX5_RXQ_TYPE_HAIRPIN || + ((conf = mlx5_rxq_get_hairpin_conf(dev, queue_index)) != NULL && + conf->tx_explicit != 0))) { if ((action_flags & MLX5_FLOW_XCAP_ACTIONS) == MLX5_FLOW_XCAP_ACTIONS) return rte_flow_error_set(error, ENOTSUP, @@ -6188,7 +6196,10 @@ struct field_modify_info modify_tcp[] = { "multiple VLAN actions"); } } - /* Hairpin flow will add one more TAG action. */ + /* + * Hairpin flow will add one more TAG action in TX implicit mode. + * In TX explicit mode, there will be no hairpin flow ID. + */ if (hairpin > 0) rw_act_num += MLX5_ACT_NUM_SET_TAG; /* extra metadata enabled: one more TAG action will be add. */ diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 034f43e..493c5f2 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1845,6 +1845,33 @@ enum mlx5_rxq_type return MLX5_RXQ_TYPE_UNDEFINED; } +/* + * Get a Rx hairpin queue configuration. + * + * @param dev + * Pointer to Ethernet device. + * @param idx + * Rx queue index. + * + * @return + * Pointer to the configuration if a hairpin RX queue, otherwise NULL. + */ +const struct rte_eth_hairpin_conf * +mlx5_rxq_get_hairpin_conf(struct rte_eth_dev *dev, uint16_t idx) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_rxq_ctrl *rxq_ctrl = NULL; + + if (idx < priv->rxqs_n && (*priv->rxqs)[idx]) { + rxq_ctrl = container_of((*priv->rxqs)[idx], + struct mlx5_rxq_ctrl, + rxq); + if (rxq_ctrl->type == MLX5_RXQ_TYPE_HAIRPIN) + return &rxq_ctrl->hairpin_conf; + } + return NULL; +} + /** * Match queues listed in arguments to queues contained in indirection table * object. diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index cdc18e3..1b5fba4 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -360,6 +360,8 @@ uint32_t mlx5_hrxq_get(struct rte_eth_dev *dev, int mlx5_hrxq_release(struct rte_eth_dev *dev, uint32_t hxrq_idx); int mlx5_hrxq_verify(struct rte_eth_dev *dev); enum mlx5_rxq_type mlx5_rxq_get_type(struct rte_eth_dev *dev, uint16_t idx); +const struct rte_eth_hairpin_conf *mlx5_rxq_get_hairpin_conf + (struct rte_eth_dev *dev, uint16_t idx); struct mlx5_hrxq *mlx5_drop_action_create(struct rte_eth_dev *dev); void mlx5_drop_action_destroy(struct rte_eth_dev *dev); uint64_t mlx5_get_rx_port_offloads(void);