From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 05CB0A00C2; Wed, 2 Nov 2022 14:45:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7225440A80; Wed, 2 Nov 2022 14:45:11 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.61]) by mails.dpdk.org (Postfix) with ESMTP id D40044069C; Wed, 2 Nov 2022 14:45:09 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m1cOHtbp36W7JC/lMD33pHUJDmwbMv0DwewCHqUEMk/4xo57IYu3q5EnrhK4VoDtqTRS8LWqa+jinQCYcWIPNnG/I+Cc7y3W7Zk3cXKQ8AZ/7nAoMRA2ao9a52S1a48Z7xBEvIb8UIuxShUbjTeWvjI85vYGJK2M8A82eGGPFaz9BL9sLCwXqpjpkVJsNRMAHM8zIMMogsIZWytCmdF25ToRWHxkXcbDyLHwTPVuNPy7ABYZzMtrlsDhY40E3cxO0x+88Ml5Q5EnzQKLIkzrXnnlAaWYIk+cecQPJKaCBfne0vL83dvf4b5bznFn7xMDIsExZggHe421JoslwobJug== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I8sPvVry5GrEuIYOGaZqWeU2Lkdcivu1N4UnvnlMb6Y=; b=SG1MJSX4XU+t8i28YAhmMX5jEa9kg25M0NJNcOfsUVUEUuvx50NAXroyEB32mgbY+Pt3rMqSZhQltlykWcwzgvUK6IPn+rOAnZxS+yJuaG/upVRG3Im2C8jaJqyfhhXixTcPv8pp0Bs6uQOxT/Fn+BT7c4sFt6D/vjdIrg2J8BgBVtwruoP5jxURe7gaVnThW9xroutfHzi6iYgHQhCzPtP8D7bhlQI3OobAodto8ryCcu3Y5BnMuYWUch0057gS8o6O3Oj3dL26wY17fykVUEjftCMChWjN4scmiDJ56yr5gh2DXAwg2ZywCJAOmc1DJSxwHwvvd3NbTRng6j2XJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I8sPvVry5GrEuIYOGaZqWeU2Lkdcivu1N4UnvnlMb6Y=; b=Qb15NAw9IjG7XI46eR7avVu3/Q+0k6aC8NoEFzTklNeKSjsI/EQsJ7P5XHXZvn2rctoMhLE0N9zV3WBW+2FQB/wQPXmIMrEkXjz+UQTIJdDGDQ2mGXsHtrHP+o8dTQn/cC4KX5zp2r9rubYrTKqrH3fB9j8T8ZIru3lOWLrnFpmnzdLNKEbjNQXcXawmwcEdegx55o4/UoClRQQELJVPYCXEHclu4ZEkY/shf+Y52r3b5cavKIixJgSypM3mXz07WFrwE1R3AkeLGblrEOUTMUBup15DjAF/jAi5Er66xIfB5QSbJCjXpEGQMOpEyKi6ZaQXvgGdJCIakga67F396A== Received: from BN9PR03CA0512.namprd03.prod.outlook.com (2603:10b6:408:131::7) by SA1PR12MB7128.namprd12.prod.outlook.com (2603:10b6:806:29c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.16; Wed, 2 Nov 2022 13:45:08 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::90) by BN9PR03CA0512.outlook.office365.com (2603:10b6:408:131::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22 via Frontend Transport; Wed, 2 Nov 2022 13:45:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20 via Frontend Transport; Wed, 2 Nov 2022 13:45:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 2 Nov 2022 06:45:01 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 2 Nov 2022 06:44:59 -0700 From: Jiawei Wang To: , CC: , , Subject: [PATCH 1/2] net/mlx5: fix flow source port checking in sample flow rule Date: Wed, 2 Nov 2022 15:44:13 +0200 Message-ID: <20221102134414.13573-2-jiaweiw@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20221102134414.13573-1-jiaweiw@nvidia.com> References: <20221102134414.13573-1-jiaweiw@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT058:EE_|SA1PR12MB7128:EE_ X-MS-Office365-Filtering-Correlation-Id: 198482a1-20ae-448a-d6fb-08dabcd8744b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fgar6aNZrbDk6c8NdxX+SbJuBFYQbAZt3kInkPzZGWck1J4YqRo2iioiB0V0Iuoud10T8srvlnRqqPXv82m/4FuMZJgnkY71NhYmEJjt6ds2yMMb5fnuHtoAHpnkRk4/pgCanA+cNVETyMW6VM60b/94gwAU/XAZ1L7ltw3EGIXNSqdUydilmJ9uitLvXNbYbQ3x90Far9Okxwu2X5GFiq+sreM6xvDuhPUHMjyvrvttRmY2tR3cAzF89d9Hg84J2oMXhMuQL4lGrBwNWs6wzapiyRXHjSwnMpCyR1gVLBoYXiv7u0xieTmH37zikuO9m92v6yPbst4USuISW7RT2zVg9+2BKSLB59Wk+nABR28zk7AAFjnGSf/Rjj9PIs5W00GNeWoMih8nOSgssag6ciw1EelHhdtrOpSupxSpSP3IeeDsXrG8DMQ4vC6Zks+0w7RyYGlQOEvElPKaeK9zOayoMNKYkeGVEZRm6Hq5tXKUMy4jcbnBCRe9vOgGwEWJLTx8kEJAq5VnC4E6OjWT8WgR2VaYGJuI2OtsIH6YMlbPW4oV/8wuHl0bsJicL2tNfU3+/89UXizDkZooV+XLvKn14Xwbbc08PV646TRtTkQSUO0PqVZgmaXGBKOArCuaTawI2rTsU/uYegG0jiKM47c2mtaYx/OL7LTFK3kJjf2MIIYu16mfq6vtdv6ofbdGm/XK51LOyLPQ/QBPLAgXW+2y8Cw1nmYnyD9qxJk71A+xsZ2/lGrzuJ2Jm8adNMws5Q/CjFxqpLmbx8/CKeQnMA== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(376002)(84040400005)(451199015)(46966006)(40470700004)(36840700001)(26005)(356005)(7636003)(82310400005)(6286002)(55016003)(40480700001)(36756003)(47076005)(4326008)(41300700001)(40460700003)(8676002)(7696005)(2616005)(8936002)(450100002)(16526019)(5660300002)(1076003)(30864003)(186003)(478600001)(70586007)(70206006)(6666004)(110136005)(6636002)(54906003)(426003)(316002)(82740400003)(36860700001)(2906002)(336012)(86362001)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2022 13:45:07.4400 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 198482a1-20ae-448a-d6fb-08dabcd8744b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7128 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The metadata register C value was lost in FDB egress while doing the flow sampler on ConnectX-5. The FDB direction checking was decided by the source port in the flow creation. If there's additional port item was added in the flow match, then the actual source port was changed. This patch adds the checking for the port id item: RTE_FLOW_ITEM_TYPE_PORT_ID, RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT, and RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR, then updates FDB egress checking and the source vport metadata from the port item, also updates the PUSH VLAN, POP VLAN and flow sampler action validation. Fixes: 04c0d3f20f54 ("net/mlx5: fix port matching in sample flow rule") Fixes: 255b8f86eb6e ("net/mlx5: fix E-Switch egress mirror flow validation") Cc: stable@dpdk.org Signed-off-by: Jiawei Wang Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.c | 55 ++++++++++++++++++++++------ drivers/net/mlx5/mlx5_flow.h | 19 ++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 63 +++++++++++++++++++++------------ 3 files changed, 104 insertions(+), 33 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 8e7d649d15..b638abf677 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -5934,7 +5934,8 @@ flow_check_match_action(const struct rte_flow_action actions[], ratio = sample->ratio; sub_type = ((const struct rte_flow_action *) (sample->actions))->type; - if (ratio == 1 && attr->transfer) + if (ratio == 1 && attr->transfer && + sub_type != RTE_FLOW_ACTION_TYPE_END) fdb_mirror = 1; break; case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: @@ -6106,9 +6107,11 @@ flow_sample_split_prep(struct rte_eth_dev *dev, break; case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: - push_vlan_idx = action_idx; - if (push_vlan_idx < sample_action_pos) + if (action_idx < sample_action_pos && + push_vlan_idx == -1) { set_tag_idx = action_idx; + push_vlan_idx = action_idx; + } break; default: break; @@ -6171,18 +6174,20 @@ flow_sample_split_prep(struct rte_eth_dev *dev, .data = tag_id, }; /* Prepare the suffix subflow items. */ + tag_spec = (void *)(sfx_items + SAMPLE_SUFFIX_ITEM); + tag_spec->data = tag_id; + tag_spec->id = set_tag->id; + tag_mask = tag_spec + 1; + tag_mask->data = UINT32_MAX; for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) { if (items->type == RTE_FLOW_ITEM_TYPE_PORT_ID || - items->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR) { + items->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR || + items->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) { memcpy(sfx_items, items, sizeof(*sfx_items)); sfx_items++; + break; } } - tag_spec = (void *)(sfx_items + SAMPLE_SUFFIX_ITEM); - tag_spec->data = tag_id; - tag_spec->id = set_tag->id; - tag_mask = tag_spec + 1; - tag_mask->data = UINT32_MAX; sfx_items[0] = (struct rte_flow_item){ .type = (enum rte_flow_item_type) MLX5_RTE_FLOW_ITEM_TYPE_TAG, @@ -6757,6 +6762,8 @@ flow_create_split_sample(struct rte_eth_dev *dev, uint16_t jump_table = 0; const uint32_t next_ft_step = 1; int ret = 0; + struct mlx5_priv *item_port_priv = NULL; + const struct rte_flow_item *item; if (priv->sampler_en) actions_n = flow_check_match_action(actions, attr, @@ -6776,8 +6783,36 @@ flow_create_split_sample(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "no memory to split " "sample flow"); + for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { + if (item->type == RTE_FLOW_ITEM_TYPE_PORT_ID) { + const struct rte_flow_item_port_id *spec; + + spec = (const struct rte_flow_item_port_id *)item->spec; + if (spec) + item_port_priv = + mlx5_port_to_eswitch_info(spec->id, true); + break; + } else if (item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) { + const struct rte_flow_item_ethdev *spec; + + spec = (const struct rte_flow_item_ethdev *)item->spec; + if (spec) + item_port_priv = + mlx5_port_to_eswitch_info(spec->port_id, true); + break; + } else if (item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR) { + const struct rte_flow_item_ethdev *spec; + + spec = (const struct rte_flow_item_ethdev *)item->spec; + if (spec) + item_port_priv = + mlx5_port_to_eswitch_info(spec->port_id, true); + break; + } + } /* The representor_id is UINT16_MAX for uplink. */ - fdb_tx = (attr->transfer && priv->representor_id != UINT16_MAX); + fdb_tx = (attr->transfer && + flow_source_vport_representor(priv, item_port_priv)); /* * When reg_c_preserve is set, metadata registers Cx preserve * their value even through packet duplication. diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index da9b65d8fe..178c9afeff 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -2118,6 +2118,25 @@ rte_col_2_mlx5_col(enum rte_color rcol) return MLX5_FLOW_COLOR_UNDEFINED; } +/** + * Indicates whether flow source vport is representor port. + * + * @param[in] priv + * Pointer to device private context structure. + * @param[in] act_priv + * Pointer to actual device private context structure if have. + * + * @return + * True when the flow source vport is representor port, false otherwise. + */ +static inline bool +flow_source_vport_representor(struct mlx5_priv *priv, struct mlx5_priv *act_priv) +{ + MLX5_ASSERT(priv); + return (!act_priv ? (priv->representor_id != UINT16_MAX) : + (act_priv->representor_id != UINT16_MAX)); +} + /* All types of Ethernet patterns used in control flow rules. */ enum mlx5_flow_ctrl_rx_eth_pattern_type { MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_ALL = 0, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1e52278191..a2b85207b1 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2208,6 +2208,7 @@ flow_dv_validate_item_port_id(struct rte_eth_dev *dev, const struct rte_flow_item *item, const struct rte_flow_attr *attr, uint64_t item_flags, + struct mlx5_priv **act_priv, struct rte_flow_error *error) { const struct rte_flow_item_port_id *spec = item->spec; @@ -2266,6 +2267,7 @@ flow_dv_validate_item_port_id(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, spec, "cannot match on a port from a" " different E-Switch"); + *act_priv = esw_priv; return 0; } @@ -2291,6 +2293,7 @@ flow_dv_validate_item_represented_port(struct rte_eth_dev *dev, const struct rte_flow_item *item, const struct rte_flow_attr *attr, uint64_t item_flags, + struct mlx5_priv **act_priv, struct rte_flow_error *error) { const struct rte_flow_item_ethdev *spec = item->spec; @@ -2340,6 +2343,7 @@ flow_dv_validate_item_represented_port(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, spec, "cannot match on a port from a different E-Switch"); + *act_priv = esw_priv; return 0; } @@ -2860,30 +2864,12 @@ flow_dv_validate_action_pop_vlan(struct rte_eth_dev *dev, struct rte_flow_error *error) { const struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_dev_ctx_shared *sh = priv->sh; - bool direction_error = false; if (!priv->sh->pop_vlan_action) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "pop vlan action is not supported"); - /* Pop VLAN is not supported in egress except for CX6 FDB mode. */ - if (attr->transfer) { - bool fdb_tx = priv->representor_id != UINT16_MAX; - bool is_cx5 = sh->steering_format_version == - MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5; - - if (fdb_tx && is_cx5) - direction_error = true; - } else if (attr->egress) { - direction_error = true; - } - if (direction_error) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, - NULL, - "pop vlan action not supported for egress"); if (action_flags & MLX5_FLOW_VLAN_ACTIONS) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, action, @@ -5794,6 +5780,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, const struct rte_flow_action_count **count, int *fdb_mirror_limit, bool root, + struct mlx5_priv *act_priv, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; @@ -5982,7 +5969,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, "E-Switch must has a dest " "port for mirroring"); if (!priv->sh->cdev->config.hca_attr.reg_c_preserve && - priv->representor_id != UINT16_MAX) + flow_source_vport_representor(priv, act_priv)) *fdb_mirror_limit = 1; } /* Continue validation for Xcap actions.*/ @@ -7134,6 +7121,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, uint32_t tag_id = 0; const struct rte_flow_action_age *non_shared_age = NULL; const struct rte_flow_action_count *count = NULL; + struct mlx5_priv *act_priv = NULL; if (items == NULL) return -1; @@ -7183,7 +7171,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, break; case RTE_FLOW_ITEM_TYPE_PORT_ID: ret = flow_dv_validate_item_port_id - (dev, items, attr, item_flags, error); + (dev, items, attr, item_flags, &act_priv, error); if (ret < 0) return ret; last_item = MLX5_FLOW_ITEM_PORT_ID; @@ -7192,7 +7180,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT: case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR: ret = flow_dv_validate_item_represented_port - (dev, items, attr, item_flags, error); + (dev, items, attr, item_flags, &act_priv, error); if (ret < 0) return ret; last_item = MLX5_FLOW_ITEM_REPRESENTED_PORT; @@ -8070,6 +8058,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, &sample_count, &fdb_mirror_limit, is_root, + act_priv, error); if (ret < 0) return ret; @@ -8246,7 +8235,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, bool direction_error = false; if (attr->transfer) { - bool fdb_tx = priv->representor_id != UINT16_MAX; + bool fdb_tx = flow_source_vport_representor(priv, act_priv); bool is_cx5 = sh->steering_format_version == MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5; @@ -8278,6 +8267,27 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, "multiple VLAN actions"); } } + /* Pop VLAN is not supported in egress except for NICs newer than CX5. */ + if (action_flags & MLX5_FLOW_ACTION_OF_POP_VLAN) { + struct mlx5_dev_ctx_shared *sh = priv->sh; + bool direction_error = false; + + if (attr->transfer) { + bool fdb_tx = flow_source_vport_representor(priv, act_priv); + bool is_cx5 = sh->steering_format_version == + MLX5_STEERING_LOGIC_FORMAT_CONNECTX_5; + + if (fdb_tx && is_cx5) + direction_error = true; + } else if (attr->egress) { + direction_error = true; + } + if (direction_error) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, + NULL, + "pop vlan action not supported for egress"); + } if (action_flags & MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY) { if ((action_flags & (MLX5_FLOW_FATE_ACTIONS & ~MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)) && @@ -8396,6 +8406,7 @@ flow_dv_prepare(struct rte_eth_dev *dev, wks->skip_matcher_reg = 0; wks->policy = NULL; wks->final_policy = NULL; + wks->vport_meta_tag = 0; /* In case of corrupting the memory. */ if (wks->flow_idx >= MLX5_NUM_MAX_DEV_FLOWS) { rte_flow_error_set(error, ENOSPC, @@ -10081,10 +10092,12 @@ flow_dv_translate_item_port_id(struct rte_eth_dev *dev, void *key, { const struct rte_flow_item_port_id *pid_m = item ? item->mask : NULL; const struct rte_flow_item_port_id *pid_v = item ? item->spec : NULL; + struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace(); struct mlx5_priv *priv; uint16_t mask, id; uint32_t vport_meta; + MLX5_ASSERT(wks); if (pid_v && pid_v->id == MLX5_PORT_ESW_MGR) { flow_dv_translate_item_source_vport(key, key_type & MLX5_SET_MATCHER_V ? @@ -10102,6 +10115,7 @@ flow_dv_translate_item_port_id(struct rte_eth_dev *dev, void *key, } else { id = priv->vport_id; vport_meta = priv->vport_meta_tag; + wks->vport_meta_tag = vport_meta; } /* * Translate to vport field or to metadata, depending on mode. @@ -12273,6 +12287,9 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev, uint32_t action_in[MLX5_ST_SZ_DW(set_action_in)]; uint64_t set_action; } action_ctx = { .set_action = 0 }; + uint32_t vport_meta_tag = wks->vport_meta_tag ? + wks->vport_meta_tag : + priv->vport_meta_tag; res->ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB; MLX5_SET(set_action_in, action_ctx.action_in, action_type, @@ -12280,7 +12297,7 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev, MLX5_SET(set_action_in, action_ctx.action_in, field, MLX5_MODI_META_REG_C_0); MLX5_SET(set_action_in, action_ctx.action_in, data, - priv->vport_meta_tag); + vport_meta_tag); res->set_action = action_ctx.set_action; } else if (attr->ingress) { res->ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_RX; -- 2.18.1