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 B182EA0C4B; Thu, 21 Oct 2021 07:10:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAF7541184; Thu, 21 Oct 2021 07:10:05 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) by mails.dpdk.org (Postfix) with ESMTP id 0FDDE4117A for ; Thu, 21 Oct 2021 07:10:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l0jvxbKc7bWjKp5lpWXpLRY8Ze20XnlYKaWe3jSlFS5JOUTwXkMPl4AqJ0zghZYorEZhWw6uw19QJOS493u1CnHfhbDMhS8jKovNgH12vqjvy03hJemgxuoprYi0HBYuqfnj8F33qHtZ642WlRF8ar5By+8PXpx5iELNP7DffVzQyr7Jza18vRheH8DnIjLgadmB2HJZQOtqblNJicOukUPKlvHVyJsGjRvt5bdFQm8e2VrzSe4NVVfiN+oC6MhwFnaJuUsCOVg+OtZbZXntVjiepzEpfG4fhHUemUFuHYp3kb4+AywNpfcZN99ZDCoqFcInbTxv/rln9LGjSCx1Bg== 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=eahzqfP2YPjjfwKoJsmSVuxbm0iuD6nwhw9/3M8qDNA=; b=WNuNeO2cmpL2J5Dny0TJoL8AGUAxln9rCoxfeAObU+WDQxCmk+KE+vnMuJ+3V++ZLw6eofTox83jF93fkH446tbhFUlcYIlijMZlf4lAOPjRQwlbcwAVK1BgRzVlSDTZvi5Z9kr6ldr5dwVWlLvEvBCeM8tNlr9HAA21BKQXOrPMz0Ayq4qBjwxZ553iOhTjFfebgYIMQUGvBgyCJJG964fchJxMXzSvbsAU3X5948LYZbs6Qbju1R2lSXv0kReVp39C3xV0m5cktuNrx74Fmw0V5NOoAE9DZxzIpgyl1v1vwYWDGclaiNN4Re8ZO9I19o+LuYq4YwZEqV4qyk+ZEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=eahzqfP2YPjjfwKoJsmSVuxbm0iuD6nwhw9/3M8qDNA=; b=HCc4rD9fztbQoEZjSNT7t/vBoZNKFrjrqCsbCqOz95yIFJlEAgsomRcihR8K2zivVTtR0bmmKJuQTxXp8zsAwGZ4VrK/vfQ2QpptqeSWsJVnmpNwHni42kXfQK4zd55uQtmYvA/Gv+5yhZx68RF+C4znrX2sebdgq58wrDtpVfceiqmc54jPrtaYdWhp0puybywGvRu+uw+nzdnTGBNtk2nu2UyvDmgYWg5eIt7zdRjC9g/IB8NXWOnOXv1qCIVo8FF3FDgC9pKVuanFZgG8EqaUAEjbXLvLFBVDJuvrZ6JqYLumsia8LVUcgkrYRkYxsE9Bg7y9yrIiRTFdnwPRJw== Received: from DM6PR06CA0037.namprd06.prod.outlook.com (2603:10b6:5:54::14) by BY5PR12MB3745.namprd12.prod.outlook.com (2603:10b6:a03:1ae::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Thu, 21 Oct 2021 05:10:00 +0000 Received: from DM6NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::39) by DM6PR06CA0037.outlook.office365.com (2603:10b6:5:54::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Thu, 21 Oct 2021 05:10:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT011.mail.protection.outlook.com (10.13.172.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 05:09:59 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 21 Oct 2021 05:09:53 +0000 From: Xueming Li To: , Zhang Yuying , Li Xiaoyun CC: , Jerin Jacob , Ferruh Yigit , Andrew Rybchenko , Viacheslav Ovsiienko , Thomas Monjalon , Lior Margalit , "Ananyev Konstantin" , Ajit Khaparde Date: Thu, 21 Oct 2021 13:08:32 +0800 Message-ID: <20211021050832.2599691-8-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211021050832.2599691-1-xuemingl@nvidia.com> References: <20210727034204.20649-1-xuemingl@nvidia.com> <20211021050832.2599691-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f664eb9-3c49-4013-6438-08d994510807 X-MS-TrafficTypeDiagnostic: BY5PR12MB3745: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ohukgriJSO1U+WcWLuzuib5fzu966/iqdZhjxibGN6QAqE7xuP9hJyoyQZgkPcSuNh3tZRYIMUI6+DTJZwOc0tGCgAQqDSA1oD9pnh0Z+USacnpwZXOVLF9CCQnP9/7FqGZ/L3bOInTHUL/760j4G/N7TbnyHTdI7Xqij8B2ENPqLmw1+ixVoLVquL6WU6MdVeCGjPsicqRwlTwDEAKoSw9P5RJB2gpTwWV7PeAwiHt/pqSKY7L+T4RLmXK4wit1CMy8KcOYxliHkP5jtuFvaQHNAapY7Ts3JW4hDVsGI2XjFOHdTapG7f7O5YPD6g0RmG5128HWfXjBW0bORQCLyPaVKWvpex7PfncBZ+rEpr0J3vFccU+2ugE18YNKBJWq7XZ3bXp82/lxvnjK1qJrcG2EyKgrgdIokPeL8wEaxdmTzGioaCa2ra+iqAjFJx7CFunYUrxhrfZVw7sfEo3CZ7tXK7MNxRUZrhTOv+2Q9Fe0V+7cuUK0m2f66xECGU0QSy725M2O+FSE5OLmps4R5sz8Goj/nQsV3irK9E4UpeDkoIrMbuvet540ODKDGLdsUioy1am2uj5ZAEnDg4qxhjX3eCEFkb86J3CGIO2hkwPpFwshaEfG9nwYfkJM7cFWQiRNgf4KaV3iS11DvZLonNzXD3vSlcvPne0Zaclt4tf4xz3Q+WWGjwKvNUZTIX2dcoHKuQdouCYFvZIGoEug+g== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(70206006)(356005)(6666004)(8936002)(7636003)(508600001)(70586007)(55016002)(2616005)(8676002)(5660300002)(336012)(186003)(83380400001)(16526019)(6286002)(4326008)(47076005)(316002)(7696005)(26005)(426003)(110136005)(2906002)(36756003)(54906003)(1076003)(36860700001)(86362001)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 05:09:59.2033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f664eb9-3c49-4013-6438-08d994510807 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3745 Subject: [dpdk-dev] [PATCH v12 7/7] app/testpmd: add forwarding engine for shared Rx queue 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 Sender: "dev" To support shared Rx queue, this patch introduces dedicate forwarding engine. The engine groups received packets by mbuf->port into sub-group, updates stream statistics and simply frees packets. Signed-off-by: Xueming Li Acked-by: Xiaoyun Li Acked-by: Ajit Khaparde --- app/test-pmd/meson.build | 1 + app/test-pmd/shared_rxq_fwd.c | 113 ++++++++++++++++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 5 + doc/guides/testpmd_app_ug/run_app.rst | 5 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 6 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 app/test-pmd/shared_rxq_fwd.c diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build index 1ad54caef2c..b5a0f7b6209 100644 --- a/app/test-pmd/meson.build +++ b/app/test-pmd/meson.build @@ -22,6 +22,7 @@ sources = files( 'noisy_vnf.c', 'parameters.c', 'rxonly.c', + 'shared_rxq_fwd.c', 'testpmd.c', 'txonly.c', 'util.c', diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c new file mode 100644 index 00000000000..c4684893674 --- /dev/null +++ b/app/test-pmd/shared_rxq_fwd.c @@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2021 NVIDIA Corporation & Affiliates + */ + +#include "testpmd.h" + +/* + * Rx only sub-burst forwarding. + */ +static void +forward_rx_only(uint16_t nb_rx, struct rte_mbuf **pkts_burst) +{ + rte_pktmbuf_free_bulk(pkts_burst, nb_rx); +} + +/** + * Get packet source stream by source port and queue. + * All streams of same shared Rx queue locates on same core. + */ +static struct fwd_stream * +forward_stream_get(struct fwd_stream *fs, uint16_t port) +{ + streamid_t sm_id; + struct fwd_lcore *fc; + struct fwd_stream **fsm; + streamid_t nb_fs; + + fc = fs->lcore; + fsm = &fwd_streams[fc->stream_idx]; + nb_fs = fc->stream_nb; + for (sm_id = 0; sm_id < nb_fs; sm_id++) { + if (fsm[sm_id]->rx_port == port && + fsm[sm_id]->rx_queue == fs->rx_queue) + return fsm[sm_id]; + } + return NULL; +} + +/** + * Forward packet by source port and queue. + */ +static void +forward_sub_burst(struct fwd_stream *src_fs, uint16_t port, uint16_t nb_rx, + struct rte_mbuf **pkts) +{ + struct fwd_stream *fs = forward_stream_get(src_fs, port); + + if (fs != NULL) { + fs->rx_packets += nb_rx; + forward_rx_only(nb_rx, pkts); + } else { + /* Source stream not found, drop all packets. */ + src_fs->fwd_dropped += nb_rx; + while (nb_rx > 0) + rte_pktmbuf_free(pkts[--nb_rx]); + } +} + +/** + * Forward packets from shared Rx queue. + * + * Source port of packets are identified by mbuf->port. + */ +static void +forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx, + struct rte_mbuf **pkts_burst) +{ + uint16_t i, nb_sub_burst, port, last_port; + + nb_sub_burst = 0; + last_port = pkts_burst[0]->port; + /* Locate sub-burst according to mbuf->port. */ + for (i = 0; i < nb_rx - 1; ++i) { + rte_prefetch0(pkts_burst[i + 1]); + port = pkts_burst[i]->port; + if (i > 0 && last_port != port) { + /* Forward packets with same source port. */ + forward_sub_burst(fs, last_port, nb_sub_burst, + &pkts_burst[i - nb_sub_burst]); + nb_sub_burst = 0; + last_port = port; + } + nb_sub_burst++; + } + /* Last sub-burst. */ + nb_sub_burst++; + forward_sub_burst(fs, last_port, nb_sub_burst, + &pkts_burst[nb_rx - nb_sub_burst]); +} + +static void +shared_rxq_fwd(struct fwd_stream *fs) +{ + struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; + uint16_t nb_rx; + uint64_t start_tsc = 0; + + get_start_cycles(&start_tsc); + nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, + nb_pkt_per_burst); + inc_rx_burst_stats(fs, nb_rx); + if (unlikely(nb_rx == 0)) + return; + forward_shared_rxq(fs, nb_rx, pkts_burst); + get_end_cycles(fs, start_tsc); +} + +struct fwd_engine shared_rxq_engine = { + .fwd_mode_name = "shared_rxq", + .port_fwd_begin = NULL, + .port_fwd_end = NULL, + .packet_fwd = shared_rxq_fwd, +}; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d76d298a4b9..6d5bbc82404 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -188,6 +188,7 @@ struct fwd_engine * fwd_engines[] = { #ifdef RTE_LIBRTE_IEEE1588 &ieee1588_fwd_engine, #endif + &shared_rxq_engine, NULL, }; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 9482dab3071..ef7a6199313 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -12,6 +12,10 @@ #include #include #include +#include +#include +#include + #include #include #ifdef RTE_HAS_JANSSON @@ -339,6 +343,7 @@ extern struct fwd_engine five_tuple_swap_fwd_engine; #ifdef RTE_LIBRTE_IEEE1588 extern struct fwd_engine ieee1588_fwd_engine; #endif +extern struct fwd_engine shared_rxq_engine; extern struct fwd_engine * fwd_engines[]; /**< NULL terminated array. */ extern cmdline_parse_inst_t cmd_set_raw; diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index faa3efb902c..74412bb82ca 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -258,6 +258,7 @@ The command line options are: tm noisy 5tswap + shared-rxq * ``--rss-ip`` @@ -399,7 +400,9 @@ The command line options are: Create queues in shared Rx queue mode if device supports. Shared Rx queues are grouped per X ports. X defaults to UINT32_MAX, - implies all ports join share group 1. + implies all ports join share group 1. A new forwarding engine + "shared-rxq" should be used for shared Rx queues. This engine does + Rx only and update stream statistics accordingly. * ``--eth-link-speed`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 6d127d9a7bc..78d23429c42 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -314,7 +314,7 @@ set fwd Set the packet forwarding mode:: testpmd> set fwd (io|mac|macswap|flowgen| \ - rxonly|txonly|csum|icmpecho|noisy|5tswap) (""|retry) + rxonly|txonly|csum|icmpecho|noisy|5tswap|shared-rxq) (""|retry) ``retry`` can be specified for forwarding engines except ``rx_only``. @@ -357,6 +357,9 @@ The available information categories are: L4 swaps the source port and destination port of transport layer (TCP and UDP). +* ``shared-rxq``: Receive only for shared Rx queue. + Resolve packet source port from mbuf and update stream statistics accordingly. + Example:: testpmd> set fwd rxonly -- 2.33.0