From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 786E76C93 for ; Tue, 10 May 2016 11:40:05 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 10 May 2016 02:40:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,604,1455004800"; d="scan'208";a="972392673" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 10 May 2016 02:40:03 -0700 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 u4A9e2F5003301 for ; Tue, 10 May 2016 10:40:02 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u4A9e2wL003361 for ; Tue, 10 May 2016 10:40:02 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u4A9e2P8003357 for dev@dpdk.org; Tue, 10 May 2016 10:40:02 +0100 From: Reshma Pattan To: dev@dpdk.org Date: Tue, 10 May 2016 10:39:57 +0100 Message-Id: <1462873202-3314-1-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1462532139-17848-1-git-send-email-reshma.pattan@intel.com> References: <1462532139-17848-1-git-send-email-reshma.pattan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] =?utf-8?q?=5BPATCHv2_0/5=5D_add_packet_capture_framewo?= =?utf-8?q?rk?= 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: Tue, 10 May 2016 09:40:06 -0000 This patchset include below changes 1)Changes to librte_ether. 2)New library librte_pdump added for packet capture framework. 3)New app/pdump tool added for packet capturing. 4)Test pmd changes done to initialize packet capture framework. 5)Documentation update. 1)librte_pdump ============== To support packet capturing on dpdk ethernet devices, a new library librte_pdump is added.Users can develop their own packet capturing application using new 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 un initialize the packet capture framework. Pdump library works on server and client 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 system. As part of enabling/disabling the packet capture, client sockets are created and multiple client sockets are allowed. Who ever calls initialization first they will succeed with the initialization, next subsequent calls of initialization are not allowed. So next users can 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 the rx/tx packets of the port for users. Users need to deque 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 port. 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 ================ Tool app/pdump is based on librte_pdump for packet capturing. This tool by default runs as secondary process, and provides the support for the command line options for packet capture. ./$(RTE_TARGET)/app/pdump -- --pdump='(port= | device_id=), (queue=2), (rx-dev= | tx-dev= | rxtx-dev=), [ring-size=1024], [mbuf-size=2048], [total-num-mbufs=8191]' 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, multiples of --pdump can be passed to capture packets on different port and queue combinations Operation: ---------- *Tool parse the user command line arguments, creates the mempool, ring and the PCAP PMD vdev with 'tx_stream' as either of the device passed in rx-dev|tx-dev|rxtx-dev parameters. *Then calls the APIs of librte_pdump i.e. rte_pdump_enable()/rte_pdump_enable_by_deviceid() to enable packet capturing on a specific port/device_id and queue by passing on port|device_id, queue, mempool and ring info. *Tool runs in while loop to dequeue the packets from the ring and write them to pcap device. *Tool can be stopped using SIGINT, upon which tool calls rte_pdump_disable()/rte_pdump_disable_by_deviceid() and free the allocated resources. Note: CONFIG_RTE_LIBRTE_PMD_PCAP flag should be set to yes to compile and run the pdump tool. 3)Test-pmd changes ================== Changes are done to test-pmd application to initialize/uninitialize the packet capture framework. So app/pdump tool can be run to see packets of dpdk ports that are used by test-pmd. Similarly any application which needs packet capture should call initialize/uninitialize apis of librate_pdump and use pdump tool to start the capture. 4)Packet capture flow between pdump tool and librte_pdump ========================================================= * Pdump tool (Secondary process) requests packet capture for specific port|device_id and queue combinations. *Library in secondary process context creates client socket and communicates the port|device_id, queue, ring and mempool to server. *Library initializes server in primary process 'test-pmd' context and serves client request to enable ethernet rxtx call-backs for given port|device_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 device passed in rx-dev|tx-dev|rxtx-dev. *Once the pdump tool is terminated with SIGINT it will disable packet capturing. *Library receives the disable packet capture request, communicate the info to server, server will remove the ethernet rxtx call-backs. *Packet capture can be seen using tcpdump command "tcpdump -ni " (or) "tcpdump –nr " 5)Example command line ====================== sudo ./x86_64-native-linuxapp-gcc/app/dpdk_pdump -- --pdump 'device_id=0000:02:00.0,queue=*,rx-dev=/tmp/rx-file.pcap,tx-dev=/tmp/tx-file.pcap,ring-size=8192,mbuf-size=2176,total-num-mbufs=16384' --pdump 'device_id=0000:01:00.0,queue=*,rx-dev=/tmp/rx2-file.pcap,tx-dev=/tmp/tx2-file.pcap,ring-size=16384,mbuf-size=2176,total-num-mbufs=32768' v2: fix compilation issues for 4.8.3 fix unnecessary #includes Reshma Pattan (5): librte_ether: protect add/remove of rxtx callbacks with spinlocks 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 | 936 ++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.c | 6 + config/common_base | 5 + doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/pdump_library.rst | 121 +++++ doc/guides/rel_notes/release_16_07.rst | 7 + doc/guides/sample_app_ug/index.rst | 1 + doc/guides/sample_app_ug/pdump.rst | 109 ++++ lib/Makefile | 1 + lib/librte_ether/rte_ethdev.c | 121 +++-- lib/librte_ether/rte_ethdev.h | 45 ++ lib/librte_ether/rte_ether_version.map | 9 + lib/librte_pdump/Makefile | 55 ++ lib/librte_pdump/rte_pdump.c | 816 ++++++++++++++++++++++++++++ lib/librte_pdump/rte_pdump.h | 186 +++++++ lib/librte_pdump/rte_pdump_version.map | 12 + mk/rte.app.mk | 1 + 20 files changed, 2443 insertions(+), 43 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 -- 2.5.0