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 2C543A0093 for ; Tue, 19 May 2020 15:16:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 251921D97E; Tue, 19 May 2020 15:16:48 +0200 (CEST) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 896C51D94F for ; Tue, 19 May 2020 15:16:44 +0200 (CEST) Received: by mail-wm1-f65.google.com with SMTP id h4so3014155wmb.4 for ; Tue, 19 May 2020 06:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LF19vLklMJ7oGdYFvHnynnO4s2AaWha6aVP+4E6u9TY=; b=Bb/g774G+WCW3phe4MhPM+DkJ38PcdkYn0vtrn81apddaVktTy+cMcCY4XIGshyWWB DMHD4M/sSMpdOI4RlnACTKndsU/WDYKPWhxgViA3xixvqb13AW1T4S+k2MLj8CflHpI3 ui13VQI4fAVFLmTDi4SsPzeI2xZ+KhgKHV5vRwH6viSg4Ymxq2wqQ6n1XirFDINYex8G eHx7yeirwFQty+sYYXN7hEHbThHxk/Q3t8JlTeKWQ06J65sSUiOUm5DLiiKayHnQBN1R F8Itxeghd/EzLgFNWKXLlb5sVl3r2q4FQXu7Vl1m1RhRC/L8U7h8QSG9eepHv8XoMDnu tknQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LF19vLklMJ7oGdYFvHnynnO4s2AaWha6aVP+4E6u9TY=; b=SJtcjkHoMyGohwA/GTZ1OEcyg5BJsbrlIjC0KEqYGEfv6aJHGyimoJTXuiRAkHb6HZ lekNYjj3e9C6G7sjdBI0WZqZHcbUcsVJ8D/DuVwVIu9wEyWdmu98xjGfBBMm+IgW2aZe uLVfDTSDGVAwo2ceHcGckN7+Obi7QunKDpOdrhDJL+f3DFunLOAWzYQy/sucwhit68np dqCfuJzO9zul7E7CD9xSxemh/QJZtxDlaspBVNQRTjRTYJ7f8/GIrxG70u2+RVqkQU6L 0NPYJGo4UtRTrzicx61s5XRgFzoWCxQrG9ck47vFA7DgSutJY0ZkHlxGwvtGUgr2HE8d Yghw== X-Gm-Message-State: AOAM530OdzY4lWZmj8LHH3w2Hp/u3N4VO7wp+ffH87JkIx0zkosRaKeM GwlsKAawZFxHi13jlmfmfm0= X-Google-Smtp-Source: ABdhPJyR6WbThw62NFQkoNu2MnLKr+FhqAAd+pU+HrKjFuUQTYSz1pn70IsyjgO24zk5+fVw5UQqnQ== X-Received: by 2002:a7b:c198:: with SMTP id y24mr5391847wmi.186.1589894204233; Tue, 19 May 2020 06:16:44 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id m1sm23390645wrx.44.2020.05.19.06.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:16:43 -0700 (PDT) From: luca.boccassi@gmail.com To: Dekel Peled Cc: Viacheslav Ovsiienko , dpdk stable Date: Tue, 19 May 2020 14:05:42 +0100 Message-Id: <20200519130549.112823-207-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> <20200519130549.112823-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/mlx5: fix match on empty VLAN item in DV mode' has been queued to stable release 19.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/21/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 23e2c36fa119fc89e02a6645f048699a5a0dee1e Mon Sep 17 00:00:00 2001 From: Dekel Peled Date: Tue, 5 May 2020 15:57:54 +0300 Subject: [PATCH] net/mlx5: fix match on empty VLAN item in DV mode [ upstream commit 92818d839e8eb0ce479db826f00aa6d62384fc92 ] In existing implementation, using wild card VLAN item is not allowed. A VLAN item in flow pattern must include VLAN ID (vid) value. This obligation contradict the flow API specification [1]. This patch updates the VLAN item validation and translation, to allow wild card VLAN item, without VLAN ID value. User guide and release notes are updated accordingly. [1] commit 40513808b165 ("doc: refine ethernet and VLAN flow rule items") Fixes: 00f75a40576b ("net/mlx5: fix VLAN match for DV mode") Signed-off-by: Dekel Peled Acked-by: Viacheslav Ovsiienko --- doc/guides/nics/mlx5.rst | 18 +++++ drivers/net/mlx5/mlx5_flow_dv.c | 116 ++++++++++++++++++++++++++------ 2 files changed, 115 insertions(+), 19 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 261002621c..75f58e6027 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -123,6 +123,24 @@ Limitations Will match any ipv4 packet (VLAN included). +- When using DV flow engine (``dv_flow_en`` = 1), flow pattern without VLAN item + will match untagged packets only. + The flow rule:: + + flow create 0 ingress pattern eth / ipv4 / end ... + + Will match untagged packets only. + The flow rule:: + + flow create 0 ingress pattern eth / vlan / ipv4 / end ... + + Will match tagged packets only, with any VLAN ID value. + The flow rule:: + + flow create 0 ingress pattern eth / vlan vid is 3 / ipv4 / end ... + + Will only match tagged packets with VLAN ID 3. + - VLAN pop offload command: - Flow rules having a VLAN pop offload command as one of their actions and diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 5b6d78c86e..9233853e1d 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1555,6 +1555,79 @@ flow_dv_validate_item_port_id(struct rte_eth_dev *dev, return 0; } +/** + * Validate VLAN item. + * + * @param[in] item + * Item specification. + * @param[in] item_flags + * Bit-fields that holds the items detected until now. + * @param[in] dev + * Ethernet device flow is being created on. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +flow_dv_validate_item_vlan(const struct rte_flow_item *item, + uint64_t item_flags, + struct rte_eth_dev *dev, + struct rte_flow_error *error) +{ + const struct rte_flow_item_vlan *mask = item->mask; + const struct rte_flow_item_vlan nic_mask = { + .tci = RTE_BE16(UINT16_MAX), + .inner_type = RTE_BE16(UINT16_MAX), + }; + const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); + int ret; + const uint64_t l34m = tunnel ? (MLX5_FLOW_LAYER_INNER_L3 | + MLX5_FLOW_LAYER_INNER_L4) : + (MLX5_FLOW_LAYER_OUTER_L3 | + MLX5_FLOW_LAYER_OUTER_L4); + const uint64_t vlanm = tunnel ? MLX5_FLOW_LAYER_INNER_VLAN : + MLX5_FLOW_LAYER_OUTER_VLAN; + + if (item_flags & vlanm) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "multiple VLAN layers not supported"); + else if ((item_flags & l34m) != 0) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "VLAN cannot follow L3/L4 layer"); + if (!mask) + mask = &rte_flow_item_vlan_mask; + ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask, + (const uint8_t *)&nic_mask, + sizeof(struct rte_flow_item_vlan), + error); + if (ret) + return ret; + if (!tunnel && mask->tci != RTE_BE16(0x0fff)) { + struct mlx5_priv *priv = dev->data->dev_private; + + if (priv->vmwa_context) { + /* + * Non-NULL context means we have a virtual machine + * and SR-IOV enabled, we have to create VLAN interface + * to make hypervisor to setup E-Switch vport + * context correctly. We avoid creating the multiple + * VLAN interfaces, so we cannot support VLAN tag mask. + */ + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VLAN tag mask is not" + " supported in virtual" + " environment"); + } + } + return 0; +} + /** * Validate the pop VLAN action. * @@ -4437,8 +4510,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, } break; case RTE_FLOW_ITEM_TYPE_VLAN: - ret = mlx5_flow_validate_item_vlan(items, item_flags, - dev, error); + ret = flow_dv_validate_item_vlan(items, item_flags, + dev, error); if (ret < 0) return ret; last_item = tunnel ? MLX5_FLOW_LAYER_INNER_VLAN : @@ -5264,29 +5337,34 @@ flow_dv_translate_item_vlan(struct mlx5_flow *dev_flow, uint16_t tci_m; uint16_t tci_v; + if (inner) { + headers_m = MLX5_ADDR_OF(fte_match_param, matcher, + inner_headers); + headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers); + } else { + headers_m = MLX5_ADDR_OF(fte_match_param, matcher, + outer_headers); + headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers); + /* + * This is workaround, masks are not supported, + * and pre-validated. + */ + if (vlan_v) + dev_flow->dv.vf_vlan.tag = + rte_be_to_cpu_16(vlan_v->tci) & 0x0fff; + } + /* + * When VLAN item exists in flow, mark packet as tagged, + * even if TCI is not specified. + */ + MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1); + MLX5_SET(fte_match_set_lyr_2_4, headers_v, cvlan_tag, 1); if (!vlan_v) return; if (!vlan_m) vlan_m = &rte_flow_item_vlan_mask; - if (inner) { - headers_m = MLX5_ADDR_OF(fte_match_param, matcher, - inner_headers); - headers_v = MLX5_ADDR_OF(fte_match_param, key, inner_headers); - } else { - headers_m = MLX5_ADDR_OF(fte_match_param, matcher, - outer_headers); - headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers); - /* - * This is workaround, masks are not supported, - * and pre-validated. - */ - dev_flow->dv.vf_vlan.tag = - rte_be_to_cpu_16(vlan_v->tci) & 0x0fff; - } tci_m = rte_be_to_cpu_16(vlan_m->tci); tci_v = rte_be_to_cpu_16(vlan_m->tci & vlan_v->tci); - MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1); - MLX5_SET(fte_match_set_lyr_2_4, headers_v, cvlan_tag, 1); MLX5_SET(fte_match_set_lyr_2_4, headers_m, first_vid, tci_m); MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_vid, tci_v); MLX5_SET(fte_match_set_lyr_2_4, headers_m, first_cfi, tci_m >> 12); -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 14:04:53.042348058 +0100 +++ 0207-net-mlx5-fix-match-on-empty-VLAN-item-in-DV-mode.patch 2020-05-19 14:04:44.600655334 +0100 @@ -1,8 +1,10 @@ -From 92818d839e8eb0ce479db826f00aa6d62384fc92 Mon Sep 17 00:00:00 2001 +From 23e2c36fa119fc89e02a6645f048699a5a0dee1e Mon Sep 17 00:00:00 2001 From: Dekel Peled Date: Tue, 5 May 2020 15:57:54 +0300 Subject: [PATCH] net/mlx5: fix match on empty VLAN item in DV mode +[ upstream commit 92818d839e8eb0ce479db826f00aa6d62384fc92 ] + In existing implementation, using wild card VLAN item is not allowed. A VLAN item in flow pattern must include VLAN ID (vid) value. This obligation contradict the flow API specification [1]. @@ -15,21 +17,19 @@ commit 40513808b165 ("doc: refine ethernet and VLAN flow rule items") Fixes: 00f75a40576b ("net/mlx5: fix VLAN match for DV mode") -Cc: stable@dpdk.org Signed-off-by: Dekel Peled Acked-by: Viacheslav Ovsiienko --- - doc/guides/nics/mlx5.rst | 18 ++++ - doc/guides/rel_notes/release_20_05.rst | 1 + - drivers/net/mlx5/mlx5_flow_dv.c | 116 +++++++++++++++++++++---- - 3 files changed, 116 insertions(+), 19 deletions(-) + doc/guides/nics/mlx5.rst | 18 +++++ + drivers/net/mlx5/mlx5_flow_dv.c | 116 ++++++++++++++++++++++++++------ + 2 files changed, 115 insertions(+), 19 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst -index c4bc77c0b6..07f5a3bccd 100644 +index 261002621c..75f58e6027 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst -@@ -127,6 +127,24 @@ Limitations +@@ -123,6 +123,24 @@ Limitations Will match any ipv4 packet (VLAN included). @@ -54,23 +54,11 @@ - VLAN pop offload command: - Flow rules having a VLAN pop offload command as one of their actions and -diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst -index 32ca4fa869..281feb0ead 100644 ---- a/doc/guides/rel_notes/release_20_05.rst -+++ b/doc/guides/rel_notes/release_20_05.rst -@@ -146,6 +146,7 @@ New Features - * Removed flow rules caching for memory saving and compliance with ethdev API. - * Optimized the memory consumption of flow. - * Added support for flow aging based on hardware counter. -+ * Added support for flow pattern with wildcard VLAN item (without VID value). - - * **Added Chacha20-Poly1305 algorithm to Cryptodev API.** - diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c -index aa5c353a3b..5a0bb9d789 100644 +index 5b6d78c86e..9233853e1d 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c -@@ -1639,6 +1639,79 @@ flow_dv_validate_item_port_id(struct rte_eth_dev *dev, +@@ -1555,6 +1555,79 @@ flow_dv_validate_item_port_id(struct rte_eth_dev *dev, return 0; } @@ -148,9 +136,9 @@ +} + /** - * Validate GTP item. + * Validate the pop VLAN action. * -@@ -4818,8 +4891,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -4437,8 +4510,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, } break; case RTE_FLOW_ITEM_TYPE_VLAN: @@ -161,7 +149,7 @@ if (ret < 0) return ret; last_item = tunnel ? MLX5_FLOW_LAYER_INNER_VLAN : -@@ -5754,29 +5827,34 @@ flow_dv_translate_item_vlan(struct mlx5_flow *dev_flow, +@@ -5264,29 +5337,34 @@ flow_dv_translate_item_vlan(struct mlx5_flow *dev_flow, uint16_t tci_m; uint16_t tci_v; @@ -178,7 +166,7 @@ + * and pre-validated. + */ + if (vlan_v) -+ dev_flow->handle->vf_vlan.tag = ++ dev_flow->dv.vf_vlan.tag = + rte_be_to_cpu_16(vlan_v->tci) & 0x0fff; + } + /* @@ -203,7 +191,7 @@ - * This is workaround, masks are not supported, - * and pre-validated. - */ -- dev_flow->handle->vf_vlan.tag = +- dev_flow->dv.vf_vlan.tag = - rte_be_to_cpu_16(vlan_v->tci) & 0x0fff; - } tci_m = rte_be_to_cpu_16(vlan_m->tci);