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 D4D9CA0526; Fri, 24 Jul 2020 15:45:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B9DBA1C01E; Fri, 24 Jul 2020 15:45:16 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id C9D2C1C01E for ; Fri, 24 Jul 2020 15:45:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595598313; 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=DDULVkyZ9YLdDKn69EauK1PCjmR0Ojdewt7zp7hrfAA=; b=bqd+/cYbn+HwD3JT6Uv1jsLFqGLg2aQCCgQRZnMm1UpwktlE1dhzC16J6mwt/UhmnnA/Wh wKbUL3h6cSZB7bcC76gJRq6XJ12kTvkaiR1plxH5CNzOddQ9h6IStwj9Fw7mabzO4Pke7Q nUpIj1Tbzpemi6zNOp2eVPUgbszFlr4= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-163-poxRMmOyNwalj8FG-3sFjA-1; Fri, 24 Jul 2020 09:45:11 -0400 X-MC-Unique: poxRMmOyNwalj8FG-3sFjA-1 Received: by mail-vk1-f198.google.com with SMTP id l8so2929830vkm.10 for ; Fri, 24 Jul 2020 06:45:11 -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=DDULVkyZ9YLdDKn69EauK1PCjmR0Ojdewt7zp7hrfAA=; b=j9DQhswpZ6iscRHVNZUXE2DLi5e9KTf5fSpoYCZyi+kpvigbgoNGZgP3rGzmfz/fl/ /zYB7wfV6Nw2rt+FqQrRBnrMI5xkcaz7zpVB5IItgkEqogSmhgiT2iMaWd2RwGaoZr5g TZdpdV73cyZcj2Yqi5K4JoMJhf2td9+5oXQRFZ45awa72pg+lUlHbzQ8ZHkP87xMD2RI PFI6blirojSbHU+qq1dVuIV+FN54LNN4H/JEAuLGKp5e1fV9vMLeLswLY6dfOzuE7wIs NY5+xyL22OwgkuPeLZENF8VAVwzOASXv3TeJRVhllyjIbKuZBV6p3z7H8COQfj56LjsE ZmZw== X-Gm-Message-State: AOAM531/kkbfGr553d7dwDmGUVksLi5htQhfcM62oJStEdSYpeFeWdG8 IetyNQ3O7uXPe1+VQMDufNoQ2IrGZruoCt2gYFlwFgOXlRyYzpd+38Q3jBDrXYCSgqjsd7xz8pk /d/NqgHKlPHRM4Zvw4xU= X-Received: by 2002:a67:cb9c:: with SMTP id h28mr7684252vsl.39.1595598311223; Fri, 24 Jul 2020 06:45:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4X88rCPK0sUYdphCI3VbmOfvaX0zuO6yBLKFfVpcBRgSC3S0IRl85XgNz5ygqFqbcfno0cmrxrLYD5RAM2vc= X-Received: by 2002:a67:cb9c:: with SMTP id h28mr7684232vsl.39.1595598310975; Fri, 24 Jul 2020 06:45:10 -0700 (PDT) MIME-Version: 1.0 References: <20200610171728.89-2-parav@mellanox.com> <20200723200910.376581-1-parav@mellanox.com> <20200723200910.376581-7-parav@mellanox.com> In-Reply-To: <20200723200910.376581-7-parav@mellanox.com> From: David Marchand Date: Fri, 24 Jul 2020 15:45:00 +0200 Message-ID: To: Parav Pandit Cc: dev , Gaetan Rivet , "Yigit, Ferruh" , Thomas Monjalon , Raslan , Ori Kam , Matan Azrad , Joyce Kong X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v8 06/10] common/mlx5: avoid using class constructor priority 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 Thu, Jul 23, 2020 at 10:10 PM Parav Pandit wrote: > > mlx5_common is shared library between mlx5 net, VDPA and regex PMD. > It is better to use common initialization helper instead of using > RTE_INIT_CLASS priority. RTE_INIT_CLASS does not exist, I suppose you meant RTE_PRIORITY_CLASS. Suggested-by: David Marchand > Signed-off-by: Parav Pandit > --- > drivers/common/mlx5/mlx5_common.c | 13 +++++++++++-- > drivers/common/mlx5/mlx5_common.h | 3 +++ > drivers/common/mlx5/rte_common_mlx5_version.map | 1 + > drivers/net/mlx5/mlx5.c | 1 + > drivers/regex/mlx5/mlx5_regex.c | 1 + > drivers/vdpa/mlx5/mlx5_vdpa.c | 1 + > 6 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c > index 1a67a1b16..2b336bb2d 100644 > --- a/drivers/common/mlx5/mlx5_common.c > +++ b/drivers/common/mlx5/mlx5_common.c > @@ -86,12 +86,21 @@ RTE_INIT_PRIO(mlx5_log_init, LOG) > rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE); > } > > +static bool mlx5_common_initialized; > + > /** > - * Initialization routine for run-time dependency on glue library. > + * One time innitialization routine for run-time dependency on glue library > + * for multiple PMDs. Each mlx5 PMD that depends on mlx5_common module, > + * must invoke in its constructor. > */ > -RTE_INIT_PRIO(mlx5_glue_init, CLASS) > +void > +mlx5_common_init(void) > { > + if (mlx5_common_initialized) > + return; > + > mlx5_glue_constructor(); > + mlx5_common_initialized = true; > } > > /** > diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h > index a811eb6c9..ebe4e9ced 100644 > --- a/drivers/common/mlx5/mlx5_common.h > +++ b/drivers/common/mlx5/mlx5_common.h > @@ -260,4 +260,7 @@ int32_t mlx5_release_dbr(struct mlx5_dbr_page_list *head, uint32_t umem_id, > uint64_t offset); > extern uint8_t haswell_broadwell_cpu; > > +__rte_internal > +void mlx5_common_init(void); > + > #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 132a0695f..65f25252a 100644 > --- a/drivers/common/mlx5/rte_common_mlx5_version.map > +++ b/drivers/common/mlx5/rte_common_mlx5_version.map > @@ -3,6 +3,7 @@ INTERNAL { > > mlx5_class_get; > > + 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 647ada339..037703d2e 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -2111,6 +2111,7 @@ RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE) > */ > RTE_INIT(rte_mlx5_pmd_init) > { > + mlx5_common_init(); > /* Build the static tables for Verbs conversion. */ > mlx5_set_ptype_table(); > mlx5_set_cksum_table(); > diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c > index 36ae9f809..4e0367052 100644 > --- a/drivers/regex/mlx5/mlx5_regex.c > +++ b/drivers/regex/mlx5/mlx5_regex.c > @@ -258,6 +258,7 @@ static struct rte_pci_driver mlx5_regex_driver = { > > RTE_INIT(rte_mlx5_regex_init) > { > + mlx5_common_init(); > if (mlx5_glue) > rte_pci_register(&mlx5_regex_driver); > } > diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c > index 67e77b11a..85dbcf956 100644 > --- a/drivers/vdpa/mlx5/mlx5_vdpa.c > +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c > @@ -846,6 +846,7 @@ RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE) > */ > RTE_INIT(rte_mlx5_vdpa_init) > { > + mlx5_common_init(); > if (mlx5_glue) > rte_pci_register(&mlx5_vdpa_driver); > } > -- > 2.25.4 > Reviewed-by: David Marchand -- David Marchand