On Wed, Jul 1, 2020 at 2:34 PM <jer...@marvell.com> wrote: > > From: Jerin Jacob <jer...@marvell.com> > > This patch series improves the rte_log registration code snippet by > avoiding duplication of the code around registration by > introducing RTE_LOG_REGISTER macro. > > Drivers not adapted to new macro > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > I have converted all existing rte_log_register() to new macro, except > the following (as it has different usage style) > 1) drivers/common/mlx5/mlx5_common.c > 2) drivers/net/e1000/e1000_logs.c > 3) drivers/net/sfc/sfc_ethdev.c > > Example usage of new macro > ~~~~~~~~~~~~~~~~~~~~~~~~~~ > -/** > - * @internal > - */ > -int otx2_logtype_base; > -/** > - * @internal > - */ > -int otx2_logtype_mbox; > -/** > - * @internal > - */ > -int otx2_logtype_npa; > -/** > - * @internal > - */ > -int otx2_logtype_nix; > -/** > - * @internal > - */ > -int otx2_logtype_npc; > -/** > - * @internal > - */ > -int otx2_logtype_tm; > -/** > - * @internal > - */ > -int otx2_logtype_sso; > -/** > - * @internal > - */ > -int otx2_logtype_tim; > -/** > - * @internal > - */ > -int otx2_logtype_dpi; > -/** > - * @internal > - */ > -int otx2_logtype_ep; > - > -RTE_INIT(otx2_log_init); > -static void > -otx2_log_init(void) > -{ > - otx2_logtype_base = rte_log_register("pmd.octeontx2.base"); > - if (otx2_logtype_base >= 0) > - rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE); > - > - otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox"); > - if (otx2_logtype_mbox >= 0) > - rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE); > - > - otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2"); > - if (otx2_logtype_npa >= 0) > - rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE); > - > - otx2_logtype_nix = rte_log_register("pmd.net.octeontx2"); > - if (otx2_logtype_nix >= 0) > - rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE); > - > - otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow"); > - if (otx2_logtype_npc >= 0) > - rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE); > - > - otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm"); > - if (otx2_logtype_tm >= 0) > - rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE); > - > - otx2_logtype_sso = rte_log_register("pmd.event.octeontx2"); > - if (otx2_logtype_sso >= 0) > - rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE); > - > - otx2_logtype_tim = > rte_log_register("pmd.event.octeontx2.timer"); > - if (otx2_logtype_tim >= 0) > - rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE); > - > - otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi"); > - if (otx2_logtype_dpi >= 0) > - rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE); > - > - otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep"); > - if (otx2_logtype_ep >= 0) > - rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE); > - > -} > +RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE); > +RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
Squashed as a single commit since the conversion patches do not give more insight than the first change. Removed unnecessary some double empty lines or at the end of files. And applied. Note: I spotted some left behind logtype declarations for mlx5_vdpa_logtype, rte_graph_logtype, librawdev_logtype and stack_logtype. Could you send a followup patch if there are unneeded? Thanks for the cleanup. -- David Marchand