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 88B15A0C46; Fri, 17 Sep 2021 10:03:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 19517410ED; Fri, 17 Sep 2021 10:03:11 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2052.outbound.protection.outlook.com [40.107.96.52]) by mails.dpdk.org (Postfix) with ESMTP id 6BF54410EA for ; Fri, 17 Sep 2021 10:03:07 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HDWCcUEnjnpyNgC32yF6MWScN2nt7fTD6uEucTEUeq4JgFwUIX45MB5Om2V1Ux6mJ3lAq04GLYNphfkmbuxJpYHrDnI7bRqWAQD/o3D8IcZU4JAtCi1FGbnD4it4draaJ1wtTFJTSV4HeGpOe0tNfnpzwfi51R9bYrDXcpq3f6E2c6meLuh+hxpqfi4Mjjy4cAzpzGF+K2q+YEyEsocgbwVNeK9eqdxxGW65IGPhzshqhfkmd5eimg2VniIeFiCZYLaepb9g+H6c2OY5hmEg7yZ7E3MffoRY+nOFnQn9/Yy8YMhvi1hjMh0pUyW7+cP5Vwcy2UiHXJJ/PFqQ0XeXyw== 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=hRKrc6i7tLggR3jGoQbEwRBdNtnuX67Fi+iOvZgJ27s=; b=IQSUhidNQGIH2ndlWeH9zCZtRaVxOdXwU+zm0OUUzvSOHRGbEyUXGrgk9tSk6XTOwfT37wnFViZZTQF5EuspextbUwVdTa5BqvOCA7YaNTsFlRqqGh/fFrEn5mLNcY0zW+6xeOzLm+hoFoTfe1eR3Y1Cja5VJEwKFFiWkfsCuOJJfpoz/xHQGRB0N5UJHD34bKuXuW/pawhZtdjYAvKcQtqJf+0B65N8B8i8f2uIMV2yF93GGmuqv/ZQjsuUykKyKFP69oppLZYkXI+ekAOk9Z/UAJa7UaLFEULNzCsaq56Uyt+Sp49JiXaN6IY/UUYJ58/shdZse6fOkWo0YoTjWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org 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=hRKrc6i7tLggR3jGoQbEwRBdNtnuX67Fi+iOvZgJ27s=; b=C0U3U8rMhAImh24yZ+DuF7ymeHNI081GTlKxGIpXmrBQh0nDSDa35PnxG9laVKmKhaKTkae7aCrUK4k2LmBSvriUleLVsjPP4YQDIpf67x6dZfgrRXUVnkaXxOQx37QlrBe69dtN7W7403+n9Hgkn40tnXdh1cba9Ehel8A9o2Y+A3RsDDqrYbYOyQYVx0pEWT37chiwZCAVW6oo81RG1lzj2dYYvPT+Yo/PWCUNCyl3oob+7CeqLidFOFfCHfmbdGh9rMH7VnP68N7Gium1G1GdeCNEZy8HWQHHMOvOVe5qdU8lFIFwt4rZLhFloeNz+0BrKIKfpS/I3k3kXBs0IA== Received: from DM6PR17CA0021.namprd17.prod.outlook.com (2603:10b6:5:1b3::34) by BN6PR1201MB2464.namprd12.prod.outlook.com (2603:10b6:404:ae::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 17 Sep 2021 08:03:05 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::21) by DM6PR17CA0021.outlook.office365.com (2603:10b6:5:1b3::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 08:03:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 08:03:05 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 17 Sep 2021 08:03:05 +0000 Received: from nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 17 Sep 2021 08:03:02 +0000 From: Xueming Li To: CC: , Jerin Jacob , Ferruh Yigit , Andrew Rybchenko , Viacheslav Ovsiienko , Thomas Monjalon , Lior Margalit , Xiaoyun Li Date: Fri, 17 Sep 2021 16:01:21 +0800 Message-ID: <20210917080121.329373-9-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210917080121.329373-1-xuemingl@nvidia.com> References: <20210727034204.20649-1-xuemingl@nvidia.com> <20210917080121.329373-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 DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d4e4e87-7efc-40b9-28bc-08d979b19493 X-MS-TrafficTypeDiagnostic: BN6PR1201MB2464: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EGSuRnS76gkkHSc4SiGifYg8aChU5Chhonq9KcjhadAFrPCxX/T7dL+e3+QblWpSoT+SCqssUW3tss5gQ++UHIcCS/blcbi8w5y09QjG7JrKivXHU6IoMFKu3kAOJ3aKZG13R4O4R2VPmMkB5YpZneO2ngnHGgazQmHuq4u2smaXiZYnc9l0e+of3fTJQE0aL9CUr0UChRG7AtQxw2j6cF/M88/zGnR/W1qwIFoSZofqIP7iKo48Q+RwNXRu7NMIfSi2s8X49GDKqRfq5ZYn//yivNM1Z7eAMM4D7T9l0bOov46//bgkDo39W/hFnPLpDSCapLdv4xHg9mEi5wclPiYRHtvmq38tqmar0PUrHG4iy2IhL04pWmRP1/U8BRgv8e5e3Y1Wue6ym8JyAdbm81hYzDynLpfl8BRB/pnUwvWncCHZ/Y9CyE85vCShuDqly8qlIQx1s/ZLU2cA8q3sqRtLCus2tiA+Bj0yRdXuQvR7RzRRryAAXJeb+odh7rgTuyIDdCDxXchu74qlPWtF9m2W3WvDkc3nDs+FVV+2RPd3vvwOGGwsnckxqV0j9nE1r4A52sSGSlDDuRQtcMfsNTaqJGG796OwX3MYOWDnINxVIKWsMc8gLcDFhda3I1Ea64I7kneZq1KtApPVjcf76zSqDs6OEOWZWiwBXHbUScj3MqQMK+l00pfOqOxVaxwIIZAUs3WGDz3GLz2EJAdpsw== 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)(54906003)(186003)(2616005)(356005)(336012)(426003)(8676002)(316002)(7636003)(6286002)(16526019)(36906005)(82310400003)(1076003)(36756003)(55016002)(6916009)(5660300002)(36860700001)(6666004)(83380400001)(4326008)(86362001)(7696005)(47076005)(70206006)(26005)(2906002)(508600001)(70586007)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 08:03:05.7101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d4e4e87-7efc-40b9-28bc-08d979b19493 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: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB2464 Subject: [dpdk-dev] [PATCH v3 8/8] app/testpmd: support shared Rx queue forwarding 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" By enabling shared Rx queue, received packets come from all member ports in same shared Rx queue. This patch adds a common forwarding function for shared Rx queue, groups source forwarding stream by looking into local streams on current lcore with packet source port(mbuf->port) and queue, then invokes callback to handle received packets for each source stream. Signed-off-by: Xueming Li --- app/test-pmd/ieee1588fwd.c | 30 +++++++++++------ app/test-pmd/testpmd.c | 69 ++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 9 ++++- 3 files changed, 97 insertions(+), 11 deletions(-) diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index 034f238c34..0151d6de74 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -90,23 +90,17 @@ port_ieee1588_tx_timestamp_check(portid_t pi) } static void -ieee1588_packet_fwd(struct fwd_stream *fs) +ieee1588_fwd_stream(struct fwd_stream *fs, uint16_t nb_rx, + struct rte_mbuf **pkt) { - struct rte_mbuf *mb; + struct rte_mbuf *mb = (*pkt); struct rte_ether_hdr *eth_hdr; struct rte_ether_addr addr; struct ptpv2_msg *ptp_hdr; uint16_t eth_type; uint32_t timesync_index; - /* - * Receive 1 packet at a time. - */ - if (rte_eth_rx_burst(fs->rx_port, fs->rx_queue, &mb, 1) == 0) - return; - - fs->rx_packets += 1; - + RTE_SET_USED(nb_rx); /* * Check that the received packet is a PTP packet that was detected * by the hardware. @@ -198,6 +192,22 @@ ieee1588_packet_fwd(struct fwd_stream *fs) port_ieee1588_tx_timestamp_check(fs->rx_port); } +/* + * Wrapper of real fwd ingine. + */ +static void +ieee1588_packet_fwd(struct fwd_stream *fs) +{ + struct rte_mbuf *mb; + + if (rte_eth_rx_burst(fs->rx_port, fs->rx_queue, &mb, 1) == 0) + return; + if (unlikely(fs->rxq_share > 0)) + forward_shared_rxq(fs, 1, &mb, ieee1588_fwd_stream); + else + ieee1588_fwd_stream(fs, 1, &mb); +} + static void port_ieee1588_fwd_begin(portid_t pi) { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index cab4b36b04..1d82397831 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2106,6 +2106,75 @@ flush_fwd_rx_queues(void) } } +/** + * 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_by_port(struct fwd_stream *src_fs, uint16_t port, uint16_t nb_rx, + struct rte_mbuf **pkts, packet_fwd_cb fwd) +{ + struct fwd_stream *fs = forward_stream_get(src_fs, port); + + if (fs != NULL) { + fs->rx_packets += nb_rx; + fwd(fs, 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. + */ +void +forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx, + struct rte_mbuf **pkts_burst, packet_fwd_cb fwd) +{ + uint16_t i, nb_fs_rx = 1, port; + + /* Locate real source fs according to mbuf->port. */ + for (i = 0; i < nb_rx; ++i) { + rte_prefetch0(pkts_burst[i + 1]); + port = pkts_burst[i]->port; + if (i + 1 == nb_rx || pkts_burst[i + 1]->port != port) { + /* Forward packets with same source port. */ + forward_by_port(fs, port, nb_fs_rx, + &pkts_burst[i + 1 - nb_fs_rx], fwd); + nb_fs_rx = 1; + } else { + nb_fs_rx++; + } + } +} + static void run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 3b8796a7a5..7869f61f74 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -276,6 +276,8 @@ struct fwd_lcore { typedef void (*port_fwd_begin_t)(portid_t pi); typedef void (*port_fwd_end_t)(portid_t pi); typedef void (*packet_fwd_t)(struct fwd_stream *fs); +typedef void (*packet_fwd_cb)(struct fwd_stream *fs, uint16_t nb_rx, + struct rte_mbuf **pkts); struct fwd_engine { const char *fwd_mode_name; /**< Forwarding mode name. */ @@ -910,6 +912,8 @@ char *list_pkt_forwarding_modes(void); char *list_pkt_forwarding_retry_modes(void); void set_pkt_forwarding_mode(const char *fwd_mode); void start_packet_forwarding(int with_tx_first); +void forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx, + struct rte_mbuf **pkts_burst, packet_fwd_cb fwd); void fwd_stats_display(void); void fwd_stats_reset(void); void stop_packet_forwarding(void); @@ -1046,7 +1050,10 @@ pkt_burst_fwd(struct fwd_stream *fs) \ if (unlikely(nb_rx == 0)) \ return; \ fs->rx_packets += nb_rx; \ - cb(fs, nb_rx, pkts_burst); \ + if (fs->rxq_share) \ + forward_shared_rxq(fs, nb_rx, pkts_burst, cb); \ + else \ + cb(fs, nb_rx, pkts_burst); \ get_end_cycles(fs, start_tsc); \ } -- 2.33.0