From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 0FC835F14 for ; Wed, 24 Oct 2018 17:55:57 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2018 08:55:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,420,1534834800"; d="scan'208";a="85250397" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by orsmga006.jf.intel.com with ESMTP; 24 Oct 2018 08:55:55 -0700 Received: from irsmsx107.ger.corp.intel.com ([169.254.10.56]) by IRSMSX106.ger.corp.intel.com ([169.254.8.45]) with mapi id 14.03.0319.002; Wed, 24 Oct 2018 16:55:54 +0100 From: "Iremonger, Bernard" To: Thomas Monjalon , "Wu, Jingjing" , "Lu, Wenzhuo" CC: "dev@dpdk.org" , "ophirmu@mellanox.com" , "wisamm@mellanox.com" , "Yigit, Ferruh" , "arybchenko@solarflare.com" Thread-Topic: [PATCH 4/5] app/testpmd: move ethdev events registration Thread-Index: AQHUa59HnwjRTxFTgkOdqBAtPaYNhqUui+Xw Date: Wed, 24 Oct 2018 15:55:54 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C260D16FD4@IRSMSX107.ger.corp.intel.com> References: <20181024134111.26771-1-thomas@monjalon.net> <20181024134111.26771-5-thomas@monjalon.net> In-Reply-To: <20181024134111.26771-5-thomas@monjalon.net> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTE5MzBmMzItOWM0YS00ODlkLTg4OWUtMjM5YzNjODYzYWY1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU25oN3MydzFUSGV6WHVISlwvbDE2d0VGZ2MxOFhDUG1nazQzdXdSUktDcXR5NFF3Rlk2TTdJVzJ5a2pzSEtUaXcifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 4/5] app/testpmd: move ethdev events registration 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: , X-List-Received-Date: Wed, 24 Oct 2018 15:55:58 -0000 Hi Thomas, > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Wednesday, October 24, 2018 2:41 PM > To: Iremonger, Bernard ; Wu, Jingjing > ; Lu, Wenzhuo > Cc: dev@dpdk.org; ophirmu@mellanox.com; wisamm@mellanox.com; Yigit, > Ferruh ; arybchenko@solarflare.com > Subject: [PATCH 4/5] app/testpmd: move ethdev events registration >=20 > The callback for ethdev events was registered on port start, so it was mi= ssing > some events. >=20 > It is now registered at the beginning of the main function. >=20 > Signed-off-by: Thomas Monjalon > --- > app/test-pmd/testpmd.c | 72 ++++++++++++++++++++++++------------------ > 1 file changed, 42 insertions(+), 30 deletions(-) >=20 > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > 72b91adf5..6eb416e7a 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -345,6 +345,21 @@ uint8_t rmv_interrupt =3D 1; /* enabled by default *= / >=20 > uint8_t hot_plug =3D 0; /**< hotplug disabled by default. */ >=20 > +/* Pretty printing of ethdev events */ > +static const char * const eth_event_desc[] =3D { > + [RTE_ETH_EVENT_UNKNOWN] =3D "unknown", > + [RTE_ETH_EVENT_INTR_LSC] =3D "LSC", How about replacing "LSC" with "interrupt link status change" > + [RTE_ETH_EVENT_QUEUE_STATE] =3D "queue state", > + [RTE_ETH_EVENT_INTR_RESET] =3D "interrupt reset", > + [RTE_ETH_EVENT_VF_MBOX] =3D "VF mbox", > + [RTE_ETH_EVENT_IPSEC] =3D "IPsec", > + [RTE_ETH_EVENT_MACSEC] =3D "MACsec", > + [RTE_ETH_EVENT_INTR_RMV] =3D "device removal", How about replacing "device removal" with "interrupt device removal" > + [RTE_ETH_EVENT_NEW] =3D "device probed", > + [RTE_ETH_EVENT_DESTROY] =3D "device released", > + [RTE_ETH_EVENT_MAX] =3D NULL, > +}; > + > /* > * Display or mask ether events > * Default to all events except VF_MBOX @@ -1934,7 +1949,6 @@ > start_port(portid_t pid) > queueid_t qi; > struct rte_port *port; > struct ether_addr mac_addr; > - enum rte_eth_event_type event_type; >=20 > if (port_id_is_invalid(pid, ENABLED_WARN)) > return 0; > @@ -2090,20 +2104,6 @@ start_port(portid_t pid) > need_check_link_status =3D 1; > } >=20 > - for (event_type =3D RTE_ETH_EVENT_UNKNOWN; > - event_type < RTE_ETH_EVENT_MAX; > - event_type++) { > - diag =3D rte_eth_dev_callback_register(RTE_ETH_ALL, > - event_type, > - eth_event_callback, > - NULL); > - if (diag) { > - printf("Failed to setup even callback for event %d\n", > - event_type); > - return -1; > - } > - } > - > if (need_check_link_status =3D=3D 1 && !no_link_check) > check_all_ports_link_status(RTE_PORT_ALL); > else if (need_check_link_status =3D=3D 0) > @@ -2522,20 +2522,6 @@ static int > eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void > *param, > void *ret_param) > { > - static const char * const event_desc[] =3D { > - [RTE_ETH_EVENT_UNKNOWN] =3D "Unknown", > - [RTE_ETH_EVENT_INTR_LSC] =3D "LSC", > - [RTE_ETH_EVENT_QUEUE_STATE] =3D "Queue state", > - [RTE_ETH_EVENT_INTR_RESET] =3D "Interrupt reset", > - [RTE_ETH_EVENT_VF_MBOX] =3D "VF Mbox", > - [RTE_ETH_EVENT_IPSEC] =3D "IPsec", > - [RTE_ETH_EVENT_MACSEC] =3D "MACsec", > - [RTE_ETH_EVENT_INTR_RMV] =3D "device removal", > - [RTE_ETH_EVENT_NEW] =3D "device probed", > - [RTE_ETH_EVENT_DESTROY] =3D "device released", > - [RTE_ETH_EVENT_MAX] =3D NULL, > - }; > - > RTE_SET_USED(param); > RTE_SET_USED(ret_param); >=20 > @@ -2545,7 +2531,7 @@ eth_event_callback(portid_t port_id, enum > rte_eth_event_type type, void *param, > fflush(stderr); > } else if (event_print_mask & (UINT32_C(1) << type)) { > printf("\nPort %" PRIu16 ": %s event\n", port_id, > - event_desc[type]); > + eth_event_desc[type]); > fflush(stdout); > } >=20 > @@ -2564,6 +2550,28 @@ eth_event_callback(portid_t port_id, enum > rte_eth_event_type type, void *param, > return 0; > } >=20 > +static int > +register_eth_event_callback(void) > +{ > + int ret; > + enum rte_eth_event_type event; > + > + for (event =3D RTE_ETH_EVENT_UNKNOWN; > + event < RTE_ETH_EVENT_MAX; event++) { > + ret =3D rte_eth_dev_callback_register(RTE_ETH_ALL, > + event, > + eth_event_callback, > + NULL); > + if (ret !=3D 0) { > + TESTPMD_LOG(ERR, "Failed to register callback for " > + "%s event\n", eth_event_desc[event]); > + return -1; > + } > + } > + > + return 0; > +} > + > /* This function is used by the interrupt thread */ static void > eth_dev_event_callback(const char *device_name, enum rte_dev_event_type > type, @@ -3048,6 +3056,10 @@ main(int argc, char** argv) > rte_panic("Cannot register log type"); > rte_log_set_level(testpmd_logtype, RTE_LOG_DEBUG); >=20 > + ret =3D register_eth_event_callback(); > + if (ret !=3D 0) > + rte_panic("Cannot register for ethdev events"); > + > #ifdef RTE_LIBRTE_PDUMP > /* initialize packet capture framework */ > rte_pdump_init(NULL); > -- > 2.19.0 Regards, Bernard