From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 25344A057C; Thu, 26 Mar 2020 11:22:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E42562C15; Thu, 26 Mar 2020 11:22:29 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) by dpdk.org (Postfix) with ESMTP id 48BEE2BAE; Thu, 26 Mar 2020 11:22:28 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g8BNRZmu7qLmOhCmE0Zom2vRU4tmKY8bL/62sI2JalNWmSB/ENOjDj+tmVYLbUOOpuSr/Bj76Iei3PhwFHE9SyP6uUrQ0Og/bE9GZlrk2b81kTUp0GZumKD++cbwmRs1nCqX+/zkDV7eDmxZvUevRPFa7//jq6qaOyDAwwtq9BifiSsdq8LSZa5ke/kemZyvvboj6tGHQEOaoTCuI0FGjAWXQnazb6En7Q0CFA8BDBj3rcxrgb9kH5zushD9Foizkhlfe9Nnado+KGDXu+j7ZzZB/4Uyv6I+r2ANk0iFs7j0lD+Yi9dZD8p9anjkupOdqpziv9R6kd4WoRdCQ1sxGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SjUdzLOosb5vzRF/2pHcBrz3SyV8YK8nYDdl7xqAByU=; b=iKNN1JhzQVMoMSBmWQhgBG8hYyWgusvp6Ia3NakFvrj8BRHFoQoyIsiEn9rBD2NgiI/Ar4Zsoig6YI68MohWqJf0PFR+5/kpEqpOJ+qQebFEcNAlskkBU+/IaAE+Ly4anlmd+CSclaPlsK31qBVEQQ3kU3MmVc58KE8ym99/b3Z9RG3uERgGGPDk5gy1sGTf6B/qhgXOIUq3ADbOvZpJrTIw6KHGW+XodYSwCckwCYEfdYhHHuAGDbD388M/wNBgv/aBG+4KrWsMQkmodBYE4sc4+J6PV2axcNdyqQb4q7F3cKxdwD6szKyN5TPpDgHi/L0tamHyqCZ4JB7Nn5DR7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SjUdzLOosb5vzRF/2pHcBrz3SyV8YK8nYDdl7xqAByU=; b=CBe/6S8oVdRoIUYaA2tG+7Giznq2TQLUezMY0ZPiV45+nrTQ2agRV3vh/zxLZcqUFpzQwAxyZhlSU5VGPkzEW+G4nZo3QqpVC0qaMBD83i786ZD4mc33A0fKOkkqMZiAdfxtLIqa1Y9uGVKmF3WKgsIxC+amO8QAG/fuUVHxgbA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=wisamm@mellanox.com; Received: from AM0PR05MB6610.eurprd05.prod.outlook.com (20.178.202.18) by AM0PR05MB6676.eurprd05.prod.outlook.com (10.141.190.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Thu, 26 Mar 2020 10:22:27 +0000 Received: from AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::f9b0:5b27:21a3:c758]) by AM0PR05MB6610.eurprd05.prod.outlook.com ([fe80::f9b0:5b27:21a3:c758%3]) with mapi id 15.20.2856.019; Thu, 26 Mar 2020 10:22:26 +0000 From: Wisam Jaddo To: orika@mellanox.com, matan@mellanox.com, dev@dpdk.org Cc: rasland@mellanox.com, viacheslavo@mellanox.com, stable@dpdk.org Date: Thu, 26 Mar 2020 10:22:00 +0000 Message-Id: <20200326102200.15281-1-wisamm@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319090237.15639-1-wisamm@mellanox.com> References: <20200319090237.15639-1-wisamm@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: PR0P264CA0104.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::20) To AM0PR05MB6610.eurprd05.prod.outlook.com (2603:10a6:208:12f::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by PR0P264CA0104.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19 via Frontend Transport; Thu, 26 Mar 2020 10:22:25 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ea6b1213-1b4a-4022-e53c-08d7d16f94ba X-MS-TrafficTypeDiagnostic: AM0PR05MB6676:|AM0PR05MB6676: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-Forefront-PRVS: 0354B4BED2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6610.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(39850400004)(396003)(376002)(366004)(136003)(346002)(478600001)(66946007)(7696005)(8886007)(36756003)(6666004)(316002)(66476007)(5660300002)(1076003)(81166006)(81156014)(8676002)(52116002)(8936002)(66556008)(450100002)(55016002)(4326008)(86362001)(186003)(26005)(956004)(2616005)(16526019)(2906002); DIR:OUT; SFP:1101; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DKHAYAKTJ4YZ3yJSpj+wSRqcwZqeEtnf85r62ZAyOVIJrGd1bWI+0nIlGAdt+NM6kzPxKYlDt9DB8YuP0IgDUAUg7FtoAjcDnB/Hx2XxZ8K2l7Ldu3fd6IXa4ZC0mnFkcMkb5Qjni3s9BkP86gJR7Seq4Xs893M+v4v4lvss8VjpxlRzdl3UD2ZYnzEoZOEKSDpuk9umrN+jXaxFoLX/MIcDj9KWJWHQKv+b58kRg3Ksn2f9kPTYXuXa9JFjNPgDjCdXu1U/M8bBVWMfoqLn2TlKu/2mKG0nH6Db9TOv0jLUQ5XeyL8Yjr36MiE1c3HBTetSdyymOJl+BXJxskhDlIZjDQT/ZhF+i58QZbsiwuPEqlhgoi+wCb3mFKSWQtT9J4g0X/Rb2w5eF8HS8tuK7QSBM8myTSvjKZ6v6szKMshW6o5WqUEnm/auLVVYMK+2 X-MS-Exchange-AntiSpam-MessageData: be7yeG4wr7N5Jx94+MooiS3kx8eBxDdSUm1rSyE+gU7XIpQv9dJnPT4ECfTxZSY24HT1dA2Tyamh0l1HAaqmVXRIKwo1VZBp59VmaSN/5KzL4VhoiUZkqbYB5vtzpSEEov69XSC/Mw8vfwb61Teuxg== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea6b1213-1b4a-4022-e53c-08d7d16f94ba X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2020 10:22:26.6983 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fdIm4Q6WLsmCCnYVmhd2qUj2V+9Dh8RLxLwYGmLfKFYgRTHFbfKpvUREVjAUU8nz7c26yZoP3BvEnYd4L5jaOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6676 Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix zero value validation for metadata 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" MARK and META items are interrelated with datapath - they might move from/to the applications in mbuf. zero value for these items has the special meaning - it means "no metadata are provided", not zero values are treated by applications and PMD as valid ones. Moreover in the flow engine domain the value zero is acceptable to match and set, and we should allow to specify zero values as rte_flow parameters for the META and MARK items and actions. In the same time zero mask has no meaning and and should be rejected on validation stage. Fixes: fcc8d2f716fd ("net/mlx5: extend flow metadata support") Fixes: e554b672aa05 ("net/mlx5: support flow tag") Fixes: 55deee1715f0 ("net/mlx5: extend flow mark support") Cc: viacheslavo@mellanox.com Cc: stable@dpdk.org Signed-off-by: Wisam Jaddo --- Changes in v2 - Fix commit message - Fix documentation - Remove extra line - Always check for zero mask --- --- doc/guides/nics/mlx5.rst | 12 ++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 19 +++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index e8f9984df0..e13c07d9ab 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -1275,6 +1275,18 @@ Supported hardware offloads | | | ConnectX-5 | | ConnectX-5 | +-----------------------+-----------------+-----------------+ +Notes for metadata +------------------ +MARK and META items are interrelated with datapath - they might move from/to +the applications in mbuf fields. Hence, zero value for these items has the +special meaning - it means "no metadata are provided", not zero values are +treated by applications and PMD as valid ones. + +Moreover in the flow engine domain the value zero is acceptable to match and +set, and we should allow to specify zero values as rte_flow parameters for the +META and MARK items and actions. In the same time zero mask has no meaning and +should be rejected on validation stage. + Notes for testpmd ----------------- diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 809833b7ee..da4a925404 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1406,6 +1406,11 @@ flow_dv_validate_item_mark(struct rte_eth_dev *dev, "mark id exceeds the limit"); if (!mask) mask = &nic_mask; + if (!mask->id) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, NULL, + "mask cannot be zero"); + ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask, (const uint8_t *)&nic_mask, sizeof(struct rte_flow_item_mark), @@ -1451,10 +1456,6 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, item->spec, "data cannot be empty"); - if (!spec->data) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM_SPEC, NULL, - "data cannot be zero"); if (config->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { if (!mlx5_flow_ext_mreg_supported(dev)) return rte_flow_error_set(error, ENOTSUP, @@ -1474,6 +1475,11 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, } if (!mask) mask = &rte_flow_item_meta_mask; + if (!mask->data) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, NULL, + "mask cannot be zero"); + ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask, (const uint8_t *)&nic_mask, sizeof(struct rte_flow_item_meta), @@ -1522,6 +1528,11 @@ flow_dv_validate_item_tag(struct rte_eth_dev *dev, "data cannot be empty"); if (!mask) mask = &rte_flow_item_tag_mask; + if (!mask->data) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM_SPEC, NULL, + "mask cannot be zero"); + ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask, (const uint8_t *)&nic_mask, sizeof(struct rte_flow_item_tag), -- 2.17.1