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 6F380A0A0C for ; Thu, 13 May 2021 21:55:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 57746410FD; Thu, 13 May 2021 21:55:27 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2082.outbound.protection.outlook.com [40.107.100.82]) by mails.dpdk.org (Postfix) with ESMTP id 3D9DF4003F; Thu, 13 May 2021 21:55:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fe+WQ6fO0VP9iHcwzgmjrw3Lv6jW+ksnZ9R5ZXe7IqTYlAguUy4KDLvZQ/tpQ1igrZHSF29pSylFg5L74ELVASHNL9YonY/28PsygibVSr0r2Pl5GfxvZrGqspCjqdqnNrE4aowvT5Dg7Mg/Mw2tTau+IDezEs1Kej7XbInZqK8IcHuMQ7AvAA5339j7zFfRhSjfCEFCRZ2dQxWi3BCaYzC2yaS7shki66l1jN7bxGI6jdVuVGJPH1aV34+VyfY7kFPmczB+/ZdPCyodsbc6/b7uZdWG6/s1ScdyBe7VUWiPDHCYfVf28ifSqFeUSs4ZBGDDVGpvjrmmfJmo/gHNPQ== 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=4cYNA9a2Vgb23I7HXfV3mjUNCW8OOCWFioTGLIw99cI=; b=cgRk3SFROy23NrecqYMcIRW864tm9BGtVqdGjnHMOH0PVwEDpVow55LQkkIWwrOh/ru9gOqOJhPrFf1pzxLdiXYVM/fkDQ/vnqQsiR+3Vnu4YqTNmHEemeakstwSc6ffEu29f8QJ3K0RJSiDE55nCoF8XdwraA5Hak2vOVgL9PMagyT9QVeq15k0H5PFrtMNeVBHe8Krn7pJygc8/lWT1ycUxTfFVuTiARhCkUJdKFJVfYH5sf3XeZuMeXm2oyPaQlxdwGLdEKO8Yh3WgyJE1q4+1HXz8XMVgsuqKJA9jmQdOtCqJVcoMC/Df0FMR1pG8F2mdWDdrADsLzoqyYRI/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=4cYNA9a2Vgb23I7HXfV3mjUNCW8OOCWFioTGLIw99cI=; b=LppYgtuf1pxsp5GorCv2hktoQ7NTdoTgVTV7zuQQh/r1X0F2rbggn4LjVHMXx7kBrzzl4x2jefDOuGGfwyNYDAQ3O5kgSQylFKnFjXKWJyZZUEKnBlH/o4pcmbC/hWTyDWpdR4ciXLXAeEil3WDLIIZtXbY42twJtEdP7qASP4g7UGbuZpp59HngTcpVq2WC83kzht1f3asamsto1zlPZOEn0RUEz64FKRZsCm1idZcSeZMQ4+OkUhcFO0dj/BfgVV9KsdhvA/kyirHRq/RCGwQ2kvWWGLbRLw2TEu4tR2H2cRdSx7i8ZGms9sqvSns2JRLJCKnD8wKfk/8d01QGlQ== Received: from MWHPR12CA0047.namprd12.prod.outlook.com (2603:10b6:301:2::33) by BN6PR12MB1873.namprd12.prod.outlook.com (2603:10b6:404:102::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.27; Thu, 13 May 2021 19:55:23 +0000 Received: from CO1NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:301:2:cafe::94) by MWHPR12CA0047.outlook.office365.com (2603:10b6:301:2::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.29 via Frontend Transport; Thu, 13 May 2021 19:55:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT061.mail.protection.outlook.com (10.13.175.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4129.25 via Frontend Transport; Thu, 13 May 2021 19:55:23 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 13 May 2021 19:55:15 +0000 From: Alexander Kozyrev To: CC: , , , Date: Thu, 13 May 2021 22:54:58 +0300 Message-ID: <20210513195458.258410-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7da154b-c179-4d76-791a-08d916490b8a X-MS-TrafficTypeDiagnostic: BN6PR12MB1873: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5KMZSt9tBKmP7dwuzzgJoneFIr4DO7KKPBcaCFHcvJRAoZIVgUbNmne41U2FseTOXJMvZUIpvQxLkU4exWkg/vD/gda2ThmmRbS3x4LrjvLC1evrlmz5owKLMCo3Fbt6LedPfC/hJX9g6j5Q4ZgG36xffKSZNXEw2tpuDw78Fu/OygRjsB5mesw1bFT0cT2gX5XQNUklXnLqL1xMlivSqglua/nj8uwt9W8bw12X0dKgu0qumEndMHCvZE/TCBA56iQ3lEK4pLst1dXs8PfLS63CX5PSqO5RrFmvqBmKtmukc8i+aTgYDs0SII5JU9JQn03JXuY1qmtytSnJK8T06VmG/CvmIJh04q29h6YqJ9RyYVucOnB9Wnutdfasn8fNNtOb+j38thQOt/unCP8S7YPZlYPh1N+eAnREsbv+gcb675vBqm3+DuTld5ojDqHopy9Xoj9Yt/LR1uEGifm9DAyyADVwsZelIEjcNKeEO4g7gYnhDtGnKB/7VDJRC1DbzfYFxfBY4t0PD0qtLgva2yyjH2j506+z0clmltLa1MQMzxmg+LMkoFgaGMfPLwsRUNcsp0lqw8UkRmF1UIYLdCSz5w9zT46ur0j4P7I1mRyPZSpurXN44ILXpx3hZQfuVC/EQZvKwsqgy3IKriMGN1VCkRt6zpsASQlvZIZowR0= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(396003)(136003)(346002)(376002)(39860400002)(46966006)(36840700001)(86362001)(36906005)(4326008)(83380400001)(82740400003)(36756003)(36860700001)(6286002)(336012)(2616005)(2906002)(316002)(426003)(47076005)(55016002)(478600001)(186003)(54906003)(16526019)(6916009)(6666004)(8676002)(1076003)(7636003)(450100002)(8936002)(26005)(70206006)(70586007)(5660300002)(7696005)(107886003)(82310400003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2021 19:55:23.0514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7da154b-c179-4d76-791a-08d916490b8a 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.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1873 Subject: [dpdk-stable] [PATCH] net/mlx5: check meta register width for modify field X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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" The modify_field Flow API assumes that the META item is 32 bits wide. But the C Register that is used for Meta item can be 16 or 32 bits wide depending on kernel and firmware configurations. Take this into consideration and use the appropriate META width. Fixes: 641dbe4fb0 ("net/mlx5: support modify field flow action") Cc: stable@dpdk.org Signed-off-by: Alexander Kozyrev --- drivers/net/mlx5/mlx5_flow_dv.c | 48 ++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 935a55ef75..c50649a107 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1356,7 +1356,8 @@ flow_dv_convert_action_modify_ipv6_dscp } static int -mlx5_flow_item_field_width(enum rte_flow_field_id field) +mlx5_flow_item_field_width(struct mlx5_dev_config *config, + enum rte_flow_field_id field) { switch (field) { case RTE_FLOW_FIELD_START: @@ -1404,7 +1405,12 @@ mlx5_flow_item_field_width(enum rte_flow_field_id field) case RTE_FLOW_FIELD_MARK: return 24; case RTE_FLOW_FIELD_META: - return 32; + if (config->dv_xmeta_en == MLX5_XMETA_MODE_META16) + return 16; + else if (config->dv_xmeta_en == MLX5_XMETA_MODE_META32) + return 32; + else + return 0; case RTE_FLOW_FIELD_POINTER: case RTE_FLOW_FIELD_VALUE: return 64; @@ -1424,6 +1430,8 @@ mlx5_flow_field_id_to_modify_info const struct rte_flow_attr *attr, struct rte_flow_error *error) { + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_dev_config *config = &priv->config; uint32_t idx = 0; uint64_t val = 0; switch (data->field) { @@ -1777,17 +1785,28 @@ mlx5_flow_field_id_to_modify_info break; case RTE_FLOW_FIELD_META: { + unsigned int xmeta = config->dv_xmeta_en; 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)); - info[idx] = (struct field_modify_info){4, 0, - reg_to_field[reg]}; - if (mask) - mask[idx] = - rte_cpu_to_be_32(0xffffffff >> - (32 - width)); + if (xmeta == MLX5_XMETA_MODE_META16) { + info[idx] = (struct field_modify_info){2, 0, + reg_to_field[reg]}; + if (mask) + mask[idx] = rte_cpu_to_be_16(0xffff >> + (16 - width)); + } else if (xmeta == MLX5_XMETA_MODE_META32) { + info[idx] = (struct field_modify_info){4, 0, + reg_to_field[reg]}; + if (mask) + mask[idx] = + rte_cpu_to_be_32(0xffffffff >> + (32 - width)); + } else { + MLX5_ASSERT(false); + } } break; case RTE_FLOW_FIELD_POINTER: @@ -1845,6 +1864,8 @@ flow_dv_convert_action_modify_field const struct rte_flow_attr *attr, struct rte_flow_error *error) { + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_dev_config *config = &priv->config; const struct rte_flow_action_modify_field *conf = (const struct rte_flow_action_modify_field *)(action->conf); struct rte_flow_item item; @@ -1855,7 +1876,8 @@ flow_dv_convert_action_modify_field uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0}; uint32_t value[MLX5_ACT_MAX_MOD_FIELDS] = {0, 0, 0, 0, 0}; uint32_t type; - uint32_t dst_width = mlx5_flow_item_field_width(conf->dst.field); + uint32_t dst_width = mlx5_flow_item_field_width(config, + conf->dst.field); if (conf->src.field == RTE_FLOW_FIELD_POINTER || conf->src.field == RTE_FLOW_FIELD_VALUE) { @@ -4710,10 +4732,10 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev, struct mlx5_dev_config *config = &priv->config; const struct rte_flow_action_modify_field *action_modify_field = action->conf; - uint32_t dst_width = - mlx5_flow_item_field_width(action_modify_field->dst.field); - uint32_t src_width = - mlx5_flow_item_field_width(action_modify_field->src.field); + uint32_t dst_width = mlx5_flow_item_field_width(config, + action_modify_field->dst.field); + uint32_t src_width = mlx5_flow_item_field_width(config, + action_modify_field->src.field); ret = flow_dv_validate_action_modify_hdr(action_flags, action, error); if (ret) -- 2.18.2