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 B1DA9A0C5A; Mon, 29 Nov 2021 13:33:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BAEE4068A; Mon, 29 Nov 2021 13:33:12 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2084.outbound.protection.outlook.com [40.107.243.84]) by mails.dpdk.org (Postfix) with ESMTP id 0898E40689; Mon, 29 Nov 2021 13:33:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUUsqCqgMhAF5AeW0RZkXEgosGhhCxL3i/Py0OG2pK18raKfV6vCNVV5QHDBohcwxjDan9hqEGdfjEUtf8FQJQ3gsvp3V0ttS5zvbxBVdeNYxgF2G6m7ejOskVl3QQ02VY36tJqVc0WdT/rVuXzjS1jOQ7xzTjkT3WaqHbDYHoA5cAYXk5L37L6p3B3YliAJfAAwXcX180OYpJ657hjE1rVHw+C/vM44y3zh8YPOEnd7klAhWebBcTCYCmFQOB3K1V88iPxmH4NbH6PA3ZEW9BFTgnaLEec4li6yJHhrbuxgPLFzHSHNT056wSwxmmlQ9r9SvQBV/F/Us2oT5deaBg== 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=BbBMXM9bTv3EKraye59FLyym9YpO+oVy35JHggOYdwA=; b=cc9E3ZKEBX19Gz/ZBHQI/+PMq6lTVE2ELPjkd11h+B71bUw+mMJJkNx/WgbJjFXdgKQ0+XyxhmznxqCDsPuClxHITsk7CTOdkjwjdN1/oFKCZivjbrevie12G80iSoD9MXzc8tjnvjYgDDefRaezk8dtBdMjDG7OOb46E7JYqKjA6gTmiCRBQ6RdNaZsrkG4f/PNLBtsr3nX0scdOKFHffiGLUJt3lnT0fO3RHvkz/zAwtIjMGq8N9yEQ0bD2z7ZyXgjzgJmQ6+AhWmHff5pIG20Hc9CwGRB6jPJoBzyeAE/+f8VmQ6RMOYyiL333W4LgT9pW8TA+FPqXSz/wgF58A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=BbBMXM9bTv3EKraye59FLyym9YpO+oVy35JHggOYdwA=; b=nWoSIkBxXOgnneXLeprMmakZippAo8Nd0XyJ/3xX1SDcELq+Qp07rRxGidxWFzQOOlO4gVoKyWqkIDFrk/63LcwzsWBUNJ7DYChV45SM9hzEgByouVGJ43R8y8z6hOgbLkFzaRtb0mMbB2fdJzfbYnaFXmC/1MOc3WxFH0AuWoB4GNlG3u/Wrhmpe9qfNZ4vUjEpNIL2/+2ycm9jZwKXYC+gJdpeIhX60Sp2dk3qvD1TBfmmHUxioqOx0PcPmaBsM7LSuCrHHGHysIzk94OkOr/dvdOcsV3VKDYr6M2OZlQ4GrwzUVhL/BMrt2nBTv1bXGjIcp3tRRZ+l81LHSF8rA== Received: from MWHPR11CA0020.namprd11.prod.outlook.com (2603:10b6:301:1::30) by DM4PR12MB5246.namprd12.prod.outlook.com (2603:10b6:5:399::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Mon, 29 Nov 2021 12:33:08 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:301:1:cafe::67) by MWHPR11CA0020.outlook.office365.com (2603:10b6:301:1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23 via Frontend Transport; Mon, 29 Nov 2021 12:33:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) 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.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4734.22 via Frontend Transport; Mon, 29 Nov 2021 12:33:08 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 29 Nov 2021 04:33:07 -0800 Received: from nvidia.com (172.20.187.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.5; Mon, 29 Nov 2021 04:33:05 -0800 From: Viacheslav Ovsiienko To: CC: , , Subject: [PATCH] net/mlx5: fix metadata endianness in modify field action Date: Mon, 29 Nov 2021 14:32:52 +0200 Message-ID: <20211129123252.19408-1-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0206633-9af7-427c-e7ef-08d9b334661b X-MS-TrafficTypeDiagnostic: DM4PR12MB5246: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n5koqw9viakqIP5kz0EE8N7fofHp0S1cjQzefzySVAwAtFz+lA/E+TMvA5ypT0fsRD0hulk+A3FTkWGKxX7wCdMTp796DGMHEBA5rfgKKT7ESXh69DAIgdA9wvvc/JQsWKonOVBeUMNotA+bHjTxb+lfneqOjz3oZZLkFWyH1lhUVOG003Vfduf+maSopMBnLPIMzQwlAa8QY9Ztp2zWN4iXQNjG6Jc0obNh4fR5qE3neZX78yN+QZ3WnQIXlPHl+5KAqjn8SFFDf7YvYbk5/gnnLvnApncBCmoWr2M2GzUH6/aqw6knB9oqC8qbE5uDY0Q5wd4eU4R319VlxYCx8hUVq+SCTyd2V7UWTw854XNdFNFEz1FWpKK1+ErsUPCpFk7kgNTprJaaRZ1nVGwtuA4kvMDublbS0mBK7SzO7jdF1eHqFA5cbzBCiw3zs+ShJ4a+CkGifH9VDadKRYU+LoAn2R6yy5wBvtVIdpsPKh48Ns2o42UPIkM0qgn859XhF46Gv/kwnLZgSOxPr2TLyZTgMTUcoF3aIIpFHBnci2oChz7WyN+W8pran1Z3KToAcd/m1/rsshZc6RC2tc6D2gEZSf2+Co407mJ+xCUdlffTjqPaoZHnJJcoD4ysSewtkvT6clZyOAd9f9yVz5SNIXBuLZXTpnlr+JurPvtMhm85somyeEcApLspFCgHnDmeXnktWAO/JCO2x4oZC5eA0w== X-Forefront-Antispam-Report: CIP:216.228.112.32; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid01.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(450100002)(1076003)(36860700001)(7696005)(6666004)(8936002)(356005)(6286002)(55016003)(82310400004)(86362001)(70586007)(2616005)(16526019)(336012)(4326008)(7636003)(508600001)(316002)(26005)(47076005)(6916009)(70206006)(186003)(54906003)(8676002)(2906002)(36756003)(83380400001)(5660300002)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 12:33:08.1309 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0206633-9af7-427c-e7ef-08d9b334661b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.32]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5246 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 As modify field action immediate source parameter the metadata should follow the CPU endianness (according to SET_META action structure format), and mlx5 PMD wrongly handled the immediate parameter metadata buffer as big-endian, resulting in wrong metadata set action with incorrect endianness. Fixes: 40c8fb1fd3b3 ("net/mlx5: update modify field action") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 4834c752d9..1c6cae8779 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1465,7 +1465,7 @@ static void mlx5_flow_field_id_to_modify_info (const struct rte_flow_action_modify_data *data, struct field_modify_info *info, uint32_t *mask, - uint32_t width, uint32_t *shift, struct rte_eth_dev *dev, + uint32_t width, struct rte_eth_dev *dev, const struct rte_flow_attr *attr, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; @@ -1820,16 +1820,11 @@ mlx5_flow_field_id_to_modify_info { uint32_t meta_mask = priv->sh->dv_meta_mask; uint32_t meta_count = __builtin_popcount(meta_mask); - uint32_t msk_c0 = - rte_cpu_to_be_32(priv->sh->dv_regc0_mask); - uint32_t shl_c0 = rte_bsf32(msk_c0); int reg = flow_dv_get_metadata_reg(dev, attr, error); if (reg < 0) return; MLX5_ASSERT(reg != REG_NON); MLX5_ASSERT((unsigned int)reg < RTE_DIM(reg_to_field)); - if (reg == REG_C_0) - *shift = shl_c0; info[idx] = (struct field_modify_info){4, 0, reg_to_field[reg]}; if (mask) @@ -1881,29 +1876,33 @@ flow_dv_convert_action_modify_field struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS] = { {0, 0, 0} }; uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0}; - uint32_t type; - uint32_t shift = 0; + uint32_t type, meta = 0; if (conf->src.field == RTE_FLOW_FIELD_POINTER || conf->src.field == RTE_FLOW_FIELD_VALUE) { type = MLX5_MODIFICATION_TYPE_SET; /** For SET fill the destination field (field) first. */ mlx5_flow_field_id_to_modify_info(&conf->dst, field, mask, - conf->width, &shift, dev, + conf->width, dev, attr, error); item.spec = conf->src.field == RTE_FLOW_FIELD_POINTER ? (void *)(uintptr_t)conf->src.pvalue : (void *)(uintptr_t)&conf->src.value; + if (conf->dst.field == RTE_FLOW_FIELD_META) { + meta = *(const unaligned_uint32_t *)item.spec; + meta = rte_cpu_to_be_32(meta); + item.spec = &meta; + } } else { type = MLX5_MODIFICATION_TYPE_COPY; /** For COPY fill the destination field (dcopy) without mask. */ mlx5_flow_field_id_to_modify_info(&conf->dst, dcopy, NULL, - conf->width, &shift, dev, + conf->width, dev, attr, error); /** Then construct the source field (field) with mask. */ mlx5_flow_field_id_to_modify_info(&conf->src, field, mask, - conf->width, &shift, - dev, attr, error); + conf->width, dev, + attr, error); } item.mask = &mask; return flow_dv_convert_modify_action(&item, -- 2.18.1