From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60083.outbound.protection.outlook.com [40.107.6.83]) by dpdk.org (Postfix) with ESMTP id 3F9D0559A for ; Wed, 17 Oct 2018 17:22:24 +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=tyuZfTT6JQ44K7gSmFG7OdLLQT1LOsmohYnkUUiGcMw=; b=fyNxqjsi9CLSTfK1y9H+VRRkFY23AOlrKO5T4Ar5Vp7jyFMi4IMjFU3499aoccwYL1eJn4HKAH0FYgGmF91YYd73djWznGEEDBPfq8TjQF3U4F7bGWnEMRutJqZMSw9B05TnTWpM3x5IES7di3rnOeIp5tGShIMl2qzMu4AQ3Gs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR05MB1257.eurprd05.prod.outlook.com (2a01:111:e400:5889::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.21; Wed, 17 Oct 2018 15:22:22 +0000 From: Raslan Darawsheh To: jingjing.wu@intel.com Cc: thomas@monjalon.net, dev@dpdk.org, shahafs@mellanox.com, rasland@mellanox.com, xuemingl@mellanox.com, orika@mellanox.com, jerin.jacob@caviumnetworks.com, david.marchand@6wind.com, bernard.iremonger@intel.com, ferruh.yigit@intel.com Date: Wed, 17 Oct 2018 18:22:10 +0300 Message-Id: <1539789731-18409-2-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539789731-18409-1-git-send-email-rasland@mellanox.com> References: <1538897848-1693-1-git-send-email-rasland@mellanox.com> <1539789731-18409-1-git-send-email-rasland@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: LO2P265CA0158.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::26) To HE1PR05MB1257.eurprd05.prod.outlook.com (2a01:111:e400:5889::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c931d3c9-4aa8-41e4-40cb-08d634445686 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:HE1PR05MB1257; X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1257; 3:fA9CEgoM4A1FfdYLKAHd/KGZRA2WPL0SIJjOwi9qo71Hpp0OQyqERUaPjFXRfMXAuIJzKbohY9sqyKZSaHxZDz9PjPC+bi5zRx88RIYMHKyrgouOawkUtgV+HL/z4lx7P8fevyDZClAc4wq51pxumyIyuhC03sNf2yg+LAERYDBiiebzmsInNvi68ipwVFM9qpc6aFZW6zPDFRspIvDpJqgcTKXcHNXuH8Hqo6CjnS7WFMfDVtm4MB/iIQOWNoFR; 25:YvegzgDrb9yEDSAJxNwg90/oyCg7oznPZrdWFg9bv0sOxNw0qFUz5R1C89ggrTqBci4sZn+wG1LOZVyJOg7p05EKkUNLvS/dxA1ADFRwy1HRDTQ1E6PBDLwu3Ff3tn6YNQwDaA5wU0rdd9XYluWbnm9OVqz00SanKoJsW9iw349BrJvqA3mVY2L9RNca/7yG8SzuQimGT9zycan+w1jNGfKFqki0Pap6jez5ahCLoqeyOiY+h031+GD3XvHilyL5YAvVWAhEuc2vGvhIPXwatT0Y/dLhV9fptLkUh1pzhLgjYR+WhCVUhqydKKSPJQMBSmdtgitrHrsSd9bISZ2w6Pqd8loNfSxa+eV0h8bn1Lo=; 31:NaZlVjN533jtht8BQpv415tfq45xOCrfrB0jZwuYt5THj/o6+4EEZvb/UXjSqTLwGM1ZREdywHyX6x2KnO3lY27vhNgz/BPZDwgi+Xkb8IiP/XQAiMxxSLeJSNrBhG0BzwYCbj9c5Q70odRhTQhx+Zz+zezul8bcps+UUDwWW9rI2OT45AD0jqEuJDOpNiXO/c+cH3o//5E3GitIs0FMSb4ZcOmlT+nthgVeirvgtsA= X-MS-TrafficTypeDiagnostic: HE1PR05MB1257: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1257; 20:MnJARV5z2ryzb1fyCNyHtuse7vjfau8PDFEG+4ounqrqxjC8+/f8NlTjR9ACOTaI/REayGLY39IJWD/BMd0cPmxA66SRIAqdvMTWO5SswBO/P/1t0AcIW8sElmA/59nftF3YPI3L+XPE56kXmWJnFs8TrWG7vC/T9JFxTpLYt8oGZoMQN4b8UEQVqTCF0tEijkAkBFRMe/YKzqBTa8jYis/3vgwYZJKtuANA88Nktn7Ud35XF34IbqEnUrAYZzfZ760zmuymx5kNB7s9RLyCP99JuX4CPiuAE13C6KdaUgF1sIn4jFdx0pz96G1CQ8AkSbm/RsXs5IjRiKwk/PKZTCT51lRkHiqVEuOKbe8Q9fLO5MinhU0DIDOB/YCjFioh0baAgytZOanYakQn2JXa9cKNHaA9NkztDxQ9E16xd/UFsc2XJV6MxtJRfczRwSJFu7m3x/Stgf6uS1lF9/SHdF5yEy7sd3Z6rcSzNqPFd1E//F1IzPwXbsEphNmFmPgw; 4:hfcVZZ8fHabdYrraP2WZeFHfGRoBqfUsTeqcRxRVKveLqc3tXEgA4bnD0sjA+jC9UZvpst40uKyu/dKBjWY6VYkV6epA9aIRF/kN/HL1MgpM7xhB4u/Xh2Vhe/+yNjA0T9lVsRZAvG1lstu0FoiHMPfjHbQNximUUri86gvncN5+m9sEusyFctzhjwPY9o1qJWRz1/YdpcKyr0L7ObKQjnS/6KNsGOGdMFsbDmQmbFRR7+SQzrPHjrY7qs99BLbu0ZopenKBkRWPsoLVkegf2Af77VXh9yU3kpIzI9JvFJNQPBKQcj4oRC1WOj/MK77t X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231355)(944501410)(52105095)(3002001)(6055026)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:HE1PR05MB1257; BCL:0; PCL:0; RULEID:; SRVR:HE1PR05MB1257; X-Forefront-PRVS: 08286A0BE2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(366004)(376002)(346002)(136003)(189003)(199004)(53936002)(47776003)(3846002)(8886007)(97736004)(55016002)(4326008)(316002)(16586007)(2361001)(66066001)(305945005)(33026002)(446003)(6116002)(11346002)(956004)(2906002)(50466002)(476003)(7736002)(486006)(21086003)(2616005)(36756003)(50226002)(51416003)(69596002)(48376002)(478600001)(5660300001)(386003)(86362001)(2351001)(52116002)(7696005)(68736007)(76176011)(186003)(25786009)(8676002)(81166006)(16526019)(81156014)(106356001)(105586002)(26005)(6916009)(6666004)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR05MB1257; H:mellanox.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-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR05MB1257; 23:I1Zp81fX7PUheeKkf12lKsN9giMHOqdnsTXvCbTKa?= =?us-ascii?Q?snWMlHNqTapMuPhzhkS0hpUqi+GGwRW3rZoTzo0A2WqV49KGoHTTteRuD4K0?= =?us-ascii?Q?M6fiTA3xwH3UetwKHReUi3qJsnOzEJAbDZ33eYLjZYJH6Idj6pCp9FG2QfyZ?= =?us-ascii?Q?BO5JG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yPqYd91qtfSIVZJeo2Zki0sqBj8jpiji03Won4LORGTlaJ+nIS1hDRp3x51V3/MrYzBIDB5KpGmSiW+TRPzr5AeLFC+z7POqsR01G/Lg==; 5:ihrONyziHFH79y7Pb93dL915MZnodoS1z4q7IsB71rGaaqxedfDNf41UaupsKRXoP7rqPZZBIi7scm83oUT3kU+W0g71se/AIcekmlGfVO/ZjzPeNXpOyGwcKxIeZZixdrRzExwxgiZFAQV7L/BEbhAQ/z0z5hhpN8c29kf0cCY=; 7:9R1nEH2xcrvnZ6/iTveg4vK8gYQCnNxV0kjwgqK6Pp86dmVWsZ6s5c6Giek138EZjifHFqpKIskyWuNYYm3ws7tuMIm5+FtDyLhKi9apho3dshgAyeinB70qNxyVUg4GMRbOBf7htDUi62/Txhp8O/QNpIWZD6iEVkfieSpLR6O5LhZPh3vlzRIsmzntvuL8gbPyikVIEoUtuAdClrCs8BAbPNZm5ugJha65aSM3qAvtuksJgnikusSHhbRht/XX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2018 15:22:22.0091 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c931d3c9-4aa8-41e4-40cb-08d634445686 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB1257 Subject: [dpdk-dev] [PATCH v6 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, 17 Oct 2018 15:22:24 -0000 add new rx/tx callback functions to be used for dumping the packets. Signed-off-by: Raslan Darawsheh Acked-by: Bernard Iremonger --- changes in v6: rebase the work on top of the fix for compilation --- --- app/test-pmd/config.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/rxonly.c | 4 --- app/test-pmd/testpmd.h | 15 +++++++++-- app/test-pmd/util.c | 19 +++++++++++++- 4 files changed, 98 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a6db5df..55fec7f 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2706,6 +2706,73 @@ set_pkt_forwarding_mode(const char *fwd_mode_name) } 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 = 0; queue < dev_info.nb_rx_queues; queue++) + if (!ports[portid].rx_dump_cb[queue]) + ports[portid].rx_dump_cb[queue] = + 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 = 0; queue < dev_info.nb_tx_queues; queue++) + if (!ports[portid].tx_dump_cb[queue]) + ports[portid].tx_dump_cb[queue] = + 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 = 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] = 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 = 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] = NULL; + } +} + +void set_verbose_level(uint16_t vb_level) { printf("Change verbose level from %u to %u\n", diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 3eca89c..5c65fc4 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -70,10 +70,6 @@ pkt_burst_receive(struct fwd_stream *fs) fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; #endif fs->rx_packets += nb_rx; - - /* - * Dump each received packet if verbose_level > 0. - */ for (i = 0; i < nb_rx; i++) rte_pktmbuf_free(pkts_burst[i]); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index cba9640..c07bee8 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -191,6 +191,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 @@ -764,8 +766,17 @@ int check_nb_rxq(queueid_t rxq); queueid_t get_allowed_max_nb_txq(portid_t *pid); int check_nb_txq(queueid_t txq); -void dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], - uint16_t nb_pkts, int is_rx); +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); + +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); + +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 diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index 3ba3b58..f4125df 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -21,7 +21,7 @@ print_ether_addr(const char *what, struct ether_addr *eth_addr) printf("%s%s", what, buf); } -void +static inline void dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], uint16_t nb_pkts, int is_rx) { @@ -149,3 +149,20 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct 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; +} -- 2.7.4