From patchwork Sun Jun 28 14:06:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dekel Peled X-Patchwork-Id: 72384 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 0657BA0350; Sun, 28 Jun 2020 16:08:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2F0AC1C2F7; Sun, 28 Jun 2020 16:08:43 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id C58A91C2F5 for ; Sun, 28 Jun 2020 16:08:40 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@mellanox.com) with SMTP; 28 Jun 2020 17:08:36 +0300 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.228.134.250]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05SE8YV4009807; Sun, 28 Jun 2020 17:08:36 +0300 From: Dekel Peled To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Sun, 28 Jun 2020 17:06:50 +0300 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 1/6] net/mlx5: rename IB flow to generic name DRV 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" As part of the effort to support DPDK on Windows and other OS, rename from IB related name to generic name. Signed-off-by: Dekel Peled --- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 11 +++++------ drivers/net/mlx5/mlx5_flow_verbs.c | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 50ec741..74d2c49 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -538,7 +538,7 @@ struct mlx5_flow_handle { /**< Index to next device flow handle. */ uint64_t layers; /**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ - void *ib_flow; /**< Verbs flow pointer. */ + void *drv_flow; /**< pointer to driver flow object. */ uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index d1eb65b..ae4b05c 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -8673,12 +8673,11 @@ struct field_modify_info modify_tcp[] = { dh->rix_default_fate = MLX5_FLOW_FATE_DEFAULT_MISS; dv->actions[n++] = priv->sh->default_miss.action; } - - dh->ib_flow = + dh->drv_flow = mlx5_glue->dv_create_flow(dv_h->matcher->matcher_object, (void *)&dv->value, n, dv->actions); - if (!dh->ib_flow) { + if (!dh->drv_flow) { rte_flow_error_set(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -9041,9 +9040,9 @@ struct field_modify_info modify_tcp[] = { handle_idx); if (!dh) return; - if (dh->ib_flow) { - claim_zero(mlx5_glue->dv_destroy_flow(dh->ib_flow)); - dh->ib_flow = NULL; + if (dh->drv_flow) { + claim_zero(mlx5_glue->dv_destroy_flow(dh->drv_flow)); + dh->drv_flow = NULL; } if (dh->fate_action == MLX5_FLOW_FATE_DROP || dh->fate_action == MLX5_FLOW_FATE_QUEUE || diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 6b86437..781c97f 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -1778,9 +1778,9 @@ return; SILIST_FOREACH(priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW], flow->dev_handles, handle_idx, handle, next) { - if (handle->ib_flow) { - claim_zero(mlx5_glue->destroy_flow(handle->ib_flow)); - handle->ib_flow = NULL; + if (handle->drv_flow) { + claim_zero(mlx5_glue->destroy_flow(handle->drv_flow)); + handle->drv_flow = NULL; } /* hrxq is union, don't touch it only the flag is set. */ if (handle->rix_hrxq) { @@ -1901,9 +1901,9 @@ handle->rix_hrxq = hrxq_idx; } MLX5_ASSERT(hrxq); - handle->ib_flow = mlx5_glue->create_flow(hrxq->qp, - &dev_flow->verbs.attr); - if (!handle->ib_flow) { + handle->drv_flow = mlx5_glue->create_flow + (hrxq->qp, &dev_flow->verbs.attr); + if (!handle->drv_flow) { rte_flow_error_set(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, From patchwork Sun Jun 28 14:06:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dekel Peled X-Patchwork-Id: 72385 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 ECF55A0350; Sun, 28 Jun 2020 16:08:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 70A251C435; Sun, 28 Jun 2020 16:08:44 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id CA8A31C2F7 for ; Sun, 28 Jun 2020 16:08:40 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@mellanox.com) with SMTP; 28 Jun 2020 17:08:37 +0300 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.228.134.250]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05SE8YV5009807; Sun, 28 Jun 2020 17:08:37 +0300 From: Dekel Peled To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Sun, 28 Jun 2020 17:06:51 +0300 Message-Id: <9fab65273a5ac747699d95543851939e355c4fb7.1593352527.git.dekelp@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 2/6] net/mlx5: rename Verbs action to generic name 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" As part of the effort to support DPDK on Windows and other OS, rename 'verbs_action' to the generic name 'action'. Signed-off-by: Dekel Peled --- drivers/net/mlx5/mlx5_flow.h | 16 ++++++++-------- drivers/net/mlx5/mlx5_flow_dv.c | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 74d2c49..22cc356 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -399,8 +399,8 @@ struct mlx5_flow_dv_encap_decap_resource { ILIST_ENTRY(uint32_t)next; /* Pointer to next element. */ rte_atomic32_t refcnt; /**< Reference counter. */ - void *verbs_action; - /**< Verbs encap/decap action object. */ + void *action; + /**< Encap/decap action object. */ uint8_t buf[MLX5_ENCAP_MAX_LEN]; size_t size; uint8_t reformat_type; @@ -413,7 +413,7 @@ struct mlx5_flow_dv_tag_resource { struct mlx5_hlist_entry entry; /**< hash list entry for tag resource, tag value as the key. */ void *action; - /**< Verbs tag action object. */ + /**< Tag action object. */ rte_atomic32_t refcnt; /**< Reference counter. */ uint32_t idx; /**< Index for the index memory pool. */ }; @@ -436,8 +436,8 @@ struct mlx5_flow_dv_modify_hdr_resource { LIST_ENTRY(mlx5_flow_dv_modify_hdr_resource) next; /* Pointer to next element. */ rte_atomic32_t refcnt; /**< Reference counter. */ - struct ibv_flow_action *verbs_action; - /**< Verbs modify header action object. */ + struct ibv_flow_action *action; + /**< Modify header action object. */ uint8_t ft_type; /**< Flow table type, Rx or Tx. */ uint32_t actions_num; /**< Number of modification actions. */ uint64_t flags; /**< Flags for RDMA API. */ @@ -458,7 +458,7 @@ struct mlx5_flow_dv_port_id_action_resource { /* Pointer to next element. */ rte_atomic32_t refcnt; /**< Reference counter. */ void *action; - /**< Verbs tag action object. */ + /**< Action object. */ uint32_t port_id; /**< Port ID value. */ }; @@ -467,7 +467,7 @@ struct mlx5_flow_dv_push_vlan_action_resource { ILIST_ENTRY(uint32_t)next; /* Pointer to next element. */ rte_atomic32_t refcnt; /**< Reference counter. */ - void *action; /**< Direct verbs action object. */ + void *action; /**< Action object. */ uint8_t ft_type; /**< Flow table type, Rx, Tx or FDB. */ rte_be32_t vlan_tag; /**< VLAN tag value. */ }; @@ -660,7 +660,7 @@ struct mlx5_flow_verbs_workspace { struct mlx5_flow { struct rte_flow *flow; /**< Pointer to the main flow. */ uint32_t flow_idx; /**< The memory pool index to the main flow. */ - uint64_t hash_fields; /**< Verbs hash Rx queue hash fields. */ + uint64_t hash_fields; /**< Hash Rx queue hash fields. */ uint64_t act_flags; /**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */ bool external; /**< true if the flow is created external to PMD. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index ae4b05c..dc8d952 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2603,13 +2603,13 @@ struct field_modify_info modify_tcp[] = { RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot allocate resource memory"); *cache_resource = *resource; - cache_resource->verbs_action = + cache_resource->action = mlx5_glue->dv_create_flow_action_packet_reformat (sh->ctx, cache_resource->reformat_type, cache_resource->ft_type, domain, cache_resource->flags, cache_resource->size, (cache_resource->size ? cache_resource->buf : NULL)); - if (!cache_resource->verbs_action) { + if (!cache_resource->action) { rte_free(cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -4030,12 +4030,12 @@ struct field_modify_info modify_tcp[] = { "cannot allocate resource memory"); *cache_resource = *resource; rte_memcpy(cache_resource->actions, resource->actions, actions_len); - cache_resource->verbs_action = + cache_resource->action = mlx5_glue->dv_create_flow_action_modify_header (sh->ctx, cache_resource->ft_type, ns, cache_resource->flags, actions_len, (uint64_t *)cache_resource->actions); - if (!cache_resource->verbs_action) { + if (!cache_resource->action) { rte_free(cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -8093,7 +8093,7 @@ struct field_modify_info modify_tcp[] = { error)) return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; action_flags |= MLX5_FLOW_ACTION_ENCAP; break; case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: @@ -8103,7 +8103,7 @@ struct field_modify_info modify_tcp[] = { error)) return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; action_flags |= MLX5_FLOW_ACTION_DECAP; break; case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: @@ -8113,7 +8113,7 @@ struct field_modify_info modify_tcp[] = { (dev, actions, dev_flow, attr, error)) return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; } else { /* Handle encap without preceding decap. */ if (flow_dv_create_action_l2_encap @@ -8121,7 +8121,7 @@ struct field_modify_info modify_tcp[] = { error)) return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; } action_flags |= MLX5_FLOW_ACTION_ENCAP; break; @@ -8133,7 +8133,7 @@ struct field_modify_info modify_tcp[] = { (dev, dev_flow, attr->transfer, error)) return -rte_errno; dev_flow->dv.actions[actions_n++] = - dev_flow->dv.encap_decap->verbs_action; + dev_flow->dv.encap_decap->action; } /* If decap is followed by encap, handle it at encap. */ action_flags |= MLX5_FLOW_ACTION_DECAP; @@ -8315,7 +8315,7 @@ struct field_modify_info modify_tcp[] = { (dev, mhdr_res, dev_flow, error)) return -rte_errno; dev_flow->dv.actions[modify_action_position] = - handle->dvh.modify_hdr->verbs_action; + handle->dvh.modify_hdr->action; } if (action_flags & MLX5_FLOW_ACTION_COUNT) { flow->counter = @@ -8778,13 +8778,13 @@ struct field_modify_info modify_tcp[] = { idx); if (!cache_resource) return 0; - MLX5_ASSERT(cache_resource->verbs_action); + MLX5_ASSERT(cache_resource->action); DRV_LOG(DEBUG, "encap/decap resource %p: refcnt %d--", (void *)cache_resource, rte_atomic32_read(&cache_resource->refcnt)); if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { claim_zero(mlx5_glue->destroy_flow_action - (cache_resource->verbs_action)); + (cache_resource->action)); ILIST_REMOVE(priv->sh->ipool[MLX5_IPOOL_DECAP_ENCAP], &priv->sh->encaps_decaps, idx, cache_resource, next); @@ -8881,13 +8881,13 @@ struct field_modify_info modify_tcp[] = { struct mlx5_flow_dv_modify_hdr_resource *cache_resource = handle->dvh.modify_hdr; - MLX5_ASSERT(cache_resource->verbs_action); + MLX5_ASSERT(cache_resource->action); DRV_LOG(DEBUG, "modify-header resource %p: refcnt %d--", (void *)cache_resource, rte_atomic32_read(&cache_resource->refcnt)); if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { claim_zero(mlx5_glue->destroy_flow_action - (cache_resource->verbs_action)); + (cache_resource->action)); LIST_REMOVE(cache_resource, next); rte_free(cache_resource); DRV_LOG(DEBUG, "modify-header resource %p: removed", From patchwork Sun Jun 28 14:06:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dekel Peled X-Patchwork-Id: 72386 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 55304A0350; Sun, 28 Jun 2020 16:09:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C3C351C43E; Sun, 28 Jun 2020 16:08:45 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D02251C2F8 for ; Sun, 28 Jun 2020 16:08:40 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@mellanox.com) with SMTP; 28 Jun 2020 17:08:38 +0300 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.228.134.250]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05SE8YV6009807; Sun, 28 Jun 2020 17:08:38 +0300 From: Dekel Peled To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Sun, 28 Jun 2020 17:06:52 +0300 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 3/6] net/mlx5: add OS specific flow related utilities 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" This patch introduces the first OS specific utility functions, for use by flow engine in different OS implementation. The first utility functions are: bool mlx5_flow_os_item_supported(item) bool mlx5_flow_os_action_supported(action) They are implemented to check OS specific support for different item types and action types. New header file is added: drivers/net/mlx5/linux/mlx5_flow_os.h This file contains the utility functions mentioned above for Linux OS. At this stage they are implemented as static inline, for efficiency, and always return true. Signed-off-by: Dekel Peled --- drivers/net/mlx5/linux/mlx5_flow_os.h | 38 +++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 20 ++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 drivers/net/mlx5/linux/mlx5_flow_os.h diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.h b/drivers/net/mlx5/linux/mlx5_flow_os.h new file mode 100644 index 0000000..4ad4e0a --- /dev/null +++ b/drivers/net/mlx5/linux/mlx5_flow_os.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#ifndef RTE_PMD_MLX5_FLOW_OS_H_ +#define RTE_PMD_MLX5_FLOW_OS_H_ + +/** + * Check if item type is supported. + * + * @param item + * Item type to check. + * + * @return + * True is this item type is supported, false if not supported. + */ +static inline bool +mlx5_flow_os_item_supported(int item __rte_unused) +{ + return true; +} + +/** + * Check if action type is supported. + * + * @param action + * Action type to check. + * + * @return + * True is this action type is supported, false if not supported. + */ +static inline bool +mlx5_flow_os_action_supported(int action __rte_unused) +{ + return true; +} + +#endif /* RTE_PMD_MLX5_FLOW_OS_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index dc8d952..d01a7e5 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -38,6 +38,7 @@ #include "mlx5.h" #include "mlx5_common_os.h" #include "mlx5_flow.h" +#include "mlx5_flow_os.h" #include "mlx5_rxtx.h" #ifdef HAVE_IBV_FLOW_DV_SUPPORT @@ -4939,6 +4940,10 @@ struct field_modify_info modify_tcp[] = { int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); int type = items->type; + if (!mlx5_flow_os_item_supported(type)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "item not supported"); switch (type) { case RTE_FLOW_ITEM_TYPE_VOID: break; @@ -5177,6 +5182,12 @@ struct field_modify_info modify_tcp[] = { } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { int type = actions->type; + + if (!mlx5_flow_os_action_supported(type)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "action not supported"); if (actions_n == MLX5_DV_MAX_NUMBER_OF_ACTIONS) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, @@ -7907,6 +7918,11 @@ struct field_modify_info modify_tcp[] = { const struct rte_flow_action *found_action = NULL; struct mlx5_flow_meter *fm = NULL; + if (!mlx5_flow_os_action_supported(action_type)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "action not supported"); switch (action_type) { case RTE_FLOW_ACTION_TYPE_VOID: break; @@ -8347,6 +8363,10 @@ struct field_modify_info modify_tcp[] = { int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); int item_type = items->type; + if (!mlx5_flow_os_item_supported(item_type)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "item not supported"); switch (item_type) { case RTE_FLOW_ITEM_TYPE_PORT_ID: flow_dv_translate_item_port_id(dev, match_mask, From patchwork Sun Jun 28 14:06:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dekel Peled X-Patchwork-Id: 72387 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 35535A0350; Sun, 28 Jun 2020 16:09:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 65BD11D14A; Sun, 28 Jun 2020 16:08:47 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D98331C2FA for ; Sun, 28 Jun 2020 16:08:40 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@mellanox.com) with SMTP; 28 Jun 2020 17:08:39 +0300 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.228.134.250]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05SE8YV7009807; Sun, 28 Jun 2020 17:08:39 +0300 From: Dekel Peled To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Sun, 28 Jun 2020 17:06:53 +0300 Message-Id: <2354f1a5073b61e10959c5749392277fd41dc7ca.1593352527.git.dekelp@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 4/6] net/mlx5: add OS specific flow type selection 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 current implementation the flow type (DV/Verbs) is selected using dedicated function flow_get_drv_type(). This patch adds OS specific function mlx5_flow_os_get_type(), to allow OS specific flow type selection. The new function is called by flow_get_drv_type(), and if it returns a valid value (DV/Verbs) no more logic is required. Otherwise the existing logic is executed. Signed-off-by: Dekel Peled --- drivers/net/mlx5/linux/mlx5_flow_os.h | 18 ++++++++++++++++++ drivers/net/mlx5/mlx5_flow.c | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.h b/drivers/net/mlx5/linux/mlx5_flow_os.h index 4ad4e0a..41691a1 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.h +++ b/drivers/net/mlx5/linux/mlx5_flow_os.h @@ -5,6 +5,24 @@ #ifndef RTE_PMD_MLX5_FLOW_OS_H_ #define RTE_PMD_MLX5_FLOW_OS_H_ +#include "mlx5_flow.h" + +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops; +#endif + +/** + * Get OS enforced flow type. MLX5_FLOW_TYPE_MAX means "non enforced type". + * + * @return + * Flow type (MLX5_FLOW_TYPE_MAX) + */ +static inline enum mlx5_flow_drv_type +mlx5_flow_os_get_type(void) +{ + return MLX5_FLOW_TYPE_MAX; +} + /** * Check if item type is supported. * diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 4700ec1..b8468c1 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -36,12 +36,10 @@ #include "mlx5_defs.h" #include "mlx5.h" #include "mlx5_flow.h" +#include "mlx5_flow_os.h" #include "mlx5_rxtx.h" /** Device flow drivers. */ -#ifdef HAVE_IBV_FLOW_DV_SUPPORT -extern const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops; -#endif extern const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops; const struct mlx5_flow_driver_ops mlx5_flow_null_drv_ops; @@ -2501,8 +2499,12 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, flow_get_drv_type(struct rte_eth_dev *dev, const struct rte_flow_attr *attr) { struct mlx5_priv *priv = dev->data->dev_private; - enum mlx5_flow_drv_type type = MLX5_FLOW_TYPE_MAX; + /* The OS can determine first a specific flow type (DV, VERBS) */ + enum mlx5_flow_drv_type type = mlx5_flow_os_get_type(); + if (type != MLX5_FLOW_TYPE_MAX) + return type; + /* If no OS specific type - continue with DV/VERBS selection */ if (attr->transfer && priv->config.dv_esw_en) type = MLX5_FLOW_TYPE_DV; if (!attr->transfer) From patchwork Sun Jun 28 14:06:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dekel Peled X-Patchwork-Id: 72388 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 5AB9CA0350; Sun, 28 Jun 2020 16:09:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A13261D15A; Sun, 28 Jun 2020 16:08:48 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id CF7161C43F for ; Sun, 28 Jun 2020 16:08:45 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@mellanox.com) with SMTP; 28 Jun 2020 17:08:40 +0300 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.228.134.250]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05SE8YV8009807; Sun, 28 Jun 2020 17:08:40 +0300 From: Dekel Peled To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Sun, 28 Jun 2020 17:06:54 +0300 Message-Id: <009295a392f53a326f70e924e5b2e43c9f2d9ecf.1593352527.git.dekelp@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 5/6] net/mlx5: add OS specific flow create and destroy 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" This patch introduces the OS specific functions, for flow create and flow destroy operations. In existing implementation, the functions to create objects (flow/table/matcher) return a pointer to the created object. The functions to destroy objects return 0 on success and errno on failure. The new OS specific functions to create objects return 0 on success, and (-1) on failure. On success, a pointer to the created object is returned using an additional parameter. Signed-off-by: Dekel Peled --- drivers/net/mlx5/linux/mlx5_flow_os.h | 114 ++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 101 +++++++++++++++--------------- 2 files changed, 164 insertions(+), 51 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.h b/drivers/net/mlx5/linux/mlx5_flow_os.h index 41691a1..2ce344c 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.h +++ b/drivers/net/mlx5/linux/mlx5_flow_os.h @@ -53,4 +53,118 @@ return true; } +/** + * Create flow rule. + * + * @param[in] matcher + * Pointer to match mask structure. + * @param[in] match_value + * Pointer to match value structure. + * @param[in] num_actions + * Number of actions in flow rule. + * @param[in] actions + * Pointer to array of flow rule actions. + * @param[out] flow + * Pointer to a valid flow rule object on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow(void *matcher, void *match_value, + size_t num_actions, void *actions[], void **flow) +{ + *flow = mlx5_glue->dv_create_flow(matcher, match_value, + num_actions, actions); + return (*flow) ? 0 : -1; +} + +/** + * Destroy flow rule. + * + * @param[in] drv_flow_ptr + * Pointer to flow rule object. + * + * @return + * 0 on success, or the value of errno on failure. + */ +static inline int +mlx5_flow_os_destroy_flow(void *drv_flow_ptr) +{ + return mlx5_glue->dv_destroy_flow(drv_flow_ptr); +} + +/** + * Create flow table. + * + * @param[in] domain + * Pointer to relevant domain. + * @param[in] table_id + * Table ID. + * @param[out] table + * Pointer to a valid flow table object on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_tbl(void *domain, uint32_t table_id, void **table) +{ + *table = mlx5_glue->dr_create_flow_tbl(domain, table_id); + return (*table) ? 0 : -1; +} + +/** + * Destroy flow table. + * + * @param[in] table + * Pointer to table object to destroy. + * + * @return + * 0 on success, or the value of errno on failure. + */ +static inline int +mlx5_flow_os_destroy_flow_tbl(void *table) +{ + return mlx5_glue->dr_destroy_flow_tbl(table); +} + +/** + * Create flow matcher in a flow table. + * + * @param[in] ctx + * Pointer to relevant device context. + * @param[in] attr + * Pointer to relevant attributes. + * @param[in] table + * Pointer to table object. + * @param[out] matcher + * Pointer to a valid flow matcher object on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_matcher(void *ctx, void *attr, void *table, + void **matcher) +{ + *matcher = mlx5_glue->dv_create_flow_matcher(ctx, attr, table); + return (*matcher) ? 0 : -1; +} + +/** + * Destroy flow matcher. + * + * @param[in] matcher + * Pointer to matcher object to destroy. + * + * @return + * 0 on success, or the value of errno on failure. + */ +static inline int +mlx5_flow_os_destroy_flow_matcher(void *matcher) +{ + return mlx5_glue->dv_destroy_flow_matcher(matcher); +} + #endif /* RTE_PMD_MLX5_FLOW_OS_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index d01a7e5..eb27595 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7340,8 +7340,8 @@ struct field_modify_info modify_tcp[] = { domain = sh->tx_domain; else domain = sh->rx_domain; - tbl->obj = mlx5_glue->dr_create_flow_tbl(domain, table_id); - if (!tbl->obj) { + ret = mlx5_flow_os_create_flow_tbl(domain, table_id, &tbl->obj); + if (ret) { rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot create flow table object"); @@ -7361,7 +7361,7 @@ struct field_modify_info modify_tcp[] = { rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot insert flow table data entry"); - mlx5_glue->dr_destroy_flow_tbl(tbl->obj); + mlx5_flow_os_destroy_flow_tbl(tbl->obj); mlx5_ipool_free(sh->ipool[MLX5_IPOOL_JUMP], idx); } rte_atomic32_inc(&tbl->refcnt); @@ -7393,7 +7393,7 @@ struct field_modify_info modify_tcp[] = { if (rte_atomic32_dec_and_test(&tbl->refcnt)) { struct mlx5_hlist_entry *pos = &tbl_data->entry; - mlx5_glue->dr_destroy_flow_tbl(tbl->obj); + mlx5_flow_os_destroy_flow_tbl(tbl->obj); tbl->obj = NULL; /* remove the entry from the hash list and free memory. */ mlx5_hlist_remove(sh->flow_tbls, pos); @@ -7437,6 +7437,7 @@ struct field_modify_info modify_tcp[] = { }; struct mlx5_flow_tbl_resource *tbl; struct mlx5_flow_tbl_data_entry *tbl_data; + int ret; tbl = flow_dv_tbl_resource_get(dev, key->table_id, key->direction, key->domain, error); @@ -7479,9 +7480,9 @@ struct field_modify_info modify_tcp[] = { dv_attr.priority = matcher->priority; if (key->direction) dv_attr.flags |= IBV_FLOW_ATTR_FLAGS_EGRESS; - cache_matcher->matcher_object = - mlx5_glue->dv_create_flow_matcher(sh->ctx, &dv_attr, tbl->obj); - if (!cache_matcher->matcher_object) { + ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, tbl->obj, + &cache_matcher->matcher_object); + if (ret) { rte_free(cache_matcher); #ifdef HAVE_MLX5DV_DR flow_dv_tbl_resource_release(dev, tbl); @@ -8693,11 +8694,10 @@ struct field_modify_info modify_tcp[] = { dh->rix_default_fate = MLX5_FLOW_FATE_DEFAULT_MISS; dv->actions[n++] = priv->sh->default_miss.action; } - dh->drv_flow = - mlx5_glue->dv_create_flow(dv_h->matcher->matcher_object, - (void *)&dv->value, n, - dv->actions); - if (!dh->drv_flow) { + err = mlx5_flow_os_create_flow(dv_h->matcher->matcher_object, + (void *)&dv->value, n, + dv->actions, &dh->drv_flow); + if (err) { rte_flow_error_set(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -8762,7 +8762,7 @@ struct field_modify_info modify_tcp[] = { dev->data->port_id, (void *)matcher, rte_atomic32_read(&matcher->refcnt)); if (rte_atomic32_dec_and_test(&matcher->refcnt)) { - claim_zero(mlx5_glue->dv_destroy_flow_matcher + claim_zero(mlx5_flow_os_destroy_flow_matcher (matcher->matcher_object)); LIST_REMOVE(matcher, next); /* table ref-- in release interface. */ @@ -9061,7 +9061,7 @@ struct field_modify_info modify_tcp[] = { if (!dh) return; if (dh->drv_flow) { - claim_zero(mlx5_glue->dv_destroy_flow(dh->drv_flow)); + claim_zero(mlx5_flow_os_destroy_flow(dh->drv_flow)); dh->drv_flow = NULL; } if (dh->fate_action == MLX5_FLOW_FATE_DROP || @@ -9242,40 +9242,40 @@ struct field_modify_info modify_tcp[] = { if (!mtd || !priv->config.dv_flow_en) return 0; if (mtd->ingress.policer_rules[RTE_MTR_DROPPED]) - claim_zero(mlx5_glue->dv_destroy_flow - (mtd->ingress.policer_rules[RTE_MTR_DROPPED])); + claim_zero(mlx5_flow_os_destroy_flow + (mtd->ingress.policer_rules[RTE_MTR_DROPPED])); if (mtd->egress.policer_rules[RTE_MTR_DROPPED]) - claim_zero(mlx5_glue->dv_destroy_flow - (mtd->egress.policer_rules[RTE_MTR_DROPPED])); + claim_zero(mlx5_flow_os_destroy_flow + (mtd->egress.policer_rules[RTE_MTR_DROPPED])); if (mtd->transfer.policer_rules[RTE_MTR_DROPPED]) - claim_zero(mlx5_glue->dv_destroy_flow - (mtd->transfer.policer_rules[RTE_MTR_DROPPED])); + claim_zero(mlx5_flow_os_destroy_flow + (mtd->transfer.policer_rules[RTE_MTR_DROPPED])); if (mtd->egress.color_matcher) - claim_zero(mlx5_glue->dv_destroy_flow_matcher - (mtd->egress.color_matcher)); + claim_zero(mlx5_flow_os_destroy_flow_matcher + (mtd->egress.color_matcher)); if (mtd->egress.any_matcher) - claim_zero(mlx5_glue->dv_destroy_flow_matcher - (mtd->egress.any_matcher)); + claim_zero(mlx5_flow_os_destroy_flow_matcher + (mtd->egress.any_matcher)); if (mtd->egress.tbl) flow_dv_tbl_resource_release(dev, mtd->egress.tbl); if (mtd->egress.sfx_tbl) flow_dv_tbl_resource_release(dev, mtd->egress.sfx_tbl); if (mtd->ingress.color_matcher) - claim_zero(mlx5_glue->dv_destroy_flow_matcher - (mtd->ingress.color_matcher)); + claim_zero(mlx5_flow_os_destroy_flow_matcher + (mtd->ingress.color_matcher)); if (mtd->ingress.any_matcher) - claim_zero(mlx5_glue->dv_destroy_flow_matcher - (mtd->ingress.any_matcher)); + claim_zero(mlx5_flow_os_destroy_flow_matcher + (mtd->ingress.any_matcher)); if (mtd->ingress.tbl) flow_dv_tbl_resource_release(dev, mtd->ingress.tbl); if (mtd->ingress.sfx_tbl) flow_dv_tbl_resource_release(dev, mtd->ingress.sfx_tbl); if (mtd->transfer.color_matcher) - claim_zero(mlx5_glue->dv_destroy_flow_matcher - (mtd->transfer.color_matcher)); + claim_zero(mlx5_flow_os_destroy_flow_matcher + (mtd->transfer.color_matcher)); if (mtd->transfer.any_matcher) - claim_zero(mlx5_glue->dv_destroy_flow_matcher - (mtd->transfer.any_matcher)); + claim_zero(mlx5_flow_os_destroy_flow_matcher + (mtd->transfer.any_matcher)); if (mtd->transfer.tbl) flow_dv_tbl_resource_release(dev, mtd->transfer.tbl); if (mtd->transfer.sfx_tbl) @@ -9330,6 +9330,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_meter_domain_info *dtb; struct rte_flow_error error; int i = 0; + int ret; if (transfer) dtb = &mtb->transfer; @@ -9355,10 +9356,9 @@ struct field_modify_info modify_tcp[] = { /* Create matchers, Any and Color. */ dv_attr.priority = 3; dv_attr.match_criteria_enable = 0; - dtb->any_matcher = mlx5_glue->dv_create_flow_matcher(sh->ctx, - &dv_attr, - dtb->tbl->obj); - if (!dtb->any_matcher) { + ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, dtb->tbl->obj, + &dtb->any_matcher); + if (ret) { DRV_LOG(ERR, "Failed to create meter" " policer default matcher."); goto error_exit; @@ -9368,10 +9368,9 @@ struct field_modify_info modify_tcp[] = { 1 << MLX5_MATCH_CRITERIA_ENABLE_MISC2_BIT; flow_dv_match_meta_reg(mask.buf, value.buf, color_reg_c_idx, rte_col_2_mlx5_col(RTE_COLORS), UINT8_MAX); - dtb->color_matcher = mlx5_glue->dv_create_flow_matcher(sh->ctx, - &dv_attr, - dtb->tbl->obj); - if (!dtb->color_matcher) { + ret = mlx5_flow_os_create_flow_matcher(sh->ctx, &dv_attr, dtb->tbl->obj, + &dtb->color_matcher); + if (ret) { DRV_LOG(ERR, "Failed to create meter policer color matcher."); goto error_exit; } @@ -9379,10 +9378,10 @@ struct field_modify_info modify_tcp[] = { actions[i++] = mtb->count_actns[RTE_MTR_DROPPED]; actions[i++] = mtb->drop_actn; /* Default rule: lowest priority, match any, actions: drop. */ - dtb->policer_rules[RTE_MTR_DROPPED] = - mlx5_glue->dv_create_flow(dtb->any_matcher, - (void *)&value, i, actions); - if (!dtb->policer_rules[RTE_MTR_DROPPED]) { + ret = mlx5_flow_os_create_flow(dtb->any_matcher, (void *)&value, i, + actions, + &dtb->policer_rules[RTE_MTR_DROPPED]); + if (ret) { DRV_LOG(ERR, "Failed to create meter policer drop rule."); goto error_exit; } @@ -9476,8 +9475,8 @@ struct field_modify_info modify_tcp[] = { for (i = 0; i < RTE_MTR_DROPPED; i++) { if (dt->policer_rules[i]) { - claim_zero(mlx5_glue->dv_destroy_flow - (dt->policer_rules[i])); + claim_zero(mlx5_flow_os_destroy_flow + (dt->policer_rules[i])); dt->policer_rules[i] = NULL; } } @@ -9545,6 +9544,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_meter_domains_infos *mtb = fm->mfts; void *actions[METER_ACTIONS]; int i; + int ret; /* Create jump action. */ if (!dtb->jump_actn) @@ -9566,11 +9566,10 @@ struct field_modify_info modify_tcp[] = { actions[j++] = mtb->drop_actn; else actions[j++] = dtb->jump_actn; - dtb->policer_rules[i] = - mlx5_glue->dv_create_flow(dtb->color_matcher, - (void *)&value, - j, actions); - if (!dtb->policer_rules[i]) { + ret = mlx5_flow_os_create_flow(dtb->color_matcher, + (void *)&value, j, actions, + &dtb->policer_rules[i]); + if (ret) { DRV_LOG(ERR, "Failed to create policer rule."); goto error; } From patchwork Sun Jun 28 14:06:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dekel Peled X-Patchwork-Id: 72389 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 6BBF2A0350; Sun, 28 Jun 2020 16:09:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E78891D166; Sun, 28 Jun 2020 16:08:49 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D05DC1C440 for ; Sun, 28 Jun 2020 16:08:45 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@mellanox.com) with SMTP; 28 Jun 2020 17:08:41 +0300 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.228.134.250]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05SE8YV9009807; Sun, 28 Jun 2020 17:08:41 +0300 From: Dekel Peled To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Sun, 28 Jun 2020 17:06:55 +0300 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 6/6] net/mlx5: add OS specific flow actions operations 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" This patch introduces the OS specific functions, for flow actions create and destroy operations. In existing implementation, the functions to create flow actions return a pointer to the created action object. The new OS specific functions to create flow actions return 0 on success, and (-1) on failure. On success, a pointer to the created action object is returned using an additional parameter. On failure errno is set. Signed-off-by: Dekel Peled --- drivers/net/mlx5/linux/mlx5_flow_os.h | 198 ++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 110 +++++++++---------- 3 files changed, 251 insertions(+), 59 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.h b/drivers/net/mlx5/linux/mlx5_flow_os.h index 2ce344c..a6bd2c0 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.h +++ b/drivers/net/mlx5/linux/mlx5_flow_os.h @@ -167,4 +167,202 @@ return mlx5_glue->dv_destroy_flow_matcher(matcher); } +/** + * Create flow action: packet reformat. + * + * @param[in] ctx + * Pointer to relevant device context. + * @param[in] domain + * Pointer to domain handler. + * @param[in] resource + * Pointer to action data resource. + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_packet_reformat(void *ctx, void *domain, + void *resource, void **action) +{ + struct mlx5_flow_dv_encap_decap_resource *res = + (struct mlx5_flow_dv_encap_decap_resource *)resource; + + *action = mlx5_glue->dv_create_flow_action_packet_reformat + (ctx, res->reformat_type, res->ft_type, + domain, res->flags, res->size, + (res->size ? res->buf : NULL)); + return (*action) ? 0 : -1; +} + +/** + * Create flow action: modify header. + * + * @param[in] ctx + * Pointer to relevant device context. + * @param[in] domain + * Pointer to domain handler. + * @param[in] resource + * Pointer to action data resource. + * @param[in] actions_len + * Total length of actions data in resource. + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_modify_header(void *ctx, void *domain, + void *resource, + uint32_t actions_len, + void **action) +{ + struct mlx5_flow_dv_modify_hdr_resource *res = + (struct mlx5_flow_dv_modify_hdr_resource *)resource; + + *action = mlx5_glue->dv_create_flow_action_modify_header + (ctx, res->ft_type, domain, res->flags, + actions_len, (uint64_t *)res->actions); + return (*action) ? 0 : -1; +} + +/** + * Create flow action: destination flow table. + * + * @param[in] tbl_obj + * Pointer to destination table object. + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_dest_flow_tbl(void *tbl_obj, void **action) +{ + *action = mlx5_glue->dr_create_flow_action_dest_flow_tbl(tbl_obj); + return (*action) ? 0 : -1; +} + +/** + * Create flow action: destination port. + * + * @param[in] domain + * Pointer to domain handler. + * @param[in] port_id + * Destination port ID. + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_dest_port(void *domain, uint32_t port_id, + void **action) +{ + /* + * Depending on rdma_core version the glue routine calls + * either mlx5dv_dr_action_create_dest_ib_port(domain, dev_port) + * or mlx5dv_dr_action_create_dest_vport(domain, vport_id). + */ + *action = mlx5_glue->dr_create_flow_action_dest_port(domain, port_id); + return (*action) ? 0 : -1; +} + +/** + * Create flow action: push vlan. + * + * @param[in] domain + * Pointer to domain handler. + * @param[in] vlan_tag + * VLAN tag value. + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_push_vlan(void *domain, rte_be32_t vlan_tag, + void **action) +{ + *action = mlx5_glue->dr_create_flow_action_push_vlan(domain, vlan_tag); + return (*action) ? 0 : -1; +} + +/** + * Create flow action: count. + * + * @param[in] cnt_obj + * Pointer to DevX counter object. + * @param[in] offset + * Offset of counter in array. + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_count(void *cnt_obj, uint16_t offset, + void **action) +{ + *action = mlx5_glue->dv_create_flow_action_counter(cnt_obj, offset); + return (*action) ? 0 : -1; +} + +/** + * Create flow action: tag. + * + * @param[in] tag + * Tag value. + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_tag(uint32_t tag, void **action) +{ + *action = mlx5_glue->dv_create_flow_action_tag(tag); + return (*action) ? 0 : -1; +} + +/** + * Create flow action: drop. + * + * @param[out] action + * Pointer to a valid action on success, NULL otherwise. + * + * @return + * 0 on success, or -1 on failure and errno is set. + */ +static inline int +mlx5_flow_os_create_flow_action_drop(void **action) +{ + *action = mlx5_glue->dr_create_flow_action_drop(); + return (*action) ? 0 : -1; +} + +/** + * Destroy flow action. + * + * @param[in] action + * Pointer to action object to destroy. + * + * @return + * 0 on success, or the value of errno on failure. + */ +static inline int +mlx5_flow_os_destroy_flow_action(void *action) +{ + return mlx5_glue->destroy_flow_action(action); +} + #endif /* RTE_PMD_MLX5_FLOW_OS_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 22cc356..43cbda8 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -436,7 +436,7 @@ struct mlx5_flow_dv_modify_hdr_resource { LIST_ENTRY(mlx5_flow_dv_modify_hdr_resource) next; /* Pointer to next element. */ rte_atomic32_t refcnt; /**< Reference counter. */ - struct ibv_flow_action *action; + void *action; /**< Modify header action object. */ uint8_t ft_type; /**< Flow table type, Rx or Tx. */ uint32_t actions_num; /**< Number of modification actions. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index eb27595..0bd1c99 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -2569,6 +2568,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_flow_dv_encap_decap_resource *cache_resource; struct mlx5dv_dr_domain *domain; uint32_t idx = 0; + int ret; resource->flags = dev_flow->dv.group ? 0 : 1; if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB) @@ -2604,13 +2604,10 @@ struct field_modify_info modify_tcp[] = { RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot allocate resource memory"); *cache_resource = *resource; - cache_resource->action = - mlx5_glue->dv_create_flow_action_packet_reformat - (sh->ctx, cache_resource->reformat_type, - cache_resource->ft_type, domain, cache_resource->flags, - cache_resource->size, - (cache_resource->size ? cache_resource->buf : NULL)); - if (!cache_resource->action) { + ret = mlx5_flow_os_create_flow_action_packet_reformat + (sh->ctx, domain, cache_resource, + &cache_resource->action); + if (ret) { rte_free(cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -2652,15 +2649,14 @@ struct field_modify_info modify_tcp[] = { { struct mlx5_flow_tbl_data_entry *tbl_data = container_of(tbl, struct mlx5_flow_tbl_data_entry, tbl); - int cnt; + int cnt, ret; MLX5_ASSERT(tbl); cnt = rte_atomic32_read(&tbl_data->jump.refcnt); if (!cnt) { - tbl_data->jump.action = - mlx5_glue->dr_create_flow_action_dest_flow_tbl - (tbl->obj); - if (!tbl_data->jump.action) + ret = mlx5_flow_os_create_flow_action_dest_flow_tbl + (tbl->obj, &tbl_data->jump.action); + if (ret) return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot create jump action"); @@ -2741,6 +2737,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_dev_ctx_shared *sh = priv->sh; struct mlx5_flow_dv_port_id_action_resource *cache_resource; uint32_t idx = 0; + int ret; /* Lookup a matching resource from cache. */ ILIST_FOREACH(sh->ipool[MLX5_IPOOL_PORT_ID], sh->port_id_action_list, @@ -2764,15 +2761,10 @@ struct field_modify_info modify_tcp[] = { RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot allocate resource memory"); *cache_resource = *resource; - /* - * Depending on rdma_core version the glue routine calls - * either mlx5dv_dr_action_create_dest_ib_port(domain, dev_port) - * or mlx5dv_dr_action_create_dest_vport(domain, vport_id). - */ - cache_resource->action = - mlx5_glue->dr_create_flow_action_dest_port - (priv->sh->fdb_domain, resource->port_id); - if (!cache_resource->action) { + ret = mlx5_flow_os_create_flow_action_dest_port + (priv->sh->fdb_domain, resource->port_id, + &cache_resource->action); + if (ret) { rte_free(cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -2817,6 +2809,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_flow_dv_push_vlan_action_resource *cache_resource; struct mlx5dv_dr_domain *domain; uint32_t idx = 0; + int ret; /* Lookup a matching resource from cache. */ ILIST_FOREACH(sh->ipool[MLX5_IPOOL_PUSH_VLAN], @@ -2847,10 +2840,10 @@ struct field_modify_info modify_tcp[] = { domain = sh->rx_domain; else domain = sh->tx_domain; - cache_resource->action = - mlx5_glue->dr_create_flow_action_push_vlan(domain, - resource->vlan_tag); - if (!cache_resource->action) { + ret = mlx5_flow_os_create_flow_action_push_vlan + (domain, resource->vlan_tag, + &cache_resource->action); + if (ret) { rte_free(cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -3991,6 +3984,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_flow_dv_modify_hdr_resource *cache_resource; struct mlx5dv_dr_domain *ns; uint32_t actions_len; + int ret; resource->flags = dev_flow->dv.group ? 0 : MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL; @@ -4031,12 +4025,10 @@ struct field_modify_info modify_tcp[] = { "cannot allocate resource memory"); *cache_resource = *resource; rte_memcpy(cache_resource->actions, resource->actions, actions_len); - cache_resource->action = - mlx5_glue->dv_create_flow_action_modify_header - (sh->ctx, cache_resource->ft_type, ns, - cache_resource->flags, actions_len, - (uint64_t *)cache_resource->actions); - if (!cache_resource->action) { + ret = mlx5_flow_os_create_flow_action_modify_header + (sh->ctx, ns, cache_resource, + actions_len, &cache_resource->action); + if (ret) { rte_free(cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -4621,6 +4613,7 @@ struct field_modify_info modify_tcp[] = { if (!cnt_free->action) { uint16_t offset; struct mlx5_devx_obj *dcs; + int ret; if (batch) { offset = MLX5_CNT_ARRAY_IDX(pool, cnt_free); @@ -4629,9 +4622,9 @@ struct field_modify_info modify_tcp[] = { offset = 0; dcs = cnt_ext->dcs; } - cnt_free->action = mlx5_glue->dv_create_flow_action_counter - (dcs->obj, offset); - if (!cnt_free->action) { + ret = mlx5_flow_os_create_flow_action_count(dcs->obj, offset, + &cnt_free->action); + if (ret) { rte_errno = errno; goto err; } @@ -7532,6 +7525,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_dev_ctx_shared *sh = priv->sh; struct mlx5_flow_dv_tag_resource *cache_resource; struct mlx5_hlist_entry *entry; + int ret; /* Lookup a matching resource from cache. */ entry = mlx5_hlist_lookup(sh->tag_table, (uint64_t)tag_be24); @@ -7554,8 +7548,9 @@ struct field_modify_info modify_tcp[] = { RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot allocate resource memory"); cache_resource->entry.key = (uint64_t)tag_be24; - cache_resource->action = mlx5_glue->dv_create_flow_action_tag(tag_be24); - if (!cache_resource->action) { + ret = mlx5_flow_os_create_flow_action_tag(tag_be24, + &cache_resource->action); + if (ret) { rte_free(cache_resource); return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -7564,7 +7559,7 @@ struct field_modify_info modify_tcp[] = { rte_atomic32_init(&cache_resource->refcnt); rte_atomic32_inc(&cache_resource->refcnt); if (mlx5_hlist_insert(sh->tag_table, &cache_resource->entry)) { - mlx5_glue->destroy_flow_action(cache_resource->action); + mlx5_flow_os_destroy_flow_action(cache_resource->action); rte_free(cache_resource); return rte_flow_error_set(error, EEXIST, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -7603,7 +7598,7 @@ struct field_modify_info modify_tcp[] = { dev->data->port_id, (void *)tag, rte_atomic32_read(&tag->refcnt)); if (rte_atomic32_dec_and_test(&tag->refcnt)) { - claim_zero(mlx5_glue->destroy_flow_action(tag->action)); + claim_zero(mlx5_flow_os_destroy_flow_action(tag->action)); mlx5_hlist_remove(sh->tag_table, &tag->entry); DRV_LOG(DEBUG, "port %u tag %p: removed", dev->data->port_id, (void *)tag); @@ -8803,8 +8798,8 @@ struct field_modify_info modify_tcp[] = { (void *)cache_resource, rte_atomic32_read(&cache_resource->refcnt)); if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { - claim_zero(mlx5_glue->destroy_flow_action - (cache_resource->action)); + claim_zero(mlx5_flow_os_destroy_flow_action + (cache_resource->action)); ILIST_REMOVE(priv->sh->ipool[MLX5_IPOOL_DECAP_ENCAP], &priv->sh->encaps_decaps, idx, cache_resource, next); @@ -8845,8 +8840,8 @@ struct field_modify_info modify_tcp[] = { (void *)cache_resource, rte_atomic32_read(&cache_resource->refcnt)); if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { - claim_zero(mlx5_glue->destroy_flow_action - (cache_resource->action)); + claim_zero(mlx5_flow_os_destroy_flow_action + (cache_resource->action)); /* jump action memory free is inside the table release. */ flow_dv_tbl_resource_release(dev, &tbl_data->tbl); DRV_LOG(DEBUG, "jump table resource %p: removed", @@ -8906,8 +8901,8 @@ struct field_modify_info modify_tcp[] = { (void *)cache_resource, rte_atomic32_read(&cache_resource->refcnt)); if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { - claim_zero(mlx5_glue->destroy_flow_action - (cache_resource->action)); + claim_zero(mlx5_flow_os_destroy_flow_action + (cache_resource->action)); LIST_REMOVE(cache_resource, next); rte_free(cache_resource); DRV_LOG(DEBUG, "modify-header resource %p: removed", @@ -8945,8 +8940,8 @@ struct field_modify_info modify_tcp[] = { (void *)cache_resource, rte_atomic32_read(&cache_resource->refcnt)); if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { - claim_zero(mlx5_glue->destroy_flow_action - (cache_resource->action)); + claim_zero(mlx5_flow_os_destroy_flow_action + (cache_resource->action)); ILIST_REMOVE(priv->sh->ipool[MLX5_IPOOL_PORT_ID], &priv->sh->port_id_action_list, idx, cache_resource, next); @@ -8986,8 +8981,8 @@ struct field_modify_info modify_tcp[] = { (void *)cache_resource, rte_atomic32_read(&cache_resource->refcnt)); if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { - claim_zero(mlx5_glue->destroy_flow_action - (cache_resource->action)); + claim_zero(mlx5_flow_os_destroy_flow_action + (cache_resource->action)); ILIST_REMOVE(priv->sh->ipool[MLX5_IPOOL_PUSH_VLAN], &priv->sh->push_vlan_action_list, idx, cache_resource, next); @@ -9281,7 +9276,7 @@ struct field_modify_info modify_tcp[] = { if (mtd->transfer.sfx_tbl) flow_dv_tbl_resource_release(dev, mtd->transfer.sfx_tbl); if (mtd->drop_actn) - claim_zero(mlx5_glue->destroy_flow_action(mtd->drop_actn)); + claim_zero(mlx5_flow_os_destroy_flow_action(mtd->drop_actn)); rte_free(mtd); return 0; } @@ -9430,8 +9425,8 @@ struct field_modify_info modify_tcp[] = { mtb->count_actns[i] = cnt->action; } /* Create drop action. */ - mtb->drop_actn = mlx5_glue->dr_create_flow_action_drop(); - if (!mtb->drop_actn) { + ret = mlx5_flow_os_create_flow_action_drop(&mtb->drop_actn); + if (ret) { DRV_LOG(ERR, "Failed to create drop action."); goto error_exit; } @@ -9481,7 +9476,7 @@ struct field_modify_info modify_tcp[] = { } } if (dt->jump_actn) { - claim_zero(mlx5_glue->destroy_flow_action(dt->jump_actn)); + claim_zero(mlx5_flow_os_destroy_flow_action(dt->jump_actn)); dt->jump_actn = NULL; } } @@ -9544,14 +9539,13 @@ struct field_modify_info modify_tcp[] = { struct mlx5_meter_domains_infos *mtb = fm->mfts; void *actions[METER_ACTIONS]; int i; - int ret; + int ret = 0; /* Create jump action. */ if (!dtb->jump_actn) - dtb->jump_actn = - mlx5_glue->dr_create_flow_action_dest_flow_tbl - (dtb->sfx_tbl->obj); - if (!dtb->jump_actn) { + ret = mlx5_flow_os_create_flow_action_dest_flow_tbl + (dtb->sfx_tbl->obj, &dtb->jump_actn); + if (ret) { DRV_LOG(ERR, "Failed to create policer jump action."); goto error; }