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 91471A04FD; Fri, 7 Oct 2022 19:46:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1CA042BE4; Fri, 7 Oct 2022 19:44:59 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2064.outbound.protection.outlook.com [40.107.220.64]) by mails.dpdk.org (Postfix) with ESMTP id 7785642BC3 for ; Fri, 7 Oct 2022 19:44:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eu1FRyQWEuH4GztIsA+QuSupv9c3s2yqljYj4lPUWBTrSdJI9Qzu1xBvxIOP3evehmoOLMWJAJBSg8VBGLV4XZrxp1JGl++pXSXt54BsMn2+JJdW17FxMd166dJs+POKuu3Ci953ohKRhPoEjINnnMwBmS1X3f0IDdP+PrmwmDj8jQWzaKTUDDcXV1OWaPZS8ud9CKdiAWJukA0Kg7lOgVjoHOzZewtN7X3qAUx9Kzt4jaWJ1VVcjO/E90YKeE4m4WuBDc+wjOeQLCBDkLvr7ew5oMHQHurE2o8qyIecalJHyk8Tw8R9auwcxltxX0ouT4SlIwdCCzxK8aetDlhEmQ== 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=DEMP+YC3l5Yu16Fd8LraaULY4ysRJg08S4fb10zD8zU=; b=aYR8cE8a/gfb64t4FDkVxFf6RD05WUYaeXP9RV/h/izakn+KDoJrbhaSdXynkvH9K7PsQe2EZJ0vi+e82iYi4+kPnEOGmY7Nyv/lPyjtzi1MEVs/Pkc2BAowFt5BSSxAKbA4q/9IpnIsss7afpPMH2dacw6QGPAUNcmiJxBZXGJ4ugB12gtDiarwFRINhapsfcVSA6Eet038llL/XYgOqa1SMNGblQRM2aggpMs3RrF1mYsSiNjPdAE5Qg0g05UH7cLwr1MMFlNmyRQnpS07PLd+fNI/8uPqk6ENK4qpXfpagPhzaFClEj3iS2SLA7yesL5HmyYrW5EIl0rkbO65BA== 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=DEMP+YC3l5Yu16Fd8LraaULY4ysRJg08S4fb10zD8zU=; b=jE63AMmGgKuKoY+435CkeR+dUkySkAykqYrgJiveM4Qt7UDBoOEJ26z/ZwlTdr31X4UXxPWLRXrYY14KXC2zbHYMqbIo4XSLEcANMdPDLY2bPVu6wFU2k9A+2z50wnB22d09+YmvqyL7Su2MmoGrj+3MVS2BpQ4PuJ413aqbNjI= Received: from MW4PR03CA0350.namprd03.prod.outlook.com (2603:10b6:303:dc::25) by SJ1PR12MB6241.namprd12.prod.outlook.com (2603:10b6:a03:458::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Fri, 7 Oct 2022 17:44:56 +0000 Received: from CO1NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::7) by MW4PR03CA0350.outlook.office365.com (2603:10b6:303:dc::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.15 via Frontend Transport; Fri, 7 Oct 2022 17:44:56 +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 CO1NAM11FT068.mail.protection.outlook.com (10.13.175.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 17:44:56 +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.28; Fri, 7 Oct 2022 12:44:53 -0500 From: Andrew Boyer To: CC: Andrew Boyer Subject: [PATCH 23/35] net/ionic: add a lookup table for packet type Date: Fri, 7 Oct 2022 10:43:24 -0700 Message-ID: <20221007174336.54354-24-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221007174336.54354-1-andrew.boyer@amd.com> References: <20221007174336.54354-1-andrew.boyer@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT068:EE_|SJ1PR12MB6241:EE_ X-MS-Office365-Filtering-Correlation-Id: 85b80556-2c31-4ba8-1cf5-08daa88ba5d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m0WPOnquGxYHv4xyUT34hHN3oXfS2/rTEBthDc1UsibLCNlrWTe0bvZ+PYVEYQgi3gSVFL8m3ODyNcwRcAoS2Ln3nx4fdIVak7QjARi9SOQHtwA7/wcFEOVbUCDvJMT0KVD0Y0gBKJ065EFbJSTYi8jlcB15iwlOeH3dnF5YGG33UZkYNerSwQ4GniptGB+0rurJukoj2YwU6TWIYn7vU+tDcxLK6avLA+C06Ao8pxOb27UUIhDoRTx6J3vi8uXBUqGgUAeR0eVnnZVDPh7nIraya1U7P7svY0UQ/tqlEs0EEa4SA6jwzb1U1JrjBQ7Axtw64tTAp5wtxGUTphcMCyCBjoJR/W9FzL/ODD3443ef6aua2jKx6AV56uwoBiyDhHCtOtnFrzzu8hB2GaRlehlc1M4liRWJB7fcUrY6u5eeVOd6oBLwkRnwA1vSmXw1g95Tm8vLsEKReUk2d9/4fM0G4vEte8V9vYsLnqGLomR2WyofX4CAEnGnZ4IiacnI1WSThsAnnoRGZJ8kU/XQGnbBymEVoq633ca0obufpx6jrxU9yPzACvSdTVr6HkT8tI+fQXYFJOo/nXgdfPhXuHFsHmfbBtFxVlnpLAv2WL+viU4vG0es1Pud5aG5QBGT8uhIqn9oNtvE9nr1fAYuz8EDLBw6acIxNhUjTaG8h4aIScxqR48+qCmjLGteyhe0RCdPX77hbO7I6KeovujEbFzyE2n1o9a4gYorv7j7ljZSsHUDtY3tigZ0TT+bskTw/fk3Jn9pbjTegMPjBnDbkJf18V1NH7YEp3nOxuSeHgmnsAlUpwYkbXzozO3Jqs0v 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)(376002)(136003)(396003)(346002)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(16526019)(336012)(4326008)(8676002)(6666004)(426003)(6916009)(316002)(26005)(36756003)(1076003)(5660300002)(2616005)(2906002)(70206006)(8936002)(356005)(83380400001)(47076005)(41300700001)(70586007)(81166007)(40480700001)(36860700001)(44832011)(40460700003)(186003)(82740400003)(86362001)(82310400005)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 17:44:56.0846 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85b80556-2c31-4ba8-1cf5-08daa88ba5d4 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: CO1NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6241 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 5ee6573a50..bb09c4eb1f 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