From patchwork Thu Jan 18 19:24:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523122 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) (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 5CB7F34CD5 for ; Thu, 18 Jan 2024 19:25:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605927; cv=fail; b=qDLwltKuuD/TyfMIRvAZVFzoHsWQoeo5+4bn5OoXhP3vYsAX/RFDPC/bqCTiWKm2IbZrFGF2objs3t0Gci5r1b8J3mo8lgQCIDUieORrWuyMs9W77uyyJRgQNxqkro9wQX0cEUgXk8rvoUM358+e2bCVzeUBS9mMow67AI5evPk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605927; c=relaxed/simple; bh=sNszYVzy97tZvq6Lf4y5DUNzPnBJqXe4AyLe/nUH2S0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NWLQz04S7v7xK0S64VGi6ryGLS4rRyrZ+nIEqU01f6/rzG9xuP8PXJINcw4mgIYcQLoqejQUSIHU8zt9iOcdRwW3TL326jZJrWE4aSEpgae2s+xteXtDPF7XGPDllUps9pgEJCIgOQ13U8AcVMgKyoqLs0593U5DrvTp5UMigR4= 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=Q5CH6HxG; arc=fail smtp.client-ip=40.107.237.78 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="Q5CH6HxG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A5P2iY0HpLqmuoAy9M22AE0xXP6qWwHD4iLl1UlWyfvXqMgYYl/Rjhm3ss3rLXw3DtHFOdluFAiGWsD+iipQf5I18IftxVrtb/u4I9OZRZ1iUMDfg2Hsk7ot+H5IPt7JGPvMvhcaanbezYRzVB+YeJFqieaeUEyJvllEAC8Hqv3oTosDkTDQAj5ZBn+PLrXM94uqVh1jcW18hqUy+dIvdrxsYrvcFU855SHdwp1hIx4DSHiSsb99fjkf/zwJJw6bxMslPHoxPMfa6oPjEbjpzsjRNu5fpagzlfYNirvD/o7ltyQxsniLdAPCINL6xvm25Qor681Lsm+jecjxpW3Dhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Iuqd0UJRY/8Pef92ox+L6iZYimdz3aw3Vpdb8kHYg9I=; b=OB74IVxuNEOopEOWcSY7z362ZN/7dZk9gvUYaJm9LhErArNx/Aa0kFo7VNK92w0gAwNW2vPaCjy+h4KUwWCsfqUmo5YSZx1jLTFVRY98E7v9f0rARXmqpCvtWcJBkUWyBnh9wAjtWKQAFq/7F5vmGwKNCbsfyKMpoYlgv5CtcBAXOZA0gmuS0HhKMLjF29WVD01uEQFb9o1+l9rWVO0e4JpUyaMIIeqR5WcxefzPWgOFo6KpdvKExpb+pKY7tXUupxaSAtIu3Q2k7P3OO6vGqiNEU2PUUp9SNLpIH11018RueC7dhaCbsCSmW3zHOWgGJuG7gCIDjayIO6+oZSNHtw== 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=Iuqd0UJRY/8Pef92ox+L6iZYimdz3aw3Vpdb8kHYg9I=; b=Q5CH6HxGGBwZntjRW05ZqQwfPCTyLU4zNHFxpk//pC3suRMLP/AeTqEzDT1jLyzIOywv6seRrQ0Gelb9bWBjLdtQTuD4cAw40TNseJAVSw0hnvz82sBmas+boVEmDbAbymciHDgYDuVbTwMvk4ybO3l/zvbJ6u2kZ9WFJHAfMBU= Received: from DS7PR05CA0094.namprd05.prod.outlook.com (2603:10b6:8:56::11) by BY5PR12MB4193.namprd12.prod.outlook.com (2603:10b6:a03:20c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Thu, 18 Jan 2024 19:25:22 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::10) by DS7PR05CA0094.outlook.office365.com (2603:10b6:8:56::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:22 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:17 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 1/9] ionic: set adminq irq affinity Date: Thu, 18 Jan 2024 11:24:52 -0800 Message-ID: <20240118192500.58665-2-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|BY5PR12MB4193:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ac2e847-1160-4e2b-7161-08dc185b36fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +s+Ltrwj4Hq8uVOHTTrpwL6d3X7GE/V9UdU4DmZyG3zU4dKqeC8tbAoCyMoF8V/xyZEfAxzAjEwhiJTPHVd+eetT7FsZvBBPiefM3c8rko+2U98E0I2LnR3NWSNQKiTDGUWImMBB6FpPmooKZtGsg1HYicw+A0Em9WoduCwm6MLwj0XTcGaaEhjoYsuNSCv52qsMqOYu1fCY0U2gZV1BQjlzR1oA4k8j9LK6k/NhwBnQjT/sDgwKA65ZZge6CH0OIJLhoHzN0rFkkQU3b43CFP6B/IZAnIoyZGHah4xSYBYswlGGi/ChIjXRmBBVq7jiEbXPpGH5qvFlQTm9Dj5H9iIVNlkO34sZBmlOeXdkFLz1245TJQSTJuNSvz4zFFtEL+uQQwX1sghnBXoisKXL1ZVEQvUdG3FAXCmxdBFW8t9zqPk6hJ2nxD7vsYtpRupNsXXefCyEWoUBF4Hq06yO3ZjeT1dykDT7Q1ehPTsCJ2gTrcpNYcxN+Gl2N29YtEM05YsCFqGgPW4nU0DXDpxzKrs9ovwicr2QR0N/25S2tdMaboGDWtJZ25YcW6/lJg5RuUhipQ7C1ZZdLIX/8V8AC2iLT6OoLYlpSbVrN850+Gfg53rxQfwaeyCsRkMJzPhcV8oDURx9tYDUIFHGwei5RLOCD56Ity2BucOpIyturbRyYwwAF0P+o7AAVBf5rpDind268cDMF/3uONevFHLrP54Stu3nZ6TPVrtWyva+DFuv1Uqva8x1P3PBF3WyxFfxcohyGFNeKqnMId2co1vvww== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(396003)(346002)(39860400002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(82310400011)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(16526019)(6666004)(8936002)(4326008)(83380400001)(336012)(26005)(8676002)(5660300002)(47076005)(316002)(70586007)(426003)(110136005)(54906003)(70206006)(478600001)(2616005)(44832011)(1076003)(81166007)(356005)(4744005)(82740400003)(41300700001)(2906002)(36756003)(86362001)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:22.2656 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ac2e847-1160-4e2b-7161-08dc185b36fd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4193 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC We claim to have the AdminQ on our irq0 and thus cpu id 0, but we need to be sure we set the affinity hint to try to keep it there. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index cf2d5ad7b68c..d92f8734d153 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -3391,9 +3391,12 @@ static int ionic_lif_adminq_init(struct ionic_lif *lif) napi_enable(&qcq->napi); - if (qcq->flags & IONIC_QCQ_F_INTR) + if (qcq->flags & IONIC_QCQ_F_INTR) { + irq_set_affinity_hint(qcq->intr.vector, + &qcq->intr.affinity_mask); ionic_intr_mask(idev->intr_ctrl, qcq->intr.index, IONIC_INTR_MASK_CLEAR); + } qcq->flags |= IONIC_QCQ_F_INITED; From patchwork Thu Jan 18 19:24:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523126 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2065.outbound.protection.outlook.com [40.107.212.65]) (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 D5F3A2E40F for ; Thu, 18 Jan 2024 19:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605931; cv=fail; b=lSRlJrpf0S0EdvJbL0Ggspu5bXq10EVmgVJgTfXTPsBG2WOsTnbDhxAezO9HYORue4Tou294EI8wLRO6xuGSXM5qVQhK1Rk8iYr2TEBzzG+CLCHv3oOYVWRmXR+BxG8iW+MVQZ7VmyVWps5zkQoiDl82Em78HAkm2ULeJKKFdec= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605931; c=relaxed/simple; bh=iL5lXyQWAEFKMD1KCjiJfwYmdVvwvQxMEdCZgH/4mMQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hih42pOlZPh1hh0gSboe2ZF5tmpTSsXsyQ5QSYHNcdisCWdeEWqNV3dGvjFnW40Yl6dFhxvU0Btz8nRrD+GpdomdxQ+z9aqciyAmWsEIGKoPLfvM8xF2KxgHIulqBFtACxbeqSbjQL5GHFTChB83bvlO3Rirx5xCNmDZJRuw1xo= 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=PkaI6a7C; arc=fail smtp.client-ip=40.107.212.65 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="PkaI6a7C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LOjdJKfKRGmjv26F7EIdXyJjc+xScBBtWFYazXSF68s4QmZzCFi19tNVYLimhq27mheooN4oEh7PCoM2I2KdsEUdDaHGL6Z6bQ7RZ6Iu65+yybzcAitcYELSbxOVREikuqIpJAl03YlPz/Fh8ilM7y8FqwAHofdBjVxiSF2CyfPeTvOb0ssTDk9bX0RpkvQITtEsVZL7YJH5VUbbBWRC6L6g7fTElAUE7XvaeaJTuwUv9dx1ZM7NBt3RWx/ZkGt66hNUc6Cn8l1UcCeuIu+b66HBJtaW2EoW48ewVy+shY4iZBphNyzoCWt3oCTk3rYj5d77m8rVU4j5I4+phNpE3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t301f4OhCMUG6dYYrx2rgTmyo0jKwpEP9FVmIjeyQDU=; b=G3G+iH8FipZJmZ5NLvJMKzaitUBZfRWg1qnWITRckk+h8rUPVZPY5iWAeF9sn/ivOUHRi+QgRak7OfFupfcibF3ntHEv6OoBu5zqamX3KtnVxM+C2RAK6C9trfs2T8eJglnNklT5ZQa+MwN0SyrCIdExwg3yufMF4FyJm7QAzapoTbf2tKEhjBa+EKDSiZIsqcUfMp2QhjrbeiREF5J0LOZuivuT9KpvxgEKm6B61BmBYrgjoZYBEBE9vtFd0XvRiK2djUeTDIbLosfufJ6Uj/XftOVaesTB/c7eSx7TU5vVYtzBw8I8LT+PAQJxvZsivkYUjrcx9esfawZ225+fwQ== 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=t301f4OhCMUG6dYYrx2rgTmyo0jKwpEP9FVmIjeyQDU=; b=PkaI6a7CmAW4gFpyXLFQTm2mS2CVgTh93scRgQPr0/HGgE4J8uHVDhJfikIjnOk1Fgqgn+sBng9kLLRuW9/4MLESZcFjtGG6ozYs82I3oXucXebdqhSij9CP6OcSedWIL77LnzhsKRa9Hv0OcAraaQOkBqxgQ8C/k/AWxLVskhc= Received: from DS7PR05CA0098.namprd05.prod.outlook.com (2603:10b6:8:56::8) by IA1PR12MB7639.namprd12.prod.outlook.com (2603:10b6:208:425::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Thu, 18 Jan 2024 19:25:23 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::69) by DS7PR05CA0098.outlook.office365.com (2603:10b6:8:56::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:22 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:18 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 2/9] ionic: add helpers for accessing buffer info Date: Thu, 18 Jan 2024 11:24:53 -0800 Message-ID: <20240118192500.58665-3-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|IA1PR12MB7639:EE_ X-MS-Office365-Filtering-Correlation-Id: d360d7de-2f99-461b-8138-08dc185b374e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wWXwiKMuFbcwo72hCrO7A9sZ853oarlJW6Oj0X/KuTJ7UIeD4QqSSGtNJ2BTH5SKrDGeV4W3kDDly874Babz7BKY+lX9VPBn6QVBhlHQqJslbC010QWakH1EkqKPBSrgzRBy/Y2ULYOZ5KyFv36KSjPEwGoT3/jylanaGj7HNeOGOqO2zO+o5ec3uU3qpxU6jeTUMyPYaHChUf60wWfzjEZFe01GTo4Gp7paLjz0btrXH05QoOKDhr+gBamp7lh1mzjlO8OTV3jhSJcRKhg8SBwmRNlQgsoLR8FCJUiWgBW99hjuMRN90TK8HROA/xkmcYilTdqguSXSMl9WdKhJiI5jKrNus/wo4DciONUfDNfij68NzB7wtBPtGBYQR4LmCjk48JBEp5I/L/NWDfUk97kqIwRmtZHFqzadF6sZ87uNjXYXGPOAEApIzYs8BTADgVKsYlggea0aAnIgKuECyT4yJG5XWtxKv97Uu9PDKCwP+i35GXYzZbL1eRmg6KXFM3cgb8EkrxIqvSIpRsuVUfhpuiNMg18IoVDing3o5KD4CI0psYyVc4JUduxKKVuHBv4CiJKQRDw/Me3s+M5xaW1XpOdM7xQqfJnTVxAYt3trv6sSnpQ7LOFdxDDPoMWf6uwZfpZfsg4ZlRrU4jSNWoSsFl4bnfQF+9PF92UBj8AB8wM8yC8K+sMk0FT+yqtNJ/9vUAENKD2hUASez83qDunKND/BtOPwTlCFdphyI/DxZaO1z10/UIIFVl7xpO58YrX/uehpCAm4UHHOVCKdmw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(376002)(346002)(39860400002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(8936002)(6666004)(8676002)(4326008)(41300700001)(16526019)(26005)(5660300002)(36756003)(1076003)(2616005)(36860700001)(336012)(426003)(2906002)(86362001)(81166007)(47076005)(83380400001)(82740400003)(356005)(44832011)(316002)(54906003)(70206006)(70586007)(110136005)(40460700003)(40480700001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:22.7968 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d360d7de-2f99-461b-8138-08dc185b374e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7639 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC These helpers clean up some of the code around DMA mapping and other buffer references, and will be used in the next few patches for the XDP support. Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_txrx.c | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 54cd96b035d6..19a7a8a8e1b3 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -88,6 +88,21 @@ static inline struct netdev_queue *q_to_ndq(struct ionic_queue *q) return netdev_get_tx_queue(q->lif->netdev, q->index); } +static inline void *ionic_rx_buf_va(struct ionic_buf_info *buf_info) +{ + return page_address(buf_info->page) + buf_info->page_offset; +} + +static inline dma_addr_t ionic_rx_buf_pa(struct ionic_buf_info *buf_info) +{ + return buf_info->dma_addr + buf_info->page_offset; +} + +static inline unsigned int ionic_rx_buf_size(struct ionic_buf_info *buf_info) +{ + 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) { @@ -207,12 +222,11 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q, return NULL; } - frag_len = min_t(u16, len, min_t(u32, IONIC_MAX_BUF_LEN, - IONIC_PAGE_SIZE - buf_info->page_offset)); + frag_len = min_t(u16, len, ionic_rx_buf_size(buf_info)); len -= frag_len; dma_sync_single_for_cpu(dev, - buf_info->dma_addr + buf_info->page_offset, + ionic_rx_buf_pa(buf_info), frag_len, DMA_FROM_DEVICE); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, @@ -262,10 +276,10 @@ static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q, return NULL; } - dma_sync_single_for_cpu(dev, buf_info->dma_addr + buf_info->page_offset, + dma_sync_single_for_cpu(dev, ionic_rx_buf_pa(buf_info), len, DMA_FROM_DEVICE); - skb_copy_to_linear_data(skb, page_address(buf_info->page) + buf_info->page_offset, len); - dma_sync_single_for_device(dev, buf_info->dma_addr + buf_info->page_offset, + skb_copy_to_linear_data(skb, ionic_rx_buf_va(buf_info), len); + dma_sync_single_for_device(dev, ionic_rx_buf_pa(buf_info), len, DMA_FROM_DEVICE); skb_put(skb, len); @@ -452,9 +466,8 @@ void ionic_rx_fill(struct ionic_queue *q) } /* fill main descriptor - buf[0] */ - desc->addr = cpu_to_le64(buf_info->dma_addr + buf_info->page_offset); - frag_len = min_t(u16, len, min_t(u32, IONIC_MAX_BUF_LEN, - IONIC_PAGE_SIZE - buf_info->page_offset)); + desc->addr = cpu_to_le64(ionic_rx_buf_pa(buf_info)); + frag_len = min_t(u16, len, ionic_rx_buf_size(buf_info)); desc->len = cpu_to_le16(frag_len); remain_len -= frag_len; buf_info++; @@ -472,10 +485,8 @@ void ionic_rx_fill(struct ionic_queue *q) } } - sg_elem->addr = cpu_to_le64(buf_info->dma_addr + buf_info->page_offset); - frag_len = min_t(u16, remain_len, min_t(u32, IONIC_MAX_BUF_LEN, - IONIC_PAGE_SIZE - - buf_info->page_offset)); + 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++; From patchwork Thu Jan 18 19:24:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523123 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2063.outbound.protection.outlook.com [40.107.223.63]) (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 EA2C32E413 for ; Thu, 18 Jan 2024 19:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605929; cv=fail; b=DWT0FWBugUgosYaTzkatGyt+UvyBjIO7uEkT0ymhJZXhgADXLUTtVwQaVIJ0hbl8heq93X16xWqX8qH8tbnTdpHS4bseWN+UOYDMfkAI6gURKaG1++LAVHxh8VXo0hhPVU5W28/d4KN55MqofP1FiPWmGQF3Bpp1abdshYyO6dY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605929; c=relaxed/simple; bh=0wIeKF9Dt1bKwFHXNxtRsnn73s3kJFATJ5BrI5qA6D8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ir0UIS3WdseRuFr5ln59R+/TRvc0b8z98Gp2kUzNL8AqVWYnrFB+GtFU22LADAQpJTTVb8c3vwMWZbxBm6weOWA5XH0Ft8i2kZmjtI1GFUs5Vh/r/6jjLjdYDeSsp1o7igXHb/9Qu+Oap0YZPHPK7bFAttPP8+rNsJkHPyTWITA= 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=DfZagepr; arc=fail smtp.client-ip=40.107.223.63 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="DfZagepr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YNBlc2fnXwew/2Tb1KSKUevdearjKUNqnQex/lMgY2GRKW6R/Ye6wxafj7jztD76B4H7VY9gaQO9PHnl6T6KKI2bxpj9xTexmiPghWD1ZxZAUQs+7NG0JPFzqWAQ8KkOgZY1JFTppRVnViWCu0WAFkMbvdTH73NJ49E4pQmK+YFZNSC+itihxb37hpl1mAnnaiJVZ7MQbtAdOM4I7smZ4EY4Nvo6J1+OSxXpeX5SClNJXY2WmJ4zllJ9CgtEFY/eSnzA+S5GIR3cbTN4A7SoSaSzuPkWDR7TVeYFaeyCPdbnSbQT68N1mo6BwlqOp/hGgcdqdOKMA6CcRMmsdKHWAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xB6sc+32yCgiNi4g2j9bFkm4E2q3QAPB3kdRX/SP8G0=; b=VZT1J2lT3Qnzy6Shr9ETXja2KbBmvgTys8aSA6rZgyA/svtPn6NO2Zg5EGBLNqx+Kw9T75brI4o09vLYSoMxBJ3gtv5jJfH+dwzFsS/MpQuz9i39UIZa5STIjiuTB0MUeOS3FNuvhi7mplZrB8IBhS6X2t2k64ZIf0hwyZIHKgplBcUM9oi3XwqjLSycnTOkvphDfknCbiXcuvfTfBwEG1/4eBZS0s1BB2S25DnVTqWZKVMINk2bJ1GGYnYUMQhQ+71gf+ia+NEtDHnHbOzhnAcg772HF0yrjDfjZgUrdsORaMrQSgScxGs0Tdu4UfDX+4imwm1Ck8xZZCOoFUHD7Q== 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=xB6sc+32yCgiNi4g2j9bFkm4E2q3QAPB3kdRX/SP8G0=; b=DfZagepr4K9H+pnTX3gsH6UYg/FIs/vDZWT+0Gtil9aI9Y7/OPeWkhKCjV8VeKCyQRY1prbtri9FnZfui5pK+5kN4PFQHKcge7NVmHsAh0Ta5rg5XUd9PMZSld47oQMqetaJ6po3IyKw9JAqiIBFbSA04lziQLuK/rJUyNzjqHE= Received: from DS7PR05CA0086.namprd05.prod.outlook.com (2603:10b6:8:56::7) by DS0PR12MB7608.namprd12.prod.outlook.com (2603:10b6:8:13b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Thu, 18 Jan 2024 19:25:23 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::52) by DS7PR05CA0086.outlook.office365.com (2603:10b6:8:56::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:23 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:19 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 3/9] ionic: use dma range APIs Date: Thu, 18 Jan 2024 11:24:54 -0800 Message-ID: <20240118192500.58665-4-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|DS0PR12MB7608:EE_ X-MS-Office365-Filtering-Correlation-Id: 82995df8-2398-48ef-a3b4-08dc185b37b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HWVut9i4wsLey+YqIhcn3ViBxkvIaIrjJCArMWiL6fP2YO9wNmkbYO9KbS2iDsrx22gD5PTmOwCetLVYxVlLRAtqIY11CLgf1l3GgTweaO1Q0F6LqRN36HRN/+SFLmSUkMFFbLY66fG9oxfjQ445PJOplPKfjAkTB3X3/ekABy60uZ3J1MCK53hasQPlPxK6MYdV9ISfLDbS58TSsEwBO1HpxnLJYgQ72IkyYrPz2u4ssebGzceYbLGtyw6eBBjFbY/wvLgOdTCVIJzps0TJFAjPomVJAOe+emrrg3B7P1RJBHYpPJ3t33ftXW1jErh/mzpspM0N65yEwUGaQbV6TmxDsCJ+YNeBorTgZuWi3zYosAt65OEynoGMkwEjAI9CHyLt4LAo1yYkbvFISa+D8Zv4vpgNSyDKgHEl8BkeoJJu1sXnOZS0tnIZgsd/Rgs8Q4M8C2K72SV0Vf+jJIl71CfjzUzjS0lZd4u/1o22weS4+pcfCxsc8jDavACrtWUOkicmOZxn0s5121BVh/zveQrjxMaMlt4EwbEdSSq13M30FwarZoi6ND3ELk5CH0KrPNObhPcuLsS4X/Wflif8OTc8YuapPvo3ITaN7NCSqtG1pQ6vZgm0S1PJ0E8QGjuEnOMljpv2vWMqV+ZxwW80ssBu+peNm4pjTfDBbzQx1OsyGNdx0gpddesTwSXc5gXE2SirVNE2JvkMfVX3JiFIXp9BqkjuEmZP4Q0IvYXuH//JFZMRrTeg5ixjVoeTRZ0ZlE4hEk0FEVM4Rzjk1LhJdA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(346002)(376002)(39860400002)(230922051799003)(64100799003)(1800799012)(451199024)(82310400011)(186009)(46966006)(36840700001)(40470700004)(81166007)(356005)(41300700001)(36756003)(336012)(8936002)(8676002)(83380400001)(16526019)(426003)(70586007)(316002)(54906003)(110136005)(70206006)(4326008)(44832011)(478600001)(6666004)(26005)(1076003)(2616005)(82740400003)(2906002)(5660300002)(47076005)(36860700001)(86362001)(40460700003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:23.4531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82995df8-2398-48ef-a3b4-08dc185b37b2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7608 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Convert Rx datapath handling to use the DMA range APIs in preparation for adding XDP handling. Signed-off-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 19a7a8a8e1b3..aee38979a9d7 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -225,9 +225,8 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q, frag_len = min_t(u16, len, ionic_rx_buf_size(buf_info)); len -= frag_len; - dma_sync_single_for_cpu(dev, - ionic_rx_buf_pa(buf_info), - frag_len, DMA_FROM_DEVICE); + dma_sync_single_range_for_cpu(dev, ionic_rx_buf_pa(buf_info), + 0, frag_len, DMA_FROM_DEVICE); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, buf_info->page, buf_info->page_offset, frag_len, @@ -276,11 +275,11 @@ static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q, return NULL; } - dma_sync_single_for_cpu(dev, ionic_rx_buf_pa(buf_info), - len, DMA_FROM_DEVICE); + dma_sync_single_range_for_cpu(dev, ionic_rx_buf_pa(buf_info), + 0, len, DMA_FROM_DEVICE); skb_copy_to_linear_data(skb, ionic_rx_buf_va(buf_info), len); - dma_sync_single_for_device(dev, ionic_rx_buf_pa(buf_info), - len, DMA_FROM_DEVICE); + dma_sync_single_range_for_device(dev, ionic_rx_buf_pa(buf_info), + 0, len, DMA_FROM_DEVICE); skb_put(skb, len); skb->protocol = eth_type_trans(skb, q->lif->netdev); From patchwork Thu Jan 18 19:24:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523127 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) (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 954B22E634 for ; Thu, 18 Jan 2024 19:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605931; cv=fail; b=arO/FAFBDlILPnYG54h4CjBdSwei3KDR1qEttDExU1k91FvqLqlOtzs+GEcHnOH5V6UVnUnkPDqdtBfP2fVjjU2f7W6e5/C/rGTnXqmZ7YEGjdss+u+p8T840qhlFn+dgcayAM0koIIBeTFPPKIStg91dt7AnNG8vS4JkQO3AVk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605931; c=relaxed/simple; bh=3h7Fzp2CbrW8gV9ndfPj0L1lcuUSGIvTQB0kerbUmLU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g9uE4Bh7nQxQ8yY30GvFyc8YkHxxjblB4/71TRc4VXIJHaOyFkp4wacTMUUdFNzDcw9zFgkBQlhW0R4N3MZxhV/M77J5kXyjhdtTqQliZ9UF7ZtCTpAvaTnXHO59urPNVSJd9O3tpRdBfh9oVq3L+G29/ECbeAkiMkS4QV1KCms= 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=jGiYJEHN; arc=fail smtp.client-ip=40.107.94.75 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="jGiYJEHN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R7agyrMKzDQj4iFESN2t/480oNnkJQObWMSCbsvQxy46tNeKdSunB44Z96epHsHH5+bx+VZHYjtATeeBs+kD47BMNJuTMjioPmhRBHlzQIFjsOy7sqd9G3uhcUNbMqCmSiEV5H8le+lM6jGHmF34Nwv+qa8wQr7lym5t/5df5meg1l1gFjTjn8TAydQbjMsVIZZDE4QcJheNwblbjKQdVJ4Gagn83+At4yK37F9m4YQvNynLtKhu+YStfyRkU5cVkjX5T+6AaWK9QgVzDln4LvWS9v65uAnAo0sDhWAWi7NpaVJ335TvlJcXlXO7811t6cT4vP0sw521uN6T2MrZUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kbLukNUnI9D4esRWJh3zPT6wqq0cnNU3Lb8JTB3HYDc=; b=ltaW85ecFpf1KdCm+lDeaZj+RTDCkDP1NSJ1YWX+RTcvXd7oav3B7tQCI7cooc/8sNA5uVyRczJ3q7Xs8FOLoTXb/F1potI02V/+cQ6OBhR6fTw06M+6YUa0fzfpV3GaSh9PVjCV+u3IIJWd/QCEeKQuFvhUJPzi44MM6sMDEESbRdSQefOz1rusav6wB4lipONabhpjn+/V8OUosDClJDMmRxWt2sYlgk5r6HUZtb4W9vz1UOM/9T49L0+0HqSuNoXLBJpbq6FeO9t3thFlnVufkOAcoDziXCsNMkMwpUqdTcUMQ+3UP/s350SKTvJRS530FmhNZ17OYFpTzkHJcA== 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=kbLukNUnI9D4esRWJh3zPT6wqq0cnNU3Lb8JTB3HYDc=; b=jGiYJEHN8nautynuSEO2NCdZv2M1V2OQVLR3xOVE0fXFiTirSJYoE9fecQ9fNcqXky3u2CgF4nL3P0wwGrxjpWoADw6pvGxjoEKUXZNO7aRANyPJ4dRFmJ5K5yH4FhhIWbnK9/kknX85EJkUxmXPnsxmD++U54RiqqaF76RRstM= Received: from DS7PR05CA0104.namprd05.prod.outlook.com (2603:10b6:8:56::16) by SJ0PR12MB6968.namprd12.prod.outlook.com (2603:10b6:a03:47b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.23; Thu, 18 Jan 2024 19:25:24 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::3c) by DS7PR05CA0104.outlook.office365.com (2603:10b6:8:56::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:23 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:20 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 4/9] ionic: add initial framework for XDP support Date: Thu, 18 Jan 2024 11:24:55 -0800 Message-ID: <20240118192500.58665-5-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|SJ0PR12MB6968:EE_ X-MS-Office365-Filtering-Correlation-Id: a46e45d9-9157-43df-f046-08dc185b37df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yOzH5RuGXtOrXv6bZKLk3zx6nxTsNftalyg9jzbDNBNJvphUygXK1IDyTIpuF+PiqZW7LerNJYEzbOWKzMKrMY1feN2MVkVF923W6eWyWwFDsty5Tl+qErGqjXfnpYtT6+/zi9LEaVnZ44BFDL3rGtvDf+J1r6CQUHIKpeG6MTgtF83Bm6Tt5aBa9dVWwKlZelXU0s3HTGGloqBEhCEhC4dKZLbJXsKJz0Y00w8h96soEKcLPAq40eur+QsVSN3pnn5ST5KFD/lmDIMUdkB85QhAwBKASKlM71IZzAJGgJAyLKmqD7RpXP9Ha5+/9z8S+YfpdqFPfggdDfdfQchug631DJgqgRZ6Sgenlvbhy1xiA+thtRhGqrKruZPupQwt26B9bawSd6vXjFmDLctjQoNxI03S5dRcnKUlRBfEVHRbGBM8rMNWRS2LXTctP8vz31tYK4zG19Qr0Aei3DNvwKFAu2KbwvVWr3pvqIUKuVai4l8lxtMxeA1ARXxS6AOmZp2ggZ9bLvL65kS/KbkqO/hsnogdPf3MS3H6lEEkzH2mJrzi0074d0ayY+ZJnIkRmOGm2sYZPhAsRBoUAtNDw8MTewDeC+Vg+uw8yPG3TzOtdchlzTTNZkTMtH8Q+Qok+vtUUxZVQYQOXL7tnXkTbZ0SqP4koRKzrOsMK26uKb/p4FzfWGS/umkCPNPU7T/ewGEvFoEJAqTqjMBkKk60I7G+uOY4dH0pjs/7Kgsb39otdfeNoW6wgykxMbJcSd0wEsChFAD3gFZ1aOY+qOGx1w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(346002)(376002)(136003)(230922051799003)(82310400011)(451199024)(186009)(64100799003)(1800799012)(46966006)(40470700004)(36840700001)(356005)(40460700003)(40480700001)(426003)(86362001)(47076005)(83380400001)(36756003)(82740400003)(81166007)(30864003)(6666004)(44832011)(8676002)(4326008)(8936002)(26005)(1076003)(2616005)(36860700001)(5660300002)(16526019)(54906003)(110136005)(316002)(70206006)(41300700001)(2906002)(70586007)(478600001)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:23.7500 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a46e45d9-9157-43df-f046-08dc185b37df X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6968 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Set up the basics for running Rx packets through XDP programs. Add new queue setup and teardown steps for adding/removing an XDP program, and add the call to run the XDP on a packet. The XDP frame size needs to be the MTU plus standard ethernet header, plus head room for XDP scribblings and tail room for a struct skb_shared_info. Also, at this point, we don't support XDP frags, only a single contiguous Rx buffer. This means that our page splitting is not very useful, so when XDP is in use we need to use the full Rx buffer size and not do sharing. Co-developed-by: Brett Creeley Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.h | 7 + .../ethernet/pensando/ionic/ionic_ethtool.c | 5 + .../net/ethernet/pensando/ionic/ionic_lif.c | 172 +++++++++++++++++- .../net/ethernet/pensando/ionic/ionic_lif.h | 7 + .../net/ethernet/pensando/ionic/ionic_stats.c | 9 + .../net/ethernet/pensando/ionic/ionic_txrx.c | 61 ++++++- 6 files changed, 255 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 2667e1cde16b..70f5725fdfe8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "ionic_if.h" #include "ionic_regs.h" @@ -195,6 +196,11 @@ typedef void (*ionic_desc_cb)(struct ionic_queue *q, #define IONIC_PAGE_GFP_MASK (GFP_ATOMIC | __GFP_NOWARN |\ __GFP_COMP | __GFP_MEMALLOC) +#define IONIC_XDP_MAX_LINEAR_MTU (IONIC_PAGE_SIZE - \ + (VLAN_ETH_HLEN + \ + XDP_PACKET_HEADROOM + \ + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))) + struct ionic_buf_info { struct page *page; dma_addr_t dma_addr; @@ -256,6 +262,7 @@ struct ionic_queue { struct ionic_txq_sg_desc *txq_sgl; struct ionic_rxq_sg_desc *rxq_sgl; }; + struct xdp_rxq_info *xdp_rxq_info; 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_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c index cd3c0b01402e..98df2ee11c51 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c @@ -721,6 +721,11 @@ static int ionic_set_channels(struct net_device *netdev, ionic_init_queue_params(lif, &qparam); + if ((ch->rx_count || ch->tx_count) && lif->xdp_prog) { + netdev_info(lif->netdev, "Split Tx/Rx interrupts not available when using XDP\n"); + return -EOPNOTSUPP; + } + if (ch->rx_count != ch->tx_count) { netdev_info(netdev, "The rx and tx count must be equal\n"); return -EINVAL; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index d92f8734d153..6e9065dd149e 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -46,6 +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_queues_config(struct ionic_lif *lif); +static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q); + static void ionic_dim_work(struct work_struct *work) { struct dim *dim = container_of(work, struct dim, work); @@ -422,6 +425,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->cq.info); @@ -862,8 +866,7 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) .type = q->type, .ver = lif->qtype_info[q->type].version, .index = cpu_to_le32(q->index), - .flags = cpu_to_le16(IONIC_QINIT_F_IRQ | - IONIC_QINIT_F_SG), + .flags = cpu_to_le16(IONIC_QINIT_F_IRQ), .intr_index = cpu_to_le16(cq->bound_intr->index), .pid = cpu_to_le16(q->pid), .ring_size = ilog2(q->num_descs), @@ -875,6 +878,9 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) }; int err; + if (!lif->xdp_prog) + ctx.cmd.q_init.flags |= cpu_to_le16(IONIC_QINIT_F_SG); + if (qcq->flags & IONIC_QCQ_F_CMB_RINGS) { ctx.cmd.q_init.flags |= cpu_to_le16(IONIC_QINIT_F_CMB); ctx.cmd.q_init.ring_base = cpu_to_le64(qcq->cmb_q_base_pa); @@ -1640,6 +1646,8 @@ static int ionic_init_nic_features(struct ionic_lif *lif) netdev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE; + netdev->xdp_features = NETDEV_XDP_ACT_BASIC; + return 0; } @@ -1777,6 +1785,18 @@ static int ionic_start_queues_reconfig(struct ionic_lif *lif) return err; } +static bool ionic_xdp_is_valid_mtu(struct ionic_lif *lif, u32 mtu, + struct bpf_prog *xdp_prog) +{ + if (!xdp_prog) + return true; + + if (mtu <= IONIC_XDP_MAX_LINEAR_MTU) + return true; + + return false; +} + static int ionic_change_mtu(struct net_device *netdev, int new_mtu) { struct ionic_lif *lif = netdev_priv(netdev); @@ -1789,8 +1809,13 @@ static int ionic_change_mtu(struct net_device *netdev, int new_mtu) .mtu = cpu_to_le32(new_mtu), }, }; + struct bpf_prog *xdp_prog; int err; + xdp_prog = READ_ONCE(lif->xdp_prog); + if (!ionic_xdp_is_valid_mtu(lif, new_mtu, xdp_prog)) + return -EINVAL; + err = ionic_adminq_post_wait(lif, &ctx); if (err) return err; @@ -2166,6 +2191,10 @@ static int ionic_txrx_enable(struct ionic_lif *lif) int derr = 0; int i, err; + err = ionic_xdp_queues_config(lif); + if (err) + return err; + for (i = 0; i < lif->nxqs; i++) { if (!(lif->rxqcqs[i] && lif->txqcqs[i])) { dev_err(lif->ionic->dev, "%s: bad qcq %d\n", __func__, i); @@ -2211,6 +2240,8 @@ static int ionic_txrx_enable(struct ionic_lif *lif) derr = ionic_qcq_disable(lif, lif->rxqcqs[i], derr); } + ionic_xdp_queues_config(lif); + return err; } @@ -2668,11 +2699,147 @@ 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) +{ + struct xdp_rxq_info *xi; + + if (!q->xdp_rxq_info) + return; + + xi = q->xdp_rxq_info; + q->xdp_rxq_info = NULL; + + xdp_rxq_info_unreg(xi); + kfree(xi); +} + +static int ionic_xdp_register_rxq_info(struct ionic_queue *q, unsigned int napi_id) +{ + struct xdp_rxq_info *rxq_info; + int err; + + rxq_info = kzalloc(sizeof(*rxq_info), GFP_KERNEL); + if (!rxq_info) + return -ENOMEM; + + 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); + kfree(rxq_info); + return err; + } + + err = xdp_rxq_info_reg_mem_model(rxq_info, MEM_TYPE_PAGE_ORDER0, NULL); + if (err) { + dev_err(q->dev, "Queue %d xdp_rxq_info_reg_mem_model failed, err %d\n", + q->index, err); + xdp_rxq_info_unreg(rxq_info); + kfree(rxq_info); + return err; + } + + q->xdp_rxq_info = rxq_info; + + return 0; +} + +static int ionic_xdp_queues_config(struct ionic_lif *lif) +{ + 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; + + 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) { + ionic_xdp_unregister_rxq_info(q); + } else { + 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; + } + } + } + + 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) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct bpf_prog *old_prog; + u32 maxfs; + + if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) { +#define XDP_ERR_SPLIT "XDP not available with split Tx/Rx interrupts" + NL_SET_ERR_MSG_MOD(bpf->extack, XDP_ERR_SPLIT); + netdev_info(lif->netdev, XDP_ERR_SPLIT); + return -EOPNOTSUPP; + } + + if (!ionic_xdp_is_valid_mtu(lif, netdev->mtu, bpf->prog)) { +#define XDP_ERR_MTU "MTU is too large for XDP without frags support" + NL_SET_ERR_MSG_MOD(bpf->extack, XDP_ERR_MTU); + netdev_info(lif->netdev, XDP_ERR_MTU); + return -EINVAL; + } + + maxfs = __le32_to_cpu(lif->identity->eth.max_frame_size) - VLAN_ETH_HLEN; + if (bpf->prog) + maxfs = min_t(u32, maxfs, IONIC_XDP_MAX_LINEAR_MTU); + netdev->max_mtu = maxfs; + + if (!netif_running(netdev)) { + old_prog = xchg(&lif->xdp_prog, bpf->prog); + } else { + mutex_lock(&lif->queue_lock); + ionic_stop_queues_reconfig(lif); + old_prog = xchg(&lif->xdp_prog, bpf->prog); + ionic_start_queues_reconfig(lif); + mutex_unlock(&lif->queue_lock); + } + + if (old_prog) + bpf_prog_put(old_prog); + + return 0; +} + +static int ionic_xdp(struct net_device *netdev, struct netdev_bpf *bpf) +{ + switch (bpf->command) { + case XDP_SETUP_PROG: + return ionic_xdp_config(netdev, bpf); + default: + return -EINVAL; + } +} + static const struct net_device_ops ionic_netdev_ops = { .ndo_open = ionic_open, .ndo_stop = ionic_stop, .ndo_eth_ioctl = ionic_eth_ioctl, .ndo_start_xmit = ionic_start_xmit, + .ndo_bpf = ionic_xdp, .ndo_get_stats64 = ionic_get_stats64, .ndo_set_rx_mode = ionic_ndo_set_rx_mode, .ndo_set_features = ionic_set_features, @@ -2755,6 +2922,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_rxq_info, b->q.xdp_rxq_info); swap(a->q_base, b->q_base); swap(a->q_base_pa, b->q_base_pa); swap(a->q_size, b->q_size); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h index 61548b3eea93..61fa4ea4f04c 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h @@ -51,6 +51,9 @@ struct ionic_rx_stats { u64 alloc_err; u64 hwstamp_valid; u64 hwstamp_invalid; + u64 xdp_drop; + u64 xdp_aborted; + u64 xdp_pass; }; #define IONIC_QCQ_F_INITED BIT(0) @@ -135,6 +138,9 @@ struct ionic_lif_sw_stats { u64 hw_rx_over_errors; u64 hw_rx_missed_errors; u64 hw_tx_aborted_errors; + u64 xdp_drop; + u64 xdp_aborted; + u64 xdp_pass; }; enum ionic_lif_state_flags { @@ -230,6 +236,7 @@ struct ionic_lif { struct ionic_phc *phc; struct dentry *dentry; + struct bpf_prog *xdp_prog; }; struct ionic_phc { diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c index 1f6022fb7679..2fb20173b2c6 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c @@ -27,6 +27,9 @@ static const struct ionic_stat_desc ionic_lif_stats_desc[] = { IONIC_LIF_STAT_DESC(hw_rx_over_errors), IONIC_LIF_STAT_DESC(hw_rx_missed_errors), IONIC_LIF_STAT_DESC(hw_tx_aborted_errors), + IONIC_LIF_STAT_DESC(xdp_drop), + IONIC_LIF_STAT_DESC(xdp_aborted), + IONIC_LIF_STAT_DESC(xdp_pass), }; static const struct ionic_stat_desc ionic_port_stats_desc[] = { @@ -149,6 +152,9 @@ static const struct ionic_stat_desc ionic_rx_stats_desc[] = { IONIC_RX_STAT_DESC(hwstamp_invalid), IONIC_RX_STAT_DESC(dropped), IONIC_RX_STAT_DESC(vlan_stripped), + IONIC_RX_STAT_DESC(xdp_drop), + IONIC_RX_STAT_DESC(xdp_aborted), + IONIC_RX_STAT_DESC(xdp_pass), }; #define IONIC_NUM_LIF_STATS ARRAY_SIZE(ionic_lif_stats_desc) @@ -185,6 +191,9 @@ static void ionic_add_lif_rxq_stats(struct ionic_lif *lif, int q_num, stats->rx_csum_error += rxstats->csum_error; stats->rx_hwstamp_valid += rxstats->hwstamp_valid; stats->rx_hwstamp_invalid += rxstats->hwstamp_invalid; + stats->xdp_drop += rxstats->xdp_drop; + stats->xdp_aborted += rxstats->xdp_aborted; + stats->xdp_pass += rxstats->xdp_pass; } static void ionic_get_lif_stats(struct ionic_lif *lif, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index aee38979a9d7..07a17be94d4d 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -177,7 +177,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(used, IONIC_PAGE_SPLIT_SZ); + size = ALIGN(used, q->xdp_rxq_info ? IONIC_PAGE_SIZE : IONIC_PAGE_SPLIT_SZ); buf_info->page_offset += size; if (buf_info->page_offset >= IONIC_PAGE_SIZE) return false; @@ -287,6 +287,54 @@ static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q, return skb; } +static bool ionic_run_xdp(struct ionic_rx_stats *stats, + struct net_device *netdev, + struct ionic_queue *rxq, + struct ionic_buf_info *buf_info, + int len) +{ + u32 xdp_action = XDP_ABORTED; + struct bpf_prog *xdp_prog; + struct xdp_buff xdp_buf; + + xdp_prog = READ_ONCE(rxq->lif->xdp_prog); + if (!xdp_prog) + return false; + + xdp_init_buff(&xdp_buf, IONIC_PAGE_SIZE, rxq->xdp_rxq_info); + xdp_prepare_buff(&xdp_buf, ionic_rx_buf_va(buf_info), + 0, len, false); + + dma_sync_single_range_for_cpu(rxq->dev, ionic_rx_buf_pa(buf_info), + 0, len, + DMA_FROM_DEVICE); + + prefetchw(&xdp_buf.data_hard_start); + + xdp_action = bpf_prog_run_xdp(xdp_prog, &xdp_buf); + + switch (xdp_action) { + case XDP_PASS: + stats->xdp_pass++; + return false; /* false = we didn't consume the packet */ + + case XDP_DROP: + ionic_rx_page_free(rxq, buf_info); + stats->xdp_drop++; + break; + + case XDP_REDIRECT: + case XDP_TX: + case XDP_ABORTED: + default: + trace_xdp_exception(netdev, xdp_prog, xdp_action); + ionic_rx_page_free(rxq, buf_info); + stats->xdp_aborted++; + } + + return true; +} + static void ionic_rx_clean(struct ionic_queue *q, struct ionic_desc_info *desc_info, struct ionic_cq_info *cq_info, @@ -297,6 +345,7 @@ static void ionic_rx_clean(struct ionic_queue *q, struct ionic_rx_stats *stats; struct ionic_rxq_comp *comp; struct sk_buff *skb; + u16 len; comp = cq_info->cq_desc + qcq->cq.desc_size - sizeof(*comp); @@ -307,10 +356,14 @@ static void ionic_rx_clean(struct ionic_queue *q, return; } + len = le16_to_cpu(comp->len); stats->pkts++; - stats->bytes += le16_to_cpu(comp->len); + stats->bytes += len; + + if (ionic_run_xdp(stats, netdev, q, desc_info->bufs, len)) + return; - if (le16_to_cpu(comp->len) <= q->lif->rx_copybreak) + if (len <= q->lif->rx_copybreak) skb = ionic_rx_copybreak(q, desc_info, comp); else skb = ionic_rx_frags(q, desc_info, comp); @@ -380,7 +433,7 @@ static void ionic_rx_clean(struct ionic_queue *q, } } - if (le16_to_cpu(comp->len) <= q->lif->rx_copybreak) + if (len <= q->lif->rx_copybreak) napi_gro_receive(&qcq->napi, skb); else napi_gro_frags(&qcq->napi); From patchwork Thu Jan 18 19:24:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523128 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) (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 835D52E62C for ; Thu, 18 Jan 2024 19:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605931; cv=fail; b=nLKmZPRIIUOhTLxt0ztGnL8DChH8nnQ5aU1SuFcy4kGI8yf9zLEmG+2cAhc1nZRC4uCesRZz0FqQxW+shdyV5bCnBcgX+klGC3Zye+mftJPgdCRTIoz62DBvzZ8Ars3vTu3RJkj2/SJYdruo8WdUkpuy6nPLf9tE1sd4IHXNiaM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605931; c=relaxed/simple; bh=EpdcKkIgYPpdVeehNi4pzLnExscutvW5b09S9vOvlNQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cj0v+DMOQBClEmaHcf9F5iLq5W/0Z7Rok2C3e/OeBFdL/QDQGRdWKDEKtZIcVBNubB4anmRK6FfqmWI3WucgTqRT69Cjd9CsVWRVnXVVEkUihf5c+CtB6nA4AOpiYr6gZ3/uFbgR5MiI6IKfDG+8X8IldQR3yecnf6xDKCGaspE= 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=jUh1Ewub; arc=fail smtp.client-ip=40.107.243.66 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="jUh1Ewub" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RxQRDCc5f+SdXtg/K5yiwdsngqwqe9G/GfbyLzpMnKd1shpLGnfu2I110Gexp7oby7EsqpGdpzJHpcz/1VC0jA4WRSgj6XRMzNuirXxz4n99497uuqC7WnIlJhzc76yaTleskFjvA4/gPIRe13sFqgU9vgWdFWrStvyoQ1+CHk27c7VhG1rX+X1zikTxSUhTYVVo8hdJ2Ee8Ckctp/z4IziXfMoCwsQiNkEAfqbfqNXHiNAMQL3aIItbSrQITxyiX2uO+nFaekTrx9BiH8+T/BiK2PMinNk8tTy+VtdN2UWOJ9XmYBFjbMZyurbd86daSxMWBFyhmj2x2FFP8onflg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4ezuKt1xTbJvXbixYp+Qutaxtz5PU0IPIJB3Ny0uipY=; b=Avtf2vB0EwVtwDqHdOymxqFpCYohSIFdSKGwf/lSglgk6z8tphEpBN1t1xHk4WGDYKw+fM435fPJczKz+OZgaMf3H4YJ/2hBoQaW1lCv5QZKcEfdq9tgTnGi7OBg7675AvG4F4ywGh8nC+SvNCWbuxOvuapVLK0Ps71UWo4IcEx2acnak1pfI3GX/Xr6wtcnasu/wMoM/mKt2/3AI69fcmq+EnBHe/VyyOjn/XTO6Okr6iIIVSB0IQ5nLXe16BMREcm1E2O/ZCoVbrhQ/sp+Vggpyh7/jWPEggnmsYY/7GlqknnJl22qJCxUjYRUK2vC+a7GNuzQSPd5tEmPOtIydw== 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=4ezuKt1xTbJvXbixYp+Qutaxtz5PU0IPIJB3Ny0uipY=; b=jUh1EwubeJOrgWjPTpLM7Vsqz9+a5uquuRqzQCXA2X7/mE5FK3SxqBcw5tSMqJn0fouj+cNfqXBQ/n83HmJXJo+Rb9Dgbawv4jDU/pN2ag7wTIiy9vx60PDJu+XxrtBvEzXs5eBFd/oeG+tuZqqGJ2uezYVInUQyycsJRsl+rGY= Received: from DS7PR05CA0094.namprd05.prod.outlook.com (2603:10b6:8:56::11) by BN9PR12MB5212.namprd12.prod.outlook.com (2603:10b6:408:11d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Thu, 18 Jan 2024 19:25:25 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::12) by DS7PR05CA0094.outlook.office365.com (2603:10b6:8:56::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:25 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:21 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 5/9] ionic: Add XDP packet headroom Date: Thu, 18 Jan 2024 11:24:56 -0800 Message-ID: <20240118192500.58665-6-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|BN9PR12MB5212:EE_ X-MS-Office365-Filtering-Correlation-Id: 73e29de1-d87e-4566-0cdb-08dc185b38c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rEUNglvBL9ZCRI34H+RYpgRG2oeas4WDNGh0y2jpfatOxhV+IHX8YJ39QPUjdKPihfFUH3oCqNLxf3899ygK0hdVuSrlEnmmf3y0/dyssegjCa1TqunAd9A7dac4sUmqcjRNUNzAKmA42nVCmoTZGPyLdoEIiFf6wntrDb74SU7Iq23VRrxIJ8ZPpn2TA0O9TN90pNtxqbBvsUp1D2i6OIKuFcW5JA5kKgzJVBDg3ESD5YhpotvnzoEvet/GrHf7qubSsXIRKvF97olrrmOfs0wZ9xcA8yeTm5XIoZ3Zo0QISOpCaFhKx5SocLlTgU9nAAZ1h/Ulu98dzBykyVMq0PmQVsjZEp0qII6jF/t4Z3IOuWzclyTnOMmAUrm5S4SRAOHjHsdY32KEjvI27Nl+ePHHQJ8sEjaSqd01MM1w1bf7boWCn8C0/b5CHFBLhLkOOaaAb0+wETQ0vZ5arkiIi10Mtzpm+0h+wQrGI6nG0+Lae2d2fHUc3HPyvC6waj2cI0mDevZaaY/sR4H2daTkKFJTc7yVIXhOOgmlGpIz650HWMQS4/7ApExC/4SWWYfTz9f3/CzrXVyKhgGrJoG2+NcLiP0zrRLPGXJy1e/Es9yqoVVodA2JUNfnP1+4DEmJiKCybh4AOnoghYZkLQOYCFGZ85sYE630JBvTjKzmWVwSBVC08MSgJutByNrB0ZbPKYR+5avRR/V3FauFlgH/qNP9hYFp2bDs/Z77bzreD4Si2N9G51sNXhzVQHzIUOsoVQV5PUfc7NkBBt5i+lLxZQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(39860400002)(136003)(376002)(396003)(230922051799003)(186009)(64100799003)(451199024)(82310400011)(1800799012)(36840700001)(46966006)(40470700004)(26005)(40480700001)(40460700003)(6666004)(426003)(336012)(16526019)(2616005)(1076003)(36756003)(86362001)(82740400003)(81166007)(356005)(41300700001)(44832011)(83380400001)(36860700001)(5660300002)(2906002)(478600001)(47076005)(110136005)(8676002)(8936002)(4326008)(316002)(54906003)(70586007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:25.2187 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73e29de1-d87e-4566-0cdb-08dc185b38c0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5212 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC If an xdp program is loaded, add headroom at the beginning of the frame to allow for editing and insertions that an XDP program might need room for, and tailroom used later for XDP frame tracking. These are only needed in the first Rx buffer in a packet, not for any trailing frags. Co-developed-by: Brett Creeley Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_txrx.c | 67 ++++++++++++------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 07a17be94d4d..072a9e376b39 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -189,7 +189,9 @@ static bool ionic_rx_buf_recycle(struct ionic_queue *q, static struct sk_buff *ionic_rx_frags(struct ionic_queue *q, struct ionic_desc_info *desc_info, - struct ionic_rxq_comp *comp) + unsigned int headroom, + unsigned int len, + unsigned int num_sg_elems) { struct net_device *netdev = q->lif->netdev; struct ionic_buf_info *buf_info; @@ -198,12 +200,10 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q, struct sk_buff *skb; unsigned int i; u16 frag_len; - u16 len; stats = q_to_rx_stats(q); buf_info = &desc_info->bufs[0]; - len = le16_to_cpu(comp->len); prefetchw(buf_info->page); @@ -215,22 +215,25 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q, return NULL; } - i = comp->num_sg_elems + 1; + i = num_sg_elems + 1; do { if (unlikely(!buf_info->page)) { dev_kfree_skb(skb); return NULL; } - frag_len = min_t(u16, len, ionic_rx_buf_size(buf_info)); + 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)); len -= frag_len; dma_sync_single_range_for_cpu(dev, ionic_rx_buf_pa(buf_info), - 0, frag_len, DMA_FROM_DEVICE); + headroom, frag_len, DMA_FROM_DEVICE); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, - buf_info->page, buf_info->page_offset, frag_len, - IONIC_PAGE_SIZE); + buf_info->page, buf_info->page_offset + headroom, + frag_len, IONIC_PAGE_SIZE); if (!ionic_rx_buf_recycle(q, buf_info, frag_len)) { dma_unmap_page(dev, buf_info->dma_addr, @@ -238,6 +241,10 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q, buf_info->page = NULL; } + /* only needed on the first buffer */ + if (headroom) + headroom = 0; + buf_info++; i--; @@ -248,19 +255,18 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q, static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q, struct ionic_desc_info *desc_info, - struct ionic_rxq_comp *comp) + unsigned int headroom, + unsigned int len) { struct net_device *netdev = q->lif->netdev; struct ionic_buf_info *buf_info; struct ionic_rx_stats *stats; struct device *dev = q->dev; struct sk_buff *skb; - u16 len; stats = q_to_rx_stats(q); buf_info = &desc_info->bufs[0]; - len = le16_to_cpu(comp->len); skb = napi_alloc_skb(&q_to_qcq(q)->napi, len); if (unlikely(!skb)) { @@ -276,10 +282,10 @@ static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q, } dma_sync_single_range_for_cpu(dev, ionic_rx_buf_pa(buf_info), - 0, len, DMA_FROM_DEVICE); - skb_copy_to_linear_data(skb, ionic_rx_buf_va(buf_info), len); + headroom, len, DMA_FROM_DEVICE); + 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), - 0, len, DMA_FROM_DEVICE); + headroom, len, DMA_FROM_DEVICE); skb_put(skb, len); skb->protocol = eth_type_trans(skb, q->lif->netdev); @@ -303,10 +309,10 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, xdp_init_buff(&xdp_buf, IONIC_PAGE_SIZE, rxq->xdp_rxq_info); xdp_prepare_buff(&xdp_buf, ionic_rx_buf_va(buf_info), - 0, len, false); + XDP_PACKET_HEADROOM, len, false); dma_sync_single_range_for_cpu(rxq->dev, ionic_rx_buf_pa(buf_info), - 0, len, + XDP_PACKET_HEADROOM, len, DMA_FROM_DEVICE); prefetchw(&xdp_buf.data_hard_start); @@ -344,6 +350,7 @@ static void ionic_rx_clean(struct ionic_queue *q, struct ionic_qcq *qcq = q_to_qcq(q); struct ionic_rx_stats *stats; struct ionic_rxq_comp *comp; + unsigned int headroom; struct sk_buff *skb; u16 len; @@ -363,10 +370,11 @@ static void ionic_rx_clean(struct ionic_queue *q, if (ionic_run_xdp(stats, netdev, q, desc_info->bufs, len)) return; + headroom = q->xdp_rxq_info ? XDP_PACKET_HEADROOM : 0; if (len <= q->lif->rx_copybreak) - skb = ionic_rx_copybreak(q, desc_info, comp); + skb = ionic_rx_copybreak(q, desc_info, headroom, len); else - skb = ionic_rx_frags(q, desc_info, comp); + skb = ionic_rx_frags(q, desc_info, headroom, len, comp->num_sg_elems); if (unlikely(!skb)) { stats->dropped++; @@ -490,8 +498,9 @@ void ionic_rx_fill(struct ionic_queue *q) unsigned int frag_len; unsigned int nfrags; unsigned int n_fill; - unsigned int i, j; unsigned int len; + unsigned int i; + unsigned int j; n_fill = ionic_q_space_avail(q); @@ -500,9 +509,12 @@ void ionic_rx_fill(struct ionic_queue *q) if (n_fill < fill_threshold) return; - len = netdev->mtu + ETH_HLEN + VLAN_HLEN; + len = netdev->mtu + VLAN_ETH_HLEN; for (i = n_fill; i; i--) { + unsigned int headroom; + unsigned int buf_len; + nfrags = 0; remain_len = len; desc_info = &q->info[q->head_idx]; @@ -517,9 +529,18 @@ void ionic_rx_fill(struct ionic_queue *q) } } - /* fill main descriptor - buf[0] */ - desc->addr = cpu_to_le64(ionic_rx_buf_pa(buf_info)); - frag_len = min_t(u16, len, ionic_rx_buf_size(buf_info)); + /* 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. + */ + headroom = q->xdp_rxq_info ? XDP_PACKET_HEADROOM : 0; + if (q->xdp_rxq_info) + buf_len = IONIC_XDP_MAX_LINEAR_MTU + VLAN_ETH_HLEN; + 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); desc->len = cpu_to_le16(frag_len); remain_len -= frag_len; buf_info++; From patchwork Thu Jan 18 19:24:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523124 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) (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 BDF1A2E3F8 for ; Thu, 18 Jan 2024 19:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605930; cv=fail; b=Zcmye38+qbcT4xwoRKuQjO7Cs9grBdMAPZMxUdTXRiXHc1sysG/8HnJDN3LpsBUWHwesancuEmZaJ2pcXXchupGlvi1loxIvzZvUAVvEEJVzcdK9UO3xmjcuwyCubAUn6d7Cgrqn+LTUKQGeFAjjH/5326a4TY2Bd6Qbhd9bxOA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605930; c=relaxed/simple; bh=1Zy0C2/VyFP3uEkle1GlX3c6PwciAE1V9ygrliXEBGg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cTDfimmPxBatecKFKgKdZKFnRCExdZijpT4kBB5uhvY1Keh95HihZBZ/Bm77csC7J5G4I7g5/hxtkuVAIZdSmR+lAOlSO1Xm6BwrkI84ATTFhiG9vhtdezXK1huyhoLSEfuQHsMk3ud644eEKqiQc/JSIy3BGbgkf3ud1z2cnBo= 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=qooPU3QV; arc=fail smtp.client-ip=40.107.94.77 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="qooPU3QV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PS22Qw5EX0r19DX0LKVyzQV0MAZcEJ6lqzFOjerKqjl6+XE2HNd9+y7wxOaLvjw+TQcBFdWdtsUEWFzeKBdGFqCB5Zan8pUkIhi9xqIvrJGeHvD+rMs+27dJoQyf8Nwre3Nsv+3FLt9MQE/3pdGAPd8fGg0Pts8tDOtHJDsXR3qWuXdLnnO5qhq0lRL63qYvrPFD1qhKk0H0zQxK1YQ/TbITiL+ArUi9tMkk0dRvaU7nTdUSqHBidXCuszM+VhK/BmAH24m92RvOhLqDQPKd63TBOBVz8jPsb7MsNjyGSsNNLr4aHfPwvJ3gH3tFU4nE8wBVLVQrFCzoZ3mB+7Mmsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N9eZ+cGTwJ/V53kDPaMRiDUP8h6YHqZUU0v1yBkrKfg=; b=UZ/m+GJv0umks9KFbwL59eYTaz+IuiTqd/fLo3NO8nx2lVJDmfobXVp4ifuuk/F5qWTae9uIxYI9ZW7754uXBFF63WnYiUOYk+gEYBjwoROdRAdx64F+jgCrd2PNN7oN87nOstA/ZH13A8qqNv4cr1o9wFC7rhfPR6TmbyN+zno6askF/IMYxC/Db8Pp46oCtwwdoAjXyyyj2FVTrLNUxwLv0jvzyoQwUNzHFWIV6xwIXGN0yL3QjaLS1m9KPSkQH2dkOgnZC2Jrm2VCsWoGD/GbNBJzziUmYYDPrD2csD2RhZGeM05cUDYpfAnPBg97Xq+E4MxUy0ssogUeZ9ahIA== 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=N9eZ+cGTwJ/V53kDPaMRiDUP8h6YHqZUU0v1yBkrKfg=; b=qooPU3QVzCJjJ/lmwNlHRarRI7IPM+tMDLTJSwia9h3kblIvOVKIBDUD1Y5FX04k4KgQuwPGBfa9t1sMZE9x2kQb9UvIrd4HQboWZ48xgpQAzEa5wDsRSvzPazeLBh7V0j+galD/+8XC0F9hX31QKlIu5H25l8oHZzFF64dwJxU= Received: from DS7PR05CA0102.namprd05.prod.outlook.com (2603:10b6:8:56::22) by BN9PR12MB5382.namprd12.prod.outlook.com (2603:10b6:408:103::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.30; Thu, 18 Jan 2024 19:25:26 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::84) by DS7PR05CA0102.outlook.office365.com (2603:10b6:8:56::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:25 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:22 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 6/9] ionic: Add XDP_TX support Date: Thu, 18 Jan 2024 11:24:57 -0800 Message-ID: <20240118192500.58665-7-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|BN9PR12MB5382:EE_ X-MS-Office365-Filtering-Correlation-Id: 12d4b00e-7dbe-4a5f-09ec-08dc185b38fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zCOOfgC48xU8O9saxPU1tX61UL8gW7mSWVIIRxpJptPfAZoqbcN+le0pRzRzBqgZ8xuLgNUnoilvcI26TzaB8/+K2/0eQ6UsYu3UYPSVLLazREcoU/GgjtYc4pV361ssSiqqH6u/VWQATlBFY+jHZzan+8B/8EMj5bzPmJFVsnjQdPHvrPbjOc8SHg8fyiPy7zw9tZih8aJbYDp436/gRk7zrP2+Ge5SGaRrg4IeUsgSIqSHLqPcogrKLKtAGBSnW84CYmw+6zq5jrf8CKogqVoNElLeE14WFk3T664wyP9RRhfY5SJv/t7Agp698h59jQzebZRL/K1RAK90yRLxa23iwUh6s3x5HRlMmAlnWXswN2M27CYokxAjaomBWVkNRUnJa6naIfjUtr+RTKW4l7cAXgwF4pvDFtDxBXBRp/HGamwHQD01wBZJEbfwsy+ZVZahZUAgA4VKwEd8byEpMT+yOoZql1+CANXmvE9yXbetmmj2yS8vpCTyXlEVpeYGdsILuTDi9EPrYQI9DDYxUA3FyJMRuxBoAq8M/k93b579XmLEUmtaPeq2xLX4x45411HvNIc8DvYzOtsIk2q8m6NKpFcrAVzKZVk/0FrMmobwymmWhSIoBytYmCDkFFYi4m4OYr5TssUqIExQoGlUlEeZBB+yUMfRVJ+TeV+3m7ZGE0j5dXFSXihZs8zBtqxofQ6Su4FFb7yFTGgEM8qg9t0LIbOvTM6bwgq0JgXZoJXgIeJY69vrcQCXA/7ClLOwM3XGBJCs/X7X9UhMGctJrA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(346002)(376002)(39860400002)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(83380400001)(16526019)(47076005)(478600001)(316002)(110136005)(70586007)(2616005)(8936002)(54906003)(26005)(6666004)(336012)(4326008)(8676002)(44832011)(426003)(82740400003)(70206006)(1076003)(356005)(81166007)(2906002)(5660300002)(41300700001)(36756003)(36860700001)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:25.6406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12d4b00e-7dbe-4a5f-09ec-08dc185b38fe X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5382 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The XDP_TX packets get fed back into the Rx queue's partnered Tx queue as an xdp_frame. Co-developed-by: Brett Creeley Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.h | 3 + .../net/ethernet/pensando/ionic/ionic_lif.c | 4 + .../net/ethernet/pensando/ionic/ionic_lif.h | 4 + .../net/ethernet/pensando/ionic/ionic_stats.c | 6 + .../net/ethernet/pensando/ionic/ionic_txrx.c | 137 +++++++++++++++++- 5 files changed, 151 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 70f5725fdfe8..76425bb546ba 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -228,6 +228,8 @@ struct ionic_desc_info { struct ionic_buf_info bufs[MAX_SKB_FRAGS + 1]; ionic_desc_cb cb; void *cb_arg; + struct xdp_frame *xdpf; + enum xdp_action act; }; #define IONIC_QUEUE_NAME_MAX_SZ 16 @@ -263,6 +265,7 @@ struct ionic_queue { struct ionic_rxq_sg_desc *rxq_sgl; }; struct xdp_rxq_info *xdp_rxq_info; + struct ionic_queue *partner; 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 6e9065dd149e..997141321c40 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -878,6 +878,9 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) }; int err; + q->partner = &lif->txqcqs[q->index]->q; + q->partner->partner = q; + if (!lif->xdp_prog) ctx.cmd.q_init.flags |= cpu_to_le16(IONIC_QINIT_F_SG); @@ -2923,6 +2926,7 @@ static void ionic_swap_queues(struct ionic_qcq *a, struct ionic_qcq *b) swap(a->q.base_pa, b->q.base_pa); swap(a->q.info, b->q.info); 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); swap(a->q_base_pa, b->q_base_pa); swap(a->q_size, b->q_size); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h index 61fa4ea4f04c..092ff08fc7e0 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h @@ -37,6 +37,7 @@ struct ionic_tx_stats { u64 dma_map_err; u64 hwstamp_valid; u64 hwstamp_invalid; + u64 xdp_frames; }; struct ionic_rx_stats { @@ -54,6 +55,7 @@ struct ionic_rx_stats { u64 xdp_drop; u64 xdp_aborted; u64 xdp_pass; + u64 xdp_tx; }; #define IONIC_QCQ_F_INITED BIT(0) @@ -141,6 +143,8 @@ struct ionic_lif_sw_stats { u64 xdp_drop; u64 xdp_aborted; u64 xdp_pass; + u64 xdp_tx; + u64 xdp_frames; }; enum ionic_lif_state_flags { diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c index 2fb20173b2c6..5d48226e66cd 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c @@ -30,6 +30,8 @@ static const struct ionic_stat_desc ionic_lif_stats_desc[] = { IONIC_LIF_STAT_DESC(xdp_drop), IONIC_LIF_STAT_DESC(xdp_aborted), IONIC_LIF_STAT_DESC(xdp_pass), + IONIC_LIF_STAT_DESC(xdp_tx), + IONIC_LIF_STAT_DESC(xdp_frames), }; static const struct ionic_stat_desc ionic_port_stats_desc[] = { @@ -138,6 +140,7 @@ static const struct ionic_stat_desc ionic_tx_stats_desc[] = { IONIC_TX_STAT_DESC(csum_none), IONIC_TX_STAT_DESC(csum), IONIC_TX_STAT_DESC(vlan_inserted), + IONIC_TX_STAT_DESC(xdp_frames), }; static const struct ionic_stat_desc ionic_rx_stats_desc[] = { @@ -155,6 +158,7 @@ static const struct ionic_stat_desc ionic_rx_stats_desc[] = { IONIC_RX_STAT_DESC(xdp_drop), IONIC_RX_STAT_DESC(xdp_aborted), IONIC_RX_STAT_DESC(xdp_pass), + IONIC_RX_STAT_DESC(xdp_tx), }; #define IONIC_NUM_LIF_STATS ARRAY_SIZE(ionic_lif_stats_desc) @@ -177,6 +181,7 @@ static void ionic_add_lif_txq_stats(struct ionic_lif *lif, int q_num, stats->tx_csum += txstats->csum; stats->tx_hwstamp_valid += txstats->hwstamp_valid; stats->tx_hwstamp_invalid += txstats->hwstamp_invalid; + stats->xdp_frames += txstats->xdp_frames; } static void ionic_add_lif_rxq_stats(struct ionic_lif *lif, int q_num, @@ -194,6 +199,7 @@ static void ionic_add_lif_rxq_stats(struct ionic_lif *lif, int q_num, stats->xdp_drop += rxstats->xdp_drop; stats->xdp_aborted += rxstats->xdp_aborted; stats->xdp_pass += rxstats->xdp_pass; + stats->xdp_tx += rxstats->xdp_tx; } static void ionic_get_lif_stats(struct ionic_lif *lif, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 072a9e376b39..a68f659e416d 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -10,6 +10,16 @@ #include "ionic_lif.h" #include "ionic_txrx.h" +static int ionic_maybe_stop_tx(struct ionic_queue *q, int ndescs); + +static dma_addr_t ionic_tx_map_single(struct ionic_queue *q, + void *data, size_t len); + +static void ionic_tx_clean(struct ionic_queue *q, + struct ionic_desc_info *desc_info, + struct ionic_cq_info *cq_info, + void *cb_arg); + static inline void ionic_txq_post(struct ionic_queue *q, bool ring_dbell, ionic_desc_cb cb_func, void *cb_arg) { @@ -293,6 +303,75 @@ static struct sk_buff *ionic_rx_copybreak(struct ionic_queue *q, return skb; } +static void ionic_xdp_tx_desc_clean(struct ionic_queue *q, + struct ionic_desc_info *desc_info) +{ + unsigned int nbufs = desc_info->nbufs; + struct ionic_buf_info *buf_info; + struct device *dev = q->dev; + + if (!nbufs) + return; + + buf_info = desc_info->bufs; + dma_unmap_single(dev, buf_info->dma_addr, + buf_info->len, DMA_TO_DEVICE); + __free_pages(buf_info->page, 0); + buf_info->page = NULL; + + desc_info->nbufs = 0; + desc_info->xdpf = NULL; + desc_info->act = 0; +} + +static int ionic_xdp_post_frame(struct net_device *netdev, + struct ionic_queue *q, struct xdp_frame *frame, + enum xdp_action act, struct page *page, int off, + bool ring_doorbell) +{ + struct ionic_desc_info *desc_info; + struct ionic_buf_info *buf_info; + struct ionic_tx_stats *stats; + struct ionic_txq_desc *desc; + size_t len = frame->len; + dma_addr_t dma_addr; + u64 cmd; + + desc_info = &q->info[q->head_idx]; + desc = desc_info->txq_desc; + buf_info = desc_info->bufs; + stats = q_to_tx_stats(q); + + dma_addr = ionic_tx_map_single(q, frame->data, len); + if (dma_mapping_error(q->dev, dma_addr)) { + stats->dma_map_err++; + return -EIO; + } + buf_info->dma_addr = dma_addr; + buf_info->len = len; + buf_info->page = page; + buf_info->page_offset = off; + + desc_info->nbufs = 1; + desc_info->xdpf = frame; + desc_info->act = act; + + cmd = encode_txq_desc_cmd(IONIC_TXQ_DESC_OPCODE_CSUM_NONE, + 0, 0, buf_info->dma_addr); + desc->cmd = cpu_to_le64(cmd); + desc->len = cpu_to_le16(len); + desc->csum_start = 0; + desc->csum_offset = 0; + + stats->xdp_frames++; + stats->pkts++; + stats->bytes += len; + + ionic_txq_post(q, ring_doorbell, ionic_tx_clean, NULL); + + return 0; +} + static bool ionic_run_xdp(struct ionic_rx_stats *stats, struct net_device *netdev, struct ionic_queue *rxq, @@ -302,6 +381,10 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, u32 xdp_action = XDP_ABORTED; struct bpf_prog *xdp_prog; struct xdp_buff xdp_buf; + struct ionic_queue *txq; + struct netdev_queue *nq; + struct xdp_frame *xdpf; + int err = 0; xdp_prog = READ_ONCE(rxq->lif->xdp_prog); if (!xdp_prog) @@ -330,14 +413,52 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, break; case XDP_REDIRECT: + goto out_xdp_abort; + case XDP_TX: + xdpf = xdp_convert_buff_to_frame(&xdp_buf); + if (!xdpf) + goto out_xdp_abort; + + txq = rxq->partner; + nq = netdev_get_tx_queue(netdev, txq->index); + __netif_tx_lock(nq, smp_processor_id()); + + if (netif_tx_queue_stopped(nq) || + unlikely(ionic_maybe_stop_tx(txq, 1))) { + __netif_tx_unlock(nq); + goto out_xdp_abort; + } + + dma_unmap_page(rxq->dev, buf_info->dma_addr, + IONIC_PAGE_SIZE, DMA_FROM_DEVICE); + + err = ionic_xdp_post_frame(netdev, txq, xdpf, XDP_TX, + buf_info->page, + buf_info->page_offset, + true); + __netif_tx_unlock(nq); + if (err) { + netdev_dbg(netdev, "tx ionic_xdp_post_frame err %d\n", err); + goto out_xdp_abort; + } + stats->xdp_tx++; + + /* the Tx completion will free the buffers */ + break; + case XDP_ABORTED: default: - trace_xdp_exception(netdev, xdp_prog, xdp_action); - ionic_rx_page_free(rxq, buf_info); - stats->xdp_aborted++; + goto out_xdp_abort; } + return true; + +out_xdp_abort: + trace_xdp_exception(netdev, xdp_prog, xdp_action); + ionic_rx_page_free(rxq, buf_info); + stats->xdp_aborted++; + return true; } @@ -880,6 +1001,16 @@ static void ionic_tx_clean(struct ionic_queue *q, struct sk_buff *skb = cb_arg; u16 qi; + if (desc_info->xdpf) { + ionic_xdp_tx_desc_clean(q->partner, desc_info); + stats->clean++; + + if (unlikely(__netif_subqueue_stopped(q->lif->netdev, q->index))) + netif_wake_subqueue(q->lif->netdev, q->index); + + return; + } + ionic_tx_desc_unmap_bufs(q, desc_info); if (!skb) From patchwork Thu Jan 18 19:24:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523125 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2068.outbound.protection.outlook.com [40.107.237.68]) (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 DBD632E62F for ; Thu, 18 Jan 2024 19:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605930; cv=fail; b=rMy9vEJwAbAb/CDZHfoPpYuKP6e3nlzkfEGuLVaUy9nP//IT9SKAPIShPxocMlL8+pF3HphOk1PjKLpHpcVP7cMaK0kCtskmWNbbFqRBHx+TZSILY7PfnfLM4DdW7+ycQ3NfxTR1yt7IIhIOjRbE2lNffnAU2UBseL7EU0EYNr0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605930; c=relaxed/simple; bh=olqJ6fsH4bqchTy4+JNG/9C7Il0YckzG2Kyl53s76yw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rIJuUG6CHO/GmUCVjxRsWsS+oLikC8l1lvTLIdRt34S5vKZN0/6GhPSlU7JeF8au4IePHbVk6WVlhotJTCytua6Ihh2jSV337wo61wt0FBak08TJbAQUPaZhwJ2emYEjZOnSczU2O/fvX6HFtEX11c9MSCHfbCIfMU0DfeUcU50= 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=1oGQjkAE; arc=fail smtp.client-ip=40.107.237.68 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="1oGQjkAE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nNcqOY1Q2t/V4JTfMW0oqtZqAWjSv23lbS3gprJaa7fE/t2mJaZ334AZKg5jdvOIyq/bzYtwpfo8Alm+yHD7yYLkzAAEy0yasG1ez/7pLHDFoChuat2wJZZpAPOeGaHK6Mi2Esqz2C4UP74mg82eRR6qsp7qcxK/BiR6fIu0W5zyvuWzTgl5MEyOeRwrBOsIJgOxy/Ykj7mFLSLL8Bi8OvEWoXmBzTnMntfsnMTxCgCjDPqaUcEfwtzYITZJf8GxvRmE9FaAg3D/T1F6141fX44LwTzf/3iMxg7tNKZ+WJ109gszfaCsbokjDThEGiptg9o3Cnc4xM3iFspLYZJnaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XaH3CEUQZTWFLWGXid1hgMgpt+AZ5G6/5wOvz+wTxLs=; b=UEFj4jaEGCjCePLoapnVNUsjZcv3PXFFilEgeQfYNy0XGweZoS/hXEZ0KBdZQemhMFnaeuqCe5DSxAauZ/cXlIcVtXL0hgBomqoZ6I3ilfqF/GyFO+keU8zx32ZGoQsyyYDR00RxmeAq8iYMlkZ3oe+ETcPheZvalBLcJUlFZwVXr6OHX1MuqikTOJmPm2EK+L3H1rGeLiAAsJ9v1ib2XAwrmxF9f6XxuRdMUNCgF1FLdwtPnj/ywKLjl4ee0srkgeb2rLpo2LfUhedn8KL+DwYAV8ZmEyzLNJxqKTsCj0fQLwT5C62/y+V/HjvzswdJxClxNRbUpmYb7dvj1ZNeJQ== 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=XaH3CEUQZTWFLWGXid1hgMgpt+AZ5G6/5wOvz+wTxLs=; b=1oGQjkAE0jtIdYB5K/p127GiYZ8PVCCM04rsdeJYLodgd2ZwvPBN3g8xBQbU2Ee9pIkldv1FuUS6W995ARrllVox1JE9vgeLNynY3Ljt5WhaIoztBlj1Zb0ldhipidPhG9b1YelWykgJ9dEGIQAQFjDLwGWIU59k+Hg9iT1qcpc= Received: from DS7PR05CA0102.namprd05.prod.outlook.com (2603:10b6:8:56::22) by SN7PR12MB8434.namprd12.prod.outlook.com (2603:10b6:806:2e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Thu, 18 Jan 2024 19:25:26 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::84) by DS7PR05CA0102.outlook.office365.com (2603:10b6:8:56::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:26 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:24 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 7/9] ionic: Add XDP_REDIRECT support Date: Thu, 18 Jan 2024 11:24:58 -0800 Message-ID: <20240118192500.58665-8-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|SN7PR12MB8434:EE_ X-MS-Office365-Filtering-Correlation-Id: 75e45c5e-71f9-48a2-8d32-08dc185b3983 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gZzxqKgWIjb4+s7Qh9tWJIgxrBF7tHhwehN79NevDzDt3av+zYPJ71vCOVjZ1SW+ZEEm1OPKSyKd2sDMvAfWNYqH9Yy5kwFV2c0DIcncTDfdZj8CpBbM77t8bBD03CLTmeAd04ld8+4IrwpfedY/WV2CE/56XZQ4PgGsx4JekoCkfgasR5coIFsBXrtpyqBAJum7AX1W1wL5yN0dSjlisSC0bodOpUfucE9a02tM1DB3njeSQ1PwOPrQbIapYJo0DEChi+DxK7VIYBsAkXDi2Uo1ZcBelEPt1bMTCxmPxWesmOT3YC9zSl+2QIB55xwioiDFPqneeJZ/qjq4wnxHKFPYIkP0B7Igol+fIR2yQxOIqm+sXhhbTh/+AM8OkGBVsI7lMhTt2FUSCeyLqZ86eBahK5LmqsZP/PTCF++ucAoRxWAsssYWu/aX9lWur6W/hJ12AbSpe3h0tvitHw66altGUwwt7gne/3KNJv9QOyARtBQC3J7vrF/FwNArSsnkrU+/UOO65gVg5Yp1kUznfAYa/GRIpnSOjQtFDFeCIrEB6DQEFYwysC9VRPpHhpBtY2Jo4QRqePDLOtaSZs+lUoE2UV5EjcBiKymU37P6zUH0Bj8jLtJoSOXNQ2aV0SqLE41bZOoWD8EqPL5BFA4Y7o5Z0TdW9BvoUPonAx9RBYZESEWDYWc0cSrQjsWTjqrAoAAsNeCi/an/Fr4SRqJtQ/AQr+DoLsBxKQwgtaM2cmgltl1MI/Mq3S8ESp/vWb8KdY/TNtUYgHa0YwmPPyM/PA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(396003)(39860400002)(346002)(376002)(230922051799003)(451199024)(1800799012)(82310400011)(64100799003)(186009)(40470700004)(46966006)(36840700001)(1076003)(336012)(16526019)(426003)(26005)(40480700001)(40460700003)(5660300002)(83380400001)(2616005)(478600001)(6666004)(70206006)(110136005)(70586007)(316002)(54906003)(47076005)(8936002)(4326008)(8676002)(36860700001)(44832011)(82740400003)(2906002)(86362001)(41300700001)(356005)(36756003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:26.4999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75e45c5e-71f9-48a2-8d32-08dc185b3983 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8434 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The XDP_REDIRECT packets are given to the XDP stack and we drop the use of the related page: it will get freed by the driver that ends up doing the Tx. Because we have some hardware configurations with limited queue resources, we use the existing datapath Tx queues rather than creating and managing a separate set of xdp_tx queues. Co-developed-by: Brett Creeley Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_dev.h | 1 + .../net/ethernet/pensando/ionic/ionic_lif.c | 3 ++- .../net/ethernet/pensando/ionic/ionic_lif.h | 2 ++ .../net/ethernet/pensando/ionic/ionic_stats.c | 3 +++ .../net/ethernet/pensando/ionic/ionic_txrx.c | 24 ++++++++++++++++++- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.h b/drivers/net/ethernet/pensando/ionic/ionic_dev.h index 76425bb546ba..bfcfc2d7bcbd 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_dev.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.h @@ -266,6 +266,7 @@ struct ionic_queue { }; struct xdp_rxq_info *xdp_rxq_info; struct ionic_queue *partner; + bool xdp_flush; 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 997141321c40..bd65b4b2c7f8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -1649,7 +1649,8 @@ static int ionic_init_nic_features(struct ionic_lif *lif) netdev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE; - netdev->xdp_features = NETDEV_XDP_ACT_BASIC; + netdev->xdp_features = NETDEV_XDP_ACT_BASIC | + NETDEV_XDP_ACT_REDIRECT; return 0; } diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h b/drivers/net/ethernet/pensando/ionic/ionic_lif.h index 092ff08fc7e0..42006de8069d 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h @@ -56,6 +56,7 @@ struct ionic_rx_stats { u64 xdp_aborted; u64 xdp_pass; u64 xdp_tx; + u64 xdp_redirect; }; #define IONIC_QCQ_F_INITED BIT(0) @@ -144,6 +145,7 @@ struct ionic_lif_sw_stats { u64 xdp_aborted; u64 xdp_pass; u64 xdp_tx; + u64 xdp_redirect; u64 xdp_frames; }; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_stats.c b/drivers/net/ethernet/pensando/ionic/ionic_stats.c index 5d48226e66cd..0107599a9dd4 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_stats.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_stats.c @@ -31,6 +31,7 @@ static const struct ionic_stat_desc ionic_lif_stats_desc[] = { IONIC_LIF_STAT_DESC(xdp_aborted), IONIC_LIF_STAT_DESC(xdp_pass), IONIC_LIF_STAT_DESC(xdp_tx), + IONIC_LIF_STAT_DESC(xdp_redirect), IONIC_LIF_STAT_DESC(xdp_frames), }; @@ -159,6 +160,7 @@ static const struct ionic_stat_desc ionic_rx_stats_desc[] = { IONIC_RX_STAT_DESC(xdp_aborted), IONIC_RX_STAT_DESC(xdp_pass), IONIC_RX_STAT_DESC(xdp_tx), + IONIC_RX_STAT_DESC(xdp_redirect), }; #define IONIC_NUM_LIF_STATS ARRAY_SIZE(ionic_lif_stats_desc) @@ -200,6 +202,7 @@ static void ionic_add_lif_rxq_stats(struct ionic_lif *lif, int q_num, stats->xdp_aborted += rxstats->xdp_aborted; stats->xdp_pass += rxstats->xdp_pass; stats->xdp_tx += rxstats->xdp_tx; + stats->xdp_redirect += rxstats->xdp_redirect; } static void ionic_get_lif_stats(struct ionic_lif *lif, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index a68f659e416d..c2be2215406a 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -413,7 +413,19 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, break; case XDP_REDIRECT: - goto out_xdp_abort; + /* unmap the pages before handing them to a different device */ + dma_unmap_page(rxq->dev, buf_info->dma_addr, + IONIC_PAGE_SIZE, DMA_FROM_DEVICE); + + err = xdp_do_redirect(netdev, &xdp_buf, xdp_prog); + if (err) { + netdev_dbg(netdev, "xdp_do_redirect err %d\n", err); + goto out_xdp_abort; + } + buf_info->page = NULL; + rxq->xdp_flush = true; + stats->xdp_redirect++; + break; case XDP_TX: xdpf = xdp_convert_buff_to_frame(&xdp_buf); @@ -803,6 +815,14 @@ int ionic_tx_napi(struct napi_struct *napi, int budget) return work_done; } +static void ionic_xdp_do_flush(struct ionic_cq *cq) +{ + if (cq->bound_q->xdp_flush) { + xdp_do_flush(); + cq->bound_q->xdp_flush = false; + } +} + int ionic_rx_napi(struct napi_struct *napi, int budget) { struct ionic_qcq *qcq = napi_to_qcq(napi); @@ -820,6 +840,7 @@ int ionic_rx_napi(struct napi_struct *napi, int 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; @@ -866,6 +887,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget) ionic_rx_fill(rxcq->bound_q); + 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; From patchwork Thu Jan 18 19:24:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523129 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2063.outbound.protection.outlook.com [40.107.95.63]) (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 2EB852E640 for ; Thu, 18 Jan 2024 19:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605932; cv=fail; b=oDZi9BhtHp9MXi5algzEvHYxUkNfAqWbZvYDseGeEmivY8SJoGxWmUqcsnn+d1QbtrjKzu/Yd4UMQFeQpXtTKXevvPXPoBezf4JpCNM7cEutEhHrzrcLVvGvgUkf9FPbp9svpqTWoJhH4aIy3sl1BTNbMskOLdSIu7Z5QV0rL+I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605932; c=relaxed/simple; bh=2g8GMJdRZHv9xdYAgNM/7eeUlVcCVapJh7bNUFKmyDU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R2oToE6KNowI0Q6pBr5ys3KnFY8WahnUHxdaxixTJRZpRlNA2UdieVppa01S7E937VddsT6Ouj3eW+/Hoqk6ZaA4Wueg41hUMNt7dHkAwghUcaoAjii2AktVi6C+eCAF6JXfWUm+GSuORaRfZD2xf6R2/kM6PEKLGZdQ9s2U+eo= 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=qbUVR0BS; arc=fail smtp.client-ip=40.107.95.63 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="qbUVR0BS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=exgy4+fUrO/CNWbrslrzBcqWqPcO7wLn8TMwNZ48Vu3N2FgGrw4YokYh3Jl5EBSz6CjcEVQhesC8RJ8zNvL+nqoLUDR4i7C/JKSV4MQsbzTJM4LZnWz0CEq8GSeL1lffLqp9o5ierJsrRNhekw+TgUcprYQfv/s5tshmk3Z7aoYGHMX71aEBOkcfg7XbJG3L+kkL3dWXSLOpV0/o6roik1yS/ZJOx7+Y3CW57dvC7NLvLzOHklJmgjFpl7toKNrlykc50bCqiXCVbaEhop84YmqZkMHXbSPzH/sxJVNs3dwjAKhQCpZWTaeHJkwpndHugsCL1MVFXZmK53TpktkDgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5RVok7rC3gV/gSSSVgsw8fEa9vrFF1HHJgTk+BLvU24=; b=KFrOaCS2HN3bDl9vSnT/4gjBe/9PT5rgigWkClHkGPQFwHsCfYuJHmosHrKKBtgD3niHYTLOsq/409a+bLmznJUOsksy1fZQ+wa+5Wi2UPNcITtSYXWEPle7C4atsckZtHZ71HliSz6h4zSEIvnFw6ovD3U863vTbLYknnacgQnYHhLD8+PjiCZZd7YUXwmlfd/gZgTmYR9jBadjkB2ohbAIkHX7KWCGJm9AepONANFnLOtkeEAAs3lY68flPAV75XU4+CshfHzSAvX/QWkwCSf7JPAD7q8KdsZ+OuXc4eYVtzuhgnfcI46USN1pMrLBRqEQRF9DsfBe1jmnKBLtJQ== 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=5RVok7rC3gV/gSSSVgsw8fEa9vrFF1HHJgTk+BLvU24=; b=qbUVR0BStOMbMwN/XUfo5yWFYU1MRG8iqGkenKy1Kt6nxGHOQVFjBS1Y1aEvDYl5zY4PBQj4q0isRFV4epzb7JR/hdeYEiPz2J1dUMqIjqYWf5lPVFKz3BkdnHGm/+sfZ65AICJvLWQZB6Pb7xJvC3GE/Bt1pApd4zZLpzXih28= Received: from DS7PR05CA0097.namprd05.prod.outlook.com (2603:10b6:8:56::26) by DS0PR12MB7945.namprd12.prod.outlook.com (2603:10b6:8:153::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Thu, 18 Jan 2024 19:25:26 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::22) by DS7PR05CA0097.outlook.office365.com (2603:10b6:8:56::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:26 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:25 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 8/9] ionic: add ndo_xdp_xmit Date: Thu, 18 Jan 2024 11:24:59 -0800 Message-ID: <20240118192500.58665-9-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|DS0PR12MB7945:EE_ X-MS-Office365-Filtering-Correlation-Id: c8e81cc5-f6c6-4346-00fa-08dc185b39b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D3IgzjJyLtQdwYny4+vTrNCEMCUxkL1jDdqk3nWet1AATtqYkJkEYmCjcnSogiacNAUsboP67+4Zv4k83Jgkbds6Y1luYbGLIbAJaLf2jSsutKHy6eodBqpYb0nXiRP+H1Lb3o0wTDaYFF6PyDBgR2LVRH0bwrqAGYmX7QtQZOxGeE/qLFUmu4QWYaaf5eMCxx9fNY97fxnZnloxMb60LRcdahsN6cVBxM1ft133vzxsjf44sM+/EXt0xTyeLgF6MU/NgalFW25F9MP6KEFIo0SvRsuU6sxzWQ+HYy6EdlM7qAI9GObPUIIuvYLhXmIp90OcMZxQCa9p4PGuY1aKM7ONjCIGBejRyuJdOO0L7wInmS00HOeIo31//lMLPfOa14oAjttLg/n0picMiNHoPMsMozG6Yhdsf/K+T46ZIRWMpAnzuy0OCUx6RaLim/p5MXUqjAp/J4nquK5NsPfjCvb9mFMZfM1rc/yp05VmLu90ajAm3GULJt/CRN7JY4e5CIDnDjR5z18gTt4KvSCVBAhQsYjaeDPP7tSEr6YRXwN4zscO9R2J9komUs5zAnt9zAADCFZ0R8DFKNsUlv5wdBargQN4Scdpj3UDm8Lrrc7jqoDCx6q0XfGOR2qWDxlloQkZnMHux21VFrs9BOgyUKp5xxahkrNEXRmOoc2eBpzxAbbwn3UJy/XdKziGRYEmWhnmbwVShR+2hjlPnCzo4aoh/31zx1Ff3HHnA+r+xTa3DOCfOHf5+ZiyLnEHCRsRoMCUi4IuJtRbjtoOAE7ZyA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(396003)(39860400002)(346002)(230922051799003)(64100799003)(451199024)(186009)(1800799012)(82310400011)(46966006)(36840700001)(40470700004)(26005)(336012)(6666004)(1076003)(16526019)(2616005)(36860700001)(426003)(47076005)(5660300002)(8676002)(4326008)(44832011)(8936002)(41300700001)(2906002)(54906003)(70586007)(478600001)(110136005)(70206006)(316002)(36756003)(81166007)(86362001)(356005)(82740400003)(83380400001)(40460700003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:26.8437 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8e81cc5-f6c6-4346-00fa-08dc185b39b8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7945 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC When our ndo_xdp_xmit is called we mark the buffer with XDP_REDIRECT so we know to return it to the XDP stack for cleaning. Co-developed-by: Brett Creeley Signed-off-by: Brett Creeley Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_lif.c | 4 +- .../net/ethernet/pensando/ionic/ionic_txrx.c | 62 ++++++++++++++++++- .../net/ethernet/pensando/ionic/ionic_txrx.h | 1 + 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index bd65b4b2c7f8..ed5d792c4780 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -1650,7 +1650,8 @@ static int ionic_init_nic_features(struct ionic_lif *lif) IFF_LIVE_ADDR_CHANGE; netdev->xdp_features = NETDEV_XDP_ACT_BASIC | - NETDEV_XDP_ACT_REDIRECT; + NETDEV_XDP_ACT_REDIRECT | + NETDEV_XDP_ACT_NDO_XMIT; return 0; } @@ -2844,6 +2845,7 @@ static const struct net_device_ops ionic_netdev_ops = { .ndo_eth_ioctl = ionic_eth_ioctl, .ndo_start_xmit = ionic_start_xmit, .ndo_bpf = ionic_xdp, + .ndo_xdp_xmit = ionic_xdp_xmit, .ndo_get_stats64 = ionic_get_stats64, .ndo_set_rx_mode = ionic_ndo_set_rx_mode, .ndo_set_features = ionic_set_features, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index c2be2215406a..618d15fb8d95 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -316,9 +316,13 @@ static void ionic_xdp_tx_desc_clean(struct ionic_queue *q, buf_info = desc_info->bufs; dma_unmap_single(dev, buf_info->dma_addr, buf_info->len, DMA_TO_DEVICE); - __free_pages(buf_info->page, 0); + if (desc_info->act == XDP_TX) + __free_pages(buf_info->page, 0); buf_info->page = NULL; + if (desc_info->act == XDP_REDIRECT) + xdp_return_frame(desc_info->xdpf); + desc_info->nbufs = 0; desc_info->xdpf = NULL; desc_info->act = 0; @@ -372,6 +376,62 @@ static int ionic_xdp_post_frame(struct net_device *netdev, return 0; } +int ionic_xdp_xmit(struct net_device *netdev, int n, + struct xdp_frame **xdp_frames, u32 flags) +{ + struct ionic_lif *lif = netdev_priv(netdev); + struct ionic_queue *txq; + struct netdev_queue *nq; + int nxmit; + int space; + int cpu; + int qi; + + if (unlikely(!test_bit(IONIC_LIF_F_UP, lif->state))) + return -ENETDOWN; + + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) + return -EINVAL; + + /* AdminQ is assumed on cpu 0, while we attempt to affinitize the + * TxRx queue pairs 0..n-1 on cpus 1..n. We try to keep with that + * affinitization here, but of course irqbalance and friends might + * have juggled things anyway, so we have to check for the 0 case. + */ + cpu = smp_processor_id(); + qi = cpu ? (cpu - 1) % lif->nxqs : cpu; + + txq = &lif->txqcqs[qi]->q; + nq = netdev_get_tx_queue(netdev, txq->index); + __netif_tx_lock(nq, cpu); + + if (netif_tx_queue_stopped(nq) || + unlikely(ionic_maybe_stop_tx(txq, 1))) { + __netif_tx_unlock(nq); + return -EIO; + } + + space = min_t(int, n, ionic_q_space_avail(txq)); + for (nxmit = 0; nxmit < space ; nxmit++) { + if (ionic_xdp_post_frame(netdev, txq, xdp_frames[nxmit], + XDP_REDIRECT, + virt_to_page(xdp_frames[nxmit]->data), + 0, false)) { + nxmit--; + break; + } + } + + if (flags & XDP_XMIT_FLUSH) + ionic_dbell_ring(lif->kern_dbpage, txq->hw_type, + txq->dbval | txq->head_idx); + + ionic_maybe_stop_tx(txq, 4); + __netif_tx_unlock(nq); + + return nxmit; +} + static bool ionic_run_xdp(struct ionic_rx_stats *stats, struct net_device *netdev, struct ionic_queue *rxq, diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h index d7cbaad8a6fb..82fc38e0f573 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.h @@ -17,4 +17,5 @@ netdev_tx_t ionic_start_xmit(struct sk_buff *skb, struct net_device *netdev); bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info); bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info); +int ionic_xdp_xmit(struct net_device *netdev, int n, struct xdp_frame **xdp, u32 flags); #endif /* _IONIC_TXRX_H_ */ From patchwork Thu Jan 18 19:25:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nelson, Shannon" X-Patchwork-Id: 13523130 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) (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 9FC4B2E647 for ; Thu, 18 Jan 2024 19:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605932; cv=fail; b=i+etVVbm3XFZp8B7o8FYChYztHnuaBMj2acw5DiTlGCeUNx/zbB7CtloQpwctTqhTHheT2HvZ2J5Os0CN+LcHVGnlfK/U5kIyb2jwpjF99/8YHaHpw6RXQb0IBwEQN/dEUjHyolJsxV16bMcPFZC+7HC6FZWJ4a4y8TB+3YCsbo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705605932; c=relaxed/simple; bh=rTrVQVuSC1trimGoRGMFEaBdqZfASNVDVv4GokqH5lQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R1Nn3xrHd2kHQjVwLZqz89flMVmDd4XSIawIdVimokvnGvJDhyUEBCiU5orb92mxAcRy0d0O3Sm6UGn6AdhQNJu/NRHPDJUi9Hn/tmcLh0BEWvxRK14I3CO9bGMOSyrFGFVazxc1ctYwui4Kh1SLDIYKjbRbrWlmXfLYnJ82LDc= 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=nN0RYHsk; arc=fail smtp.client-ip=40.107.94.47 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="nN0RYHsk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=naHltLWGre9aNw5JAogWJ4stASzK4Q+bDb3H54m9O2r+lSHhaGM0CJk+LsKcYE4Ne3IV7PNaivgWqxSJmmzaZLLbZCcKcj1jFDWVkzNd+bPRl3D2cPqspz+ru9PqaWdpofjOJ2jFX8myV9SgoTfgJ0TaoD3Iy+NHCMctYyIJnqwrc+qppOQB1qimgOjDIgKbrHFHXbRjjjhjORjy5N+MoTet5CcvB9jvouTz/lwMbw1/I8p490TrtNgiMpxCgutukN1ODLlmRpz1Q3ma9q6ZH7knz+nkHg98p/14/PjcgEuN/i0JtliYDrut52H8aiYQC+keWirqZll3jPBJVwPrDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vB7CWYYDAYBhZgUXqHPwf+6AaIYuCIi8OUqGMl1C40U=; b=JcV76LVp1Z4aU6Tds3iEXQbby4gXxr3MRi7JHzNVjsri4COajI/govuSIdtdoT4uJMBXH55XoJMD2C5GL9AuprUIIbmIDIYcwWWKfLTxHkItwWRadxntmMOj+1X/1oCCX0WZLuo3tx8QNM7V7lSyd6t10tRqB+FmCXhsAMt7PluYtdTeUnDXwAy7wpeJhXVm2XESuxCmRkl5/518zRw0kd0NKwdfcADP0IL4bQb6LvnnBxF7evfl4ywIdXXhHmxSPv06v8PlGNLH648Xah7gd2pgrqLcQmB0nRjnFJi716bskxZCC2crrpNrqVmn0pZc9InQj9a9xJpI0WW8q5kIWA== 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=vB7CWYYDAYBhZgUXqHPwf+6AaIYuCIi8OUqGMl1C40U=; b=nN0RYHsk8fOZGUdswxyFhQRU+IVhJVK+XWbIrNHzN/X0LA3pPlUfantKfCLoryuIPojJ6c4OKcmqT81l0zUOkH+5jbE5kaKSbcX40qDW2XfaNJb2sEOdxfMc3hh2KnVAKORKUrpEJpNgBg8+lD0npsN5XdjlU8EcARmOMQmgtXI= Received: from DS7PR05CA0086.namprd05.prod.outlook.com (2603:10b6:8:56::7) by IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.29; Thu, 18 Jan 2024 19:25:28 +0000 Received: from DS3PEPF000099DC.namprd04.prod.outlook.com (2603:10b6:8:56:cafe::ab) by DS7PR05CA0086.outlook.office365.com (2603:10b6:8:56::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.8 via Frontend Transport; Thu, 18 Jan 2024 19:25:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DC.mail.protection.outlook.com (10.167.17.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Thu, 18 Jan 2024 19:25:27 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 18 Jan 2024 13:25:26 -0600 From: Shannon Nelson To: , , , , CC: , , Shannon Nelson Subject: [PATCH RFC net-next 9/9] ionic: implement xdp frags support Date: Thu, 18 Jan 2024 11:25:00 -0800 Message-ID: <20240118192500.58665-10-shannon.nelson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240118192500.58665-1-shannon.nelson@amd.com> References: <20240118192500.58665-1-shannon.nelson@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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DC:EE_|IA1PR12MB6458:EE_ X-MS-Office365-Filtering-Correlation-Id: ae85ead3-9ade-40a3-48ef-08dc185b3a42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wmp//zhCN++DUqBzcAiYAxrPAutmt9Qe5vTwR0/DVMtWJXqvaYtR+tLIwEtAtfvIDk9I8baUkPyY8fB1dIzjgeEJs+JwWUhzw+Ht/JkCmOEHMV/xxGIYehButWwwFQfjo96R/wMYuxxhLdDGioQPFyJNEHvJmDmGqE/Bbp6pPvp4SlqZGDDWxT1S8Lz7CzgzxCFrvd+IH9losGpl0Kpw1irvkefoU/oECWuh/GGQATzyl7kUml9GiSm7AdHWdOR6ipC4Lktzro/M0Vl6YdNccH4azLSpey1dpW1+5K1S2/c+9lqmuo8j82MM3wiiRqqEiaSWqOmyU6MuEQRgBTDz2dpEdsQ8c9NahoTMRpPWhAlDs2l+sOEHyFzLChUfl/41YLZI8pzHyKCstkHVQNNHiykGTIsAS3PU5A7DSpNAwaUCdsqfBCDpxN0hIGc5Zt6HMgG56djqzC6W8ExZBrOV7Ci3m6kVIlPJsityfqfE0V8qTYVQYGs5rcZANeUp3niypvMVdCeA6Aea9ScxX+8rT172faRo1s+vc2rZLdHhksfYfgq17+XhYlu8TfJRwsuVNA3tGr2Z1xNUPrpFjdv3cPAPmQAUf9rRAQCeo1khLdADm/NqCr1zFHoPr+EFCUDIu0vRYia5R+lQMXcwBGheDFFONAzr+f+dX31zWsho8/DW7dXBu4aznc9fpUychipOcnP4mVynXg04x+HJB9p2KfFIeYLM1zY0ALgSZiZreDN4WsNjXNM70lWxy4ZVtD7uAQsqlIOcCsQhYqoY8ucDNA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(376002)(346002)(136003)(39860400002)(230922051799003)(186009)(451199024)(82310400011)(64100799003)(1800799012)(40470700004)(36840700001)(46966006)(426003)(6666004)(1076003)(36860700001)(16526019)(336012)(2616005)(26005)(81166007)(5660300002)(83380400001)(47076005)(41300700001)(4326008)(2906002)(44832011)(70586007)(110136005)(70206006)(54906003)(8936002)(8676002)(478600001)(316002)(86362001)(36756003)(82740400003)(356005)(40460700003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 19:25:27.7499 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae85ead3-9ade-40a3-48ef-08dc185b3a42 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6458 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add support for using scatter-gather / frags in XDP in both Rx and Tx paths. Co-developed-by: Brett Creeley 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 | 91 ++++++++++++++++++- 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index ed5d792c4780..11adf3f55fd0 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -881,7 +881,8 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) q->partner = &lif->txqcqs[q->index]->q; q->partner->partner = q; - if (!lif->xdp_prog) + if (!lif->xdp_prog || + (lif->xdp_prog->aux && lif->xdp_prog->aux->xdp_has_frags)) ctx.cmd.q_init.flags |= cpu_to_le16(IONIC_QINIT_F_SG); if (qcq->flags & IONIC_QCQ_F_CMB_RINGS) { @@ -1651,7 +1652,9 @@ static int ionic_init_nic_features(struct ionic_lif *lif) netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | - NETDEV_XDP_ACT_NDO_XMIT; + NETDEV_XDP_ACT_RX_SG | + NETDEV_XDP_ACT_NDO_XMIT | + NETDEV_XDP_ACT_NDO_XMIT_SG; return 0; } @@ -1799,6 +1802,9 @@ static bool ionic_xdp_is_valid_mtu(struct ionic_lif *lif, u32 mtu, if (mtu <= IONIC_XDP_MAX_LINEAR_MTU) return true; + if (xdp_prog->aux && xdp_prog->aux->xdp_has_frags) + return true; + return false; } @@ -2809,7 +2815,7 @@ static int ionic_xdp_config(struct net_device *netdev, struct netdev_bpf *bpf) } maxfs = __le32_to_cpu(lif->identity->eth.max_frame_size) - VLAN_ETH_HLEN; - if (bpf->prog) + if (bpf->prog && !(bpf->prog->aux && bpf->prog->aux->xdp_has_frags)) maxfs = min_t(u32, maxfs, IONIC_XDP_MAX_LINEAR_MTU); netdev->max_mtu = maxfs; diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c index 618d15fb8d95..f80ee7a870fb 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c @@ -15,6 +15,13 @@ static int ionic_maybe_stop_tx(struct ionic_queue *q, int ndescs); static dma_addr_t ionic_tx_map_single(struct ionic_queue *q, void *data, size_t len); +static dma_addr_t ionic_tx_map_frag(struct ionic_queue *q, + const skb_frag_t *frag, + size_t offset, size_t len); + +static void ionic_tx_desc_unmap_bufs(struct ionic_queue *q, + struct ionic_desc_info *desc_info); + static void ionic_tx_clean(struct ionic_queue *q, struct ionic_desc_info *desc_info, struct ionic_cq_info *cq_info, @@ -309,6 +316,7 @@ static void ionic_xdp_tx_desc_clean(struct ionic_queue *q, unsigned int nbufs = desc_info->nbufs; struct ionic_buf_info *buf_info; struct device *dev = q->dev; + int i; if (!nbufs) return; @@ -320,6 +328,15 @@ static void ionic_xdp_tx_desc_clean(struct ionic_queue *q, __free_pages(buf_info->page, 0); buf_info->page = NULL; + 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_REDIRECT) xdp_return_frame(desc_info->xdpf); @@ -360,8 +377,38 @@ static int ionic_xdp_post_frame(struct net_device *netdev, desc_info->xdpf = frame; desc_info->act = act; + if (xdp_frame_has_frags(frame)) { + struct ionic_txq_sg_elem *elem; + struct skb_shared_info *sinfo; + struct ionic_buf_info *bi; + skb_frag_t *frag; + int i; + + bi = &buf_info[1]; + sinfo = xdp_get_shared_info_from_frame(frame); + frag = sinfo->frags; + elem = desc_info->txq_sg_desc->elems; + 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_mapping_error(q->dev, dma_addr)) { + stats->dma_map_err++; + ionic_tx_desc_unmap_bufs(q, desc_info); + return -EIO; + } + bi->dma_addr = dma_addr; + bi->len = skb_frag_size(frag); + bi->page = skb_frag_page(frag); + + elem->addr = cpu_to_le64(bi->dma_addr); + elem->len = cpu_to_le16(bi->len); + elem++; + + desc_info->nbufs++; + } + } + cmd = encode_txq_desc_cmd(IONIC_TXQ_DESC_OPCODE_CSUM_NONE, - 0, 0, buf_info->dma_addr); + 0, (desc_info->nbufs - 1), buf_info->dma_addr); desc->cmd = cpu_to_le64(cmd); desc->len = cpu_to_le16(len); desc->csum_start = 0; @@ -444,6 +491,8 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, struct ionic_queue *txq; struct netdev_queue *nq; struct xdp_frame *xdpf; + int remain_len; + int frag_len; int err = 0; xdp_prog = READ_ONCE(rxq->lif->xdp_prog); @@ -451,8 +500,9 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, return false; xdp_init_buff(&xdp_buf, IONIC_PAGE_SIZE, rxq->xdp_rxq_info); + 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, len, false); + XDP_PACKET_HEADROOM, frag_len, false); dma_sync_single_range_for_cpu(rxq->dev, ionic_rx_buf_pa(buf_info), XDP_PACKET_HEADROOM, len, @@ -460,6 +510,43 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats, prefetchw(&xdp_buf.data_hard_start); + /* We limit MTU size to one buffer if !xdp_has_frags, so + * if the recv len is bigger than one buffer + * then we know we have frag info to gather + */ + remain_len = len - frag_len; + if (remain_len) { + struct skb_shared_info *sinfo; + struct ionic_buf_info *bi; + skb_frag_t *frag; + + bi = buf_info; + sinfo = xdp_get_shared_info_from_buff(&xdp_buf); + sinfo->nr_frags = 0; + sinfo->xdp_frags_size = 0; + xdp_buff_set_frags_flag(&xdp_buf); + + do { + if (unlikely(sinfo->nr_frags >= MAX_SKB_FRAGS)) { + err = -ENOSPC; + goto out_xdp_abort; + } + + 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); + skb_frag_fill_page_desc(frag, bi->page, 0, frag_len); + sinfo->xdp_frags_size += frag_len; + remain_len -= frag_len; + + if (page_is_pfmemalloc(bi->page)) + xdp_buff_set_frag_pfmemalloc(&xdp_buf); + } while (remain_len > 0); + } + xdp_action = bpf_prog_run_xdp(xdp_prog, &xdp_buf); switch (xdp_action) {