From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30080.outbound.protection.outlook.com [40.107.3.80]) by dpdk.org (Postfix) with ESMTP id 52E624C8B for ; Mon, 24 Sep 2018 14:49:08 +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=ogHxNYgIvOyAFElCX0PNQv9D/SBZ0/wq+vPvrCrh5Q0=; b=fKCHM9IA+OG3biDlTmYeoFMN9SdjiZMcDSLq1cPsfeNpAXnhFeIAUmzP2mOacA7iH1T9rDEmhnrF/es8T7Dm9zmt5tRqqpqFVZfbSM3pLugumeafUbsNXZKX0ExvKTYfSBimWhwuEfZkILucL7jGlS/biXZXF99RTB2XIHx3/XQ= Received: from DB5PR05MB1254.eurprd05.prod.outlook.com (10.162.157.140) by DB5PR05MB1205.eurprd05.prod.outlook.com (10.161.244.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Mon, 24 Sep 2018 12:49:05 +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.1164.017; Mon, 24 Sep 2018 12:49:05 +0000 From: Raslan Darawsheh To: "jingjing.wu@intel.com" CC: Thomas Monjalon , "dev@dpdk.org" , Shahaf Shuler , Raslan Darawsheh , "Xueming(Steven) Li" , Ori Katz , "jerin.jacob@caviumnetworks.com" , "david.marchand@6wind.com" Thread-Topic: [PATCH v2 2/3] app/testpmd: add packet dump callback functions Thread-Index: AQHUVAT68boOsol2NEekHP/d+J2RqA== Date: Mon, 24 Sep 2018 12:49:05 +0000 Message-ID: <1537793304-27883-2-git-send-email-rasland@mellanox.com> References: <1536739583-29166-2-git-send-email-rasland@mellanox.com> <1537793304-27883-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1537793304-27883-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: VI1PR04CA0105.eurprd04.prod.outlook.com (2603:10a6:803:64::40) 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; DB5PR05MB1205; 6:s+E5pN2CEv5LrRqVq9R9ABaDPvNHYLBgnY6i9ZrDW+K+nupcU+uELGZ5/kFTxOMFFaRCQ2HAfS3Ql2g0dNTKpFNgpOp92DKmmZO0R3QIZJ+qCnxX70OoWk7rzMt6gtXoyBBhCG1YvUuGl5MSf1N01E+LFOQh5oWc4ySeD+10pG52GLokfreRaQxpVVpJNddtAsurWIgkujuMu8eJ5LQldcXisbeqZxj7ZwfqhfxMdsVBk8sgkB2qEP5IEtiJOtl/b4lNqhTm3HrBxNSmw88n/qtMu9W8YbfK0OMNX5sgEjbWEp1dzTHrqnjBOTe6xnKBspkBPLVhJyR4tGBPNbgK4lLFhmZ8O1OE+68GVQATE/O8uE1bGNf5TPXKoTaKDmUEAGXMlzS2oV249QYulM11g4+QHuJkls4bZGtSkAt5Bg6YexPAg5cp9CYjW1AnrdPdu9Tquv3KG/RkEqRz2/6pSw==; 5:x0mSOC1+LzaLlW+j6PkP9XWOGxT7tZCGVgop1InujRfUaEzO7Tzz0VoKMtosCcQdX6cQnHeJLxGEpmm7Xuo1rsjwa00DrXjxOaYur/XIbos2xyZZoyrqyJEHTXawTqX4C0tlXYfSbvkNkxWUjmUMWUED/0yZnP8xYu9PdmyL0B0=; 7:hqC4U8zsVqh2GFJAVSzEzvRMBSGw5NogM1oV01gQs5tJXkicSW4i+J5uDoLQxJRpRLPVWQz/9BHQV7lb1qAbhKUijgcqiXDVVWpbeIJjtRO7ib1zsikpYPK2cgIDcnBZb3vPMcoAxK6f9VikY9gGdEfP+0C+Q8QbEVvCwvvXJbQi3ypeOyiXlZtqrefnDDm2fcMaNom4bxqI4p/W5JR0ZisGlp6wuYN1otrJDVEwDLHOmAe1yWmN9SR6QAuxXDwR x-ms-office365-filtering-correlation-id: 7aadbf3c-951d-436e-219f-08d6221c1c47 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB5PR05MB1205; x-ms-traffictypediagnostic: DB5PR05MB1205: 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)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051); SRVR:DB5PR05MB1205; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1205; x-forefront-prvs: 0805EC9467 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(346002)(136003)(376002)(199004)(189003)(2900100001)(71190400001)(386003)(6506007)(2351001)(102836004)(8936002)(36756003)(6486002)(478600001)(68736007)(6116002)(3846002)(5250100002)(2906002)(81166006)(81156014)(8676002)(25786009)(106356001)(53936002)(26005)(316002)(186003)(5640700003)(99286004)(86362001)(4326008)(52116002)(14454004)(105586002)(305945005)(6436002)(54906003)(11346002)(575784001)(476003)(7736002)(97736004)(446003)(256004)(2616005)(486006)(6512007)(71200400001)(50226002)(6916009)(66066001)(5660300001)(2501003)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1205; H:DB5PR05MB1254.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: erN90zUe6Sbyoir+9Jt3apSowLBhUsv65uhr0p5ouO5kTCZd5wPovE87Sf4SlHOsCW3gy+2v4iPX9NecYn6l6cjUXqljMMFwoGsEOYkJElkeu7Pls2ZpxwV+qEPG7YvDzXn6gkDypJobyduRnYzRbe5WejVb6CwLNRosKO4dCE1l8LaE/oDojpIuMRG9RoEoDz3LRzYPbtdvnUvLooXQKWluwd99866pdt60vPzBhOs12KPeHBx0hP/WiyYn/AD/N1/hLoYOnNw++Q96JHEYaOlBOnAYi7CdAV4bufjVZHUqyfzebayeFEMl9c91IPWJhyjulBOBqZi2ibDQW/MfxL39ZS5vZMc/tk5aiaPt1Hg= 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: 7aadbf3c-951d-436e-219f-08d6221c1c47 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2018 12:49:05.5544 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1205 Subject: [dpdk-dev] [PATCH v2 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: Mon, 24 Sep 2018 12:49:08 -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 97c8349..9a40ec7 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -142,3 +142,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