From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA2EFC5DF63 for ; Wed, 6 Nov 2019 17:39:51 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 7D7142173E for ; Wed, 6 Nov 2019 17:39:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D7142173E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3FD8C1E863; Wed, 6 Nov 2019 18:38:30 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id B721F1D44E for ; Wed, 6 Nov 2019 18:38:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 6 Nov 2019 19:38:09 +0200 Received: from pegasus11.mtr.labs.mlnx (pegasus11.mtr.labs.mlnx [10.210.16.104]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xA6Hc93Y026718; Wed, 6 Nov 2019 19:38:09 +0200 Received: from pegasus11.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id xA6Hc9ji021157; Wed, 6 Nov 2019 17:38:09 GMT Received: (from viacheslavo@localhost) by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id xA6Hc8u8021156; Wed, 6 Nov 2019 17:38:09 GMT X-Authentication-Warning: pegasus11.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: matan@mellanox.com, rasland@mellanox.com, thomas@monjalon.net, orika@mellanox.com, Yongseok Koh Date: Wed, 6 Nov 2019 17:37:45 +0000 Message-Id: <1573061873-20898-12-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573061873-20898-1-git-send-email-viacheslavo@mellanox.com> References: <1572940915-29416-1-git-send-email-viacheslavo@mellanox.com> <1573061873-20898-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH v2 11/19] net/mlx5: check the maximal modify actions number 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" If the extensive metadata registers are supported, it can be regarded inclusively that the extensive metadata support is possible. E.g. metadata register copy action, supporting 16 modify header actions, reserving register across different steering domain (FDB and NIC) and so on. This patch handles the maximal amount of header modify actions depending on discovered metadata registers support. Signed-off-by: Yongseok Koh Signed-off-by: Viacheslav Ovsiienko Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.h | 9 +++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index f2b6726..c1d0a65 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -348,8 +348,13 @@ struct mlx5_flow_dv_tag_resource { uint32_t tag; /**< the tag value. */ }; -/* Number of modification commands. */ -#define MLX5_MODIFY_NUM 8 +/* + * Number of modification commands. + * If extensive metadata registers are supported + * the maximal actions amount is 16 and 8 otherwise. + */ +#define MLX5_MODIFY_NUM 16 +#define MLX5_MODIFY_NUM_NO_MREG 8 /* Modify resource structure */ struct mlx5_flow_dv_modify_hdr_resource { diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index fb56329..80280ab 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2749,6 +2749,27 @@ struct field_modify_info modify_tcp[] = { } /** + * Get the maximum number of modify header actions. + * + * @param dev + * Pointer to rte_eth_dev structure. + * + * @return + * Max number of modify header actions device can support. + */ +static unsigned int +flow_dv_modify_hdr_action_max(struct rte_eth_dev *dev) +{ + /* + * There's no way to directly query the max cap. Although it has to be + * acquried by iterative trial, it is a safe assumption that more + * actions are supported by FW if extensive metadata register is + * supported. + */ + return mlx5_flow_ext_mreg_supported(dev) ? MLX5_MODIFY_NUM : + MLX5_MODIFY_NUM_NO_MREG; +} +/** * Find existing modify-header resource or create and register a new one. * * @param dev[in, out] @@ -2775,6 +2796,10 @@ struct field_modify_info modify_tcp[] = { struct mlx5_flow_dv_modify_hdr_resource *cache_resource; struct mlx5dv_dr_domain *ns; + if (resource->actions_num > flow_dv_modify_hdr_action_max(dev)) + return rte_flow_error_set(error, EOVERFLOW, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "too many modify header items"); if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB) ns = sh->fdb_domain; else if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_TX) -- 1.8.3.1