From mboxrd@z Thu Jan 1 00:00:00 1970 From: Reshma Pattan Subject: =?utf-8?q?=5BPATCH_v6_0/8=5D_add_packet_capture_framew?= =?utf-8?q?ork?= Date: Thu, 9 Jun 2016 09:50:02 +0100 Message-ID: <1465462210-4203-1-git-send-email-reshma.pattan@intel.com> References: <1465393107-32587-1-git-send-email-reshma.pattan@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable To: dev@dpdk.org Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 7B8ACC35A for ; Thu, 9 Jun 2016 10:50:18 +0200 (CEST) Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u598oAKO028664 for ; Thu, 9 Jun 2016 09:50:10 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u598oA3T004253 for ; Thu, 9 Jun 2016 09:50:10 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u598oAPQ004249 for dev@dpdk.org; Thu, 9 Jun 2016 09:50:10 +0100 In-Reply-To: <1465393107-32587-1-git-send-email-reshma.pattan@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch set include below changes 1)Changes to librte_ether. 2)A new library librte_pdump added for packet capture framework. 3)A new app/pdump tool added for packet capturing. 4)Test pmd changes done to initialize packet capture framework. 5)Documentation update. 1)librte_pdump =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D To support packet capturing on dpdk Ethernet devices, a new library librt= e_pdump is added.Users can develop their own packet capturing application using n= ew library APIs. Operation: ---------- Pdump library provides APIs to support packet capturing on dpdk Ethernet = devices. Library provides APIs to initialize the packet capture framework, enable/= disable the packet capture and uninitialize the packet capture framework. Pdump library works on client/server based model. Sever is responsible for enabling/disabling the packet captures. Clients are responsible for requesting enable/disable of the packet captures. As part of packet capture framework initialization, pthread and the server socket is created. Only one server socket is allowed on the sy= stem. As part of enabling/disabling the packet capture, client sockets are crea= ted and multiple client sockets are allowed. Who ever calls initialization first they will succeed with the initializa= tion, next subsequent calls of initialization are not allowed. So next users ca= n only request enabling/disabling the packet capture. Applications using below APIs need to pass port/device_id, queue, mempool= and ring parameters. Library uses user provided ring and mempool to mirror th= e rx/tx packets of the port for users. Users need to dequeue the rings and write = the packets to vdev(pcap/tuntap) to view the packets using any standard tools. Note: Mempool and Ring should be mc/mp supportable. Mempool mbuf size should be big enough to handle the rx/tx packets of a p= ort. APIs: ----- rte_pdump_init() rte_pdump_enable() rte_pdump_enable_by_deviceid() rte_pdump_disable() rte_pdump_disable_by_deviceid() rte_pdump_uninit() 2)app/pdump tool =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Tool app/pdump is designed based on librte_pdump for packet capturing in = DPDK. This tool by default runs as secondary process, and provides the support = for the command line options for packet capture. ./build/app/dpdk_pdump -- --pdump '(port=3D | device_id=3D), (queue=3D), (rx-dev=3D | tx-dev=3D), [ring-size=3D], [mbuf-size=3D], [total-num-mbufs=3D]' Parameters inside the parenthesis represents the mandatory parameters. Parameters inside the square brackets represents optional parameters. User has to pass on packet capture parameters under --pdump parameters, m= ultiples of --pdump can be passed to capture packets on different port and queue comb= inations Operation: ---------- *Tool parse the user command line arguments, creates the mempool, ring and the PCAP PMD vdev with 'tx_stream' as eithe= r of the device passed in rx-dev|tx-dev parameters. *Then calls the APIs of librte_pdump i.e. rte_pdump_enable()/rte_pdump_en= able_by_deviceid() to enable packet capturing on a specific port/device_id and queue by pass= ing on port|device_id, queue, mempool and ring info. *Tool runs in while loop to dequeue the packets from the ring and write t= hem to pcap device. *Tool can be stopped using SIGINT, upon which tool calls rte_pdump_disable()/rte_pdump_disable_by_deviceid() and free the allocate= d resources. Note: CONFIG_RTE_LIBRTE_PMD_PCAP flag should be set to yes to compile and run t= he pdump tool. 3)Test-pmd changes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Changes are done to test-pmd application to initialize/uninitialize the p= acket capture framework. So app/pdump tool can be run to see packets of dpdk ports that are used b= y test-pmd. Similarly any application which needs packet capture should call initiali= ze/uninitialize APIs of librte_pdump and use pdump tool to start the capture. 4)Packet capture flow between pdump tool and librte_pdump =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D * Pdump tool (Secondary process) requests packet capture for specific port|device_id and queue combinations. *Library in secondary process context creates client socket and communica= tes the port|device_id, queue, ring and mempool to server. *Library initializes server in primary process 'test-pmd' context and ser= ver serves the client request to enable Ethernet rxtx call-backs for a given port|de= vice_id and queue. *Copy the rx/tx packets to passed mempool and enqueue the packets to ring= for secondary process. *Pdump tool will dequeue the packets from ring and writes them to PCAPMD = vdev, so ultimately packets will be seen on the device that is passed in rx-dev= |tx-dev. *Once the pdump tool is terminated with SIGINT it will disable the packet= capturing. *Library receives the disable packet capture request, communicate the inf= o to server, server will remove the Ethernet rxtx call-backs. *Packet capture can be seen using tcpdump command "tcpdump -ni " (or) "tcpdump =E2=80=93nr " 5)Example command line =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ./build/app/dpdk_pdump -- --pdump 'device_id=3D0000:02:0.0,queue=3D*,tx-d= ev=3D/tmp/dt-file.pcap,rx-dev=3D/tmp/dr-file.pcap,ring-size=3D8192,mbuf-s= ize=3D2176,total-num-mbufs=3D32768' --pdump 'device_id=3D0000:01:00.0,que= ue=3D*,rx-dev=3D/tmp/d-file.pcap,tx-dev=3D/tmp/d-file.pcap,ring-size=3D16= 384,mbuf-size=3D2176,total-num-mbufs=3D32768' v6: removed below deprecation notice patch from patch set. http://dpdk.org/dev/patchwork/patch/13372/ v5: addressed code review comments for below patches http://dpdk.org/dev/patchwork/patch/12955/ http://dpdk.org/dev/patchwork/patch/12951/ v4: added missing deprecation notice for ABI changes of rte_eth_dev_info stru= cture. made doc changes as per doc guidelines. replaced rte_eal_vdev_init with rte_eth_dev_attach in pdump tool. removed rxtx-dev parameter from pdump tool command line. v3: app/pdump: Moved cleanup code from signal handler to main. divided librte_ether changes into multiple patches. example command changed in app/pdump application guide v2: fix compilation issues for 4.8.3 fix unnecessary #includes Reshma Pattan (8): librte_ether: protect add/remove of rxtx callbacks with spinlocks librte_ether: add new api rte_eth_add_first_rx_callback librte_ether: add new fields to rte_eth_dev_info struct librte_ether: make rte_eth_dev_get_port_by_name rte_eth_dev_get_name_by_port public lib/librte_pdump: add new library for packet capturing support app/pdump: add pdump tool for packet capturing app/test-pmd: add pdump initialization uninitialization doc: update doc for packet capture framework MAINTAINERS | 8 + app/Makefile | 1 + app/pdump/Makefile | 45 ++ app/pdump/main.c | 814 ++++++++++++++++++++++++++= +++++ app/test-pmd/testpmd.c | 6 + config/common_base | 5 + doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/pdump_library.rst | 107 ++++ doc/guides/rel_notes/release_16_07.rst | 13 + doc/guides/sample_app_ug/index.rst | 1 + doc/guides/sample_app_ug/pdump.rst | 122 +++++ lib/Makefile | 1 + lib/librte_ether/rte_ethdev.c | 123 +++-- lib/librte_ether/rte_ethdev.h | 59 +++ lib/librte_ether/rte_ether_version.map | 9 + lib/librte_pdump/Makefile | 55 +++ lib/librte_pdump/rte_pdump.c | 841 ++++++++++++++++++++++++++= ++++++ lib/librte_pdump/rte_pdump.h | 186 +++++++ lib/librte_pdump/rte_pdump_version.map | 12 + mk/rte.app.mk | 1 + 20 files changed, 2366 insertions(+), 44 deletions(-) create mode 100644 app/pdump/Makefile create mode 100644 app/pdump/main.c create mode 100644 doc/guides/prog_guide/pdump_library.rst create mode 100644 doc/guides/sample_app_ug/pdump.rst create mode 100644 lib/librte_pdump/Makefile create mode 100644 lib/librte_pdump/rte_pdump.c create mode 100644 lib/librte_pdump/rte_pdump.h create mode 100644 lib/librte_pdump/rte_pdump_version.map --=20 2.5.0