From patchwork Fri Sep 6 23:26:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13794862 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAEB015B14B for ; Fri, 6 Sep 2024 23:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665200; cv=fail; b=UB5XTdT51sIQP8Q0YzY7O/FwpOEHdJEnpRL1UOgZv/1yoXgzV9t9EuGe63MceR4xwCcLF5LQt5GO0GC9iSlKHLu5RwFBHy9JYjjCQkRDbS79wWO7K7rtZJy1yJKSDCUREl4pfR7dbEjEPrtdqjd+RdyNDzvv7IMbTmFKd112fJs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665200; c=relaxed/simple; bh=j3CRyk6Y0uBremxXdEIQSJdVQVA5Iabxi3t9ThH6b30=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Oi1U3f5hWlqh/bnCn/rdHpJ89ZeVcN9se+uIB74axEc46bO3sM3EqJIGEnW3zOQCDLU2XUWwuPW8H/8hB5ZdAJ1IOmTvsBaN/XclZscfIl17Rpucfwy/cUbGDK/VQSx8l2wE6PtL9vNoj2M2hq7J99nVTHe+U8m6E8u28MfvP5U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=ACO9+SsN; arc=fail smtp.client-ip=40.107.93.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ACO9+SsN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HUzPg5VKYSBMBO9UocsaTXZXHWgGvYrgIHs+OvnGnYxkkuJCj7PMcHK0lBNpt2JbsZ5jK7uOw395ACji9O3YfEQrXI6PTE9k91sAB+iSsQsBu72yikRSs7fUsfLyRyTPUsEmC0tiGTZDOOB9NUwKakIH1kA6vOYRaaY5Xpi7FhhB/zrHk9n8bCC3odS/xSeWXFZiE12BPuUHLH0R6KEZCA4DJSjtJ76m9tE8cjgcCY8bRTiw8Pwi4ZjRIb8ofjLESnEU9VOv4zpGzQmQLD2ZMGrVRtgNPUo95JgJxu5P5oDBcJBmooAcH+1qMN9Welb1Bu1eWzZGeo+NQMPV6QdqYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ydGgXlmc6O+3iLJTFB/BCjqDr+bSvPG4muJH5tyCb50=; b=JvkRCit+exXg2QfVhVtR1IthIirM3XGWXXRSBYvl4IZ7YICMY5/ipCfVo2ttX4LlZ8/JrU0V7ujwgg80kROMcc+xEe8vzYWyCpnqi3rLht/KWcSLPT56bJS5tREgvRA8nzMDUR3Y5IGKjFe5M1/SeCZjdkBMsJnApCKet6SOGRhaHhnPYPgrCWmfdMZiwBt4UMUeOyQ3XMoc7oiwNrcgBiRMq/5MY+R1QN9OQ9S8gm7Jc/3iBjtEzuwotsE8BfDb5d3S6N36yNAQaJ0rgLtu7D/vQyLlpTtQ6yerDvitLZZYpperKlYcihPUFy4jLT4r7915vZBm2hDDxXhxkiEf/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 (0) 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=ydGgXlmc6O+3iLJTFB/BCjqDr+bSvPG4muJH5tyCb50=; b=ACO9+SsNm4aBegfLdptY6Rjuc2E9LV0JY3EksFSiu+0Pvu4v5ODE3Yc8uS4RN4ndyJ5siFQbLWj6EeNhF8HNG7Gmv1Uo5Fvq6sk59D8gtCch3iKW3/F1A4YA56BnJ4fsQnQMcmHaU8tjCtEW4vU6b0IQbWPi0EcqFWdiL9CR1e4= Received: from PH7PR17CA0066.namprd17.prod.outlook.com (2603:10b6:510:325::15) by IA1PR12MB8519.namprd12.prod.outlook.com (2603:10b6:208:44c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.17; Fri, 6 Sep 2024 23:26:35 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::75) by PH7PR17CA0066.outlook.office365.com (2603:10b6:510:325::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.17 via Frontend Transport; Fri, 6 Sep 2024 23:26:35 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 23:26:35 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 18:26:33 -0500 From: Brett Creeley To: , , , , CC: , Subject: [PATCH v3 net-next 1/7] ionic: debug line for Tx completion errors Date: Fri, 6 Sep 2024 16:26:17 -0700 Message-ID: <20240906232623.39651-2-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240906232623.39651-1-brett.creeley@amd.com> References: <20240906232623.39651-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B4:EE_|IA1PR12MB8519:EE_ X-MS-Office365-Filtering-Correlation-Id: 518d78de-a5b2-4499-7ac0-08dccecb598e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: ezNlMI2gDgGgwWi6Dz3FV95S45vB4BeT4okbHbtLXwEVTwDc9LALJTZV6c6+eQbkNpjeX8gTstdJGHUhtLu+pBjWAGLN7ITfgi3TlaP11rEg6qE2QGIPKAg6PqACwZZMLBNawmo0uCH1rADNKIan4Y5h/yEF0u8C1acUK8DodxDxjU+/c2wa3w313ptSkbFpldWW3MCgTSeaxBLsgCgfXaFTo3oCEDfj/ksnn3ns1rL8+0vza0SGHa9EOBr5OYzY8yykQe4ITkgSAmNL+wI1h1uJ/h75+8OhjmYE3KArg9zQ6eKk5FuR8tcovmzsooQv/sSuD58VDHYSGJxzWZp3qQArZQ+rRod+P+vk5SGwUnMIdZQQ0czNXvZ8FwYmy1EJsxRMXc+p8cknC0LfVALT/PzMFz89riD4Hene0obq+4C27e5z7yv4eqn1lPMl0rQ6BuONQLTznJxCxjPzE56kffDUa7xk6IOA9wQn8EBa2pm/R4GzqW8ZIGvos5nyqosB5WrdGUxIfTnQph0PocS6I3JHQ9ziasCQuYOzzBJbCbzZ7tvEMmAAL04moEKeh8W0KxHNR3DOGT7AsG5jlorQ/KCM63SuWWVClK1Mx0ZRaV8WShJsbE5BEN5ngBNepwB/z5pmR1RB2Cy2RqjKHmpP7W6aqc+pzmVK+t8qMGnsmkKob3RfRMFCEN/c/Tl3AduHlWocModKccbW1MTpFWV6rdO7V80cU6sHgf55XAPxDas4DyX4KU603lOOIH+l/oe/lmafKW8Hs6qsCpA72/DaD2mMzD1hBrfcTwgQ/F5a6vgzdLdl5puX2pXC9gL+ton//V3rjLGqW3j1SZ4laS+1QpZChXtVUEVYwezas0Cpgs//QnEMPWQ7RqOdfNauLTYG78nvHRYP2aOIpPgT5IdbCoj3MZ8f+o8QrGwijpP3XTd3f37DCbRPz/0f3G75ChKmLpxcwsviGipITiX59ONTUBkwLOV+1zDzz7oNUtP0hYitO50aSePe3f2yJue9QMKDy9bFkb+ROYWfuajVijFhM31jAPGP49DlZi+twsegp1aSx7Z2ZU89wMLb+rTuDk6rl7LCSJBeUVY9cFefO7arvirM7VsZNC9a2RM6X52gLczMVgOausI4vBL6137vPOL0RsAyV3b3M4viV1aNoOKmPEu+d8zAb2V1HzdOm8FSjMCrxAIZq8+9Bk4G21Qra9h36WJuBtN/fNQcGzTJM8lQzXPHMrmCyEUz69GDMTRblzIp7VwkvTcaX/2LFnQiZPmpU7xUBlioKycgleL2Fg1RSB6V+tWeywPZFiQosFoZigaw3V07FgWZTY4a4xnLxIWi/3TCbI/8FkxlGETI3/ZkPVZe5nH3QHNllwoA/rqgHAWVcZe3DmwR0VApmy2xnoTv88V3HuPbdmSxcBBzZ4EG1vqygAN83lcp3wlbwxe4fZ0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 23:26:35.5023 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 518d78de-a5b2-4499-7ac0-08dccecb598e 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8519 X-Patchwork-Delegate: kuba@kernel.org From: Shannon Nelson Here's a little debugging aid in case the device starts throwing Tx completion errors. Signed-off-by: Shannon Nelson Signed-off-by: Brett Creeley --- drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index fc79baad4561..ccdc0eefabe4 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -648,7 +648,14 @@ static void ionic_rx_clean(struct ionic_queue *q, stats = q_to_rx_stats(q); - if (comp->status) { + if (unlikely(comp->status)) { + /* Most likely status==2 and the pkt received was bigger + * than the buffer available: comp->len will show the + * pkt size received that didn't fit the advertised desc.len + */ + dev_dbg(q->dev, "q%d drop comp->status %d comp->len %d desc->len %d\n", + q->index, comp->status, comp->len, q->rxq[q->head_idx].len); + stats->dropped++; return; } From patchwork Fri Sep 6 23:26:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13794863 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2085.outbound.protection.outlook.com [40.107.95.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B900C15B559 for ; Fri, 6 Sep 2024 23:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665201; cv=fail; b=HxSS9l6AUxP9orOUCGjepWsPRerYanEYK9M7YJH0neAvpFONJSkhsR5g0L+iv9TPivx+gueZZTt6GMNIb3I2Xe6Un1hR9U3bS1shQJZz9dLzkFbwR+qM7IAqzTpz+TFvLQ0XEISUzz5pUayrQrKpWqt2TqKxxBCNRl76bjAGaZQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665201; c=relaxed/simple; bh=xygfFePx6C38dTuDIxq1Ea+gYpmBGE6BYC2sShPAaHw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Nv9xyuUdg+/Ud/4D4Njti2No1CUDK733u/M8uxA4CvAGaFQfPlIot35SKkfM6gyi9MLPwhvp7be+Q0rdAHczE1PDgecTcKuRiMRROHSWiwj5TEFAPkQCRSJfFx9wOkM7FXvfWsjqQJKh1O9jhbo+teBwgOWcxOzGiONPuAP6tBQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=JcIAo96E; arc=fail smtp.client-ip=40.107.95.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="JcIAo96E" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hC1mRsIYtenOwDg4p2n4efytkD81DwVPUOL0YslMydt9tuX0tmbdYWtJjGT92s1R/1hJZq6DDKwCBCBQE/41MFQIEtNFPDLe1a2PzxFUf3fHGRu62vu6MRptScwhe6ih9AVW3vVoH4S/Oqqfm2Q9Qu7MHp2Zsa0AcVgtHu16GijkWm/S5D/7E/CBBiC1Ex2oTcj0vvLyCrgqcaZnBqVyjzgsfYPigCFe4fKvR3dkUjqJVvPRbc9noJ5H+iWbHL/gPWSdqcpIUxKk1rZ9IgF8ONCWytCvrgUSBO/T96wwOBGpe8iqNKLzEMIW+2GXpxRuXHJUmQ+70kseZ9GNqlDNwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=o+eL95GQjVFHwYMPzNnHcgUwc5a3KthXmWL6tGRm1P0=; b=WXeIgS0B9VhURiGao4CYE5/Qy0VGw6Qo8dk1UqR5j4DcfHUtdwwH5VvLnFqJNdZChU2rlPjSIvKpzqWh4llgprl6cDaUh92bsb7kqMJN5mV0b7bmXKmVLUxZ4HX4orZIfq73NLCmrP3JIlYVZUw2b8W6mrz22pHBYZoeJKc+EaaD1DbeWSaXE2gJP8jX8AB1Gi4HKpNeS81kp4p7SxY+MqEHQfgSSxX+2EYxAVlCpg2/a+3nGPvtN2JaDMf+UqWIF/u3Ese2zwHgZEHQTf1vgeuSgWx71PYD3JTP0sYj/+WNE6JoZaKsg3rdIUMyAgHBkV8Oe5+mVFwDuW9yZcARLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 (0) 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=o+eL95GQjVFHwYMPzNnHcgUwc5a3KthXmWL6tGRm1P0=; b=JcIAo96EbA5D9dP6AH9YIqiORYYiJWXYrB4IfdSVmwVrTAudXY5j6vkWPYcrm51bi6+jdItwNhLEN3i6N6QopJSL1oTQvqXmhUnq++ekIXdbtWOwqw8B71Aum9UEy3QfZxZqzkfVLSL+7eLyGhXmGNbkPcqJsMoiqjk5i1ZKd8E= Received: from PH7PR17CA0070.namprd17.prod.outlook.com (2603:10b6:510:325::10) by DS0PR12MB7655.namprd12.prod.outlook.com (2603:10b6:8:11e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.28; Fri, 6 Sep 2024 23:26:36 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::cd) by PH7PR17CA0070.outlook.office365.com (2603:10b6:510:325::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.20 via Frontend Transport; Fri, 6 Sep 2024 23:26:36 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 23:26:36 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 18:26:34 -0500 From: Brett Creeley To: , , , , CC: , Subject: [PATCH v3 net-next 2/7] ionic: rename ionic_xdp_rx_put_bufs Date: Fri, 6 Sep 2024 16:26:18 -0700 Message-ID: <20240906232623.39651-3-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240906232623.39651-1-brett.creeley@amd.com> References: <20240906232623.39651-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B4:EE_|DS0PR12MB7655:EE_ X-MS-Office365-Filtering-Correlation-Id: 74e3fb8d-0c76-4e0b-2730-08dccecb59fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: pG7IaVmrm/XoLZ8DrK2ln89520V8ijC40TN6XMgR0hxEhWe/PTI4oPrxIu7fpsEcp9na+36mnXaOOKRrl+p26fq6wfVkHN7r1m+2qXueV7FMRFrq8aLiuwQMyO3V+X8YH9ojYUVaa0CujylNEqtbTQ7HCScvoqY8tppnhu8x08zJ0drtzFK6ze694ocGZn7XrLFMLwtr24mRzjhrYuybmj4WzlF+0s89E47SL4cgCmMYpMbtIyxIL5T4GjyhhC5/kc4Kpm3ZOfwP1ukXUMvNPKnuMEn6aiJ525r78BivBGPu8qpGywLey2k0abZQCC4KTNrjpRJbRytetICZfH/GKRYmRrKEBwjzm3Dq91B29gsZ92igqJjED/Adcx5oYcbQ/D6+j3XraB8WM0/XFcGevpLIm/ViX1x6z6YRQN1fqCYo27FY3c/n0jKIgVGiyJMWubZQQ4R8jWbIu7iKBmFSalBNVtBPkxSTx3d+YvCRGP66qiwgcH7oQTCFrSvzNELhB8jgkBxObDpFDfGCl/8u1d4p8vKAtxzAceLYu5M7SMEO92A5GhRmloE5ferYe+5GWbUNMTtv46IW39IyRjUMLGjiDdmj8vSspmdxsmic7hEVuKJ0SrykwEW7uP1XJxg7R2frHwM2Q8E5JgJIzGg5mYB+k5CIqWJjSI9CA4rS9gm991tmBpMGASXY3Ln6zwcGXMhs0QS+sQRzdWLdDIHihwgfqbpo3gy5sSG3KdTGbBMxpay9GeLZLzBCryWmlhK8207rhzaYrbUUFvpyv61P+3NfUZgT3WQl41/3CnAIzTiNhBx1RFvM728QkjwoAyCoS5WXJncMFmQf8Cm97KaeNFrC4WjgSwpiHCOTCtRBUKw50y41nVk0Jnv1l7DaVVkNL3EIepc2F8j+C2k5V3WQJQb0yVjYwhhSjDKGkP2KgNTQ8pnprGW5s/0jPDBrdNhHD1Gl+HCJ4ryg3JA0FPMW8wG0l3PbaV0b5bXl0LgrefwfpeD1pECgNsCIIuFEirDri5BlQ+7660gMArUy18y387IM07v5a+7BepdawZiuf4sTsxNG64vztCo9P2xyUk4N4Y4dwBi7Y1rhRas4fUjOcWF02+TkTd9yinwXp5A0VB5BtAanTU/JZr53Iol4NtqzsVORl6QsZm6uA6mUuderB2g62pcp9pkI467aOxB6QSZx2ePfffWRJCjL5MvFI4wjoE6yhPKCg7AsfTO2nlJxc8kBmiGWs60vNuUPTYVLpouyjoCv9aKTDZLltR2rrP16cP3St1XIglgAPLPlJx6JTXz6vCIKmEp27mobnzWD34Kt9yEWkmNetGTV2JAmYbTMbJpdFbwvcN6kAaln4qtIMfJpjsaMqCW5umpUMZHSFMt4XK4FPSCwgIatKyORs6g+DHOa1k0qd9FEe375My9YRpvWoDoNeYO6sqx8z8OKF9h4oH4q69LGTTcANCT7/GPU X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 23:26:36.2366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74e3fb8d-0c76-4e0b-2730-08dccecb59fc 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7655 X-Patchwork-Delegate: kuba@kernel.org From: Shannon Nelson We aren't "putting" buf, we're just unlinking them from our tracking in order to let the XDP_TX and XDP_REDIRECT tx clean paths take care of the pages when they are done with them. This rename clears up the intent. Signed-off-by: Shannon Nelson Signed-off-by: Brett Creeley --- drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index ccdc0eefabe4..d62b2b60b133 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -481,9 +481,9 @@ int ionic_xdp_xmit(struct net_device *netdev, int n, return nxmit; } -static void ionic_xdp_rx_put_bufs(struct ionic_queue *q, - struct ionic_buf_info *buf_info, - int nbufs) +static void ionic_xdp_rx_unlink_bufs(struct ionic_queue *q, + struct ionic_buf_info *buf_info, + int nbufs) { int i; @@ -600,7 +600,7 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, netdev_dbg(netdev, "tx ionic_xdp_post_frame err %d\n", err); goto out_xdp_abort; } - ionic_xdp_rx_put_bufs(rxq, buf_info, nbufs); + ionic_xdp_rx_unlink_bufs(rxq, buf_info, nbufs); stats->xdp_tx++; /* the Tx completion will free the buffers */ @@ -612,7 +612,7 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, netdev_dbg(netdev, "xdp_do_redirect err %d\n", err); goto out_xdp_abort; } - ionic_xdp_rx_put_bufs(rxq, buf_info, nbufs); + ionic_xdp_rx_unlink_bufs(rxq, buf_info, nbufs); rxq->xdp_flush = true; stats->xdp_redirect++; break; From patchwork Fri Sep 6 23:26:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13794866 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0DE815B559 for ; Fri, 6 Sep 2024 23:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665205; cv=fail; b=S6QX4T6P7+RB8083znw/ZsWa8XRBFLUmUd1ItycwFS+EpO7E4l/lUm41+B2CLnNSrZ5ALzABLo+AtnPyThccg1ghBPrTDd4wDtuniUIznSHpOsgfRf7tTu3dapz8RL22dqki18NpzEUGHQ/UTTsVbWfT6Wp3n9kdgOf6aO+kfD4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665205; c=relaxed/simple; bh=2UaVosjwKBuHzvjsWnkMsgpBJihegPBQ8SLhoV15+es=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UW2rUgcUSqmql95nm1cj2qYUL29zb7Wt7IsBdxLBrPpceaxxYjBJal6O1NBAh7yoDzhBrsoxhsUTjB3dy4xFUdxxCIqJABc8Hb+5YO9ldxEb0t04GjriuXEsy1q3h53npKovVGN7f6tWDNRNAWZ6W7J2iboYIXI5u66n5SNcsF4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=JXk4uzWA; arc=fail smtp.client-ip=40.107.92.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="JXk4uzWA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vLFaknY0Gw7C44gzwQxs/nJ/WZRzSPeukiCJ925o36imGLCZ1OjBTlnglyJTWkZBxybrN/bKoVAR3QsnbwJc2PRECowHkj9MM4qgXqipiob+DwgM9nq088OCeo+3A1PjcPHlxBREYxnraRcBumveqpr8i2wR9vqnWmmGWLyNtQoAE+eYZG6Ku2kF6wiMhnXGULo7Q6uT4fAVTAVbfHrfPu4Vpfee9/MDJGzjAmPY8vGh+2bH5jfcovrGgjdQlHeNSGdGXcDGsyChy+bNBMNAN+8WtqRhd2RPegFtrc90wBTitvutCnJOvtAOlDcHhO6QOJpM6Qb118qwEGkcD1LzYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PuJUawiH3ZS/MZ9sfmV1cu8RCe5V6iRRkd8pPYSRBCU=; b=BQwUNN/EoDV7cqV15n8Oex18CEGG/Jw+ok4uUMHFbEVYVVyr+E3RVLyuZneCeddbtR42p+LAqNhyU2AApDwkfa1DF/Jj10Br0UqUzr9FQH04uemoNQDrmkB3lneHfVGo3QSeGzbCP4qGMStBOm9YTZ5QP6U80rHK2wiH9d3ukcyVdlnFx1rvViSETAt8piF6+ZD6+qCBGt0xxagzi1k+XnVK0Q/1avrLjt8AI13s+o6H+Ya14lGpkN2jTyrhlsYYKWsjCcha05VgbFtlqGKe43WeKEkC6B58b/6QI1S3HqDke6TXT7FLyy985Cm2tUPmPvj5L/Mg71jExyjD5aie8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 (0) 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=PuJUawiH3ZS/MZ9sfmV1cu8RCe5V6iRRkd8pPYSRBCU=; b=JXk4uzWASgTdwtTwm8Df7g86kZD0eubBfCIQil1K52xBKsmf//2XnY1glMlsPJ/MpLEs0kSq8G4sT9HJ5x8esBAKEmVW0b8+ECPVxPhQBDD0SWHesyTt4eaLcKSzsV1RMazLAdUlKm/rxhsxAwmdWJldyk/MgKun1v0xu0TPEp8= Received: from PH7PR17CA0069.namprd17.prod.outlook.com (2603:10b6:510:325::29) by DM4PR12MB6614.namprd12.prod.outlook.com (2603:10b6:8:bb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Fri, 6 Sep 2024 23:26:37 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::68) by PH7PR17CA0069.outlook.office365.com (2603:10b6:510:325::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27 via Frontend Transport; Fri, 6 Sep 2024 23:26:37 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 23:26:37 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 18:26:35 -0500 From: Brett Creeley To: , , , , CC: , Subject: [PATCH v3 net-next 3/7] ionic: use per-queue xdp_prog Date: Fri, 6 Sep 2024 16:26:19 -0700 Message-ID: <20240906232623.39651-4-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240906232623.39651-1-brett.creeley@amd.com> References: <20240906232623.39651-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B4:EE_|DM4PR12MB6614:EE_ X-MS-Office365-Filtering-Correlation-Id: 2995a128-2e16-418e-205d-08dccecb5a97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: TfxReoEyhBkoxTg3awLvpA/WZWP7pNMvt7B5AQV/RMs0cxtatqAzg8qIaRfmmfzHBq5FJf9/xrE6X1DxnZ6EEqbxQUswjNWV/1IJfqtjt+YL4OrgbJov6/T+6DiEoOKyCa9wMB/mGaqqPsYTv4dpuxdZmmoSpW4qMjsDLMmTAFHQHsAfy3CniAtgwrd7YL+6hJS7WlGAD7aBiyKN2wkpcDMU1tUnC/bdMJMi+4ftfobw+QL3xLDXOTaTYV3EMP1JuPc9KkKbSkuCOI38EbVVzKVkr6X664UaTefnnbw68UglAO3yrjIe1oYdwj8ck5oOrsPXMN8GLUpnbaoIXVF6eJN2HkbqXNBLZHXhsd6+WskDaCy9MlfmEk+CEKOs+EvmBb/hdhbqVHLoLwuLp4fEOcCxAhNr7tBE7qsvF5bfpYBpEszjFqtQ1va2bjUXhjhJglDHSHndBUu1KCiigf5JTPLnSB02f1LYbny4RZ3T6najaEcVVg4EoMNxEBCO36mH6MvDFLvQd6HXG0pibg/mMoDy6A8BbYY40lS3tfgAGVKxO8hC5clXTrT/3+pXi7I8qsZj2hXxABlkG03pR2ayj2oe6RKPWrhF2xmBl5ZF60PbJ1z2c6C/kBGfjndHmqiOresO7AVDe2IzmsC9ACCB7LkXTPLFsLbvpRazCjx3j5WiP7xiPyl7WhRDoBHchVfhcoQnRjuz7VIJyPZZ9o8niId1eGnyZJOqLrO6l5KoqUW1KEMi7hc2sgOtX8XfspXRT4k7OrBM+DVFohx1AChPDXXdwrG1vPh50TwDt/eso8ZF01Mqk+udO5xyB0xx9hl0xvJEfI7rjgpxOAxCpz8V5aOnIPSaGBLWe+2QURgPuxoT4Hoyu1kDnJhA85F0lVFOrUuizmdHxFi6V0j6nYkulti1yyUuCaNLFl5ndWB3oS+FT2FIwiyfTgdlVDreU7B2Z1GuRsbxizy+eDyWjx84k04nIhoZZfr7LtblIt+JEGvht/eH3Uzfu5v3/ZSdPCMFB7+BIwcMWdBoIcypdMK0mQMYo8ttaMsCrUp2zbOcXMJaxBIa57dlF60QrrIb2evVuN57eOb/Ho9Z/7lLZZY/CRZTLbPPmfHFAAuID3ZKTaoHgxBgy9DedStSSQnLzs8vuQgFf2/FnWoLJ1KtKOtxoJrFttgkqHboPwj9ugOWwJzqEBjwebMwc/pFO6kawpgVkIIm0MNd1d4o/G196or8CXaOJ0h1LZHBqu20wCDGrsfvPgz+wudUHHNz3tfcVsk6IJPaAD4pkN6xAFnCNX/gNc1jYGcPID8ftl1Uw66Gg0qccOgwA2THlefiTiQc9UQ5LdE68JLS6iKYZA2YkOHzdsP/wP4TtdgUuNisNqp6KPC0aVKw2CYIgxxAPSP5IetDOhfpYaGZZoY92KRrJz/1hrWAohPPE+0xatwjUp+dKrxoLmZ2/nRlQgt9Z8+QyUlZ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 23:26:37.2366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2995a128-2e16-418e-205d-08dccecb5a97 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6614 X-Patchwork-Delegate: kuba@kernel.org From: Shannon Nelson We originally were using a per-interface xdp_prog variable to track a loaded XDP program since we knew there would never be support for a per-queue XDP program. With that, we only built the per queue rxq_info struct when an XDP program was loaded and removed it on XDP program unload, and used the pointer as an indicator in the Rx hotpath to know to how build the buffers. However, that's really not the model generally used, and makes a conversion to page_pool Rx buffer cacheing a little problematic. This patch converts the driver to use the more common approach of using a per-queue xdp_prog pointer to work out buffer allocations and need for bpf_prog_run_xdp(). We jostle a couple of fields in the queue struct in order to keep the new xdp_prog pointer in a warm cacheline. Signed-off-by: Shannon Nelson Signed-off-by: Brett Creeley --- .../net/ethernet/pensando/ionic/ionic_dev.h | 7 +++- .../net/ethernet/pensando/ionic/ionic_lif.c | 37 ++++++++++--------- .../net/ethernet/pensando/ionic/ionic_txrx.c | 21 +++++------ 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index c647033f3ad2..19ae68a86a0b 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -238,9 +238,8 @@ struct ionic_queue { unsigned int index; unsigned int num_descs; unsigned int max_sg_elems; + u64 features; - unsigned int type; - unsigned int hw_index; unsigned int hw_type; bool xdp_flush; union { @@ -261,7 +260,11 @@ struct ionic_queue { struct ionic_rxq_sg_desc *rxq_sgl; }; struct xdp_rxq_info *xdp_rxq_info; + struct bpf_prog *xdp_prog; struct ionic_queue *partner; + + unsigned int type; + unsigned int hw_index; dma_addr_t base_pa; dma_addr_t cmb_base_pa; dma_addr_t sg_base_pa; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index aa0cc31dfe6e..79eda0ca82a1 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -46,7 +46,7 @@ static int ionic_start_queues(struct ionic_lif *lif); static void ionic_stop_queues(struct ionic_lif *lif); static void ionic_lif_queue_identify(struct ionic_lif *lif); -static int ionic_xdp_queues_config(struct ionic_lif *lif); +static int ionic_xdp_rxqs_update(struct ionic_lif *lif); static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q); static void ionic_dim_work(struct work_struct *work) @@ -2143,7 +2143,7 @@ static int ionic_txrx_enable(struct ionic_lif *lif) int derr = 0; int i, err; - err = ionic_xdp_queues_config(lif); + err = ionic_xdp_rxqs_update(lif); if (err) return err; @@ -2192,7 +2192,7 @@ static int ionic_txrx_enable(struct ionic_lif *lif) derr = ionic_qcq_disable(lif, lif->rxqcqs[i], derr); } - ionic_xdp_queues_config(lif); + ionic_xdp_rxqs_update(lif); return err; } @@ -2698,35 +2698,35 @@ static int ionic_xdp_register_rxq_info(struct ionic_queue *q, unsigned int napi_ return err; } -static int ionic_xdp_queues_config(struct ionic_lif *lif) +static int ionic_xdp_rxqs_update(struct ionic_lif *lif) { + struct bpf_prog *xdp_prog; unsigned int i; int err; if (!lif->rxqcqs) return 0; - /* There's no need to rework memory if not going to/from NULL program. - * If there is no lif->xdp_prog, there should also be no q.xdp_rxq_info - * This way we don't need to keep an *xdp_prog in every queue struct. - */ - if (!lif->xdp_prog == !lif->rxqcqs[0]->q.xdp_rxq_info) - return 0; - + xdp_prog = READ_ONCE(lif->xdp_prog); for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) { struct ionic_queue *q = &lif->rxqcqs[i]->q; - if (q->xdp_rxq_info) { + if (q->xdp_prog) { ionic_xdp_unregister_rxq_info(q); - continue; + q->xdp_prog = NULL; } - err = ionic_xdp_register_rxq_info(q, lif->rxqcqs[i]->napi.napi_id); - if (err) { - dev_err(lif->ionic->dev, "failed to register RX queue %d info for XDP, err %d\n", - i, err); - goto err_out; + if (xdp_prog) { + unsigned int napi_id = lif->rxqcqs[i]->napi.napi_id; + + err = ionic_xdp_register_rxq_info(q, napi_id); + if (err) { + dev_err(lif->ionic->dev, "failed to register RX queue %d info for XDP, err %d\n", + i, err); + goto err_out; + } } + q->xdp_prog = xdp_prog; } return 0; @@ -2878,6 +2878,7 @@ static void ionic_swap_queues(struct ionic_qcq *a, struct ionic_qcq *b) swap(a->q.base, b->q.base); swap(a->q.base_pa, b->q.base_pa); swap(a->q.info, b->q.info); + swap(a->q.xdp_prog, b->q.xdp_prog); swap(a->q.xdp_rxq_info, b->q.xdp_rxq_info); swap(a->q.partner, b->q.partner); swap(a->q_base, b->q_base); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index d62b2b60b133..858ab4fd9218 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -190,7 +190,7 @@ static bool ionic_rx_buf_recycle(struct ionic_queue *q, if (page_to_nid(buf_info->page) != numa_mem_id()) return false; - size = ALIGN(len, q->xdp_rxq_info ? IONIC_PAGE_SIZE : IONIC_PAGE_SPLIT_SZ); + size = ALIGN(len, q->xdp_prog ? IONIC_PAGE_SIZE : IONIC_PAGE_SPLIT_SZ); buf_info->page_offset += size; if (buf_info->page_offset >= IONIC_PAGE_SIZE) return false; @@ -639,8 +639,7 @@ static void ionic_rx_clean(struct ionic_queue *q, struct net_device *netdev = q->lif->netdev; struct ionic_qcq *qcq = q_to_qcq(q); struct ionic_rx_stats *stats; - struct bpf_prog *xdp_prog; - unsigned int headroom; + unsigned int headroom = 0; struct sk_buff *skb; bool synced = false; bool use_copybreak; @@ -664,14 +663,13 @@ static void ionic_rx_clean(struct ionic_queue *q, stats->pkts++; stats->bytes += len; - xdp_prog = READ_ONCE(q->lif->xdp_prog); - if (xdp_prog) { - if (ionic_run_xdp(stats, netdev, xdp_prog, q, desc_info->bufs, len)) + if (q->xdp_prog) { + if (ionic_run_xdp(stats, netdev, q->xdp_prog, q, desc_info->bufs, len)) return; synced = true; + headroom = XDP_PACKET_HEADROOM; } - headroom = q->xdp_rxq_info ? XDP_PACKET_HEADROOM : 0; use_copybreak = len <= q->lif->rx_copybreak; if (use_copybreak) skb = ionic_rx_copybreak(netdev, q, desc_info, @@ -814,7 +812,7 @@ void ionic_rx_fill(struct ionic_queue *q) len = netdev->mtu + VLAN_ETH_HLEN; for (i = n_fill; i; i--) { - unsigned int headroom; + unsigned int headroom = 0; unsigned int buf_len; nfrags = 0; @@ -835,11 +833,12 @@ void ionic_rx_fill(struct ionic_queue *q) * XDP uses space in the first buffer, so account for * head room, tail room, and ip header in the first frag size. */ - headroom = q->xdp_rxq_info ? XDP_PACKET_HEADROOM : 0; - if (q->xdp_rxq_info) + if (q->xdp_prog) { buf_len = IONIC_XDP_MAX_LINEAR_MTU + VLAN_ETH_HLEN; - else + headroom = XDP_PACKET_HEADROOM; + } else { buf_len = ionic_rx_buf_size(buf_info); + } frag_len = min_t(u16, len, buf_len); desc->addr = cpu_to_le64(ionic_rx_buf_pa(buf_info) + headroom); From patchwork Fri Sep 6 23:26:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13794867 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2067.outbound.protection.outlook.com [40.107.220.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1831615CD54 for ; Fri, 6 Sep 2024 23:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665205; cv=fail; b=KSmQK5rsUApWfS2sse0VkQ1lMIoW04rtSpMUSBg+zYL+gWagZH8Y5Ciu7VtPzWBGwkcVdlSEv4pnyZAzvGTd87kZ7mdAkPRKO6B9D8jpPXtogq3kz0R2rQQ7XMqlVQKv81TOCx+DWggTvQnwuewJ+02ruwpNLubD6L4Y14fReqQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665205; c=relaxed/simple; bh=N/9CGr3xkN5VXZcjx7uEX7DntK/NqF3lq2Qz9oYniSw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f6QNK3czHdqtXRpCE2d9hGcKMuMW152hgjnBXaINw3a2WAVA/tYQQA/XuDuURTeSogzmImcpSEbiDk6c311UhDNIBRf6H0I7lyGckDL2WvKPyQhdnMOPBpJIfYOP2RB0zrpdqUh4goKrNX+2xABSYs+x+Nv7xVWczltsX7eqmxs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=RpAi7aBp; arc=fail smtp.client-ip=40.107.220.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="RpAi7aBp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p5CRhwO+ZBE+/4kMu5NHOULjuWCZnyBYMpIkSfICLZetE6q+iH5u4QqE4vi5EbCpZZ1XUl7TQd2mzXZFpUdFH+bRmwuCA9/M/XL+7ysISkIcB4hHdv15Kx6Tjt+9u4fX2CnSiqXDY53nbVBf9EP5GmVxVE7Pcfz+hW3mEUtNVp1UTP0zMltx7Q+618k2873t/9/oOFl9JVh90zQdaCxZhyrP9f2UAT0NsLbnu5wxQ86r23KNaNsLh8t1IenItl0zr84RGS8sKj/qPJyGPkHj1JTZl7ItsxLDJndFwTuR0lzNwpUrwF1LPOyBW/XBEb81Usd7kMutkO97gTJWmRGw5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=AeHIgufQIsbv+dtTpewUhkoerNj840U6heJDELx9bFM=; b=h0ZBmY37i7XrigOqrBK5WNXg2UaPFw2eCFvMWRPcUeawEBmBbPO8LHnKqUwtIOM7hG9rUraZyFzjdM4U8b7bSNytSqbLV8l9HOw8U6TMZK6JCsWy06tyHJeibOv8lSJWBo7pboWAM3cKZtLdOCbAVT6LL1QlRad5JXbPaO2kyGFra3hL4VqNaZwiDeOhO/gNv/l0TyoKGlQJXGOLzj9ETNJxcJ7Szf9l6yofNI4Q0rd3F+f3/bL/I7T00YRZ8+uBP7BIN4tuWRgczoEAg5l3xMumK07BDhFeKKtOTm3cgAV6lsV+aITSzqYpswiP284fJ8xxwBsOHtCYldU2zyD7aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 (0) 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=AeHIgufQIsbv+dtTpewUhkoerNj840U6heJDELx9bFM=; b=RpAi7aBpyBzmwrYWbUWI+ZWcSMz82/CNOyBq8vk6rrYFPu8lnY1cxj6HtuDBPc9HZboycL9AiIaXAoI8qRu617ra7jODiYxJSrPlK6HKlrhjZreJhSgvlIeFQyzPrLHTrDcqOxFWYepfXmlq/iwoFJ5gBVR/O3sfGtDEgvvLJB4= Received: from PH7PR17CA0066.namprd17.prod.outlook.com (2603:10b6:510:325::15) by DS7PR12MB5765.namprd12.prod.outlook.com (2603:10b6:8:74::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.28; Fri, 6 Sep 2024 23:26:38 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::63) by PH7PR17CA0066.outlook.office365.com (2603:10b6:510:325::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.17 via Frontend Transport; Fri, 6 Sep 2024 23:26:38 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 23:26:38 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 18:26:36 -0500 From: Brett Creeley To: , , , , CC: , Subject: [PATCH v3 net-next 4/7] ionic: always use rxq_info Date: Fri, 6 Sep 2024 16:26:20 -0700 Message-ID: <20240906232623.39651-5-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240906232623.39651-1-brett.creeley@amd.com> References: <20240906232623.39651-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B4:EE_|DS7PR12MB5765:EE_ X-MS-Office365-Filtering-Correlation-Id: ba79dc4a-7ddf-4d79-8fd4-08dccecb5b28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: gta0mzRQIzz08XS+GxuGqi4QOqdHvml8C1We7nZQBKy0le1hInSSRrh2jRorUHaBq1KLLpHmd2gS6p0ZmqHSCJVr2QGhC14/mxzVCHOGRPPp6k8pn8eRcWb0b3J4tMEsCa/ikPJ1exujfdoUEsZZb0chdHWK/msa9iVhH0ko9l28ajeH56JP2/9mTyhQH/ODCxx4s+E3u7iT7kUUYTQvq31BfrkUwZdR5kvOEg3ndRQ014ELs/9kSV/6PaLSRGZmp41YkKW+cJAnttSpOjx5RtLF35d95Dc3F99ZA9You6T41Xe8XHyVnHPjJGQSmlp62SZ05JLMzc9qMkLvhGxw1+oWF3xUw3rMpoqxu4/0jnFXPC2YPhLfqyqZOX3GA5PJ/Et4Nl16R9CRC+BsfZF4MC5343/6JPncrtypPpaMX4kcj8LydSyu78lVPlUjD8+z6l2ZZTFbJDUSLLBZoZVJAjH8i0BoFs+TDHY5Kkj6HfI2Qr+v5Si1oP5M6vbfRqGH1R6b4VHgQZ+8JFyah0Qkt5n/CBDgcDYZdOyL9RYstiLKx9iuc26YOlW0xZclUKiSXGwaAuOF0mxUNk1Kuegj1D3dPinT+b9S0QuADstV48+lBNOYtLrc030E2CyHiMZHJOEteGMIbLytDniyImpWyKpO7cT6baJn/4gy5PDQJpSJrROI8wRZeUwtCJug8F7Ow1K8sABxK+AywjuismACuDgZsZ1wO6mQKZS5aAxdRQPomih7SyLWSUXVOBJ28Y7ZuWH9rMRdzYY0Kb+Z8ckXyBXY+/9fbDYOWYaW8nR0FdwNJ+zdlkJ5e3uuSQETY8EJ66XzWW1wsS3KwV1K6iNxNRxVDzkoaupQIKQVmlHUSXWwVMTzdDmNV88gQ3PY2RRYu1Edx/KE+MDsnnKrpeRo992SXMVMj7q7apaRz239DJKZLybDygpr8QfLDuJle+WSM120iazts21aWNqPFaDHG2GSf0I6GcgoMP4H0pGhmtZe76xtiFPssYj2uI/9KPYO4h/GPXX/g3ibD9MusQ1eSBBoNSxdMsoa1ZUA7GbobDrxHIrfrKiVXC7OwnDegYqSYISw12sMCR6s3k7QVIgaWt2OWyCFAooMH9tUH14aD6CH2YXt18AFZrVP+DUXplws74M0mt0+x4FvtI1BVLvddX/z/inLBQLp6OEMAv1Dk+Tc+3C/4KeZaeASwleuxJ0Sb/T8JwAtcV9pNGP+JmV0CE77wH8z1ODFFVsC+Wang/SLoChTDFeBHFnrBaNVKrI/nPrtQN4Vea7taDUhV1LJchF7y6G2eHACkRpczBRAZ/Q4Ev/B+H1kieBFFr33aL/k4C/NNmlXOcWsYSB20yeG9widll+OQo1inDKawAciAK1hQ0og8D0BzoHU2yUwSujz/DGtjsYa8UyetDNqiMeJQKsraj2dFNvjw4Tps7BiJzSEpfs3kTpHa3ruaIvDF3Ot X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 23:26:38.2054 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba79dc4a-7ddf-4d79-8fd4-08dccecb5b28 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5765 X-Patchwork-Delegate: kuba@kernel.org From: Shannon Nelson Instead of setting up and tearing down the rxq_info only when the XDP program is loaded or unloaded, we will build the rxq_info whether or not XDP is in use. This is the more common use pattern and better supports future conversion to page_pool. Since the rxq_info wants the napi_id we re-order things slightly to tie this into the queue init and deinit functions where we do the add and delete of napi. Signed-off-by: Shannon Nelson Signed-off-by: Brett Creeley --- .../net/ethernet/pensando/ionic/ionic_lif.c | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 79eda0ca82a1..5d1bf54e3133 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -46,8 +46,9 @@ static int ionic_start_queues(struct ionic_lif *lif); static void ionic_stop_queues(struct ionic_lif *lif); static void ionic_lif_queue_identify(struct ionic_lif *lif); -static int ionic_xdp_rxqs_update(struct ionic_lif *lif); -static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q); +static void ionic_xdp_rxqs_prog_update(struct ionic_lif *lif); +static void ionic_unregister_rxq_info(struct ionic_queue *q); +static int ionic_register_rxq_info(struct ionic_queue *q, unsigned int napi_id); static void ionic_dim_work(struct work_struct *work) { @@ -380,6 +381,7 @@ static void ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq) if (!(qcq->flags & IONIC_QCQ_F_INITED)) return; + ionic_unregister_rxq_info(&qcq->q); if (qcq->flags & IONIC_QCQ_F_INTR) { ionic_intr_mask(idev->intr_ctrl, qcq->intr.index, IONIC_INTR_MASK_SET); @@ -437,9 +439,7 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq) qcq->sg_base_pa = 0; } - ionic_xdp_unregister_rxq_info(&qcq->q); ionic_qcq_intr_free(lif, qcq); - vfree(qcq->q.info); qcq->q.info = NULL; } @@ -925,6 +925,11 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) netif_napi_add(lif->netdev, &qcq->napi, ionic_rx_napi); else netif_napi_add(lif->netdev, &qcq->napi, ionic_txrx_napi); + err = ionic_register_rxq_info(q, qcq->napi.napi_id); + if (err) { + netif_napi_del(&qcq->napi); + return err; + } qcq->flags |= IONIC_QCQ_F_INITED; @@ -2143,9 +2148,7 @@ static int ionic_txrx_enable(struct ionic_lif *lif) int derr = 0; int i, err; - err = ionic_xdp_rxqs_update(lif); - if (err) - return err; + ionic_xdp_rxqs_prog_update(lif); for (i = 0; i < lif->nxqs; i++) { if (!(lif->rxqcqs[i] && lif->txqcqs[i])) { @@ -2192,7 +2195,7 @@ static int ionic_txrx_enable(struct ionic_lif *lif) derr = ionic_qcq_disable(lif, lif->rxqcqs[i], derr); } - ionic_xdp_rxqs_update(lif); + ionic_xdp_rxqs_prog_update(lif); return err; } @@ -2651,7 +2654,7 @@ static void ionic_vf_attr_replay(struct ionic_lif *lif) ionic_vf_start(ionic); } -static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q) +static void ionic_unregister_rxq_info(struct ionic_queue *q) { struct xdp_rxq_info *xi; @@ -2665,7 +2668,7 @@ static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q) kfree(xi); } -static int ionic_xdp_register_rxq_info(struct ionic_queue *q, unsigned int napi_id) +static int ionic_register_rxq_info(struct ionic_queue *q, unsigned int napi_id) { struct xdp_rxq_info *rxq_info; int err; @@ -2698,44 +2701,20 @@ static int ionic_xdp_register_rxq_info(struct ionic_queue *q, unsigned int napi_ return err; } -static int ionic_xdp_rxqs_update(struct ionic_lif *lif) +static void ionic_xdp_rxqs_prog_update(struct ionic_lif *lif) { struct bpf_prog *xdp_prog; unsigned int i; - int err; if (!lif->rxqcqs) - return 0; + return; xdp_prog = READ_ONCE(lif->xdp_prog); for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) { struct ionic_queue *q = &lif->rxqcqs[i]->q; - if (q->xdp_prog) { - ionic_xdp_unregister_rxq_info(q); - q->xdp_prog = NULL; - } - - if (xdp_prog) { - unsigned int napi_id = lif->rxqcqs[i]->napi.napi_id; - - err = ionic_xdp_register_rxq_info(q, napi_id); - if (err) { - dev_err(lif->ionic->dev, "failed to register RX queue %d info for XDP, err %d\n", - i, err); - goto err_out; - } - } q->xdp_prog = xdp_prog; } - - return 0; - -err_out: - for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) - ionic_xdp_unregister_rxq_info(&lif->rxqcqs[i]->q); - - return err; } static int ionic_xdp_config(struct net_device *netdev, struct netdev_bpf *bpf) From patchwork Fri Sep 6 23:26:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13794864 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2057.outbound.protection.outlook.com [40.107.95.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4257A15C15D for ; Fri, 6 Sep 2024 23:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665203; cv=fail; b=stw+g3OfDUpaQiXY8NAQTl9C1yL57SjjWpwrSg1ntHlY4MLSYK85W/FGYoCBnvsvUezeFRCobW5PbTreqO7IuCWnXxvPsdqk3nfYz/JJ4t2sV7rh/YP7OgsAgWiitoaYGDrEdrJ1MuobrSUicw/phDJytyyXHXP8VWokaj8lIcs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665203; c=relaxed/simple; bh=kHems8DIreB8SOHaBhCgEJdiwYYA53voGI2qzuCTNyc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J4oOJGmFmnRz7nYWKKALwSThj+UBbz665dw5vYWIzrwuU3KP7gWYzWNjHqdhR5xRjZuJ+mcMzTtd5oq9/gVvJjmTr53dqlM2OSVq7UKi8EVEo8gm3bnyRIPZqT+fOo9tjw+PRc83qInAq9RxG9J6EuQZAE2ip+JQscNw+Kz8+z0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=K9DxVod+; arc=fail smtp.client-ip=40.107.95.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="K9DxVod+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BiEqOdVOB3iR/ZYHnFrACwwhPIGFb11M0xAMGhCCS0vKqWpsz0FdG3381KliIPdKvH1z0mdBdk0T1EATaw7dxv1GziYi01MZLY69cd/2kDoqskX62hsieXV0KCyIrT2DdMy0/705d5Zuv+HGnIfLu+b38XgMtcVouCQCn77IgDGfm1iv0PgP8F1vynv0H28QkMvHZaf3zkkkgioq6g0AEqZoGUzQr4K6QKT5wg6Pn9uDMvf0aNectYjC0QINmbG11iSw6HshVBnh+9EBgwyiV17gkLiBd2tcRsHumZ4HPObQcHJTZGexdApVZjd2c8G1kgXTw6GnxXCgEsgG2ASRAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=BvEOADZJRD7P5hVJ1acoMaFhRfxPZYWDzQwJePkUmA4=; b=U+JDVr5p5/O3sosUJUfqqt3kC4TSkFRfVtmVy9w6l/FG+FB+4CiVp/AVIKyFHSHgtEgImIcdhQr35K7265jRqQBaxr0mUUoVRjMS3O1Oo1JwJvSM6JzuVueQpwOB2UzvOWEiLld0ejRDhEOjQNBvP42L2V2u/noATCi2GPCsHPBjIJUiCAijC1X4tfjjX13d6WAH3hlXjQGj4WjGbiziq6Zb9hOPyD9IUkeWHv7XAMolIPzyp93fI6EeqdecrXDgveOM0xTojAO2ykmRsExaZ2CTIyQO9eKyz5qu7sptBDJAMrR6sExgB9jU8xdoxopLLNbLXMT34LmQ7r/Y/VxAjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 (0) 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=BvEOADZJRD7P5hVJ1acoMaFhRfxPZYWDzQwJePkUmA4=; b=K9DxVod+VWhpDxSp7PKYJwdmvQadM0cUNUZmQMWRfsH/DANko9SHqU+da0taTmUR6l/OnZ5l53CttPvWxoGBL+VUcHZyQpN06/RNLcstz3l2HXvjKWFwZtCmbkk+Wts6ICZNquG94g427cIDyhPrWj/T5gIIDoo0NZlsuASik74= Received: from PH7PR17CA0049.namprd17.prod.outlook.com (2603:10b6:510:325::26) by PH7PR12MB8828.namprd12.prod.outlook.com (2603:10b6:510:26b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Fri, 6 Sep 2024 23:26:39 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::ff) by PH7PR17CA0049.outlook.office365.com (2603:10b6:510:325::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.19 via Frontend Transport; Fri, 6 Sep 2024 23:26:39 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 23:26:39 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 18:26:37 -0500 From: Brett Creeley To: , , , , CC: , Subject: [PATCH v3 net-next 5/7] ionic: Fully reconfigure queues when going to/from a NULL XDP program Date: Fri, 6 Sep 2024 16:26:21 -0700 Message-ID: <20240906232623.39651-6-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240906232623.39651-1-brett.creeley@amd.com> References: <20240906232623.39651-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B4:EE_|PH7PR12MB8828:EE_ X-MS-Office365-Filtering-Correlation-Id: be9e1cae-a683-4512-88cf-08dccecb5bc3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: 92DlupnA18QnqPMM6wfPb5f7YWLBoe3l28jBiAABCFLuW1RlqVBx1qZ32Glc3VCTmJcefrrSFCWJDidnhML4I3fhGMOvBgk3ZolNUGS3TGiRAcetzrcc+Sd592vE6qUXaRI0o4eKwMB6cSr8IrlWPJ4Gkyj6Ub+PQChgtEwMCLSwXjiqbde9A6GapMSACzeSvaJCmd6FySYPZvD5Qwu1TPeWpqztIU+UEPvSVuPvu7RtCw3bfQVLWKV0Gxs/fDOPcUzx4gZhf7YbsvqICQR8yKQw5eHDaq3xIf8Ey++JxPGr0X7s79Om6FnMh8fxZ5Nj577TYxNN9d2lACXH5tq+oLTclODacxtZ5slpvahMVOUn55PAbkYahM2C/55vC+UBW5wV0GE53O6oF2NsNpKiTnUsNZzWIGRAhLtwyi2eWhySUG9ib53xiV1d76y2jus4pPsgGcEW2OQmtl6CKrE0gnq7R+ztAhCu3QWB9E54whCtbI2LCDIUAD3ghM1QK0Rkp18TMgf6IHPr/EOiqfoQF5uFS5q7Jf9zQirTnC7XoxOCYxLgCszEF2I7w5GCnQEa9SQexVGZC1N1UEdANw5UowjQDLbhPhFnnfXTPw1DBAwBKP/0ITmTybil0+ws+nk1IREj1+5oGwGmIG3P8+a03gZwxGPixbNwsZ/coL7t3b3ilJ4fSBuPtblJv5FIRKDci/OKfgz+Iwj5iwp1jcg79D4sNhuc/CnBx7g4sFkFcfGRjpVgyCT1hp89Mza+fdbCoT3s/b2IsF8DaAZkPFhcXQLXqdw7JUG8n/pIUhAUUGYJiLG+lAJ74uqOCBv/OQUZB2XfEJo5itCoXSikGFMz+z1xkZ9hn/1oUa9glO1OSE4YJgIN4oF6a5ovVExlYXyuCOLBMEq0jcwWc3NOirHQ/iHw0n9MSadMmG4tiMye17HUQafp9CfD/kQNYk+AHpkm99qWv1KgtTDyCjBb7jCp/eA6n+2VCshJNHEJwBQ8/vifIEr1IJDWq4deWoEiwvlMwefDQ/6dXloYb1bdxINkcNT+AXOfOXHq+4TGpN8UwZRXcNlqI+b0ncFvTqqb4mxvT2K/2qbWALVBuzS52J86iPObTnd+/UGH+t2VRZMXbKsm9SZ1Dqccqx5KHqAxdc83DZTnwrgrI5SX2QpKQBwbfMV4+d3f2ENclAqDU7bnittkIjDSu1udKqCseRIcrjETnnXj3KmTO4tO9ZOHKyEevIGSv1VSJ3mrrJpHgJvpLdDpmfy1GObyjkVa5g9PeSJL4vstiq1l93oHOYis4ddks26pvyDz99nq4FfcLCRBXO9LjFhDW9c9l8ZJGiKJuoXqoLzx4hZ2tBf11IXif4/70lCeKv7iV2Q6RzceLXQ+uVKi+ICEbgKXoZMfwpeJ0MYYSrFvcoJNWMXdYQ2shZOv0C1v8JzkTeDSZr9o03Po7EOyPRisGPBAq0OG1c0eX6rX X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 23:26:39.2210 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be9e1cae-a683-4512-88cf-08dccecb5bc3 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8828 X-Patchwork-Delegate: kuba@kernel.org Currently when going to/from a NULL XDP program the driver uses ionic_stop_queues_reconfig() and then ionic_start_queues_reconfig() in order to re-register the xdp_rxq_info and re-init the queues. This is fine until page_pool(s) are used in an upcoming patch. In preparation for adding page_pool support make sure to completely rebuild the queues when going to/from a NULL XDP program. Without this change the call to mem_allocator_disconnect() never happens when going to a NULL XDP program, which eventually results in xdp_rxq_info_reg_mem_model() failing with -ENOSPC due to the mem_id_pool ida having no remaining space. Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 11 ++++++++--- drivers/net/ethernet/pensando/ionic/ionic_lif.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 5d1bf54e3133..1146ff160039 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -2745,10 +2745,13 @@ static int ionic_xdp_config(struct net_device *netdev, struct netdev_bpf *bpf) if (!netif_running(netdev)) { old_prog = xchg(&lif->xdp_prog, bpf->prog); } else { + struct ionic_queue_params qparams; + + ionic_init_queue_params(lif, &qparams); + qparams.xdp_prog = bpf->prog; mutex_lock(&lif->queue_lock); - ionic_stop_queues_reconfig(lif); + ionic_reconfigure_queues(lif, &qparams); old_prog = xchg(&lif->xdp_prog, bpf->prog); - ionic_start_queues_reconfig(lif); mutex_unlock(&lif->queue_lock); } @@ -2908,7 +2911,8 @@ int ionic_reconfigure_queues(struct ionic_lif *lif, } if (qparam->nxqs != lif->nxqs || qparam->nrxq_descs != lif->nrxq_descs || - qparam->rxq_features != lif->rxq_features) { + qparam->rxq_features != lif->rxq_features || + qparam->xdp_prog != lif->xdp_prog) { rx_qcqs = devm_kcalloc(lif->ionic->dev, lif->ionic->nrxqs_per_lif, sizeof(struct ionic_qcq *), GFP_KERNEL); if (!rx_qcqs) { @@ -2984,6 +2988,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif, goto err_out; rx_qcqs[i]->q.features = qparam->rxq_features; + rx_qcqs[i]->q.xdp_prog = qparam->xdp_prog; } } diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h index 3e1005293c4a..e01756fb7fdd 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h @@ -268,6 +268,7 @@ struct ionic_queue_params { unsigned int ntxq_descs; unsigned int nrxq_descs; u64 rxq_features; + struct bpf_prog *xdp_prog; bool intr_split; bool cmb_tx; bool cmb_rx; @@ -280,6 +281,7 @@ static inline void ionic_init_queue_params(struct ionic_lif *lif, qparam->ntxq_descs = lif->ntxq_descs; qparam->nrxq_descs = lif->nrxq_descs; qparam->rxq_features = lif->rxq_features; + qparam->xdp_prog = lif->xdp_prog; qparam->intr_split = test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state); qparam->cmb_tx = test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state); qparam->cmb_rx = test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state); From patchwork Fri Sep 6 23:26:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13794868 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2041.outbound.protection.outlook.com [40.107.244.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C12ED15B14D for ; Fri, 6 Sep 2024 23:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665207; cv=fail; b=L7ooR7LioHE0mr9miR9EHPr3XuJCst7kIfYWTHTsTEddTdQ9e4ASn3fo7uvdAgFRqTudiIfG8aYFt4WA1pbXqW6cmfkKsnPbFFedF7/x4QjE5j6fPFWxL9PnS8nC7p/Ptdy4x8il2pilw/SgyzN6Ck8U1n2GDO4iRp9RGp2SaCc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665207; c=relaxed/simple; bh=7xTmUvW54Dbm1rUtf2gJeYWUiL/L/oiBBGBmCuYhRXI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lk3BuDrYPXtCiMRppgoyj28H+xpFieQJW92LALTD23riZ6ypy40VS536ZhNSivL+C/5j2jQD6OAc0KJdlFGsMqtEfeXOnj1NmS/LrMcaQLMvgsQ5JmJlzKHuugFaOSgRzLTeQp1b8qzYG0XENKJCGbNDIlPWBNIHN+5oC01eEqE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Y7r9UbVh; arc=fail smtp.client-ip=40.107.244.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Y7r9UbVh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i/r8XWrchRUGT/xo1TUXz5n2o2EXG57mK8kbr2pXyKxg6QNTNKbv8jU2+i1skIRDGrmzbedGDBXFVbIqSQ208r0DFMfzBnIm9zJAaZKtpTg4h3owONmFvEf8Gi+7/ncYN2TojPcnKmUz6PHRl2Oo7vuSqhvcCqyv3ejW8wEax3ClA4bgra6IV+Ty7Vku4yD8aWDbbZLhGi33yWt/ffG14SJUKeqv9SFZL1hKhpPhSFA/w1MIX8KrYmF+9Co2G93OrhDdcZl6/ZyxSUcqUEinaPFutqG/pgLMYuOoYKKPq2K1QEC8PNO2HGM+ZDPI9ffPpQ23nSsGFKT8GcE2zU8SYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=F7lHOh7aZPiZhYWO9BZ+ywBAF2oHj0aIPOrO/T1X9Oc=; b=kqY86jDdO5qxprfSJ+KzR+UYNIxCeW2E9UhKEE8WuabNEX9C1LSo0qiAAOemjHTByyhcBiEg8XQ8S4ERVJu251cFrect80BTGRZAdV1InD7lwtUQJ71WXyeVfqdsyWgwjTZgUuJksaRUrsdBsOTdycEL67nvdYTpK5N7X4VZsr4uSGfLwWj5uVRD6sjhM36yExsxvHj1j+c8mxmMFOVO5GbzhcMNypS+0E5/n2/EVh+PuQ6iepryv1Ci6mYolA+ElmiHFhQcMSlw72BhvdxXlej4F4h2MM07YtaBkq1Mzm/zeldssZq1GvJ+ywiN7BM7a/9uBHPG/x07KYZpitXLnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 (0) 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=F7lHOh7aZPiZhYWO9BZ+ywBAF2oHj0aIPOrO/T1X9Oc=; b=Y7r9UbVhVKkMgkpUHQrypIRbzq36OuYDgQ8LxIXkouLDUwh+7VLsvWKtgffNotCj6t54umHnfzjWwbo3lGm32TZVeOn7qNpvyu1ls92fp7Or/7Nq9s34tlhrRcKWfFP7yIBu941RjObw5q57NB7OFJb91MjvmOE45XwZCBE5dhk= Received: from PH7PR17CA0050.namprd17.prod.outlook.com (2603:10b6:510:325::22) by PH7PR12MB6417.namprd12.prod.outlook.com (2603:10b6:510:1ff::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Fri, 6 Sep 2024 23:26:40 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::67) by PH7PR17CA0050.outlook.office365.com (2603:10b6:510:325::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.16 via Frontend Transport; Fri, 6 Sep 2024 23:26:39 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 23:26:39 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 18:26:37 -0500 From: Brett Creeley To: , , , , CC: , Subject: [PATCH v3 net-next 6/7] ionic: convert Rx queue buffers to use page_pool Date: Fri, 6 Sep 2024 16:26:22 -0700 Message-ID: <20240906232623.39651-7-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240906232623.39651-1-brett.creeley@amd.com> References: <20240906232623.39651-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B4:EE_|PH7PR12MB6417:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e1e8c4b-7019-4570-d41b-08dccecb5c0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: 62PlrQjKtjcG3TfB9MvLwynm5JDV2ylvkDfgHBqLe3yofg1j2Nli+jafbfV25tasKcLWvSimRMTGkDBmZFbo84CbhKlEUZ59SyplkIflcwVA24s94XMk2Oh6D4PM/l3t1/sX4Sd10AZbbwm7u6A9W6ZA0O2dTbfqD9DwS7Zs9/rMJ3BG9oZYFs4JJ/8foUuhXTr+6FcasjNc/dZ+6IrK89rxD3GX+NSWB2XJQPatigL6EZy8G+6ERH8RQKZGFFAPR8d+Jvcn45p7O3MmC/wXs8xS4LQOn9JH6ZfJTCconuZ4pr13+AbMhnu0YS0GT2lNKbu3e1UBQX9whgZYOHMKeOtZofa91mLzQyuZPm0OdGz2iqAjvhvymJvkk5/SamAymt0TyVuupaStbglbqcgm4tXqT9rDgSb4EtCEbd7lxIgIPx8rre+JUB3F1uHKI4pvbwV9yfS5W8VoVU1FurilcLVSccb1tAC48Sn+ZQGRwOLTv1oAJJHLWYtaJH+AnLcpZmDvydwZ2aMSXcJPXWjaZdwSUuOL+8t19kb322+Ri0r3aEqpvFjSkAk8Yr4t4fNoRYE98P0atxVIx91Imfd0Z6XXIDVgzWTnNjr9gWT6AHO2AiVv3b3jHV4MY5iWSk8DyheCS6g6VqWPLsa1FQZpVAU3BMBB+BD3QSYyHiWWZiLA8kyT4T9OoFSNUflD+XhfyEVxJ0pU0T5P06m4lbHC3y0USgI6II85Ej/ANkVVzu31XOmIlkLun/3EcODMXJrhmQ4hMnI4aDHKZey6xn9HkjT62p3HCvTEA/1UXqAXEuprqpKMvJV+9AFknOykHnlsAKhACnytn8taQrdiEC/KkSRksiLu0aWpGrl+Y+8YBuyyn5joBEzLQ/5lmwjpCk5XcfIZe5BfRl9iwwie+VWZpBOrJAEJC6E0/+wceILiujPo/moeK8+aMHcih0jY8N5iuDBv7FOIHtlnoum7BXwzWB4O2BGgWqlJIaiVP3/2r0JRmpC06hsUCfeqIJSFV64920yBrMsjeWP6U68KONDs+IczM023pZhyQAC1Qon/BhpmcRX0Zw/ryqUl02hNC8XZkdWrL7mIr2wd7CMHhBcC1T0s/BkQDwLXG1dPwK+b/81S64Auu3KCBw08HMhqU0B9LuExaAHBW55uEEzVzSLW4/xvAGZpiIWHe2AOrIIPTVsY/i+/L6KKET2yY/n+L7Mhigt5OSDFfCrPkzICX6wpuYVHLGpNroOKcGQPo1X05GwNrPJBz9KGoraTQvjONVLW8aFSx0CQVK+n3+UHhy1sFzjlMymLkVHsGgoTbNfCGuOtx87/Z02BgbPg5lQy9CLEjM15eY3hVSjwL2HkveL7Nck8l/yonFZI8I3ylRi5hO0v6qmU7KbI50Mx6wzYALhizT0zxFMBJbxK6RjZoKsLvTTAz9HKiWow8ZrgfHKRJK9dIrEsLyTeOt4wrn0DuBOB X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 23:26:39.7210 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1e8c4b-7019-4570-d41b-08dccecb5c0f 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6417 X-Patchwork-Delegate: kuba@kernel.org From: Shannon Nelson Our home-grown buffer management needs to go away and we need to be playing nicely with the page_pool infrastructure. This converts the Rx traffic queues to use page_pool. Also, since ionic_rx_buf_size() was removed, redefine IONIC_PAGE_SIZE to account for IONIC_MAX_BUF_LEN being the largest allowed buffer to prevent overflowing u16 variables, which could happen when PAGE_SIZE is defined as >= 64KB. include/linux/minmax.h:93:37: warning: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Signed-off-by: Shannon Nelson Signed-off-by: Brett Creeley --- drivers/net/ethernet/pensando/Kconfig | 1 + .../net/ethernet/pensando/ionic/ionic_dev.h | 16 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 80 +++- .../net/ethernet/pensando/ionic/ionic_txrx.c | 344 +++++++++--------- 4 files changed, 233 insertions(+), 208 deletions(-) diff --git a/drivers/net/ethernet/pensando/Kconfig b/drivers/net/ethernet/pensando/Kconfig index 3f7519e435b8..01fe76786f77 100644 --- a/drivers/net/ethernet/pensando/Kconfig +++ b/drivers/net/ethernet/pensando/Kconfig @@ -23,6 +23,7 @@ config IONIC depends on PTP_1588_CLOCK_OPTIONAL select NET_DEVLINK select DIMLIB + select PAGE_POOL help This enables the support for the Pensando family of Ethernet adapters. More specific information on this driver can be diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 19ae68a86a0b..6f9a9843b87e 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -181,10 +181,7 @@ struct ionic_queue; struct ionic_qcq; #define IONIC_MAX_BUF_LEN ((u16)-1) -#define IONIC_PAGE_SIZE PAGE_SIZE -#define IONIC_PAGE_SPLIT_SZ (PAGE_SIZE / 2) -#define IONIC_PAGE_GFP_MASK (GFP_ATOMIC | __GFP_NOWARN |\ - __GFP_COMP | __GFP_MEMALLOC) +#define IONIC_PAGE_SIZE MIN(PAGE_SIZE, IONIC_MAX_BUF_LEN) #define IONIC_XDP_MAX_LINEAR_MTU (IONIC_PAGE_SIZE - \ (VLAN_ETH_HLEN + \ @@ -248,11 +245,6 @@ struct ionic_queue { struct ionic_rxq_desc *rxq; struct ionic_admin_cmd *adminq; }; - union { - void __iomem *cmb_base; - struct ionic_txq_desc __iomem *cmb_txq; - struct ionic_rxq_desc __iomem *cmb_rxq; - }; union { void *sg_base; struct ionic_txq_sg_desc *txq_sgl; @@ -261,8 +253,14 @@ struct ionic_queue { }; struct xdp_rxq_info *xdp_rxq_info; struct bpf_prog *xdp_prog; + struct page_pool *page_pool; struct ionic_queue *partner; + union { + void __iomem *cmb_base; + struct ionic_txq_desc __iomem *cmb_txq; + struct ionic_rxq_desc __iomem *cmb_rxq; + }; unsigned int type; unsigned int hw_index; dma_addr_t base_pa; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 1146ff160039..59d3eea2c0bc 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "ionic.h" #include "ionic_bus.h" @@ -439,6 +440,9 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq) qcq->sg_base_pa = 0; } + page_pool_destroy(qcq->q.page_pool); + qcq->q.page_pool = NULL; + ionic_qcq_intr_free(lif, qcq); vfree(qcq->q.info); qcq->q.info = NULL; @@ -553,7 +557,8 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, unsigned int cq_desc_size, unsigned int sg_desc_size, unsigned int desc_info_size, - unsigned int pid, struct ionic_qcq **qcq) + unsigned int pid, struct bpf_prog *xdp_prog, + struct ionic_qcq **qcq) { struct ionic_dev *idev = &lif->ionic->idev; struct device *dev = lif->ionic->dev; @@ -579,6 +584,31 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, goto err_out_free_qcq; } + if (type == IONIC_QTYPE_RXQ) { + struct page_pool_params pp_params = { + .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV, + .order = 0, + .pool_size = num_descs, + .nid = NUMA_NO_NODE, + .dev = lif->ionic->dev, + .napi = &new->napi, + .dma_dir = DMA_FROM_DEVICE, + .max_len = PAGE_SIZE, + .netdev = lif->netdev, + }; + + if (xdp_prog) + pp_params.dma_dir = DMA_BIDIRECTIONAL; + + new->q.page_pool = page_pool_create(&pp_params); + if (IS_ERR(new->q.page_pool)) { + netdev_err(lif->netdev, "Cannot create page_pool\n"); + err = PTR_ERR(new->q.page_pool); + new->q.page_pool = NULL; + goto err_out_free_q_info; + } + } + new->q.type = type; new->q.max_sg_elems = lif->qtype_info[type].max_sg_elems; @@ -586,12 +616,12 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, desc_size, sg_desc_size, pid); if (err) { netdev_err(lif->netdev, "Cannot initialize queue\n"); - goto err_out_free_q_info; + goto err_out_free_page_pool; } err = ionic_alloc_qcq_interrupt(lif, new); if (err) - goto err_out_free_q_info; + goto err_out_free_page_pool; err = ionic_cq_init(lif, &new->cq, &new->intr, num_descs, cq_desc_size); if (err) { @@ -712,6 +742,8 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, devm_free_irq(dev, new->intr.vector, &new->napi); ionic_intr_free(lif->ionic, new->intr.index); } +err_out_free_page_pool: + page_pool_destroy(new->q.page_pool); err_out_free_q_info: vfree(new->q.info); err_out_free_qcq: @@ -734,7 +766,7 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif) sizeof(struct ionic_admin_comp), 0, sizeof(struct ionic_admin_desc_info), - lif->kern_pid, &lif->adminqcq); + lif->kern_pid, NULL, &lif->adminqcq); if (err) return err; ionic_debugfs_add_qcq(lif, lif->adminqcq); @@ -747,7 +779,7 @@ static int ionic_qcqs_alloc(struct ionic_lif *lif) sizeof(union ionic_notifyq_comp), 0, sizeof(struct ionic_admin_desc_info), - lif->kern_pid, &lif->notifyqcq); + lif->kern_pid, NULL, &lif->notifyqcq); if (err) goto err_out; ionic_debugfs_add_qcq(lif, lif->notifyqcq); @@ -965,7 +997,7 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif) err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, txq_i, "hwstamp_tx", flags, num_desc, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_tx_desc_info), - lif->kern_pid, &txq); + lif->kern_pid, NULL, &txq); if (err) goto err_qcq_alloc; @@ -1025,7 +1057,7 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, rxq_i, "hwstamp_rx", flags, num_desc, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_rx_desc_info), - lif->kern_pid, &rxq); + lif->kern_pid, NULL, &rxq); if (err) goto err_qcq_alloc; @@ -2051,7 +2083,7 @@ static int ionic_txrx_alloc(struct ionic_lif *lif) err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, num_desc, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_tx_desc_info), - lif->kern_pid, &lif->txqcqs[i]); + lif->kern_pid, NULL, &lif->txqcqs[i]); if (err) goto err_out; @@ -2083,7 +2115,8 @@ static int ionic_txrx_alloc(struct ionic_lif *lif) err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, num_desc, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_rx_desc_info), - lif->kern_pid, &lif->rxqcqs[i]); + lif->kern_pid, lif->xdp_prog, + &lif->rxqcqs[i]); if (err) goto err_out; @@ -2679,15 +2712,15 @@ static int ionic_register_rxq_info(struct ionic_queue *q, unsigned int napi_id) err = xdp_rxq_info_reg(rxq_info, q->lif->netdev, q->index, napi_id); if (err) { - dev_err(q->dev, "Queue %d xdp_rxq_info_reg failed, err %d\n", - q->index, err); + netdev_err(q->lif->netdev, "q%d xdp_rxq_info_reg failed, err %d\n", + q->index, err); goto err_out; } - err = xdp_rxq_info_reg_mem_model(rxq_info, MEM_TYPE_PAGE_ORDER0, NULL); + err = xdp_rxq_info_reg_mem_model(rxq_info, MEM_TYPE_PAGE_POOL, q->page_pool); if (err) { - dev_err(q->dev, "Queue %d xdp_rxq_info_reg_mem_model failed, err %d\n", - q->index, err); + netdev_err(q->lif->netdev, "q%d xdp_rxq_info_reg_mem_model failed, err %d\n", + q->index, err); xdp_rxq_info_unreg(rxq_info); goto err_out; } @@ -2853,7 +2886,16 @@ static int ionic_cmb_reconfig(struct ionic_lif *lif, static void ionic_swap_queues(struct ionic_qcq *a, struct ionic_qcq *b) { - /* only swapping the queues, not the napi, flags, or other stuff */ + /* only swapping the queues and napi, not flags or other stuff */ + swap(a->napi, b->napi); + + if (a->q.type == IONIC_QTYPE_RXQ) { + swap(a->q.page_pool, b->q.page_pool); + a->q.page_pool->p.napi = &a->napi; + if (b->q.page_pool) /* is NULL when increasing queue count */ + b->q.page_pool->p.napi = &b->napi; + } + swap(a->q.features, b->q.features); swap(a->q.num_descs, b->q.num_descs); swap(a->q.desc_size, b->q.desc_size); @@ -2943,7 +2985,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif, err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, 4, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_tx_desc_info), - lif->kern_pid, &lif->txqcqs[i]); + lif->kern_pid, NULL, &lif->txqcqs[i]); if (err) goto err_out; } @@ -2952,7 +2994,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif, err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, num_desc, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_tx_desc_info), - lif->kern_pid, &tx_qcqs[i]); + lif->kern_pid, NULL, &tx_qcqs[i]); if (err) goto err_out; } @@ -2974,7 +3016,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif, err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, 4, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_rx_desc_info), - lif->kern_pid, &lif->rxqcqs[i]); + lif->kern_pid, NULL, &lif->rxqcqs[i]); if (err) goto err_out; } @@ -2983,7 +3025,7 @@ int ionic_reconfigure_queues(struct ionic_lif *lif, err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, num_desc, desc_sz, comp_sz, sg_desc_sz, sizeof(struct ionic_rx_desc_info), - lif->kern_pid, &rx_qcqs[i]); + lif->kern_pid, qparam->xdp_prog, &rx_qcqs[i]); if (err) goto err_out; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 858ab4fd9218..35e3751dd5a7 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "ionic.h" #include "ionic_lif.h" @@ -118,108 +119,57 @@ static void *ionic_rx_buf_va(struct ionic_buf_info *buf_info) static dma_addr_t ionic_rx_buf_pa(struct ionic_buf_info *buf_info) { - return buf_info->dma_addr + buf_info->page_offset; + return page_pool_get_dma_addr(buf_info->page) + buf_info->page_offset; } -static unsigned int ionic_rx_buf_size(struct ionic_buf_info *buf_info) +static void __ionic_rx_put_buf(struct ionic_queue *q, + struct ionic_buf_info *buf_info, + bool recycle_direct) { - return min_t(u32, IONIC_MAX_BUF_LEN, IONIC_PAGE_SIZE - buf_info->page_offset); -} - -static int ionic_rx_page_alloc(struct ionic_queue *q, - struct ionic_buf_info *buf_info) -{ - struct device *dev = q->dev; - dma_addr_t dma_addr; - struct page *page; - - page = alloc_pages(IONIC_PAGE_GFP_MASK, 0); - if (unlikely(!page)) { - net_err_ratelimited("%s: %s page alloc failed\n", - dev_name(dev), q->name); - q_to_rx_stats(q)->alloc_err++; - return -ENOMEM; - } - - dma_addr = dma_map_page(dev, page, 0, - IONIC_PAGE_SIZE, DMA_FROM_DEVICE); - if (unlikely(dma_mapping_error(dev, dma_addr))) { - __free_pages(page, 0); - net_err_ratelimited("%s: %s dma map failed\n", - dev_name(dev), q->name); - q_to_rx_stats(q)->dma_map_err++; - return -EIO; - } - - buf_info->dma_addr = dma_addr; - buf_info->page = page; - buf_info->page_offset = 0; - - return 0; -} - -static void ionic_rx_page_free(struct ionic_queue *q, - struct ionic_buf_info *buf_info) -{ - struct device *dev = q->dev; - - if (unlikely(!buf_info)) { - net_err_ratelimited("%s: %s invalid buf_info in free\n", - dev_name(dev), q->name); - return; - } - if (!buf_info->page) return; - dma_unmap_page(dev, buf_info->dma_addr, IONIC_PAGE_SIZE, DMA_FROM_DEVICE); - __free_pages(buf_info->page, 0); + page_pool_put_full_page(q->page_pool, buf_info->page, recycle_direct); buf_info->page = NULL; + buf_info->len = 0; + buf_info->page_offset = 0; } -static bool ionic_rx_buf_recycle(struct ionic_queue *q, - struct ionic_buf_info *buf_info, u32 len) -{ - u32 size; - - /* don't re-use pages allocated in low-mem condition */ - if (page_is_pfmemalloc(buf_info->page)) - return false; - - /* don't re-use buffers from non-local numa nodes */ - if (page_to_nid(buf_info->page) != numa_mem_id()) - return false; - - size = ALIGN(len, q->xdp_prog ? IONIC_PAGE_SIZE : IONIC_PAGE_SPLIT_SZ); - buf_info->page_offset += size; - if (buf_info->page_offset >= IONIC_PAGE_SIZE) - return false; - get_page(buf_info->page); +static void ionic_rx_put_buf(struct ionic_queue *q, + struct ionic_buf_info *buf_info) +{ + __ionic_rx_put_buf(q, buf_info, false); +} - return true; +static void ionic_rx_put_buf_direct(struct ionic_queue *q, + struct ionic_buf_info *buf_info) +{ + __ionic_rx_put_buf(q, buf_info, true); } static void ionic_rx_add_skb_frag(struct ionic_queue *q, struct sk_buff *skb, struct ionic_buf_info *buf_info, - u32 off, u32 len, + u32 headroom, u32 len, bool synced) { if (!synced) - dma_sync_single_range_for_cpu(q->dev, ionic_rx_buf_pa(buf_info), - off, len, DMA_FROM_DEVICE); + page_pool_dma_sync_for_cpu(q->page_pool, + buf_info->page, + buf_info->page_offset + headroom, + len); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, - buf_info->page, buf_info->page_offset + off, - len, - IONIC_PAGE_SIZE); + buf_info->page, buf_info->page_offset + headroom, + len, buf_info->len); - if (!ionic_rx_buf_recycle(q, buf_info, len)) { - dma_unmap_page(q->dev, buf_info->dma_addr, - IONIC_PAGE_SIZE, DMA_FROM_DEVICE); - buf_info->page = NULL; - } + /* napi_gro_frags() will release/recycle the + * page_pool buffers from the frags list + */ + buf_info->page = NULL; + buf_info->len = 0; + buf_info->page_offset = 0; } static struct sk_buff *ionic_rx_build_skb(struct ionic_queue *q, @@ -244,12 +194,13 @@ static struct sk_buff *ionic_rx_build_skb(struct ionic_queue *q, q_to_rx_stats(q)->alloc_err++; return NULL; } + skb_mark_for_recycle(skb); if (headroom) frag_len = min_t(u16, len, IONIC_XDP_MAX_LINEAR_MTU + VLAN_ETH_HLEN); else - frag_len = min_t(u16, len, ionic_rx_buf_size(buf_info)); + frag_len = min_t(u16, len, IONIC_PAGE_SIZE); if (unlikely(!buf_info->page)) goto err_bad_buf_page; @@ -260,7 +211,7 @@ static struct sk_buff *ionic_rx_build_skb(struct ionic_queue *q, for (i = 0; i < num_sg_elems; i++, buf_info++) { if (unlikely(!buf_info->page)) goto err_bad_buf_page; - frag_len = min_t(u16, len, ionic_rx_buf_size(buf_info)); + frag_len = min_t(u16, len, buf_info->len); ionic_rx_add_skb_frag(q, skb, buf_info, 0, frag_len, synced); len -= frag_len; } @@ -277,11 +228,13 @@ static struct sk_buff *ionic_rx_copybreak(struct net_device *netdev, struct ionic_rx_desc_info *desc_info, unsigned int headroom, unsigned int len, + unsigned int num_sg_elems, bool synced) { struct ionic_buf_info *buf_info; struct device *dev = q->dev; struct sk_buff *skb; + int i; buf_info = &desc_info->bufs[0]; @@ -292,54 +245,52 @@ static struct sk_buff *ionic_rx_copybreak(struct net_device *netdev, q_to_rx_stats(q)->alloc_err++; return NULL; } - - if (unlikely(!buf_info->page)) { - dev_kfree_skb(skb); - return NULL; - } + skb_mark_for_recycle(skb); if (!synced) - dma_sync_single_range_for_cpu(dev, ionic_rx_buf_pa(buf_info), - headroom, len, DMA_FROM_DEVICE); + page_pool_dma_sync_for_cpu(q->page_pool, + buf_info->page, + buf_info->page_offset + headroom, + len); + skb_copy_to_linear_data(skb, ionic_rx_buf_va(buf_info) + headroom, len); - dma_sync_single_range_for_device(dev, ionic_rx_buf_pa(buf_info), - headroom, len, DMA_FROM_DEVICE); skb_put(skb, len); skb->protocol = eth_type_trans(skb, netdev); + /* recycle the Rx buffer now that we're done with it */ + ionic_rx_put_buf_direct(q, buf_info); + buf_info++; + for (i = 0; i < num_sg_elems; i++, buf_info++) + ionic_rx_put_buf_direct(q, buf_info); + return skb; } static void ionic_xdp_tx_desc_clean(struct ionic_queue *q, - struct ionic_tx_desc_info *desc_info) + struct ionic_tx_desc_info *desc_info, + bool in_napi) { - unsigned int nbufs = desc_info->nbufs; - struct ionic_buf_info *buf_info; - struct device *dev = q->dev; - int i; + struct xdp_frame_bulk bq; - if (!nbufs) + if (!desc_info->nbufs) return; - buf_info = desc_info->bufs; - dma_unmap_single(dev, buf_info->dma_addr, - buf_info->len, DMA_TO_DEVICE); - if (desc_info->act == XDP_TX) - __free_pages(buf_info->page, 0); - buf_info->page = NULL; + xdp_frame_bulk_init(&bq); + rcu_read_lock(); /* need for xdp_return_frame_bulk */ - buf_info++; - for (i = 1; i < nbufs + 1 && buf_info->page; i++, buf_info++) { - dma_unmap_page(dev, buf_info->dma_addr, - buf_info->len, DMA_TO_DEVICE); - if (desc_info->act == XDP_TX) - __free_pages(buf_info->page, 0); - buf_info->page = NULL; + if (desc_info->act == XDP_TX) { + if (likely(in_napi)) + xdp_return_frame_rx_napi(desc_info->xdpf); + else + xdp_return_frame(desc_info->xdpf); + } else if (desc_info->act == XDP_REDIRECT) { + ionic_tx_desc_unmap_bufs(q, desc_info); + xdp_return_frame_bulk(desc_info->xdpf, &bq); } - if (desc_info->act == XDP_REDIRECT) - xdp_return_frame(desc_info->xdpf); + xdp_flush_frame_bulk(&bq); + rcu_read_unlock(); desc_info->nbufs = 0; desc_info->xdpf = NULL; @@ -363,9 +314,17 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame, buf_info = desc_info->bufs; stats = q_to_tx_stats(q); - dma_addr = ionic_tx_map_single(q, frame->data, len); - if (!dma_addr) - return -EIO; + if (act == XDP_TX) { + dma_addr = page_pool_get_dma_addr(page) + + off + XDP_PACKET_HEADROOM; + dma_sync_single_for_device(q->dev, dma_addr, + len, DMA_TO_DEVICE); + } else /* XDP_REDIRECT */ { + dma_addr = ionic_tx_map_single(q, frame->data, len); + if (!dma_addr) + return -EIO; + } + buf_info->dma_addr = dma_addr; buf_info->len = len; buf_info->page = page; @@ -387,10 +346,21 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame, frag = sinfo->frags; elem = ionic_tx_sg_elems(q); for (i = 0; i < sinfo->nr_frags; i++, frag++, bi++) { - dma_addr = ionic_tx_map_frag(q, frag, 0, skb_frag_size(frag)); - if (!dma_addr) { - ionic_tx_desc_unmap_bufs(q, desc_info); - return -EIO; + if (act == XDP_TX) { + struct page *pg = skb_frag_page(frag); + + dma_addr = page_pool_get_dma_addr(pg) + + skb_frag_off(frag); + dma_sync_single_for_device(q->dev, dma_addr, + skb_frag_size(frag), + DMA_TO_DEVICE); + } else { + dma_addr = ionic_tx_map_frag(q, frag, 0, + skb_frag_size(frag)); + if (dma_mapping_error(q->dev, dma_addr)) { + ionic_tx_desc_unmap_bufs(q, desc_info); + return -EIO; + } } bi->dma_addr = dma_addr; bi->len = skb_frag_size(frag); @@ -488,8 +458,6 @@ static void ionic_xdp_rx_unlink_bufs(struct ionic_queue *q, int i; for (i = 0; i < nbufs; i++) { - dma_unmap_page(q->dev, buf_info->dma_addr, - IONIC_PAGE_SIZE, DMA_FROM_DEVICE); buf_info->page = NULL; buf_info++; } @@ -516,11 +484,9 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, frag_len = min_t(u16, len, IONIC_XDP_MAX_LINEAR_MTU + VLAN_ETH_HLEN); xdp_prepare_buff(&xdp_buf, ionic_rx_buf_va(buf_info), XDP_PACKET_HEADROOM, frag_len, false); - - dma_sync_single_range_for_cpu(rxq->dev, ionic_rx_buf_pa(buf_info), - XDP_PACKET_HEADROOM, frag_len, - DMA_FROM_DEVICE); - + page_pool_dma_sync_for_cpu(rxq->page_pool, buf_info->page, + buf_info->page_offset + XDP_PACKET_HEADROOM, + frag_len); prefetchw(&xdp_buf.data_hard_start); /* We limit MTU size to one buffer if !xdp_has_frags, so @@ -542,15 +508,16 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, do { if (unlikely(sinfo->nr_frags >= MAX_SKB_FRAGS)) { err = -ENOSPC; - goto out_xdp_abort; + break; } frag = &sinfo->frags[sinfo->nr_frags]; sinfo->nr_frags++; bi++; - frag_len = min_t(u16, remain_len, ionic_rx_buf_size(bi)); - dma_sync_single_range_for_cpu(rxq->dev, ionic_rx_buf_pa(bi), - 0, frag_len, DMA_FROM_DEVICE); + frag_len = min_t(u16, remain_len, bi->len); + page_pool_dma_sync_for_cpu(rxq->page_pool, bi->page, + buf_info->page_offset, + frag_len); skb_frag_fill_page_desc(frag, bi->page, 0, frag_len); sinfo->xdp_frags_size += frag_len; remain_len -= frag_len; @@ -569,14 +536,16 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, return false; /* false = we didn't consume the packet */ case XDP_DROP: - ionic_rx_page_free(rxq, buf_info); + ionic_rx_put_buf_direct(rxq, buf_info); stats->xdp_drop++; break; case XDP_TX: xdpf = xdp_convert_buff_to_frame(&xdp_buf); - if (!xdpf) - goto out_xdp_abort; + if (!xdpf) { + err = -ENOSPC; + break; + } txq = rxq->partner; nq = netdev_get_tx_queue(netdev, txq->index); @@ -588,7 +557,8 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, ionic_q_space_avail(txq), 1, 1)) { __netif_tx_unlock(nq); - goto out_xdp_abort; + err = -EIO; + break; } err = ionic_xdp_post_frame(txq, xdpf, XDP_TX, @@ -598,19 +568,17 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, __netif_tx_unlock(nq); if (unlikely(err)) { netdev_dbg(netdev, "tx ionic_xdp_post_frame err %d\n", err); - goto out_xdp_abort; + break; } ionic_xdp_rx_unlink_bufs(rxq, buf_info, nbufs); stats->xdp_tx++; - - /* the Tx completion will free the buffers */ break; case XDP_REDIRECT: err = xdp_do_redirect(netdev, &xdp_buf, xdp_prog); if (unlikely(err)) { netdev_dbg(netdev, "xdp_do_redirect err %d\n", err); - goto out_xdp_abort; + break; } ionic_xdp_rx_unlink_bufs(rxq, buf_info, nbufs); rxq->xdp_flush = true; @@ -619,15 +587,15 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, case XDP_ABORTED: default: - goto out_xdp_abort; + err = -EIO; + break; } - return true; - -out_xdp_abort: - trace_xdp_exception(netdev, xdp_prog, xdp_action); - ionic_rx_page_free(rxq, buf_info); - stats->xdp_aborted++; + if (err) { + ionic_rx_put_buf_direct(rxq, buf_info); + trace_xdp_exception(netdev, xdp_prog, xdp_action); + stats->xdp_aborted++; + } return true; } @@ -673,7 +641,8 @@ static void ionic_rx_clean(struct ionic_queue *q, use_copybreak = len <= q->lif->rx_copybreak; if (use_copybreak) skb = ionic_rx_copybreak(netdev, q, desc_info, - headroom, len, synced); + headroom, len, + comp->num_sg_elems, synced); else skb = ionic_rx_build_skb(q, desc_info, headroom, len, comp->num_sg_elems, synced); @@ -794,6 +763,9 @@ void ionic_rx_fill(struct ionic_queue *q) struct ionic_buf_info *buf_info; unsigned int fill_threshold; struct ionic_rxq_desc *desc; + unsigned int first_frag_len; + unsigned int first_buf_len; + unsigned int headroom = 0; unsigned int remain_len; unsigned int frag_len; unsigned int nfrags; @@ -811,35 +783,42 @@ void ionic_rx_fill(struct ionic_queue *q) len = netdev->mtu + VLAN_ETH_HLEN; - for (i = n_fill; i; i--) { - unsigned int headroom = 0; - unsigned int buf_len; + if (q->xdp_prog) { + /* Always alloc the full size buffer, but only need + * the actual frag_len in the descriptor + * XDP uses space in the first buffer, so account for + * head room, tail room, and ip header in the first frag size. + */ + headroom = XDP_PACKET_HEADROOM; + first_buf_len = IONIC_XDP_MAX_LINEAR_MTU + VLAN_ETH_HLEN + headroom; + first_frag_len = min_t(u16, len + headroom, first_buf_len); + } else { + /* Use MTU size if smaller than max buffer size */ + first_frag_len = min_t(u16, len, IONIC_PAGE_SIZE); + first_buf_len = first_frag_len; + } + for (i = n_fill; i; i--) { + /* fill main descriptor - buf[0] */ nfrags = 0; remain_len = len; desc = &q->rxq[q->head_idx]; desc_info = &q->rx_info[q->head_idx]; buf_info = &desc_info->bufs[0]; - if (!buf_info->page) { /* alloc a new buffer? */ - if (unlikely(ionic_rx_page_alloc(q, buf_info))) { - desc->addr = 0; - desc->len = 0; - return; - } - } - - /* fill main descriptor - buf[0] - * XDP uses space in the first buffer, so account for - * head room, tail room, and ip header in the first frag size. - */ - if (q->xdp_prog) { - buf_len = IONIC_XDP_MAX_LINEAR_MTU + VLAN_ETH_HLEN; - headroom = XDP_PACKET_HEADROOM; - } else { - buf_len = ionic_rx_buf_size(buf_info); + buf_info->len = first_buf_len; + frag_len = first_frag_len - headroom; + + /* get a new buffer if we can't reuse one */ + if (!buf_info->page) + buf_info->page = page_pool_alloc(q->page_pool, + &buf_info->page_offset, + &buf_info->len, + GFP_ATOMIC); + if (unlikely(!buf_info->page)) { + buf_info->len = 0; + return; } - frag_len = min_t(u16, len, buf_len); desc->addr = cpu_to_le64(ionic_rx_buf_pa(buf_info) + headroom); desc->len = cpu_to_le16(frag_len); @@ -850,16 +829,26 @@ void ionic_rx_fill(struct ionic_queue *q) /* fill sg descriptors - buf[1..n] */ sg_elem = q->rxq_sgl[q->head_idx].elems; for (j = 0; remain_len > 0 && j < q->max_sg_elems; j++, sg_elem++) { - if (!buf_info->page) { /* alloc a new sg buffer? */ - if (unlikely(ionic_rx_page_alloc(q, buf_info))) { - sg_elem->addr = 0; - sg_elem->len = 0; + frag_len = min_t(u16, remain_len, IONIC_PAGE_SIZE); + + /* Recycle any leftover buffers that are too small to reuse */ + if (unlikely(buf_info->page && buf_info->len < frag_len)) + ionic_rx_put_buf_direct(q, buf_info); + + /* Get new buffer if needed */ + if (!buf_info->page) { + buf_info->len = frag_len; + buf_info->page = page_pool_alloc(q->page_pool, + &buf_info->page_offset, + &buf_info->len, + GFP_ATOMIC); + if (unlikely(!buf_info->page)) { + buf_info->len = 0; return; } } sg_elem->addr = cpu_to_le64(ionic_rx_buf_pa(buf_info)); - frag_len = min_t(u16, remain_len, ionic_rx_buf_size(buf_info)); sg_elem->len = cpu_to_le16(frag_len); remain_len -= frag_len; buf_info++; @@ -889,17 +878,12 @@ void ionic_rx_fill(struct ionic_queue *q) void ionic_rx_empty(struct ionic_queue *q) { struct ionic_rx_desc_info *desc_info; - struct ionic_buf_info *buf_info; unsigned int i, j; for (i = 0; i < q->num_descs; i++) { desc_info = &q->rx_info[i]; - for (j = 0; j < ARRAY_SIZE(desc_info->bufs); j++) { - buf_info = &desc_info->bufs[j]; - if (buf_info->page) - ionic_rx_page_free(q, buf_info); - } - + for (j = 0; j < ARRAY_SIZE(desc_info->bufs); j++) + ionic_rx_put_buf(q, &desc_info->bufs[j]); desc_info->nbufs = 0; } @@ -1172,7 +1156,7 @@ static void ionic_tx_clean(struct ionic_queue *q, struct sk_buff *skb; if (desc_info->xdpf) { - ionic_xdp_tx_desc_clean(q->partner, desc_info); + ionic_xdp_tx_desc_clean(q->partner, desc_info, in_napi); stats->clean++; if (unlikely(__netif_subqueue_stopped(q->lif->netdev, q->index))) From patchwork Fri Sep 6 23:26:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brett Creeley X-Patchwork-Id: 13794869 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2042.outbound.protection.outlook.com [40.107.223.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72FC115B15D for ; Fri, 6 Sep 2024 23:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665207; cv=fail; b=LYXT8iILskFWGW/uDHsrJcsm2Y+/3vmjcHbKmDdgblDxwM3ip1jeOP3cDx+vT+SUUXHTE2DtGjiC54mS9rRzaq6GFKZY0XdM7a1Sm4fm5Wb4s21Z/uS2dJGzit0G2LvmuASCc6nimDyBJYS2foMsR5npitAMBdxJ8H/guGnxnio= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725665207; c=relaxed/simple; bh=EifgC7wuYchGB6lRz7K10XrJxp7sDpBs/4LBBIt4tcI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aSGe1UMV1FZe9xanUFhhN7o6+lxFTJdDPBwa5RdwMZeQkRXSDbGqNkCNhfdHyA2CXAm32iB9HTV8VOJick9CanCidM3w1NRjPRJ7UoIRMolQYfCP/G5cxkd78VM/xJzgQ5oWo0oN4MM0xRtUWmw4JNo/nW9ZZAisYcTA5MRnlbw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=vZLda7GX; arc=fail smtp.client-ip=40.107.223.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vZLda7GX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Npvdw0S/QOv0HSK0H+TVE7V+CvsKaK3Mb+aPmaE5sKhnpivvBjYSzU9uYqZjh26oDyhzNRXEgnzyCkQzUpoeL/gTdnikLcC84vpXYOpz+05ijcBFdZsr4LXlbBBZ510eMpll7DvAp2skzq8Sc49pLTgglzvI+yExEw5q6c3q+n5Tw0JS4dLe4fLJ/VwGm9QxY3XxZM/fvLjpQvqrLad81QUrsw7vzmpp7alIeObpeFOsdzhripxafTJITdhkhc2T02JgK6cixM1wM7f4qNXNuza+S/3k0FAyndAa5tw8qMtIj1KjLILBogTaK1lKwOmpp18eqiZDCo1Nl0y+jvUx6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jfUDM545Wj3CTKEshVQwJJzWX1t+D2LNqFTybP5ZFKY=; b=PYgqQSixM/yaDCX5PvsuYI5Madf4J1uheVnZ/EInvmPIWHXmCdDH7vLw62yvN25uq+8v2Uj3FR9K8YLFly/MlWK+GvYrPklZeyiTO/URqjkMuJSHd47SDunHaKmcTi32MsJQl8OjAjefBt/LYKHoCItvkzQ2gdALsQyzBGo1UiXdZcuRPHiN9K5cS35l8YBOXc28HTBcV1yvRYu1LCU5Esd9R3Dcgsjrp/JKZ16/tsoJXWGuB7UysdtVA8qogYCi9WXFcxeh064Ue7sUSnUTLgFpKnS0MpkN7ptOYavpKLCtJ/zbTUK4ihr0wh/VugrbZmmL3+Py9+W9yk/L4oY43A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 (0) 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=jfUDM545Wj3CTKEshVQwJJzWX1t+D2LNqFTybP5ZFKY=; b=vZLda7GX/6RtzO+oGZNdF9LuavxaAPrpmgUugYLwhpqPUfr4atmOpIdSOvoH3hQ8GigsNzR4GHSXIL4DgvMNP6YduWFF8AnKH1X/zM0rHEymsJnza+mjhAbXPyevUaMBwbTl6NuIW0QgahqEdlDwBU7DjCDkq7Vvl3vCpTY8tzE= Received: from PH7PR17CA0066.namprd17.prod.outlook.com (2603:10b6:510:325::15) by CH3PR12MB8482.namprd12.prod.outlook.com (2603:10b6:610:15b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Fri, 6 Sep 2024 23:26:40 +0000 Received: from SN1PEPF000397B4.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::11) by PH7PR17CA0066.outlook.office365.com (2603:10b6:510:325::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.17 via Frontend Transport; Fri, 6 Sep 2024 23:26:40 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SN1PEPF000397B4.mail.protection.outlook.com (10.167.248.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 23:26:40 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 18:26:38 -0500 From: Brett Creeley To: , , , , CC: , Subject: [PATCH v3 net-next 7/7] ionic: Allow XDP program to be hot swapped Date: Fri, 6 Sep 2024 16:26:23 -0700 Message-ID: <20240906232623.39651-8-brett.creeley@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240906232623.39651-1-brett.creeley@amd.com> References: <20240906232623.39651-1-brett.creeley@amd.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B4:EE_|CH3PR12MB8482:EE_ X-MS-Office365-Filtering-Correlation-Id: ea3a777c-383f-4448-e409-08dccecb5c60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: BgrhnrBvproo3Sr69I9W6+38KchSVKYsRPne98gSt0k8c0Sk6rjfEpvo2OTlXQBEUdPExfofPCGdjzdnGQGAa2R9nBgegrW7dA6DVea5OHLNT5ORtCMgIwBpooraNR8X6uULQmzIixvUtZNLL7uEQ+Cx8vwLmf8ZjGpwY4uqd49QBPQDUt99a9ShDOkn6e4+5V5r015UWFIbt4dZWkZ/YknerzBC26w+9gNPeiSxN1bmvZMZdDpGxtXhf90Xe/aWvskla3COe2FhJm+nQE/kPy3Dpq/+TNWmV0pOyYMGJZSOdW50EY7wPhXxHBwx1sgRNC8Lq6IiMjBQngCjtUThcieMBHfTgA5m2hiBPhoAAgWGtz5f9jBgK7UnnVziY6J71uC8SkOWFAVd9dm3WKRtXl+kcq5yC3UHieCGWbGzx8AV36ev3sDT5ZZ0zimAJsvRRXUzvxIPu0z3FqoXjqfEZtNvoh/FiQJ0IrVL4RLahD94lLjtjDXNoY1LJfSYh2l7jl5Wqt0JcGDr6zwed11eQw8tXXrpNLkDbT+HEMbuJoSmDCqN/LnyGtuwQ4ie9KuWU7Xf8hrUBxRYjMrooV5LDw/6NlBkfsSQWJi96ktpW62m7nX6DsEQWD4UHg8utkqkUD4HS1VAiH8CU4xinxs0fUseMq+/zZv1OetVN4YZtFg6bbaG9dYleklCYPIH4paxErThb5HJJYSzho0BeKr3Dapt5J6pMxOeN7m3CyEWd2wKVFK7gFw4uicV+q0qLsZDuvlaa/0P0cRkgpPt6DjWyIfLtAER7djtMfOUA6sFn3pVhG4Zc72oHPYL3AhVP8Kl0ykEZp/w7NmhgU3M47kDyK3+iSRBFjh5m4/LMuZCq21WzNYEXW87iR9NxTCBwLrIBFirVopG0umhEd0M4hY7fdQ373Fxw+3pSxHjoyk5YN4LR4KHbf5jfq0+n1t7Av6lPyE+Rmd2Erj4SVXzr8cDxfGGXfPuJjAgxI9X7XZoMEdm1nec1kJUu3yvv4k3atAiOiK7GC8zUOZPGbEWnt42Sax7yBa2TOpjx0Nmj2NIIB3WEFnREZGTBDUq6ssFha+6UDxw8SPo3j0XeOmGAZm3xHNhwzx1/Z0YDCITNfoK6qrOiXIysC3AgORGg8JksjyC3Ao8ug4bomU86X49SAfJQzUNgKHFxAVyK/KFcrXQYhL+12Vzb9FRQ2ooZGdMKcuzcJw5XCeCsaogyy8GbWnzwKX7sVeIkiWu+Q/LHw4pMMnp4b3eN96fwSnXuNW4YbPpIbTXWJ+G27ouiJqHqE3k4HppcQdgFxlI/NTZJJ8KS4+Vth/FZDrWeNphpqsajNi7aLUjSHheEEkYC77CUFUoJuB5jfyNAq5X/OHKUNt7e+j6wLZgEFeZiPOBmheBYqnaA+AKJO2p2AnXhEip24v5M0FB52VkXMk1BOvuVjkcyxvr6kPIx/BItJGLviAlqnY/ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 23:26:40.2523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea3a777c-383f-4448-e409-08dccecb5c60 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8482 X-Patchwork-Delegate: kuba@kernel.org Using examples of other driver(s), add the ability to hot-swap an XDP program without having to reconfigure the queues. To prevent the q->xdp_prog to be read/written more than once use READ_ONCE() and WRITE_ONCE() on the q->xdp_prog. The q->xdp_prog was being checked in multiple different for loops in the hot path. The change to allow xdp_prog hot swapping created the possibility for many READ_ONCE(q->xdp_prog) calls during a single napi callback. Refactor the Rx napi handling to allow a previous READ_ONCE(q->xdp_prog) (or NULL for hwstamp_rxq) to be passed into the relevant functions. Also, move other Rx related hotpath handling into the newly created ionic_rx_cq_service() function to reduce the scope of the xdp_prog local variable and put all Rx handling in one function similar to Tx. Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_lif.c | 12 ++-- .../net/ethernet/pensando/ionic/ionic_txrx.c | 58 +++++++++++++------ .../net/ethernet/pensando/ionic/ionic_txrx.h | 4 +- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 59d3eea2c0bc..a3965532464f 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -1074,7 +1074,7 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) goto err_qcq_init; if (test_bit(IONIC_LIF_F_UP, lif->state)) { - ionic_rx_fill(&rxq->q); + ionic_rx_fill(&rxq->q, NULL); err = ionic_qcq_enable(rxq); if (err) goto err_qcq_enable; @@ -2190,7 +2190,8 @@ static int ionic_txrx_enable(struct ionic_lif *lif) goto err_out; } - ionic_rx_fill(&lif->rxqcqs[i]->q); + ionic_rx_fill(&lif->rxqcqs[i]->q, + READ_ONCE(lif->rxqcqs[i]->q.xdp_prog)); err = ionic_qcq_enable(lif->rxqcqs[i]); if (err) goto err_out; @@ -2203,7 +2204,7 @@ static int ionic_txrx_enable(struct ionic_lif *lif) } if (lif->hwstamp_rxq) { - ionic_rx_fill(&lif->hwstamp_rxq->q); + ionic_rx_fill(&lif->hwstamp_rxq->q, NULL); err = ionic_qcq_enable(lif->hwstamp_rxq); if (err) goto err_out_hwstamp_rx; @@ -2746,7 +2747,7 @@ static void ionic_xdp_rxqs_prog_update(struct ionic_lif *lif) for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) { struct ionic_queue *q = &lif->rxqcqs[i]->q; - q->xdp_prog = xdp_prog; + WRITE_ONCE(q->xdp_prog, xdp_prog); } } @@ -2777,6 +2778,9 @@ static int ionic_xdp_config(struct net_device *netdev, struct netdev_bpf *bpf) if (!netif_running(netdev)) { old_prog = xchg(&lif->xdp_prog, bpf->prog); + } else if (lif->xdp_prog && bpf->prog) { + old_prog = xchg(&lif->xdp_prog, bpf->prog); + ionic_xdp_rxqs_prog_update(lif); } else { struct ionic_queue_params qparams; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 35e3751dd5a7..0eeda7e502db 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -602,7 +602,8 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, static void ionic_rx_clean(struct ionic_queue *q, struct ionic_rx_desc_info *desc_info, - struct ionic_rxq_comp *comp) + struct ionic_rxq_comp *comp, + struct bpf_prog *xdp_prog) { struct net_device *netdev = q->lif->netdev; struct ionic_qcq *qcq = q_to_qcq(q); @@ -631,8 +632,8 @@ static void ionic_rx_clean(struct ionic_queue *q, stats->pkts++; stats->bytes += len; - if (q->xdp_prog) { - if (ionic_run_xdp(stats, netdev, q->xdp_prog, q, desc_info->bufs, len)) + if (xdp_prog) { + if (ionic_run_xdp(stats, netdev, xdp_prog, q, desc_info->bufs, len)) return; synced = true; headroom = XDP_PACKET_HEADROOM; @@ -718,7 +719,7 @@ static void ionic_rx_clean(struct ionic_queue *q, napi_gro_frags(&qcq->napi); } -bool ionic_rx_service(struct ionic_cq *cq) +static bool __ionic_rx_service(struct ionic_cq *cq, struct bpf_prog *xdp_prog) { struct ionic_rx_desc_info *desc_info; struct ionic_queue *q = cq->bound_q; @@ -740,11 +741,16 @@ bool ionic_rx_service(struct ionic_cq *cq) q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1); /* clean the related q entry, only one per qc completion */ - ionic_rx_clean(q, desc_info, comp); + ionic_rx_clean(q, desc_info, comp, xdp_prog); return true; } +bool ionic_rx_service(struct ionic_cq *cq) +{ + return __ionic_rx_service(cq, NULL); +} + static inline void ionic_write_cmb_desc(struct ionic_queue *q, void *desc) { @@ -755,7 +761,7 @@ static inline void ionic_write_cmb_desc(struct ionic_queue *q, memcpy_toio(&q->cmb_txq[q->head_idx], desc, sizeof(q->cmb_txq[0])); } -void ionic_rx_fill(struct ionic_queue *q) +void ionic_rx_fill(struct ionic_queue *q, struct bpf_prog *xdp_prog) { struct net_device *netdev = q->lif->netdev; struct ionic_rx_desc_info *desc_info; @@ -783,7 +789,7 @@ void ionic_rx_fill(struct ionic_queue *q) len = netdev->mtu + VLAN_ETH_HLEN; - if (q->xdp_prog) { + if (xdp_prog) { /* Always alloc the full size buffer, but only need * the actual frag_len in the descriptor * XDP uses space in the first buffer, so account for @@ -964,6 +970,32 @@ static void ionic_xdp_do_flush(struct ionic_cq *cq) } } +static unsigned int ionic_rx_cq_service(struct ionic_cq *cq, + unsigned int work_to_do) +{ + struct ionic_queue *q = cq->bound_q; + unsigned int work_done = 0; + struct bpf_prog *xdp_prog; + + if (work_to_do == 0) + return 0; + + xdp_prog = READ_ONCE(q->xdp_prog); + while (__ionic_rx_service(cq, xdp_prog)) { + if (cq->tail_idx == cq->num_descs - 1) + cq->done_color = !cq->done_color; + + cq->tail_idx = (cq->tail_idx + 1) & (cq->num_descs - 1); + + if (++work_done >= work_to_do) + break; + } + ionic_rx_fill(q, xdp_prog); + ionic_xdp_do_flush(cq); + + return work_done; +} + int ionic_rx_napi(struct napi_struct *napi, int budget) { struct ionic_qcq *qcq = napi_to_qcq(napi); @@ -974,12 +1006,8 @@ int ionic_rx_napi(struct napi_struct *napi, int budget) if (unlikely(!budget)) return budget; - work_done = ionic_cq_service(cq, budget, - ionic_rx_service, NULL, NULL); + work_done = ionic_rx_cq_service(cq, budget); - ionic_rx_fill(cq->bound_q); - - ionic_xdp_do_flush(cq); if (work_done < budget && napi_complete_done(napi, work_done)) { ionic_dim_update(qcq, IONIC_LIF_F_RX_DIM_INTR); flags |= IONIC_INTR_CRED_UNMASK; @@ -1020,12 +1048,8 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget) if (unlikely(!budget)) return budget; - rx_work_done = ionic_cq_service(rxcq, budget, - ionic_rx_service, NULL, NULL); - - ionic_rx_fill(rxcq->bound_q); + rx_work_done = ionic_rx_cq_service(rxcq, budget); - ionic_xdp_do_flush(rxcq); if (rx_work_done < budget && napi_complete_done(napi, rx_work_done)) { ionic_dim_update(rxqcq, 0); flags |= IONIC_INTR_CRED_UNMASK; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h index 9e73e324e7a1..b2b9a2dc9eb8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h @@ -4,9 +4,11 @@ #ifndef _IONIC_TXRX_H_ #define _IONIC_TXRX_H_ +struct bpf_prog; + void ionic_tx_flush(struct ionic_cq *cq); -void ionic_rx_fill(struct ionic_queue *q); +void ionic_rx_fill(struct ionic_queue *q, struct bpf_prog *xdp_prog); void ionic_rx_empty(struct ionic_queue *q); void ionic_tx_empty(struct ionic_queue *q); int ionic_rx_napi(struct napi_struct *napi, int budget);