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 90B11A0C47; Wed, 11 Aug 2021 16:05:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF27F4120F; Wed, 11 Aug 2021 16:04:57 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2047.outbound.protection.outlook.com [40.107.237.47]) by mails.dpdk.org (Postfix) with ESMTP id EF7BD411F8 for ; Wed, 11 Aug 2021 16:04:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jdUrF5O8fou10ldqEAakswr+Y+t4QY/HSMXR4+R7oj3u5QGUIKDz7Zx8Oq3PKk9yFJHePB3tN8vM9Ye1lCgQ/S12flIIZOVuMoE9jdoJFJckb0WOiOFBdUN5CNIzCffcM/Y+sHRaymM2WDlooIwLPLvkIyNZh4k9rH0cig7GIkM7E2KT1E/TcNfVt4cN7KJuEukK3gJWvpFlonYfpj0akfY5K9Qk/Vi2ccbtlw5J3rQHk3bRfjUqPRZwGKD4OCTuyJ6zNaBgud7nnV6ajelVRGOOR6bFoQvYj6Br1SO6nRg4NS8xIxCd1irZwbImUyONfEvwHqd3EK69JB7n7XIwCw== 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-SenderADCheck; bh=eKyBeZb3SLJrUxuSsA8v5fJ/EpaPQQ4b8O4wqQZmYfs=; b=EgW0u1hBdKKjhk7F6d9OvaslmXEw1RetiL9PSQLhc9/UKf4EiAUYqO8AyQRjQu/zbXZyt27cFEQLfLozKmddqjHi1GdiuUMUbxJFXbyQNZtK9ycUd7TtR8O2bC3tDISdE1oi7kaVIjtc8tccqmm9OYrYUeVJGhM//wbYYW1T5pUphppuOZTXz++M6Ebdh+dDbRAYJkpvT1b0k8r6r5M0z57fzwLVuBVnh/lJV6r5CRpcUaV98Sf1GFkFAsA4Au7iDHiYME2ODelIU/lIay03YX722TefnRoIZlDdUyZTFRo0IArzPxy6+1pP2lS0dueuNFLxJ6S3YxFKhKin1nMakA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com 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=eKyBeZb3SLJrUxuSsA8v5fJ/EpaPQQ4b8O4wqQZmYfs=; b=LnnQG576V4VNcSS5EOePkX4nFLE6dtxRN0u1sBc/vd9B7cvuO5Z8cNbRlnxGjS2la6FnlNt3bOM0sjGJjOLBWZPYmk7uj+A7vdZUsCvVppIxOIqQzjzUrG19URVckF0Jx4GHLQ2WrWy3Y3bjwk/I1C4JqcV+u5MndSgAuFVCuEJc+5bey82p2274ZCluXOCKMuK36mhdBiuJ/DHQ4pshMnGVdYwPjrKvgF5tp9bTd7RofR7VYEvvWFaKhXwkZGOSxVaL6oNRVH3SbJSqCtClS1Xe69y9biTlC+2YkS4TvxvQV6SRUmiPC07Qy/1A4O6y+VkO9piWhWAcfOMBndwhqQ== Received: from DM5PR19CA0022.namprd19.prod.outlook.com (2603:10b6:3:151::32) by CH2PR12MB4165.namprd12.prod.outlook.com (2603:10b6:610:a4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.21; Wed, 11 Aug 2021 14:04:53 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:3:151:cafe::c1) by DM5PR19CA0022.outlook.office365.com (2603:10b6:3:151::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.13 via Frontend Transport; Wed, 11 Aug 2021 14:04:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; 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 DM6NAM11FT064.mail.protection.outlook.com (10.13.172.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4415.14 via Frontend Transport; Wed, 11 Aug 2021 14:04:52 +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.2; Wed, 11 Aug 2021 14:04:50 +0000 From: Xueming Li To: CC: , , Xiaoyun Li Date: Wed, 11 Aug 2021 17:04:07 +0300 Message-ID: <20210811140418.393264-5-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210811140418.393264-1-xuemingl@nvidia.com> References: <20210727034204.20649-1-xuemingl@nvidia.com> <20210811140418.393264-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: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 874bfb5d-cd9a-4272-e9d2-08d95cd0fdb9 X-MS-TrafficTypeDiagnostic: CH2PR12MB4165: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:568; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iwXaNM9CkqXqsZW6jmNeUCoQlbCD2bSNe4k0teQ9syPqdzPtSfm4ThlyGizxYBkw3bhoIR/SQ2UC76x2KTnRHXToYSpMecaznBnK6OdT9WWOHypxY59R/3PXQ4XyouJvRkZNB5fOAy98D68I8zNl7PyA6TUq6CTZpmV7s35PTs+XcmwapeSuzq+mVRdJQ5PchMhvzYVgYURKAVnfi1dVSfHZPxXREeZkgkzjPoz8UsfrzMC/fHqECznOASEzrrHSrOVWZITqQJldqoKpoQTmO7hVmrWUOhs+w2kjwmMscys3AfhZUGe3F92jBKWhMxYFqNiQg8s/OufSbdbZVrGmnC0Cx1GyRgru3kKnRchcVE3K4M+5uEx51IkNXCj85aMLUsF8fGP2iDzmRRdxxzgphCYoOMafvqIkDrUnGYpy2BKfQr2xKyMsKoofoRuC1ovoJg2Ym0zIp0SCikD/SoGjL8iQ3XHkqaI7i7YsKMMPHedsvBKSt8ghO2TRrvAXUGEzY+o7z/g8J/lAUVNsFhM3JR8NnopbmSIrPi38Moxgh46t6rl4Ghe9tpQnsD7F75FWS8xWNyVrAUv3ecRA0Z5cuylMY6jdcCfN6dVgOGQxQmd/k9sJ/Mu0tDwW+JWMEYovvjrt9ns4imBjhLX1ygphRdIpVW5N/I827xChhfgsq801oJBoTxhqMZNXGhvVSpmvECHxFcXDZHAVMinfC5iLgwc/a/FJOL4h91mt7jzWiX4= 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)(39860400002)(376002)(396003)(346002)(136003)(36840700001)(46966006)(82740400003)(36756003)(316002)(82310400003)(4326008)(8936002)(36906005)(426003)(70586007)(70206006)(2616005)(36860700001)(16526019)(86362001)(6666004)(54906003)(7636003)(47076005)(8676002)(336012)(356005)(1076003)(26005)(6286002)(109986005)(2906002)(7696005)(55016002)(478600001)(5660300002)(186003)(266003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2021 14:04:52.7899 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 874bfb5d-cd9a-4272-e9d2-08d95cd0fdb9 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: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4165 Subject: [dpdk-dev] [PATCH v2 05/15] app/testpmd: adds common forwarding 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" 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 up local streams on current lcore with packet source port(mbuf->port) and queue, then invokes callback to handle received packets for source stream. Signed-off-by: Xueming Li --- app/test-pmd/testpmd.c | 69 ++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 4 +++ 2 files changed, 73 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d941bd982e..f46bd97948 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2034,6 +2034,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 6497c56359..13141dfed9 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -272,6 +272,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. */ @@ -897,6 +899,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); -- 2.25.1