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 50E45A0597; Thu, 9 Apr 2020 13:31:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 364431C222; Thu, 9 Apr 2020 13:31:47 +0200 (CEST) Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by dpdk.org (Postfix) with ESMTP id 448831C1D6 for ; Thu, 9 Apr 2020 13:31:45 +0200 (CEST) Received: by mail-io1-f67.google.com with SMTP id m4so3468373ioq.6 for ; Thu, 09 Apr 2020 04:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rtQWfrKb3+MkERDZAmHJNmNhKzAwx0yuL9pAv1nLoX8=; b=JFaTdJYpgXe99jmpimmC2y95EMKUfWxA8wrF9iSZ+8MmvjIbC/DvoapL5jS9ZFVJNL 4rmme0ERUA2mtiz8i+O03/uxmw2LxWuax5mAMIR18BzcNaE4fNEJIvxg8ef2WHnD6/uT QaZThuYRP/ith8TcLMJnJK19/9gP+32t8zHN6B5LeSI9sq8eqZ3iSjUc0wiOREh/F+RQ ug5pjxbKJojxiU/ZZpztJ/IKeGYO0Mxl1wJ7A+zjyiCODMqVUunlrSu0j46ERA+22O35 MIx/e8fYCpWy9S0iXSbpUi0x267C9WV1PRzFygdM3qDHnJXY+0jrzMfEJ5BViuaxJ/D7 EcnA== 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=rtQWfrKb3+MkERDZAmHJNmNhKzAwx0yuL9pAv1nLoX8=; b=awSFIdCdLoO45Kxq/C47f4s0k6z97ZZpswdov6g4Q5koOexPKQUQpPXRtPS3H0G8bf xkqQXBih6lUFOOTcLQw6rOUXdZlGgLh4qTD2kwSbk427uN3cOJ9pfDyYx287uIjZB7Nq +z5QvAo8+aeRccwDnSbt7tX0f9kfzeztxXLHaO5dTw1L/+s4LnOMJIzfHYxTNMBNOpGj G1OrX5WplovEW9eQHvpfG498+1js5mGgMH2uEfFfHZjbqXbNrXOUPG7oOi6takAImPkD ZrTrKaXdD1H6rOH7Ye4GoTQGhBjoTEXZC7qHwY01m9JFSM7mQxKN/NaXqmg9FH/A3yVZ JLNA== X-Gm-Message-State: AGi0PuYbA/syqlbZOgIeGwTzfaVJUtsL77P0VwdiYkW4LuQZNzFpR2Y1 RvGcrBLB/5/udRf/KWXAN4WdK19pC7LBaflg18Q= X-Google-Smtp-Source: APiQypJplGVZjVOAPlQVGOE5I1VO//v514orRVcX6Tdi5+SmPky0J1030jN4N3TPY5vQqFdECsVnXrFNuBgZ0spC7tY= X-Received: by 2002:a02:9a0d:: with SMTP id b13mr2183597jal.60.1586431904441; Thu, 09 Apr 2020 04:31:44 -0700 (PDT) MIME-Version: 1.0 References: <1583114253-15345-1-git-send-email-xiangxia.m.yue@gmail.com> <1586429580-6990-1-git-send-email-xiangxia.m.yue@gmail.com> In-Reply-To: <1586429580-6990-1-git-send-email-xiangxia.m.yue@gmail.com> From: Jerin Jacob Date: Thu, 9 Apr 2020 17:01:28 +0530 Message-ID: To: Tonghao Zhang Cc: Olivier Matz , Andrew Rybchenko , Gage Eads , "Artem V. Andreev" , Jerin Jacob , Nithin Dabilpuram , Vamsi Attunuru , Hemant Agrawal , David Marchand , Anatoly Burakov , "Richardson, Bruce" , dpdk-dev Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH dpdk-dev 1/2] eal: introduce last-init queue for libraries initialization 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, Apr 9, 2020 at 4:24 PM wrote: > > From: Tonghao Zhang > > This patch introduces last-init queue, user can register a > callback for theirs initialization. Running rte_last_init_run(), > the almost resource of DPDK are available, such as memzone, ring. > With this way, user don't introduce additional codes in eal layer. > > [This patch will be used for next patch.] > > Signed-off-by: Tonghao Zhang > --- > lib/librte_eal/common/eal_common_last_init.c | 43 ++++++++++++++++++++++++++++ > lib/librte_eal/common/meson.build | 1 + > lib/librte_eal/freebsd/Makefile | 1 + > lib/librte_eal/freebsd/eal.c | 7 +++++ > lib/librte_eal/include/rte_last_init.h | 36 +++++++++++++++++++++++ Update doc/api/doxy-api-index.md and hook to documenion. > +void > +rte_last_init_register(rte_last_init_cb cb, const void *arg) > +{ > + struct rte_last_init *last; > + > + RTE_VERIFY(cb); > + > + last = malloc(sizeof(*last)); Does not look like this memory is NOT freed anywhere. > + if (last == NULL) > + rte_panic("Alloc memory for rte_last_init node failed\n"); > + > + last->cb = cb; > + last->arg = arg; > + > + TAILQ_INSERT_TAIL(&rte_last_init_list, last, next); > +} > + > +int > +rte_last_init_run(void) > +{ > + struct rte_last_init *init; > + int ret; > + > + TAILQ_FOREACH(init, &rte_last_init_list, next) { > + ret = init->cb(init->arg); > + if (ret) > + return ret; > + } > + > + return 0; > +} > diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build > +typedef int (*rte_last_init_cb)(const void *arg); > + > +/** > + * A structure describing a generic initialization. > + */ > +struct rte_last_init { > + TAILQ_ENTRY(rte_last_init) next; /**< Next bus object in linked list */ > + const void *arg; > + rte_last_init_cb cb; > +}; No need to expose this structure. Move to eal_private.h > + > +/** Double linked list of buses */ > +TAILQ_HEAD(rte_last_init_list, rte_last_init); No need to expose this structure. Move to eal_private.h > + > +void rte_last_init_register(rte_last_init_cb cb, const void *arg); Add Doxygen comment. Should we change to rte_init_register()? add an enum to specify where to call this RTE_INIT_PRE, RTE_INIT_POST to take care of the future needs. Just thought of bringing this point to make sure we can use this scheme for another use case IF ANY. > +int rte_last_init_run(void); No need to expose this function in public API. Move to eal_private.h. Please start the internal functions with eal_(dont use rte_ for internal functions)