From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 538082B9B for ; Wed, 9 Mar 2016 13:23:15 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 09 Mar 2016 04:23:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,311,1455004800"; d="scan'208";a="932983797" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by fmsmga002.fm.intel.com with ESMTP; 09 Mar 2016 04:23:11 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.35]) by irsmsx110.ger.corp.intel.com ([169.254.15.10]) with mapi id 14.03.0248.002; Wed, 9 Mar 2016 12:23:09 +0000 From: "Ananyev, Konstantin" To: "Yigit, Ferruh" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v5 4/4] examples/ethtool: add control interface support to the application Thread-Index: AQHRefjZkCwLgC4ZIU2/YnAp8c9r959RBznQ Date: Wed, 9 Mar 2016 12:23:09 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836B1A3F8@irsmsx105.ger.corp.intel.com> References: <1456846920-28770-1-git-send-email-ferruh.yigit@intel.com> <1457523689-6223-1-git-send-email-ferruh.yigit@intel.com> <1457523689-6223-5-git-send-email-ferruh.yigit@intel.com> In-Reply-To: <1457523689-6223-5-git-send-email-ferruh.yigit@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNGM5NjRmYzgtNDJiMS00NzZkLThjYTItMjVlZTA4MGY2ZDE2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImdXZFwvWVh2SUVIRVpsOEVUY3E3b3B4ZmJyMmlKckZjZmlVNklUVElDbXAwPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 4/4] examples/ethtool: add control interface support to the application X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Mar 2016 12:23:15 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit > Sent: Wednesday, March 09, 2016 11:41 AM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH v5 4/4] examples/ethtool: add control interfac= e support to the application >=20 > Control interface APIs added into the sample application. >=20 > To have the support corresponding kernel module (KCP) needs to be inserte= d. > If kernel module is not there, application will run as it is without > kernel control path support. >=20 > When KCP module inserted, running application creates a virtual Linux > network interface (dpdk$) per DPDK port. This interface can be used by > traditional Linux tools. >=20 > Signed-off-by: Ferruh Yigit > Acked-by: Remy Horton > --- >=20 > v4, v5: > * No update >=20 > v3: > * Use blocking mode control interface processing, instead of poll mode >=20 > v2: > * No update on sample app > --- > doc/guides/sample_app_ug/ethtool.rst | 41 ++++++++++++++++++++++++++++++= ++++++ > examples/ethtool/main.c | 31 +++++++++++++++++++++++++-- > 2 files changed, 70 insertions(+), 2 deletions(-) >=20 > diff --git a/doc/guides/sample_app_ug/ethtool.rst b/doc/guides/sample_app= _ug/ethtool.rst > index 65240ae..af591c2 100644 > --- a/doc/guides/sample_app_ug/ethtool.rst > +++ b/doc/guides/sample_app_ug/ethtool.rst > @@ -130,3 +130,44 @@ interface that accepts commands as described in `usi= ng the > application`_. Individual call-back functions handle the detail > associated with each command, which make use of librte_ethtool > library. > + > +Control Interface > +~~~~~~~~~~~~~~~~~ > + > +If Kernel Control Path (KCP) kernel module (rte_kcp.ko) inserted, > +virtual interfaces created for each DPDK port for control purposes. > + > +Created interfaces are named as dpdk#, like: > + > +.. code-block:: console > + > + # ifconfig dpdk0; ifconfig dpdk1 > + dpdk0: flags=3D4099 mtu 1500 > + ether 90:e2:ba:0e:49:b9 txqueuelen 1000 (Ethernet) > + RX packets 0 bytes 0 (0.0 B) > + RX errors 0 dropped 0 overruns 0 frame 0 > + TX packets 0 bytes 0 (0.0 B) > + TX errors 0 dropped 0 overruns 0 carrier 0 collisions= 0 > + > + dpdk1: flags=3D4099 mtu 1500 > + ether 00:1b:21:76:fa:21 txqueuelen 1000 (Ethernet) > + RX packets 0 bytes 0 (0.0 B) > + RX errors 0 dropped 0 overruns 0 frame 0 > + TX packets 0 bytes 0 (0.0 B) > + TX errors 0 dropped 0 overruns 0 carrier 0 collisions= 0 > + > +Regular Linux commands can be issued on interfaces: > + > +.. code-block:: console > + > + # ethtool -i dpdk0 > + driver: rte_ixgbe_pmd > + version: RTE 2.3.0-rc0 > + firmware-version: > + expansion-rom-version: > + bus-info: 0000:08:00.1 > + supports-statistics: yes > + supports-test: no > + supports-eeprom-access: yes > + supports-register-dump: yes > + supports-priv-flags: no > diff --git a/examples/ethtool/main.c b/examples/ethtool/main.c > index 2c655d8..72fbe4c 100644 > --- a/examples/ethtool/main.c > +++ b/examples/ethtool/main.c > @@ -1,7 +1,7 @@ > /*- > * BSD LICENSE > * > - * Copyright(c) 2015 Intel Corporation. All rights reserved. > + * Copyright(c) 2015-2016 Intel Corporation. All rights reserved. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -44,6 +44,7 @@ > #include > #include > #include > +#include >=20 > #include "ethapp.h" >=20 > @@ -54,7 +55,6 @@ > #define PKTPOOL_EXTRA_SIZE 512 > #define PKTPOOL_CACHE 32 >=20 > - > struct txq_port { > uint16_t cnt_unsent; > struct rte_mbuf *buf_frames[MAX_BURST_LENGTH]; > @@ -259,11 +259,32 @@ static int slave_main(__attribute__((unused)) void = *ptr_data) > return 0; > } >=20 > +static void * > +control_function(__attribute__((unused)) void *arg) > +{ > + int port_id; > + > + while (1) { > + /* blocking call with 1 sec timeout */ > + port_id =3D rte_eth_control_interface_msg_exist(1); > + if (port_id < 0) > + continue; > + > + lock_port(port_id); > + rte_eth_control_interface_msg_process( > + RTE_ETHTOOL_CTRL_IF_PROCESS_MSG); > + unlock_port(port_id); As I stated in offline code review, I think that just lock/unlock here is n= ot enough. You either have to update port_active flag here based on dev->data->dev_st= arted, or check dev->data->dev_started directly in your data-path or somehow else inform IO thread that the port is stopped and RX/TX is not possible over it= . Otherwise sending stop command over your control interface while RX/TX is a= ctive would cause your app to crash.=20 Konstantin > + } > + > + return 0; > +} > + > int main(int argc, char **argv) > { > int cnt_args_parsed; > uint32_t id_core; > uint32_t cnt_ports; > + pthread_t control_thread; >=20 > /* Init runtime enviornment */ > cnt_args_parsed =3D rte_eal_init(argc, argv); > @@ -293,6 +314,9 @@ int main(int argc, char **argv) > id_core =3D rte_get_next_lcore(id_core, 1, 1); > rte_eal_remote_launch(slave_main, NULL, id_core); >=20 > + pthread_create(&control_thread, NULL, control_function, NULL); > + rte_eth_control_interface_create(); > + > ethapp_main(); >=20 > app_cfg.exit_now =3D 1; > @@ -301,5 +325,8 @@ int main(int argc, char **argv) > return -1; > } >=20 > + rte_eth_control_interface_destroy(); > + pthread_cancel(control_thread); > + > return 0; > } > -- > 2.5.0