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 6EF33A0A0C; Fri, 2 Jul 2021 11:15:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B256641381; Fri, 2 Jul 2021 11:15:20 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by mails.dpdk.org (Postfix) with ESMTP id 6E6A84137E; Fri, 2 Jul 2021 11:15:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQ4N2jVOwmrFnztrFe/0/jPz75tjRrM6lL8uul4xsFzWa6Nz8mGmgj3eWoERj0em1POoHyWtb2eYGoxN5l3/xZGlT4mdvACF0YuThapMjLwUU5fR+CwKIeVFxxeEgIznm3F0h59/ZwYJmh3D/TftYfwncnjcOMtz55cRKP2hG5V7GuYrVz1NSwQFUycGCuQxelojD9qL8obNoYNL1rjo97M3DCv5uIKZWHinkZumLFSf3rpZHXejIwt3TqQToojg9jXNesRXRr3HaVr+SrYefo3EA/CdgKAzmpD/8LIbidtp4KzeK1RbJUaHunE73oIdCCERaifLEGRq1jilu4b+OA== 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=qEhvYQ14PzUQ9VG9FruRDetQkv2cU657efRb0qkxEOg=; b=Sc28NMtdRJ9PFRYQGyVLTOSYUWerW8WTJeoF0qCVppUC4tvFho7R3xGr/EJDVsOdhA3GMrl7ZvoYHvYy2hl/YLujdZmj5qX6DRhYt6NMU5TmU5adQKyh2X6XrwS2AbjC/Eg6W5As8wtRJk5QQti9hOaw2kjFmbtgu62k5zlnZ8xeoOgIjZ9YB54SZ4HRT1cCWtr3L6FHg56+K+4Ax1Nt3Opvdd8AiOPTQ6U6NPWFhMqekYOg5iQJhJYu3cSIh/u+y01BvxjBXWjfFU7DcQqP2W4Q7p7R0KQ6L5XlZLtlG/03vM2Bx5AuPfbpMwqK8JVTiQL2/EqD4/gm8OyFf3oWUQ== 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=qEhvYQ14PzUQ9VG9FruRDetQkv2cU657efRb0qkxEOg=; b=sD9FriDtdtgAKETtbFAHHEU0vZgagWKlmMofh4+9dPiuhwAb9fgNHiyP+68E55ooueVhe2lCdFJ++qE4Upzwtm4ClyHMERyZY8fWMjUp5epL7gVFIP01KqfC7JSTAnlRdQ/6kbzeEUam8BEzQ/WCh94aJw2ZfcLmkmrSZcVTDvf4zdLCa0+2mzThC+l1QojWI2fvD67aYCefVDoPMlM2V5qKOQ48LjiKHgB3BckqKPMFPaF3D2MBCvpdyQn1aiipVbpwaROQQDUouTERVCy/CkPHCFHiCHfKT0YnaPn8fT2/HzX1xLmuaZS9n1BhCNfqCcw68r8/imNIWSDRZMW7bQ== Received: from DM5PR20CA0005.namprd20.prod.outlook.com (2603:10b6:3:93::15) by DM6PR12MB3593.namprd12.prod.outlook.com (2603:10b6:5:11c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22; Fri, 2 Jul 2021 09:15:14 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:3:93:cafe::f) by DM5PR20CA0005.outlook.office365.com (2603:10b6:3:93::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 09:15:14 +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 DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 09:15:14 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jul 2021 09:15:11 +0000 From: Shun Hao To: , , , , Li Zhang CC: , , , , Date: Fri, 2 Jul 2021 12:14:44 +0300 Message-ID: <20210702091446.24635-3-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20210702091446.24635-1-shunh@nvidia.com> References: <20210702091446.24635-1-shunh@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a35a770-6e83-48a5-041a-08d93d39e6ec X-MS-TrafficTypeDiagnostic: DM6PR12MB3593: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PWGB2EcQPVNT32IqMsdIiBvyCHVanm2/z8agq+Mjg/Xbi6wVkbAA6tTs7EDTYzoTk240mzTd4P5RYB+2vc+tPzF2Dk8plY+sACq17hvZyNdK+hbOoJ0FvPYezAxtPkGRPvjmh8M8olopLsckEti9G/6PAqxL1IXXNFF/pghFPG/dcw53LVcW1Kby8pS9unSQit92RVch/QpueQW3yS2PbnhRGDuc956w2YOhye3gHrAGKAbDCOZagwakQD1il13KMP4Mrjn9DBb20oRxnFJnN0PbR3v2s0TtIgAIMK3PR/bwrZ0LmAE31dzfFGkyxJemTqFYWZtf18jzk5joNGsEOCjw5GTI0upCVeR8RDrupu8+k72RrZUGj7LSDAmp7xOxLcgNNnDaWhpqBn57OBqK1zu5J7E/38OrMO3sqnH/RgsqF9w4XvwM4BYj6aOl3w9CJz7vlg/xVk1BcDCo/FeoKatxjN/ad81b6xyscISPxVvuQ4/fFHOoS1SHrFE+qd+UxEDsJwQORE3NogHipIK/ac4EUIBpcBqkBk6MNs9MGLqu2KlpBawrt6RJl5TQK0Qr58y3d7HWDJg9nrWAu2v3LTobRd+4x+2RjtC4jsboJCbcAQsp4VQQDw+He8pNXH1fOcZ5YaYL7ZxAMvUZZ7J2M/RZR0N38d7MaCmK5Z+9WJDOO6f+MsUslI4iTjwXGcwA5TAZc01OnMC4BETDWHo3ow== 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)(346002)(396003)(136003)(39860400002)(376002)(36840700001)(46966006)(356005)(336012)(426003)(316002)(4326008)(2616005)(36756003)(47076005)(6286002)(6636002)(83380400001)(26005)(36906005)(7636003)(6666004)(86362001)(16526019)(186003)(70586007)(478600001)(70206006)(7696005)(2906002)(110136005)(8936002)(1076003)(54906003)(8676002)(5660300002)(55016002)(36860700001)(82310400003)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 09:15:14.5073 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a35a770-6e83-48a5-041a-08d93d39e6ec 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3593 Subject: [dpdk-dev] [PATCH v1 2/4] net/mlx5: fix meter policy ID table container 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 Sender: "dev" The meter policy handlers are managed by user IDs and the driver used l3 table in order to map the user ID to the internal driver handler of the policy. The l3 table was wrongly saved in the shared device structure which manages all the switch domain ports what made the user IDs shared between different ethdev ports. Move the policy l3 table to be per port by saving it in the port private structure. Fixes: afb4aa4f122 ("net/mlx5: support meter policy operations") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5.c | 2 -- drivers/net/mlx5/mlx5.h | 3 +-- drivers/net/mlx5/mlx5_flow_meter.c | 38 ++++++++++++------------------ 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index cf1815cb74..5f10a45c02 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -600,8 +600,6 @@ mlx5_aso_flow_mtrs_mng_init(struct mlx5_dev_ctx_shared *sh) if (sh->meter_aso_en) { rte_spinlock_init(&sh->mtrmng->pools_mng.mtrsl); LIST_INIT(&sh->mtrmng->pools_mng.meters); - sh->mtrmng->policy_idx_tbl = - mlx5_l3t_create(MLX5_L3T_TYPE_DWORD); } sh->mtrmng->def_policy_id = MLX5_INVALID_POLICY_ID; } diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 0226327bc3..6eae7b6fd7 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -870,8 +870,6 @@ struct mlx5_flow_mtr_mng { /* Default policy id. */ uint32_t def_policy_ref_cnt; /** def_policy meter use count. */ - struct mlx5_l3t_tbl *policy_idx_tbl; - /* Policy index lookup table. */ struct mlx5_flow_tbl_resource *drop_tbl[MLX5_MTR_DOMAIN_MAX]; /* Meter drop table. */ struct mlx5_flow_dv_matcher * @@ -1375,6 +1373,7 @@ struct mlx5_priv { uint8_t mtr_color_reg; /* Meter color match REG_C. */ struct mlx5_legacy_flow_meters flow_meters; /* MTR list. */ struct mlx5_l3t_tbl *mtr_profile_tbl; /* Meter index lookup table. */ + struct mlx5_l3t_tbl *policy_idx_tbl; /* Policy index lookup table. */ struct mlx5_l3t_tbl *mtr_idx_tbl; /* Meter index lookup table. */ uint8_t skip_default_rss_reta; /* Skip configuration of default reta. */ uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */ diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 87c5782956..6f962a8d52 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -512,11 +512,9 @@ mlx5_flow_meter_policy_find(struct rte_eth_dev *dev, struct mlx5_flow_meter_sub_policy *sub_policy = NULL; union mlx5_l3t_data data; - if (policy_id > MLX5_MAX_SUB_POLICY_TBL_NUM || - !priv->sh->mtrmng->policy_idx_tbl) + if (policy_id > MLX5_MAX_SUB_POLICY_TBL_NUM || !priv->policy_idx_tbl) return NULL; - if (mlx5_l3t_get_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id, &data) || + if (mlx5_l3t_get_entry(priv->policy_idx_tbl, policy_id, &data) || !data.dword) return NULL; if (policy_idx) @@ -524,8 +522,7 @@ mlx5_flow_meter_policy_find(struct rte_eth_dev *dev, sub_policy = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], data.dword); /* Remove reference taken by the mlx5_l3t_get_entry. */ - mlx5_l3t_clear_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id); + mlx5_l3t_clear_entry(priv->policy_idx_tbl, policy_id); if (sub_policy) if (sub_policy->main_policy_id) return sub_policy->main_policy; @@ -605,9 +602,8 @@ __mlx5_flow_meter_policy_delete(struct rte_eth_dev *dev, } } } - if (priv->sh->mtrmng->policy_idx_tbl && clear_l3t) { - if (mlx5_l3t_clear_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id)) { + if (priv->policy_idx_tbl && clear_l3t) { + if (mlx5_l3t_clear_entry(priv->policy_idx_tbl, policy_id)) { rte_spinlock_unlock(&mtr_policy->sl); return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, @@ -770,14 +766,12 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, goto policy_add_err; } data.dword = policy_idx; - if (!priv->sh->mtrmng->policy_idx_tbl) { - priv->sh->mtrmng->policy_idx_tbl = - mlx5_l3t_create(MLX5_L3T_TYPE_DWORD); - if (!priv->sh->mtrmng->policy_idx_tbl) + if (!priv->policy_idx_tbl) { + priv->policy_idx_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_DWORD); + if (!priv->policy_idx_tbl) goto policy_add_err; } - if (mlx5_l3t_set_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id, &data)) + if (mlx5_l3t_set_entry(priv->policy_idx_tbl, policy_id, &data)) goto policy_add_err; return 0; policy_add_err: @@ -1840,9 +1834,8 @@ mlx5_flow_meter_rxq_flush(struct rte_eth_dev *dev) if (!priv->mtr_en) return; - if (priv->sh->mtrmng->policy_idx_tbl && priv->sh->refcnt == 1) { - MLX5_L3T_FOREACH(priv->sh->mtrmng->policy_idx_tbl, - i, entry) { + if (priv->policy_idx_tbl) { + MLX5_L3T_FOREACH(priv->policy_idx_tbl, i, entry) { policy_idx = *(uint32_t *)entry; sub_policy = mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], @@ -1908,9 +1901,8 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error) NULL, "MTR object meter profile invalid."); } } - if (priv->sh->mtrmng->policy_idx_tbl && priv->sh->refcnt == 1) { - MLX5_L3T_FOREACH(priv->sh->mtrmng->policy_idx_tbl, - i, entry) { + if (priv->policy_idx_tbl) { + MLX5_L3T_FOREACH(priv->policy_idx_tbl, i, entry) { policy_idx = *(uint32_t *)entry; sub_policy = mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], @@ -1931,8 +1923,8 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error) "meter policy invalid."); mlx5_free(sub_policy->main_policy); } - mlx5_l3t_destroy(priv->sh->mtrmng->policy_idx_tbl); - priv->sh->mtrmng->policy_idx_tbl = NULL; + mlx5_l3t_destroy(priv->policy_idx_tbl); + priv->policy_idx_tbl = NULL; } if (priv->mtr_profile_tbl) { MLX5_L3T_FOREACH(priv->mtr_profile_tbl, i, entry) { -- 2.20.0