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 77737A0527; Mon, 20 Jul 2020 21:08:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 127CA1BFBA; Mon, 20 Jul 2020 21:08:45 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id DC2A22C6E for ; Mon, 20 Jul 2020 21:08:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595272122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BfHKyjgbbiAt0lx0YSsNyhLYuIESjO+PJ72sPNn0sss=; b=ReknDv1vzLRpyH9AKcFnmI2tL1ukQFD2UkdLGeY9QOy4EZrAKFnDDFirPzHktBFP3gfOOw UNopddG2oq1KhHieoHcmwTEgYp9lknghHmE6efmpTQtezo3/DuSJt3j4eOHak43uMli/aa DCTmAW2Dr1C7F9m2o93wQsgR7WB4X6s= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-muJ9MXttM4mYS823cIaijA-1; Mon, 20 Jul 2020 15:08:38 -0400 X-MC-Unique: muJ9MXttM4mYS823cIaijA-1 Received: by mail-vk1-f197.google.com with SMTP id j198so7444182vkc.15 for ; Mon, 20 Jul 2020 12:08:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BfHKyjgbbiAt0lx0YSsNyhLYuIESjO+PJ72sPNn0sss=; b=GCRreHvj8INBSM//eatEgcyXwlb9tSbrQ01rv9YdPyXGEISD7J6G0uDlp1cpQqU5GX oiCT4llg300WrXhQ0/XJ+u3d7bIPs4gFzdCDxx9aTjSReKSXfP9RsFmyiGdHGTgJP2By zNfd3JTV1P9WfUP8NDoiFkYvPDJNZFDfae+emQm5VVhsYpTDsO+VMHt1aNwfq35jC8wy 9KEVibxH4xkFEDRJjCd7YIxwYFgFIcpzIG3zUQJh7qQceLMA9YD1dDNXSX8QJ1mF8CUW Z4ayVNZG1jturghdbLv5G2HQkU7EfWRXRfFCp3Egj+ad7LhNyLDprJ6U/yJiVyqEtH9g 3BDw== X-Gm-Message-State: AOAM533I0oP6S3wiReB7KIhfZkRA2gAN6s1u/Qlh5NCjt0EEKlUiSaVl 4+0LHpO9SO0m92a35QC3svJEyZECLWTWrQFK5MQ7YqPStSMj946YnfMTjPYeQC/OpT/f0pK/87y DvIgoO71+BeAf6OrJDnc= X-Received: by 2002:a1f:acc2:: with SMTP id v185mr17257481vke.18.1595272117538; Mon, 20 Jul 2020 12:08:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw02ZGXP1q4t7Jfuh+cyDwwSM/qbBWbq1aHNbV+ctnTLD70CuQ7aNdlbL598KXigTp6pbNzPZ3klklkuF11+Gg= X-Received: by 2002:a1f:acc2:: with SMTP id v185mr17257457vke.18.1595272117118; Mon, 20 Jul 2020 12:08:37 -0700 (PDT) MIME-Version: 1.0 References: <20200610171728.89-2-parav@mellanox.com> <20200717134924.922390-3-parav@mellanox.com> <2791231.CMBUAsGlKG@thomas> In-Reply-To: <2791231.CMBUAsGlKG@thomas> From: David Marchand Date: Mon, 20 Jul 2020 21:08:26 +0200 Message-ID: To: Thomas Monjalon , Ori Kam Cc: Parav Pandit , Ferruh Yigit , dev , Gaetan Rivet , Raslan , Matan Azrad , Joyce Kong Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v7 2/9] eal: introduce RTE common initialization level 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" On Mon, Jul 20, 2020 at 6:48 PM Thomas Monjalon wrote: > > 20/07/2020 18:21, Ferruh Yigit: > > On 7/17/2020 2:49 PM, Parav Pandit wrote: > > > Currently mlx5_common uses CLASS priority to initialize > > > common code before initializing the PMD. > > > However mlx5_common is not really a class, it is the pre-initialization > > > code needed for the PMDs. > > > > > > In subsequent patch a needed initialization sequence is: > > > (a) Initialize bus (say pci) > > > (b) Initialize common code of a driver (mlx5_common) > > > (c) Register mlx5 class PMDs (mlx5 net, mlx5 vdpa) > > > Information registered by these PMDs is used by mlx5_bus_pci PMD. > > > This mlx5 class PMDs should not confused with rte_class. > > > (d) Register mlx5 PCI bus PMD > > > > > > Hence, introduce a new RTE priority level RTE_PRIO_COMMON which > > > can be used for common initialization and RTE_PRIO_CLASS by mlx5 PMDs > > > for class driver initialization. > > > > > > Signed-off-by: Parav Pandit > > > Acked-by: Matan Azrad > > > --- > > > Changelog: > > > v2->v3: > > > - new patch > > > --- > > > lib/librte_eal/include/rte_common.h | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/lib/librte_eal/include/rte_common.h b/lib/librte_eal/include/rte_common.h > > > index 8f487a563..522afe58e 100644 > > > --- a/lib/librte_eal/include/rte_common.h > > > +++ b/lib/librte_eal/include/rte_common.h > > > @@ -135,6 +135,7 @@ typedef uint16_t unaligned_uint16_t; > > > > > > #define RTE_PRIORITY_LOG 101 > > > #define RTE_PRIORITY_BUS 110 > > > +#define RTE_PRIORITY_COMMON 119 > > > #define RTE_PRIORITY_CLASS 120 > > > #define RTE_PRIORITY_LAST 65535 > > > > > > > > > > I guess the name "common" selected because of the intention to use it by the > > common piece of the driver, but only from eal perspective the name > > "PRIORITY_COMMON" looks so vague, it doesn't describe any purpose. > > You're right. > > > Also the value doesn't leave any gap between the class priority, what else can > > be needed in the future in between, right? > > And we can imagine a bus requiring a common lib > to be initialized before. > > > @Thomas, @David, I am reluctant to get this eal change through the next-net, can > > you please review/ack it first? > > What about skipping this patch and using "RTE_PRIORITY_CLASS - 1" > in the code? net and vdpa code expect the common code being initialised. It is a dependency internal to mlx5 drivers, I see nothing generic. The common driver can provide a init function called by net and vdpa drivers in constructor context (not that I like calling complex init, but it should be equivalent to current state). It expresses a clear dependency and there is no constructor semantic to invent, nor runtime breakage possible because someone tweaks the priority order in the future. There is also some hack about a haswell/broadwell detection in LOG priority that makes no sense. I compile-tested following: $ git diff next-net-mlx/master -- lib/librte_eal/ drivers/*/mlx5/ diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 79cd5ba344..3fb9a8ab89 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -49,14 +49,6 @@ RTE_INIT_PRIO(mlx5_log_init, LOG) rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE); } -/** - * Initialization routine for run-time dependency on glue library. - */ -RTE_INIT_PRIO(mlx5_glue_init, COMMON) -{ - mlx5_glue_constructor(); -} - /** * This function is responsible of initializing the variable * haswell_broadwell_cpu by checking if the cpu is intel @@ -67,7 +59,7 @@ RTE_INIT_PRIO(mlx5_glue_init, COMMON) * if the cpu is haswell or broadwell the variable will be set to 1 * otherwise it will be 0. */ -RTE_INIT_PRIO(mlx5_is_haswell_broadwell_cpu, LOG) +static void mlx5_is_haswell_broadwell_cpu(void) { #ifdef RTE_ARCH_X86_64 unsigned int broadwell_models[4] = {0x3d, 0x47, 0x4F, 0x56}; @@ -114,6 +106,21 @@ RTE_INIT_PRIO(mlx5_is_haswell_broadwell_cpu, LOG) haswell_broadwell_cpu = 0; } +/** + * Initialization routine for run-time dependency on glue library. + */ +void mlx5_common_init(void) +{ + static bool init_once = false; + + if (init_once) + return; + + mlx5_glue_constructor(); + mlx5_is_haswell_broadwell_cpu(); + init_once = true; +} + /** * Allocate page of door-bells and register it using DevX API. * diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 5b9b7bd5a9..30961bc8cc 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -254,6 +254,10 @@ int64_t mlx5_get_dbr(void *ctx, struct mlx5_dbr_page_list *head, __rte_internal int32_t mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id, uint64_t offset); + +__rte_internal +void mlx5_common_init(void); + extern uint8_t haswell_broadwell_cpu; #endif /* RTE_PMD_MLX5_COMMON_H_ */ diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map index fe62fa2b2f..039d221333 100644 --- a/drivers/common/mlx5/rte_common_mlx5_version.map +++ b/drivers/common/mlx5/rte_common_mlx5_version.map @@ -1,6 +1,7 @@ INTERNAL { global: + mlx5_common_init; mlx5_common_verbs_reg_mr; mlx5_common_verbs_dereg_mr; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 846398dd3d..d0e9345a55 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1989,6 +1989,8 @@ RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE) */ RTE_INIT_PRIO(rte_mlx5_pmd_init, CLASS) { + mlx5_common_init(); + /* Build the static tables for Verbs conversion. */ mlx5_set_ptype_table(); mlx5_set_cksum_table(); diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 70692ea1d2..9dc3e8fa56 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -844,6 +844,8 @@ RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE) */ RTE_INIT_PRIO(rte_mlx5_vdpa_init, CLASS) { + mlx5_common_init(); + if (mlx5_glue) rte_mlx5_pci_driver_register(&mlx5_vdpa_driver); } diff --git a/lib/librte_eal/include/rte_common.h b/lib/librte_eal/include/rte_common.h index 522afe58ed..8f487a563d 100644 --- a/lib/librte_eal/include/rte_common.h +++ b/lib/librte_eal/include/rte_common.h @@ -135,7 +135,6 @@ typedef uint16_t unaligned_uint16_t; #define RTE_PRIORITY_LOG 101 #define RTE_PRIORITY_BUS 110 -#define RTE_PRIORITY_COMMON 119 #define RTE_PRIORITY_CLASS 120 #define RTE_PRIORITY_LAST 65535 -- David Marchand