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 1C3DBA0C41; Thu, 30 Sep 2021 16:57:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 699AF4113A; Thu, 30 Sep 2021 16:57:32 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2046.outbound.protection.outlook.com [40.107.100.46]) by mails.dpdk.org (Postfix) with ESMTP id 9F777410E5 for ; Thu, 30 Sep 2021 16:57:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cSB5Qx7FRhFexrCW9fzDok6Ru8L6JdvYYPju3Ml0NO5c1dpyhSb2dSPqMJ6H+UOLGNusmZfxXRH8oSv7sls+eZ6WhzcIpx6eb+ewwF+yO4SlUWz+YB1qe7JyYc0xMAy/8iis2HAFusYmkfxEccVmmQoWmQvqA+ctgjo4COiSArUDHmwaoI50Bdu1j/HesSrgHYD/gQKpVjj+eWWG2J2/qV0lcyXtZwADfK9Gw8AL0/gRPcgGGb6RrRz7ERVTGDOHf6DGJeTPyGyR0tca/I2a/UF/Iuw8BjZv0kI8EtZ++JybhM9EtRusM/dzgFrT5Sy4SBSMVLMdGrDlILfVOwQeOg== 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; bh=NzlJXDYllOj/fY4LNhvgZ9UsXz29nSZs/6mB59vj2vI=; b=SKalLZPKt6YYCHisRDhV48p252BHZMJ7l4Fwb6jUB4EENbSqxrzeuwdLBTL7Fb6eFo/m9t6F97qX58sgIiE74Vl+pMRxLnjTAZJXY9zDWCOYaWNNe2kFa1l+OgutAPICtkVfZhDofdFjiw06niGD9N4pHhh7bjPYnPn1Z1CmZV9BXFU1cXskN3Y43SbEiujixRLhPh8h70p3vXp/S3x4VL7BZ2g5qYzwY05xwcMWlbI8Ki1XDrwAou5v+2KuuEKX9Qz/M6E/zuNZG5AvA/I5Twt0FPxYpMYnwq56s1v+0oPdRS3Uf7knAOsIaBuqArRmRN/y/qm1WirN9FFtKR2VOA== 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=none 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=NzlJXDYllOj/fY4LNhvgZ9UsXz29nSZs/6mB59vj2vI=; b=qUmJLOnVZpnHGMdDXC0CZEGWOhkZnHwsayNO/X4dpa/Mhyq13H7YGqE8UajvGVTZMe8ZX6tZ8qfIk7eYwOtzBk3QfCOeJkONLoXYXwq10qVtOjVctRUFovSzFr+W2oQ4B2UfYObl26kI3UV4kvWqDoJwrhqMleSFSYajNkfjUOUJVOwbm4u48jlRnaxTfsjeqQan7F3EPKR8lnmafQDhm2fkAEY9YObQXGYBEoZ2e3cgOlbdptoczGCckvFekG5mYm/JALA9Pp2R6rwW34hMlXQ6EodRnjNcBBA56dZKesNEMv/GQVFCeEZfFElwzAY4/lSnPWy02BYMEPHHwGaO2g== Received: from MWHPR14CA0020.namprd14.prod.outlook.com (2603:10b6:300:ae::30) by CH0PR12MB5041.namprd12.prod.outlook.com (2603:10b6:610:e0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Thu, 30 Sep 2021 14:57:25 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:300:ae:cafe::46) by MWHPR14CA0020.outlook.office365.com (2603:10b6:300:ae::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Thu, 30 Sep 2021 14:57:25 +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 CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 14:57:25 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 30 Sep 2021 14:57:21 +0000 From: Xueming Li To: CC: , Jerin Jacob , Ferruh Yigit , Andrew Rybchenko , Viacheslav Ovsiienko , Thomas Monjalon , Lior Margalit , "Ananyev Konstantin" , Xiaoyun Li Date: Thu, 30 Sep 2021 22:56:02 +0800 Message-ID: <20210930145602.763969-7-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210930145602.763969-1-xuemingl@nvidia.com> References: <20210727034204.20649-1-xuemingl@nvidia.com> <20210930145602.763969-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc62b1e4-7103-4726-8b75-08d984229d48 X-MS-TrafficTypeDiagnostic: CH0PR12MB5041: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vNy5LlbZSniue19SUPlONIsuT3/zgAyy2qboHvnc3DgniuDT8cbqEYVNJFg5HtIyncZp6ZAgh/5vv8D2KHc7ZEKCR1hph7HU44xUQ4H6IQl3cR1REV2NUqZybHdX/IPPib9bU6C3KQ12ji9UYZP+o38+iBehBbx7wTYJFSbGReREyds/HagiL6QywUIKxfPgZceYyRVLJ6sv4crUqzHET3ILyNj5F60j1L4aKnVAJWcRlpAeUOloNniWyM4dNwaIthZuhFLVBAq3keEvfCivkTSkREJ6SSuy2sz8+1XkyiVcU2AqhBNlBmEfcH0DpodB2BG3mzbozqczdNveor5f0SJF6jv5BbFP3IxzE2ZCMfpBtenlf8h4v9HBcoC8/qwKz7v2Pn7gh0BkY2WtadZbkDesQ5yNxKq/hypwO/lQkhmfESHHfv2ZlVxVTUEE+dLIqBFL1HS/rZzMhpF8rUwoJwunmlMNNP1eUnW1zXuMLwD1gkWQKk3ZZLXPEpv1XZEe2/MhhsFVS7wPrnbeTgdn+CLtOqOk9YLK72W1/xzrdiO2EIBO/rZkD0If4PZUh43aZHflbXgyFqn6wppPdms7g8+pO3p96S70PZTh/GfakWBqIV31qP+dDdUoyJwfSFfb1xJz3ybspUD/t5JRx25DtdEPgVyph4U4D5vVy0eJais7y4FZC10kBbyqTu8PGKiWskLwlYUOMZD32o3vVEqL7w== 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)(36756003)(16526019)(7696005)(356005)(83380400001)(36860700001)(86362001)(186003)(7636003)(336012)(6916009)(426003)(5660300002)(70586007)(26005)(70206006)(6666004)(82310400003)(6286002)(55016002)(2906002)(54906003)(4326008)(316002)(508600001)(8676002)(1076003)(8936002)(2616005)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 14:57:25.0468 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc62b1e4-7103-4726-8b75-08d984229d48 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: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5041 Subject: [dpdk-dev] [PATCH v4 6/6] 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 --- app/test-pmd/meson.build | 1 + app/test-pmd/shared_rxq_fwd.c | 148 ++++++++++++++++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/run_app.rst | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 6 files changed, 156 insertions(+), 1 deletion(-) 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 98f3289bdfa..07042e45b12 100644 --- a/app/test-pmd/meson.build +++ b/app/test-pmd/meson.build @@ -21,6 +21,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..4e262b99bc7 --- /dev/null +++ b/app/test-pmd/shared_rxq_fwd.c @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2021 NVIDIA Corporation & Affiliates + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 cab4b36b046..681ea591871 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 f121a2da90c..f1fd607e365 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -299,6 +299,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 43c85959e0b..7b83d4b3944 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -252,6 +252,7 @@ The command line options are: tm noisy 5tswap + shared-rxq * ``--rss-ip`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index bbef7063741..a30e2f4dfae 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 accrodingly. + Example:: testpmd> set fwd rxonly -- 2.33.0