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 D6902A0560; Tue, 18 Oct 2022 21:46:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBF064114A; Tue, 18 Oct 2022 21:46:34 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by mails.dpdk.org (Postfix) with ESMTP id 0FB624281C for ; Tue, 18 Oct 2022 21:46:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nWV15TL0ob0W8wrIRRfW00tn0bKEwhanL+r5OdVz/rRc3YPNKXe//7fqjnDoI7Z8LzJE2u8Kq+1Ipk14KcHL+1XP0Ftw5IyQRBGRIodPWlZM845OP7ufe2k260/2LOzP3uLxGPt+pP6P8qvbaZdsrKFpBVzWgy8xYt1NB9w45zncjYxdkVmbB/A7vhXsJ4V5gNwoPMeEYK2G7iOw7xJbB3LhK30X63CZo8iVuSwrOD+1ETuthcf8m5eYUmt1z8KRcmvjRDLLE35A2qCWRFR/n57GJ6Ma6SnCrb/5Iu1VFFvcZZsg4hR7yh9olg5aBrk4RGiDgIVYeixYAoy77H5eaw== 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=B5T9vMP4GDIptQNqMrHeInHQ7CXw1zOO1HnXeMfcjBA=; b=Rq0ehsVVJtrtH3KW8IguQYX/q4TziUe8DjzmmXy6OqvNTfBxXXMwxspzdOhXFlmx2jdM9yyzQ20IMmzgqw+4h9UR/SQ5tU70kJcFUU7wi+McangZpIaRjpzh6GD721LeODWeszEWzG+1CO3W3Mz4AKr0duRB/kDoAypOHBYNSs0uNjaV97MmeAW7aCIjNCFC+hUiKN+pM7plgqlzGQtywx0o7VI5FgUL8XBGnbDN63MWU/MARPgK3ieq2odVAURfMG7cwvROKsDzG8je6GC13I2e1B4h2eFjhAYgUZH21DC8DWU9Zs8XQg3BDHla4L/6TcFnqEpocDzV8z6PMmQXTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B5T9vMP4GDIptQNqMrHeInHQ7CXw1zOO1HnXeMfcjBA=; b=OZENeGVaC0Cul9oQcxAfb94NqBUx8+SDF6oTQDreIl6YRyql40vptsjTpOcvuI3Do1SsDYNTC0/AR7RWQcHe8QoAOmcHvwz5eJUTz4BOiJ0WXi3bFKxUlG0CHINXtdxBb3dpQpVSeUFGVaSjl7jnYe8dKxZNppJSWDieyUUiMOM= Received: from DM6PR07CA0047.namprd07.prod.outlook.com (2603:10b6:5:74::24) by DM4PR12MB5231.namprd12.prod.outlook.com (2603:10b6:5:39b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 19:46:27 +0000 Received: from DM6NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::4d) by DM6PR07CA0047.outlook.office365.com (2603:10b6:5:74::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 19:46:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT052.mail.protection.outlook.com (10.13.172.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Tue, 18 Oct 2022 19:46:27 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 14:46:26 -0500 From: Andrew Boyer To: CC: Andrew Boyer Subject: [PATCH v2 24/36] net/ionic: add a lookup table for packet type Date: Tue, 18 Oct 2022 12:41:19 -0700 Message-ID: <20221018194131.23006-25-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221011005032.47584-1-andrew.boyer@amd.com> References: <20221011005032.47584-1-andrew.boyer@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT052:EE_|DM4PR12MB5231:EE_ X-MS-Office365-Filtering-Correlation-Id: 5dbe2ac8-2a8c-49e8-5dac-08dab1417236 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fVS6EYP+wDdpREH7f7IDf0f+ScxcOcfn151u5ZR2u6rvTo62YGn24YL1XJXojbSepmYkc00oy6UAVj3KDY6zI9c5nWyZRpxlkphbWcdoucPZ6PMFaENLcxOqm+p1Jw7N0c2qhFA22P9+oIhji573YOi+9x292gf4zKoFTqk/7RGvxK3QijA4wlcFVtd1xJ9B5bPL1i7kbOWNqVOh0vOsQNqTTrtvWG67uw4spD1lbqoXdgwD0pO+KxM9kqzDSw3TosSWWSqKU4x/ko4KQZaalYqf9g+rolivGiDIvdQtSLFeTB6h3UVQ+fSM+Tp5FDHqUf6CR7S+cZU36Fpn5EuSJLNBYeKEM6s529XX2AkcZmRrf5bdBql5AkKCoB+fUBMqc7OTCf6OUyuWGRYfYKIUj7afaTTZkwYYYHfA27QyQ0OyshxLY9rrRKsu7xXXBzQvmi4UnzejYlb5hsECP7fmDhf9QTZjb+gdCTaAzeNV0tmA358P3XVeQ87CwdqsA2M2DWeDfreWtKJrQjcW5J6iMqA6Xha4tjL+tytha+AhX0mQF/S4h3mt0JXAHkTFsbNSfODEXtCf58fFrp9CBSgE+2QS9R5XpzvV24sWv6He7gR3jXc5SRyu84U0iyOg5KAf8wXwJxjAoza1W+XE7ZvXz/PPBER3RR5ds9nK2Uxf4scD2NJtlg1COQkJ1KtJpQrySgcGpenNrZfxkvVcjgrPJd8OvWTuBxmRerxnGcG0O0+TdzAED+2phitBJuQNPBZKyV8llmq7Z1wks6Pc4Qeq+jY0I3CLeRLGeTrkGmKH/FgCUwq4kp/n7rgyYp7A6mwD X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199015)(40470700004)(46966006)(36840700001)(2906002)(36756003)(8936002)(82310400005)(5660300002)(86362001)(4326008)(6666004)(40460700003)(41300700001)(26005)(2616005)(44832011)(16526019)(1076003)(186003)(478600001)(336012)(8676002)(426003)(82740400003)(70586007)(81166007)(356005)(70206006)(83380400001)(47076005)(6916009)(316002)(40480700001)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 19:46:27.2721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5dbe2ac8-2a8c-49e8-5dac-08dab1417236 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5231 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 This improves performance by reducing branching. Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_rxtx.c | 63 ++++++++++++++++------------------ 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c index cb5ae7671d..8a544c03d3 100644 --- a/drivers/net/ionic/ionic_rxtx.c +++ b/drivers/net/ionic/ionic_rxtx.c @@ -804,6 +804,22 @@ ionic_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, return 0; } +/* RTE_PTYPE_UNKNOWN is 0x0 */ +static const uint32_t ionic_ptype_table[IONIC_RXQ_COMP_PKT_TYPE_MASK] + __rte_cache_aligned = { + [IONIC_PKT_TYPE_NON_IP] = RTE_PTYPE_UNKNOWN, + [IONIC_PKT_TYPE_IPV4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4, + [IONIC_PKT_TYPE_IPV4_TCP] = + RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP, + [IONIC_PKT_TYPE_IPV4_UDP] = + RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP, + [IONIC_PKT_TYPE_IPV6] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6, + [IONIC_PKT_TYPE_IPV6_TCP] = + RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP, + [IONIC_PKT_TYPE_IPV6_UDP] = + RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP, +}; + /* * Cleans one descriptor. Connects the filled mbufs into a chain. * Does not advance the tail index. @@ -820,6 +836,7 @@ ionic_rx_clean_one(struct ionic_rx_qcq *rxq, uint32_t pkt_type; uint32_t left, i; uint16_t cq_desc_len; + uint8_t ptype; void **info; cq_desc_len = rte_le_to_cpu_16(cq_desc->len); @@ -895,41 +912,19 @@ ionic_rx_clean_one(struct ionic_rx_qcq *rxq, rxm->ol_flags = pkt_flags; /* Packet Type */ - switch (cq_desc->pkt_type_color & IONIC_RXQ_COMP_PKT_TYPE_MASK) { - case IONIC_PKT_TYPE_IPV4: - pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4; - break; - case IONIC_PKT_TYPE_IPV6: - pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6; - break; - case IONIC_PKT_TYPE_IPV4_TCP: - pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | - RTE_PTYPE_L4_TCP; - break; - case IONIC_PKT_TYPE_IPV6_TCP: - pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | - RTE_PTYPE_L4_TCP; - break; - case IONIC_PKT_TYPE_IPV4_UDP: - pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | - RTE_PTYPE_L4_UDP; - break; - case IONIC_PKT_TYPE_IPV6_UDP: - pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | - RTE_PTYPE_L4_UDP; - break; - default: - { - struct rte_ether_hdr *eth_h = rte_pktmbuf_mtod(rxm, + ptype = cq_desc->pkt_type_color & IONIC_RXQ_COMP_PKT_TYPE_MASK; + pkt_type = ionic_ptype_table[ptype]; + if (pkt_type == RTE_PTYPE_UNKNOWN) { + struct rte_ether_hdr *eth_h = rte_pktmbuf_mtod(rxm, struct rte_ether_hdr *); - uint16_t ether_type = eth_h->ether_type; - if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP)) - pkt_type = RTE_PTYPE_L2_ETHER_ARP; - else - pkt_type = RTE_PTYPE_UNKNOWN; - stats->mtods++; - break; - } + uint16_t ether_type = eth_h->ether_type; + if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP)) + pkt_type = RTE_PTYPE_L2_ETHER_ARP; + else if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_LLDP)) + pkt_type = RTE_PTYPE_L2_ETHER_LLDP; + else if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_1588)) + pkt_type = RTE_PTYPE_L2_ETHER_TIMESYNC; + stats->mtods++; } rxm->packet_type = pkt_type; -- 2.17.1