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 E29C2A051E; Wed, 10 Jun 2020 19:18:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D37451BFB9; Wed, 10 Jun 2020 19:18:12 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2089.outbound.protection.outlook.com [40.107.22.89]) by dpdk.org (Postfix) with ESMTP id B1F041BFA7 for ; Wed, 10 Jun 2020 19:18:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=maRR8LL6WVx0/Q3q6TMLKAYbT1Yi8ueqjCLbIM3NLUaE7cAsLbgpHGi/Sv/qlPRSjrm7JJycX24dzs4inRIDCR4WID3udz+nOKbG86Frxl7DW1ZR32c/U/nPVL5uIqxgLT/GApvPZLUrtE1eE+MFHVLUbSirDa6ykPmDFsp+Fm6RA/OwCnWKyAib/SXOaOq67rYS6Pqpuy5iDGPNYG7uRUyF2ODw3O9oHeZ7mzR8XLQScCojBCPdg3aWxPfmYxKaNVsWZMBBARLbGcYHjnmL1LVlipD9Fyn1l656ez9Lgvm0ToZ85KPCdQQAwa5oi/opoMM4c3TLu//lChpC3a63gQ== 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=swvaHp4j8SSJlcCi3oWJoIvCr7XOOe7xjnEY4S0MirU=; b=ZLRt/5cMdjm4KTxyGrbVFuP2hNrcqT1SGZFkpg//rFMYxkooewsWJ+EF5y5k8wz1kQaCSJGoBGCXUeDvwk7EMdYCZflriB5xQWtxtXg9B8hvEShnYWnjWaZfIGKkFP+AP1E7tx5CwY1Bhc0EukqNhjoYE1tBIwoluDvMp1PR+kb/cashmq+GjxESI7Hj1HulDIeN1oB8JKUaQa9HMI+Exs5ikQjwW3gAXjn1C2i814BDvTf9imvg/axJRmKB1xj0ADTcVsvkayg6mBOMeT3DTpZXSSbKvzjJKk5Qmwec0dPa3a0sxcpDLMBUBMYH/BVUlMMkLKroqAtzaz2uBvV9pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=swvaHp4j8SSJlcCi3oWJoIvCr7XOOe7xjnEY4S0MirU=; b=tigeXSzw71eaPgQ7USwQCeH7K1qvue4jgNs/b4fpd5SxBF7xjgkppW5+zYQ4FFeTTbeKVRABIv99ZbFdpptl9NE61XLOSuwx1exT07uaqB028W0zlYVk+IHobWvEntFhKB29uCJcoRSeNMawW0H0ebisjnqJ3sCVUi7fE+3ciQE= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4866.eurprd05.prod.outlook.com (2603:10a6:208:c0::32) by AM0PR05MB5346.eurprd05.prod.outlook.com (2603:10a6:208:f5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Wed, 10 Jun 2020 17:18:10 +0000 Received: from AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::d44d:a804:c730:d2b7]) by AM0PR05MB4866.eurprd05.prod.outlook.com ([fe80::d44d:a804:c730:d2b7%2]) with mapi id 15.20.3066.023; Wed, 10 Jun 2020 17:18:10 +0000 From: Parav Pandit To: dev@dpdk.org Cc: ferruh.yigit@intel.com, thomasm@mellanox.com, orika@mellanox.com, matan@mellanox.com, Parav Pandit Date: Wed, 10 Jun 2020 17:17:24 +0000 Message-Id: <20200610171728.89-3-parav@mellanox.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200610171728.89-1-parav@mellanox.com> References: <20200610171728.89-1-parav@mellanox.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SN6PR16CA0060.namprd16.prod.outlook.com (2603:10b6:805:ca::37) To AM0PR05MB4866.eurprd05.prod.outlook.com (2603:10a6:208:c0::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sw-mtx-036.mtx.labs.mlnx (208.176.44.194) by SN6PR16CA0060.namprd16.prod.outlook.com (2603:10b6:805:ca::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.21 via Frontend Transport; Wed, 10 Jun 2020 17:18:07 +0000 X-Mailer: git-send-email 2.25.4 X-Originating-IP: [208.176.44.194] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 749a08a4-8cc0-43ea-a8f3-08d80d623eb8 X-MS-TrafficTypeDiagnostic: AM0PR05MB5346: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 0430FA5CB7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UjsJEDmhtpgAYoaPhOyduCbpRaFu160p51woXHUGlYOom+A+nim6fEPvg/tl50BJBCje3ioG5ILDKgcA/ZjNUQTVoj2hDDRipoZTzuM4GvVEpnNdq5t2uqAjPGuqUnHvwtmVrNs1Zu8cEUxsyEf6TongZtmyGvvn2kLnEIwFOHZUswy79b1PKd5c4J2vBy5NZhqqyOeQpcnFa1H6hO/WC6hRWyUfVNKYLOQdKKQJ17PqfqCZiFJVEC89kOIjtXl74g8j2txa4cdMzOKz2re5kSdd6rQvM2JCEI1dCoOpexkbG9aAvSmPtk4cJXFpkM4DtF8WO4x3xQ2ao+891Ie+1g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4866.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(346002)(396003)(136003)(39860400002)(376002)(66476007)(6506007)(36756003)(16526019)(6486002)(6916009)(2906002)(316002)(26005)(5660300002)(186003)(66556008)(66946007)(6512007)(6666004)(8936002)(8676002)(4326008)(2616005)(83380400001)(956004)(478600001)(1076003)(86362001)(52116002)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: B9dss4eJEB9TYUOLMe8NHQZBx2PE2iTqeOJGTXIyPIBSJSI23S2JRFUZArjhdYy6BJYtSHbPG9/0J2ip1O512Ge2PAUFGe6DRJM+cF8bn2QZIEnULl50gOQXzmGRD6DAF9GiOwVPBiYSYENkPoDdGXowFJ7bvkWlHNeasT275ko3LUnjZOsaH+iZP+rTiLJ5MEswtaL3arR2t0XXWx15ZcAfgCmJkHOOolzvrBKCYQ1jAxKDTXKD9TItGgefj1kpiZTZLXd3mK3fncQeIRbkBYa2+DYFjFVibDXceFqHw3dBtuBqIxRjheKmZkQpilHUSWyUaW7YHYVBhoyHu/xqg90MdaFo8J86bOlqNexzAALplFC1Vs57PB7F55RPX25ZicKUDVMpVKfA8XO8ykjJhvBIYSNdM/bPdoN6iMk/nkt56rbESRUedJ15jipGXKFB/xq5K8NBwIaFep7itxwO7QeAe6jdpH/0J7aEb16iePVqUONpMHyHGj11Gd8VTLIR X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 749a08a4-8cc0-43ea-a8f3-08d80d623eb8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2020 17:18:09.8981 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fqtjFzsqeexLIEex4GkEzlw7feAa67XMp+oYu1+aawQ0me1H4bjfXOVHL++o9NJL1HlGyfqhZCn/5eoUnBZF7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5346 Subject: [dpdk-dev] [RFC PATCH 2/6] common/mlx5: use class enable check helper function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Currently mlx5_class_get() returns enabled single valid class. To support multiple class and to improve readability of code, change it to mlx5_class_enabled(). With this function, each class enablement can be checked, to load class specific driver. Signed-off-by: Parav Pandit --- drivers/common/mlx5/mlx5_common.c | 12 +++++++----- drivers/common/mlx5/mlx5_common.h | 5 +++-- drivers/common/mlx5/rte_common_mlx5_version.map | 2 +- drivers/net/mlx5/linux/mlx5_os.c | 3 ++- drivers/vdpa/mlx5/mlx5_vdpa.c | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index db94d4aa8..96c415842 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -37,22 +37,24 @@ mlx5_class_check_handler(__rte_unused const char *key, const char *value, return 0; } -enum mlx5_class -mlx5_class_get(struct rte_devargs *devargs) +bool +mlx5_class_enabled(const struct rte_devargs *devargs, enum mlx5_class dev_class) { struct rte_kvargs *kvlist; const char *key = MLX5_CLASS_ARG_NAME; + /* Default NET CLASS is enabled if user didn't specify the class */ enum mlx5_class ret = MLX5_CLASS_NET; if (devargs == NULL) - return ret; + return dev_class == MLX5_CLASS_NET ? true : false; kvlist = rte_kvargs_parse(devargs->args, NULL); if (kvlist == NULL) - return ret; + return dev_class == MLX5_CLASS_NET ? true : false; if (rte_kvargs_count(kvlist, key)) rte_kvargs_process(kvlist, key, mlx5_class_check_handler, &ret); rte_kvargs_free(kvlist); - return ret; + + return (ret & dev_class) ? true : false; } diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 8e679c699..1d59873c8 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -202,13 +202,14 @@ int mlx5_dev_to_pci_addr(const char *dev_path, struct rte_pci_addr *pci_addr); #define MLX5_CLASS_ARG_NAME "class" enum mlx5_class { + MLX5_CLASS_INVALID, MLX5_CLASS_NET, MLX5_CLASS_VDPA, - MLX5_CLASS_INVALID, }; __rte_internal -enum mlx5_class mlx5_class_get(struct rte_devargs *devargs); +bool mlx5_class_enabled(const struct rte_devargs *devargs, + enum mlx5_class dev_class); __rte_internal void mlx5_translate_port_name(const char *port_name_in, struct mlx5_switch_info *port_info_out); diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map index 350e77140..01fa0cc25 100644 --- a/drivers/common/mlx5/rte_common_mlx5_version.map +++ b/drivers/common/mlx5/rte_common_mlx5_version.map @@ -1,7 +1,7 @@ INTERNAL { global: - mlx5_class_get; + mlx5_class_enabled; mlx5_create_mr_ext; diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 92422dbe6..06772b7ae 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1377,11 +1377,12 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct mlx5_dev_config dev_config; int ret; - if (mlx5_class_get(pci_dev->device.devargs) != MLX5_CLASS_NET) { + if (!mlx5_class_enabled(pci_dev->device.devargs, MLX5_CLASS_NET)) { DRV_LOG(DEBUG, "Skip probing - should be probed by other mlx5" " driver."); return 1; } + if (rte_eal_process_type() == RTE_PROC_PRIMARY) mlx5_pmd_socket_init(); ret = mlx5_init_once(); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 1113d6cef..96776b64e 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -451,7 +451,7 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct mlx5_hca_attr attr; int ret; - if (mlx5_class_get(pci_dev->device.devargs) != MLX5_CLASS_VDPA) { + if (!mlx5_class_enabled(pci_dev->device.devargs, MLX5_CLASS_VDPA)) { DRV_LOG(DEBUG, "Skip probing - should be probed by other mlx5" " driver."); return 1; -- 2.25.4