From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50064.outbound.protection.outlook.com [40.107.5.64]) by dpdk.org (Postfix) with ESMTP id A09581B1C1 for ; Wed, 3 Oct 2018 17:16:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fgjv/dQKv3OymA5BUoOzkEI38v4989Lx5TIKIx7EnGY=; b=uf2ZQZ7igd7VQNCE2bxO0saDA2+bznDKJHmzG0xbnNEIJn9aDXUxFT40EUVePvgxVYeyf1qD28nXUcxNt9F0i/xZPQoAhNEVDimPfuK73QYWY4imiazoTiHFRYEtEMSUm5FynW3AkbCdNpJXnAg8Ym9pSygfeF+iRKLWi63MuIs= Received: from DB5PR05MB1254.eurprd05.prod.outlook.com (10.162.157.140) by DB5PR05MB1301.eurprd05.prod.outlook.com (10.162.157.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.22; Wed, 3 Oct 2018 15:16:23 +0000 Received: from DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5]) by DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5%2]) with mapi id 15.20.1185.026; Wed, 3 Oct 2018 15:16:23 +0000 From: Raslan Darawsheh To: "jingjing.wu@intel.com" CC: Thomas Monjalon , "dev@dpdk.org" , Shahaf Shuler , Raslan Darawsheh , "Xueming(Steven) Li" , Ori Kam , "jerin.jacob@caviumnetworks.com" , "david.marchand@6wind.com" , "bernard.iremonger@intel.com" Thread-Topic: [PATCH v3 2/3] app/testpmd: add packet dump callback functions Thread-Index: AQHUWywLl8r8XGf6Mkqt6mR3yaEDTg== Date: Wed, 3 Oct 2018 15:16:23 +0000 Message-ID: <1538579773-23054-2-git-send-email-rasland@mellanox.com> References: <1537793304-27883-1-git-send-email-rasland@mellanox.com> <1538579773-23054-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1538579773-23054-1-git-send-email-rasland@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: AM0PR01CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::41) To DB5PR05MB1254.eurprd05.prod.outlook.com (2a01:111:e400:51cc::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR05MB1301; 6:fig5EBIFZFjvlBAYrw5EWSqLpITf1kkR8C7YXTr67jTRawUescFwzBN8Jhwp7cKcnRIT3NGsZl4yN0XBTkWPfxMb7zmXlcsv/uKooFSavAPzuIJr/csjx8wggHFhxApbpgU2KFdhBYgaT0sAjQTnJxu8db0xl/uZb4YL2IjOB/tvJOhTPCSP9udaoTANx8s6HTpJOGSbtOVMGAFROBiu46I2r/eyW4Lhmt80hIcrK3eC8OGw86bxwF/Qgyp1oEq8D1IDi0IsnyV3Qgid6ucTajzyRi35ZlrTwamewzpZ0jSfCT4oeglnc5/11y0dx6NXj9stZ2BppSTdDdou7HUn0wrqYLshpYXVUi+sKHE/eH4po9FgWWaDgx71xBGHNYp5Wi19j07XcxOLTLcyb7SoLZeEp/aNtaEHlrOlMAEnAw+8k2kNM1WN6ZHLR2YtETHCUc5jBkXUfsxiJ5w15eeNPg==; 5:DApMCD+wjtN6qKeo+BYgKsy4D5H3EugzQEVD72LoqwhDoPH+PB41DXt31enWpbf5YvyQHDFc1n1m9kxLYy1VeIsQdzJRPQ2a3qfXrB4ZnkocKZoc3B2Y6l9yFLvL5gKl9aDrjOWC9ymdCyz473oVTwoT6vuuD9/cshWMFzIcJTg=; 7:V7tZtcq8bRRJStyECD/ZgvPVF+I7fF5KmebyV6w9f0ZiOu5NjxdhHvrc8stSbygeIGeHfjtsaW3E9zaO8JffD3ejkoFQ0TtfTwVRK7kSl36DtLj8+680ykeBTl3hjOG7/C8XVE8XMvwfkQtCTjQDM5++SoMHf5Smz170IB2kq5B2yDpR8xWwfhj50ocKluau7dvtrh8jprwX1HO2RMReyCC9ed/+Y/A99ajdeRjWbJAu7oH87+XEdaOSG0k/3+xJ x-ms-office365-filtering-correlation-id: 312f37ed-bb08-40cc-eeea-08d629432e07 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB5PR05MB1301; x-ms-traffictypediagnostic: DB5PR05MB1301: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051); SRVR:DB5PR05MB1301; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1301; x-forefront-prvs: 0814A2C7A3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(346002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(2616005)(8936002)(6436002)(476003)(478600001)(106356001)(68736007)(6486002)(5250100002)(186003)(5660300001)(97736004)(2900100001)(7736002)(76176011)(52116002)(305945005)(53936002)(5640700003)(99286004)(50226002)(575784001)(71200400001)(54906003)(71190400001)(2501003)(8676002)(81156014)(81166006)(486006)(36756003)(25786009)(102836004)(86362001)(6512007)(4326008)(6916009)(256004)(14454004)(105586002)(66066001)(316002)(6506007)(6116002)(2351001)(386003)(3846002)(446003)(11346002)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1301; H:DB5PR05MB1254.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 31hpJxoFepEBXeN3UWydJxWJvmYyzBjbHum+r/Tm0joCNgmGvwJl7+t0Gvozk9Wz7coKhQZa+fL2/KL6py+1Bh1Ln6ImhlzF+0lMAd73dyeQwbwBIt4aeg2is3hZ3alXWAaKdG+DPLnbRYg1IMz7iDv4yWRRsEC17lwOCX8SDgTOzOfwKyP4Y9WD32+7TaRVZg8AeiLOI3eMK2lKdKITZdLyVVyPqD3g9UAb96UpvpBApkPYJ5Qh5sTX+1cLTtawPxaYuoNnPQx/6WHe80sQN+jTQkRepsrhWB7i1OwX9KeH7EEMYjRQliagoP03AN/M5b63Ii68Vy790aXR+zoiQZMW+ti3GuCjIdZWvEBgs7s= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 312f37ed-bb08-40cc-eeea-08d629432e07 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Oct 2018 15:16:23.7478 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1301 Subject: [dpdk-dev] [PATCH v3 2/3] app/testpmd: add packet dump callback functions 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, 03 Oct 2018 15:16:25 -0000 add new rx/tx callback functions to be used for dumping the packets. Signed-off-by: Raslan Darawsheh --- app/test-pmd/config.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ app/test-pmd/testpmd.h | 15 +++++++++++ app/test-pmd/util.c | 17 +++++++++++++ 3 files changed, 99 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a0f9349..fb45fea 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2896,6 +2896,73 @@ set_pkt_forwarding_mode(const char *fwd_mode_name) } =20 void +add_rx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + + rte_eth_dev_info_get(portid, &dev_info); + for (queue =3D 0; queue < dev_info.nb_rx_queues; queue++) + if (!ports[portid].rx_dump_cb[queue]) + ports[portid].rx_dump_cb[queue] =3D + rte_eth_add_rx_callback(portid, queue, + dump_rx_pkts, NULL); +} + +void +add_tx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + rte_eth_dev_info_get(portid, &dev_info); + for (queue =3D 0; queue < dev_info.nb_tx_queues; queue++) + if (!ports[portid].tx_dump_cb[queue]) + ports[portid].tx_dump_cb[queue] =3D + rte_eth_add_tx_callback(portid, queue, + dump_tx_pkts, NULL); +} + +void +remove_rx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + rte_eth_dev_info_get(portid, &dev_info); + for (queue =3D 0; queue < dev_info.nb_rx_queues; queue++) + if (ports[portid].rx_dump_cb[queue]) { + rte_eth_remove_rx_callback(portid, queue, + ports[portid].rx_dump_cb[queue]); + ports[portid].rx_dump_cb[queue] =3D NULL; + } +} + +void +remove_tx_dump_callbacks(portid_t portid) +{ + struct rte_eth_dev_info dev_info; + uint16_t queue; + + if (port_id_is_invalid(portid, ENABLED_WARN)) + return; + rte_eth_dev_info_get(portid, &dev_info); + for (queue =3D 0; queue < dev_info.nb_tx_queues; queue++) + if (ports[portid].tx_dump_cb[queue]) { + rte_eth_remove_tx_callback(portid, queue, + ports[portid].tx_dump_cb[queue]); + ports[portid].tx_dump_cb[queue] =3D NULL; + } +} + +void set_verbose_level(uint16_t vb_level) { printf("Change verbose level from %u to %u\n", diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index a1f6614..c0d7656 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -180,6 +180,8 @@ struct rte_port { uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ uint8_t slave_flag; /**< bonding slave port */ struct port_flow *flow_list; /**< Associated flows. */ + const struct rte_eth_rxtx_callback *rx_dump_cb[MAX_QUEUE_ID+1]; + const struct rte_eth_rxtx_callback *tx_dump_cb[MAX_QUEUE_ID+1]; #ifdef SOFTNIC struct softnic_port softport; /**< softnic params */ #endif @@ -743,6 +745,19 @@ int check_nb_rxq(queueid_t rxq); queueid_t get_allowed_max_nb_txq(portid_t *pid); int check_nb_txq(queueid_t txq); =20 + +uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *p= kts[], + uint16_t nb_pkts, __rte_unused uint16_t max_pkts, + __rte_unused void *user_param); + +uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *p= kts[], + uint16_t nb_pkts, __rte_unused void *user_param); + +void add_rx_dump_callbacks(portid_t portid); +void remove_rx_dump_callbacks(portid_t portid); +void add_tx_dump_callbacks(portid_t portid); +void remove_tx_dump_callbacks(portid_t portid); + /* * Work-around of a compilation error with ICC on invocations of the * rte_be_to_cpu_16() function. diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index 12bbe91..3d111a2 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -144,3 +144,20 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struc= t rte_mbuf *pkts[], printf(" ol_flags: %s\n", buf); } } + +uint16_t +dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, __rte_unused uint16_t max_pkts, + __rte_unused void *user_param) +{ + dump_pkt_burst(port_id, queue, pkts, nb_pkts, 1); + return nb_pkts; +} + +uint16_t +dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], + uint16_t nb_pkts, __rte_unused void *user_param) +{ + dump_pkt_burst(port_id, queue, pkts, nb_pkts, 0); + return nb_pkts; +} --=20 2.7.4