From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50052.outbound.protection.outlook.com [40.107.5.52]) by dpdk.org (Postfix) with ESMTP id 6C4904C74 for ; Sun, 7 Oct 2018 09:38:11 +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=kuRO8ePpsb4ENwYCqQuVJbUzPpH8wSHCgST3jDuxwZU=; b=OVnHq3yF+Zc0/GsFjs+4iiiNlOsSVr5WSav+xX/bq8U7hYjgzPSBn20DpFcHbNiaZCS/W6eMYwoXv1DgIyNpCvLE2Kv8JPOmr7NYYSGlcTt2WUvPGMD5wiTZ2ewuFSJ4OcedsRmAJ+qwU5nflNm/6QyEJ6sAlnX4IJgvMo23HNI= Received: from DB5PR05MB1254.eurprd05.prod.outlook.com (10.162.157.140) by DB5PR05MB1672.eurprd05.prod.outlook.com (10.165.6.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.27; Sun, 7 Oct 2018 07:38:09 +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.029; Sun, 7 Oct 2018 07:38:09 +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 v4 2/3] app/testpmd: add packet dump callback functions Thread-Index: AQHUXhCxpXLGA/tZEUGjKwmgQ65AJQ== Date: Sun, 7 Oct 2018 07:38:09 +0000 Message-ID: <1538897848-1693-2-git-send-email-rasland@mellanox.com> References: <1537793304-27883-1-git-send-email-rasland@mellanox.com> <1538897848-1693-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1538897848-1693-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: HE1PR06CA0130.eurprd06.prod.outlook.com (2603:10a6:7:16::17) 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; DB5PR05MB1672; 6:YzLARHCnDCntiOrzbtCEbzGsWjZGdh3/LqvOFF5rPj3KHT91mL+Osy8NJTX0VrE3EnM43GX4JawaUI0dZrdmYGTL2FUZh/Qtq3FRGmtxQbOf4a/GafHXcdD26YommXThIVWSY3dYWcTNpQNqvxwF+OeEUMK3+5JC6fgdkt1tgDoZJKlTI/PytLrWN05OFh2zqy9OgEXVxeWHrHWkPk16UXbT4kjW7cMhnQwCH9n/4jq7rKU4hPt9SzF5dEnhgWBuRskT8mj2y9pjYThE04Y/2bFAlCXZV//4LT9wFp2G95/zCz5U2hexq4odt03D+0HC9ievj8+7gLDvFGnZGKhy36NYGKuXiH/chM47hEMdd4tSCUwe3gxS/MxjcvRLcdqZ6SMYzY3jw1D6v88rIIWrm63xOLo2ldYJepmypnd+tyQfIIYD25Q3JJQFRM0CRxBEtoVV+1/w9u43hInVROSoAA==; 5:ahsIyCPMd2DIR29hhI/S/CcoPHZ7MwU/dsxNBm9tV4vCF+twI2IcTBc7vJmErt1HAcuYbVBwl5/f/IeJm4PCuU5vQgF99l5rL5q3O4MHzxvU/7v2ynm4Wc76o75qLlqjnx0lYMSG59B38NomyZi2l24slT80II6tSKZ+R5jrFFc=; 7:UaJz077/Jma1PdjFPQvUAFwvGGP+sn10XulIx9oQ+mYKoekkAhRVAAFsu7KE8ec5BQY7AP5hpOKnxk7icThqnpbWq9pmP8dtHLk3RsOW/vBoLyrCpJssZvSWOBuNJQFiUfgiJZzKPhvUHsPCimXH7KfaMpFqMn7tiDL3apfB/H3+MrYFeeRUKOp2LP8SL8l0uYPxdJfA+Va41penIjXLFeuGrRB1lmfvcoSsas3RELQAEWRFyz2pNSxfERcCEfbc x-ms-office365-filtering-correlation-id: d91f4aac-cc6f-46ea-7ea2-08d62c27d3b1 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:DB5PR05MB1672; x-ms-traffictypediagnostic: DB5PR05MB1672: 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051); SRVR:DB5PR05MB1672; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1672; x-forefront-prvs: 0818724663 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(366004)(346002)(396003)(376002)(189003)(199004)(86362001)(575784001)(478600001)(71190400001)(71200400001)(97736004)(305945005)(6436002)(5660300001)(7736002)(36756003)(53936002)(316002)(68736007)(2900100001)(14454004)(66066001)(256004)(102836004)(26005)(8936002)(2351001)(8676002)(486006)(5250100002)(5640700003)(25786009)(446003)(2501003)(54906003)(81166006)(6512007)(81156014)(476003)(2906002)(186003)(6916009)(11346002)(6506007)(386003)(99286004)(2616005)(50226002)(6116002)(4326008)(76176011)(3846002)(52116002)(6486002)(106356001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1672; 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: kTPvvs08jv5E5EmPfY11xqwmHDxjwsIQci/R09mcflZYNXWCXxG3KE66TBLOUVeL5bjaEY6RJnZ5DgyKXxMf6b4ymWE+2BtXN0YvoSA64mI9tsDZy2Stvv5J1w5BsfGEwodHjJ4OnsECmYywWBEXNyYm+jOHuiqKJTCdgCyjyJ6SST8UtnnfYc6PJ28aEyMMPoyLYnsJ+LDUdSmNCsywYsA2K64+1sV6AAd3MjTwsIfZoCANFL5gRBaVJoOQNYN+y8rik+8QHyslZt/c0yRxW7JwX+Ou4Bpoe57lb18c94cV9BGiE9wqHLN5V6oxo1gS1L2v8Uvh2kMD2xybXvB87COH9IkAxwcW0IRAjMPvLww= 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: d91f4aac-cc6f-46ea-7ea2-08d62c27d3b1 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Oct 2018 07:38:09.1429 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1672 Subject: [dpdk-dev] [PATCH v4 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: Sun, 07 Oct 2018 07:38:11 -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 e56b712..6fa2284 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -148,3 +148,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