From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 14DBEA00C3; Thu, 13 Jan 2022 10:21:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9905740696; Thu, 13 Jan 2022 10:21:33 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2075.outbound.protection.outlook.com [40.107.220.75]) by mails.dpdk.org (Postfix) with ESMTP id EBA1640150; Thu, 13 Jan 2022 10:21:31 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fo4kVVAKBlUwM+XLHOqwMN7LdXe6SWFDSAexuf7DezXIzwO+R3AC2dzEEDuFjX7bAxylSB5McR+LoBi2xmmUTSFTfgyFMWeOvVxxbiIxs19UvWtoZeQRm3N7J++92jRv6lpzljHlrQGGXV8zyv4D9Cpa/UDEMejO6Ax7I9zXj99oTctNQQX2Rre40Z8cpFOh7Oy5Q/vY3NUtvDXMlWCFn4qaAsyJdIG3rWlgzaZJ5SpozX35XSo5N9e8s2Mlg2knLgV7WJb/WNCumyJW4QrxsmmZ9EWIQRn4AMzio8UxcBBXQW47Di6hs+vTQ1cj1sR8VoKWIZmt4mm8Tqje3oqFlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CeclkSkLH94Y9QZ+Gko6QSrbKAsDytFIFwjq1qJjPU4=; b=Zfakcj79MuLvTd9lWzZ0R9qG0eU4QmjLYlc2Ih43CCk+PvfhmDhwa48h8Xgu5xbt+p1PZSmgLX9m7A7PKjyvSBJP73B9uGY3Ap+ss9BJwuxHBRTnVHmlvTpvK3nujSs9LrFhR710hneKgBAGndp5J3Yu1ZyB06arRfrqR2GlwX1PTTRfyWSxVeJJNfuu5xLHUpaoDlZmZFGP6v91oYxMEmhbC9KES15luGTv/aknCJExhtUMczFeSzuGhBFQkfq0vwTvlb8hHyqnxB2Edms0Utv9nqVHm1PjwuL/4TYw2uLnvU3yylrigcO5nCkTI7KVe6lYrDQ8+3mnP66TQakAHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CeclkSkLH94Y9QZ+Gko6QSrbKAsDytFIFwjq1qJjPU4=; b=kt9Otj2HyLcPemK/uUqxXbq8DrqKcTl0oLXUfwxhL4/PECNYlWw2udZzyuxSX+d2ZcdKjoW38/Usvf/9gPPXTm9AWxzUUYWL6TxCef2OSa1r9xqpQyz46cm0afPdQVgB/KgASYdjSeKvGS5GXi7wc+2CvqufSbUMJyKwP589pcyDHtvyz5hdF2lMQPq97TLOF53l+0E0vyrWdeFcKrD3LbDmayfm6Xtf83Lfbflq2fhnw70bWNd4gQurLoNDAS2GZsQXFb76uzrrFKvBFJy9FTDJCWNOnw6DmDgU4Ejf/pnEVpguZTqAYUwaAU6jdopVOogtlr3pBLDmJFEolfjwTg== Received: from BN9P220CA0014.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::19) by DM6PR12MB3819.namprd12.prod.outlook.com (2603:10b6:5:1c6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Thu, 13 Jan 2022 09:21:29 +0000 Received: from BN8NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::72) by BN9P220CA0014.outlook.office365.com (2603:10b6:408:13e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11 via Frontend Transport; Thu, 13 Jan 2022 09:21:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by BN8NAM11FT018.mail.protection.outlook.com (10.13.176.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4888.9 via Frontend Transport; Thu, 13 Jan 2022 09:21:29 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 13 Jan 2022 09:21:28 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.9; Thu, 13 Jan 2022 01:21:25 -0800 From: Dmitry Kozlyuk To: CC: Xiaoyun Li , Aman Singh , Yuying Zhang , , , Raslan Darawsheh Subject: [PATCH] app/testpmd: skip stopped queues when forwarding Date: Thu, 13 Jan 2022 11:21:03 +0200 Message-ID: <20220113092103.282538-1-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb3b6ed9-68e9-4402-7431-08d9d67614f6 X-MS-TrafficTypeDiagnostic: DM6PR12MB3819:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TGSxDT8HyXErKhbgctfViwzt0oPHNP58LIPiI+oYdi1CfM8kJ86QJ2PDIA8G5Jdb29MMTOVXSS8RD7np3CBoKzMCN+YuRfI4rlOVxvhIxNfJnaH4xNh7Y6BfCGt6lT0YXfTz1w7uylW0jwiqDtATWRW9Ua8mK2FzRii4mJ77R71Jbn4nCUcdCGQBFpVGc7Ua5Uz14OnoZQtKxzeKjkOO81Vz9WKo1Gi2HZxkAfU3t+gMtsY0Cuw2A3yEydXJg+QfbtfcoBELaMq604HcWxdo43bfflX6/7jnrq8crR/bbaf0pmLuT+1Q9wTohwR75dc0COTrrfssKAb7jZQGvZoyls877xIIaKLvJuElBwNxYLZoPVE141NKQpcgJFTVg4fRfGePFqDD96IzgFyCs7a6AufFEAkQc1LpzHavX+HdANjdTawM+c6s2a43z2paJJWJ9+6I+2qqALzTP6bfLhvsQ7TevRi3Qr+uvXagfh8VaH92KVPb87Qc15dPso40h3kKC8TdNGxVAFBnf8ACKE5OFTs5GsO5QMI9Mxm0hsKYkTOHKGmaGr3TxGshvMKZSaCGu/V5CcDnLRG9c4t4hrpQatR3joks9mekXKGJ/EcgTSlIvLYArTbu/YaBhqJbpOe/wf6C6pIAjmL+V2N9wwgv/zSHtXtKHQkyBHdKfUsQEuzq1iyy92rJRnGb9UIBdTxIVJOBEsUq6Tkl76syCeoqJy4R4ein7TJ6nHXe3OyEk0ZeXKottNlE7gm8J3siWgkK+4D/l1rUic5tamA2WaOIPv7NYT3Er7yL3pPwyzyVBcU= X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(40470700002)(36840700001)(46966006)(54906003)(2906002)(81166007)(70206006)(8936002)(70586007)(5660300002)(426003)(16526019)(6286002)(4326008)(186003)(508600001)(336012)(6916009)(26005)(7696005)(107886003)(6666004)(316002)(356005)(8676002)(47076005)(36756003)(2616005)(55016003)(86362001)(82310400004)(40460700001)(36860700001)(83380400001)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 09:21:29.4098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb3b6ed9-68e9-4402-7431-08d9d67614f6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3819 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org After "port rxq|txq stop" the stopped queue was used in forwarding nonetheless, which may cause undefined behavior in the PMD. Record the configured queue state and account for it when launching forwarding as follows: +--------+---------+-----------------+---------------+ |RxQ |TxQ |Configured mode |Launch routine | +--------+---------+-----------------+---------------+ |stopped |stopped |* |- | |stopped |started |txonly |(configured) | |stopped |started |* |- | |started |stopped |* |rxonly | |started |started |* |(configured) | +--------+---------+-----------------+---------------+ Display stopped queues on "show port config rxtx". Fixes: 5f4ec54f1d16 ("testpmd: queue start and stop") Cc: jing.d.chen@intel.com Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Reviewed-by: Raslan Darawsheh --- app/test-pmd/cmdline.c | 8 ++++++++ app/test-pmd/config.c | 6 ++++++ app/test-pmd/testpmd.c | 18 ++++++++++++++++-- app/test-pmd/testpmd.h | 10 ++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index e626b1c7d9..8b0920e23d 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2702,6 +2702,14 @@ cmd_config_rxtx_queue_parsed(void *parsed_result, if (ret == -ENOTSUP) fprintf(stderr, "Function not supported in PMD\n"); + if (ret == 0) { + struct rte_port *port; + struct queue_state *states; + + port = &ports[res->portid]; + states = isrx ? port->rxq_state : port->txq_state; + states[res->qid].stopped = !isstart; + } } cmdline_parse_token_string_t cmd_config_rxtx_queue_port = diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 1722d6c8f8..7ce9cb483a 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2817,6 +2817,9 @@ rxtx_config_display(void) rx_conf->share_qid); printf("\n"); } + for (qid = 0; qid < nb_rxq; qid++) + if (ports[pid].rxq_state[qid].stopped) + printf(" RX queue %d is stopped\n", qid); /* per tx queue config only for first queue to be less verbose */ for (qid = 0; qid < 1; qid++) { @@ -2850,6 +2853,9 @@ rxtx_config_display(void) printf(" TX offloads=0x%"PRIx64" - TX RS bit threshold=%d\n", offloads_tmp, tx_rs_thresh_tmp); } + for (qid = 0; qid < nb_txq; qid++) + if (ports[pid].txq_state[qid].stopped) + printf(" TX queue %d is stopped\n", qid); } } diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 6c387bde84..36ff845181 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2152,6 +2152,8 @@ flush_fwd_rx_queues(void) for (rxp = 0; rxp < cur_fwd_config.nb_fwd_ports; rxp++) { for (rxq = 0; rxq < nb_rxq; rxq++) { port_id = fwd_ports_ids[rxp]; + if (ports[port_id].rxq_state[rxq].stopped) + continue; /** * testpmd can stuck in the below do while loop * if rte_eth_rx_burst() always returns nonzero @@ -2223,8 +2225,20 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) static int start_pkt_forward_on_core(void *fwd_arg) { - run_pkt_fwd_on_lcore((struct fwd_lcore *) fwd_arg, - cur_fwd_config.fwd_eng->packet_fwd); + struct fwd_lcore *fc = fwd_arg; + struct fwd_stream *fsm = fwd_streams[fc->stream_idx]; + struct queue_state *rxq = &ports[fsm->rx_port].rxq_state[fsm->rx_queue]; + struct queue_state *txq = &ports[fsm->tx_port].txq_state[fsm->tx_queue]; + struct fwd_engine *fwd_engine = cur_fwd_config.fwd_eng; + packet_fwd_t packet_fwd; + + /* Check if there will ever be any packets to send. */ + if (rxq->stopped && (txq->stopped || fwd_engine != &tx_only_engine)) + return 0; + /* Force rxonly mode if RxQ is started, but TxQ is stopped. */ + packet_fwd = !rxq->stopped && txq->stopped ? rx_only_engine.packet_fwd + : fwd_engine->packet_fwd; + run_pkt_fwd_on_lcore(fc, packet_fwd); return 0; } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 2149ecd93a..2744fa4d76 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -216,6 +216,12 @@ struct xstat_display_info { bool allocated; }; +/** Application state of a queue. */ +struct queue_state { + /** The queue is stopped and should not be used. */ + bool stopped; +}; + /** * The data structure associated with each port. */ @@ -256,6 +262,10 @@ struct rte_port { uint64_t mbuf_dynf; const struct rte_eth_rxtx_callback *tx_set_dynf_cb[RTE_MAX_QUEUES_PER_PORT+1]; struct xstat_display_info xstats_info; + /** Per-Rx-queue state. */ + struct queue_state rxq_state[RTE_MAX_QUEUES_PER_PORT]; + /** Per-Tx-queue state. */ + struct queue_state txq_state[RTE_MAX_QUEUES_PER_PORT]; }; /** -- 2.25.1