From patchwork Thu Jul 28 18:57:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931672 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F24DC04A68 for ; Thu, 28 Jul 2022 18:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbiG1S6p (ORCPT ); Thu, 28 Jul 2022 14:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230403AbiG1S6o (ORCPT ); Thu, 28 Jul 2022 14:58:44 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2074.outbound.protection.outlook.com [40.107.95.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A49E676451 for ; Thu, 28 Jul 2022 11:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LwGxkWljATcYGC88HD7t4O9IdoDFSxSQeISxGn2BWGyNn/625+lsP1xHgaANKHsW3/IgtC5kvhXYHJvMm1ocaZ0HIUPb5IF4bojuy0YjH86FyWeN/Aqnl1fgQ76rgdHnIQ2E00l+cdUAqxbOJN1aMjWaGwU+ejkJCAmw2mM8IFi25BWy1RAU4qEizidgS91GdOb0gscn5GGxpfL0C1U9RsiaIja0p3/aSyJM+AJVC1joHVWT+olsX1A4mSUm9cjMvrYIJpS/gZ0Zv9bujZImNhpTCgCoOG/1K3/eSIhx/6c7ea6Uh4cftfyp0sJkxFOciadH4oD0v95otDwCev/zOg== 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=Nf49AhWBjnE/r+5jl7yktB0YkFTItVCPHNLkkT+ld/k=; b=TontmA1tDXG0rBndgFjS54Z/aZh6bviGJOh4TW4bR8Oo9UY0KbZKT5J2zSL4Wawr4upeXYDUp68JUZqL5vww1OVEfTYUb6P/XWWwH9LPA2ej5+pZ5VTHsrYeixr2fRIf587yI+gnFzfrIwdjg/ZxXcufNNKbnzlWUGwASKVjmv8cNKYILcACZw6sX79RIlOfpc+C5sgz2bqugOLB3kf4NHhUM9NZ6VWo4OpuWDX5VdIhEttSfGkiikwbhTOqrl0/K3vSF+D7ZRkdyZKbEIzSoCygM+fIBujEW3i5pwh8jVHSC4fh9BYCnLRPLZ4XokN5iZDJQokWG1eiNPyFcwmgcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nf49AhWBjnE/r+5jl7yktB0YkFTItVCPHNLkkT+ld/k=; b=H5ZolXYh10shbklU1MyNVYjSMRKsV0eiJNW2kkldEp4j5Wx+qOrE7DY9aZj7K0qHa62pwqayaWKUBQHRRYRj/K0Pqod7XMXMb4HseOoaw+5E8MxbLI+3Wx5yYkjdQt0IhZFy1RRzc/gwTxJjwY/zZsUCa0mxdaFrqJQH8y+2mEfM+k33Zg4x7SP4WeYkk8nO6DprbvFEBqj6YIt1HGkqaUFT1smgBZ6QC2JPFl1yG6heTowrY+FJxSghbvvRobp2IMhtbJ3cXFrLWhk0oEY8t+AMihwHdDuqZmP8kkTEjxiRTzaXompf1gi+W4Vr3cDKvC2MUqoCTW1gdsBHVr/FHg== Received: from BN9P223CA0019.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::24) by MN0PR12MB6270.namprd12.prod.outlook.com (2603:10b6:208:3c2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.24; Thu, 28 Jul 2022 18:58:40 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10b:cafe::c) by BN9P223CA0019.outlook.office365.com (2603:10b6:408:10b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=xilinx.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 BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:39 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:38 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:38 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:37 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 01/10] sfc: plumb ef100 representor stats Date: Thu, 28 Jul 2022 19:57:43 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74f0c718-0946-457d-6fa5-08da70cb2ed7 X-MS-TrafficTypeDiagnostic: MN0PR12MB6270:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DuTzsEwP3x9pv+LSNAHHSkMmHnquomJahJ1cplk3iWouFvfVN1QYoxFfcj7fsILopnoc8MoNJD1p2mS6KNxFo3H/S1eryR/h0lgfVUhImpaIJ8Lej08ZRhBeTMcA2UqGM5DzI9L9ROuihalnpdWhowkrz1zupZlZLYXRGNMilJnn+70kp9b7KD81aPAbvITIfZt/UMbD3Wq7W5ckjEHrJJ3urzihGG7JcrmxYOr/5DEh5GHWT0MafrXvFcgGtwPfTkoKpST6FuNBIK9Kj2tPrnhichlI0qGjunhuJ/43SPW87udXxRkwbc8AGkzpCajGNfc7/jMCh6PLr+3z9BbIJHk20JsXFyESVOee3CD/EEXN1iKIfiYd3+9g24xK2GOyWaPrJN2KgSIRU+oI+X1o9DcI2O/EzlSlqV2FuQ5g5ukD/dPtjcJmRZ2Kl6X3qFUBQZWbpk1Lygh1av+7+0w8u7gnmS/NaVC1Fx0MJ431f59Nyoha97g5dCmXBqGAiwwoTqpSL7QASPZ52Qg9pQmFWY5sJsGpkQS4az3OJfFMREQg9pV//+vfuIYi+OQvV5i4SEbK35y5B4OGPpo2eZ3JAUM4iluasKts8FojOXxqLrKNYOc33hbJPwnD9B4JxHFmw1QBiC626Sn7tAYohb/ZdAnSL1KmuRRdGEXPIGqaDcq462L/iHea1vV5vlCXizMvvr85l7rajfibNL78Mvt3v6janO5QcW5YqJEeboeVwHE6Lsc6x4Wz0aaGBA38Hyq35EjCACi9fu92g8in9ESNnBHFrY+mSs6T01qOUf7s4dHqh39UVhK0IUYr66Rx2oxVhqi0ceqZwKjdPUJlkG2RBw== 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:(13230016)(4636009)(346002)(376002)(39860400002)(396003)(136003)(36840700001)(40470700004)(46966006)(36756003)(55446002)(356005)(8936002)(81166007)(82740400003)(42882007)(40480700001)(186003)(47076005)(36860700001)(83170400001)(9686003)(336012)(82310400005)(316002)(70206006)(26005)(478600001)(110136005)(6666004)(8676002)(4326008)(5660300002)(54906003)(40460700003)(2876002)(70586007)(41300700001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:39.2264 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74f0c718-0946-457d-6fa5-08da70cb2ed7 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: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6270 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Implement .ndo_get_stats64() method to read values out of struct efx_rep_sw_stats. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index d07539f091b8..102071ed051b 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -79,10 +79,24 @@ static int efx_ef100_rep_get_phys_port_name(struct net_device *dev, return 0; } +static void efx_ef100_rep_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 *stats) +{ + struct efx_rep *efv = netdev_priv(dev); + + stats->rx_packets = atomic64_read(&efv->stats.rx_packets); + stats->tx_packets = atomic64_read(&efv->stats.tx_packets); + stats->rx_bytes = atomic64_read(&efv->stats.rx_bytes); + stats->tx_bytes = atomic64_read(&efv->stats.tx_bytes); + stats->rx_dropped = atomic64_read(&efv->stats.rx_dropped); + stats->tx_errors = atomic64_read(&efv->stats.tx_errors); +} + static const struct net_device_ops efx_ef100_rep_netdev_ops = { .ndo_start_xmit = efx_ef100_rep_xmit, .ndo_get_port_parent_id = efx_ef100_rep_get_port_parent_id, .ndo_get_phys_port_name = efx_ef100_rep_get_phys_port_name, + .ndo_get_stats64 = efx_ef100_rep_get_stats64, }; static void efx_ef100_rep_get_drvinfo(struct net_device *dev, From patchwork Thu Jul 28 18:57:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931673 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACDC9C04A68 for ; Thu, 28 Jul 2022 18:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229776AbiG1S6q (ORCPT ); Thu, 28 Jul 2022 14:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbiG1S6o (ORCPT ); Thu, 28 Jul 2022 14:58:44 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7ECE2A71E for ; Thu, 28 Jul 2022 11:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtL0czTHgpibfkM9+TA1PJIYq4M+LRzj8cqC84mjQFT3u6fkeHzaogowSPMBaJK8gVq1sz88bTjIM8IjIYlrzsf+f17m6xlBBRMgPxWLb9HuTLMVTu4uWjZqcKhyYlf77b57Zi5M6ReVImFXObSxcHAWMzUNLH8ElKYF+qu2dLt1xtuFpKuooDhnGA8hnc4xUygClti0Ilgs5X8T0WqLYL/Ysxjr7jmnSue1GXyHKZoqwg15d96HSw6FZ5VwsBzpmlJfVvmw4mlco8H92+9xVDHC6nW5ggeLHRurC7ehvindMy7EMVCAt058ZweZYrZf6JCvpiKXP4uvNfeV4N/1DA== 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=DggtUei1bA7tcaYBGILcO8uL6PwnvobY/ZfO76mhf5U=; b=RHj1lFI3WVBAo7uDkXh5v9CgTfj88xbZ7jXfsYNKRuNyFsHZx3RfXqlXbfiotloXntABEhGVk7DEf8i5HUgOFSwE8zeMCU2WkVPEP+xaGi8Yf1aRghxo1Ph5wLd82ZLarvfBcjQ7qdgWC6hpsdCSeokS0AFMA3L30q/B9s3sHdFkw+W04AZpA/eTMCh9FKCX3agFmIiSU+8FgnQZjrQOBgFFBMjORQI5tzOvG/yFHFEMPRdGBFRLR/WJh3GDS1Oo8pMVpmuesCct0N0nTf1Ys0kMgBvWzJmRx2d+rT6fY/vwYhuHaz89zoKDKvP21rrK3vyjCg38DMNUIsAt/SOCAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DggtUei1bA7tcaYBGILcO8uL6PwnvobY/ZfO76mhf5U=; b=2ETM854S0z7m1nQF1gLe2n0jiM/OpEZ3bmMH2ji/fu8HMkzDqA/2xNO6v7rXiweoa347g+qEzH5vcKq/UdoG+sT6otjXb7xJMZY3Xt1VQsp4VohuB7hwtEdB2osytc2xLn3bATaeCiLcIQrVyMXblBlsni6Wv4sKjTcsLOGl1Tr+Yw+MfkGFsh1L16G+nFQH6khbmEjn1PdxPF5+wccbxonW97e/K8b03heo9jfTJeSdmEElFNT0FUOYwMjJvHColGukbcZs2ySRy4LXxIOmNGYiS/UZbrQhq+L+SvVRrf/BclCWnuDDh4X9G58bsM4kyFXZ3T96ZDGPNEe/FRY2mw== Received: from BN9PR03CA0116.namprd03.prod.outlook.com (2603:10b6:408:fd::31) by CH2PR12MB4022.namprd12.prod.outlook.com (2603:10b6:610:22::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Thu, 28 Jul 2022 18:58:41 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fd:cafe::52) by BN9PR03CA0116.outlook.office365.com (2603:10b6:408:fd::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.23 via Frontend Transport; Thu, 28 Jul 2022 18:58:41 +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=fail action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:40 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:39 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:39 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:38 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 02/10] sfc: ef100 representor RX NAPI poll Date: Thu, 28 Jul 2022 19:57:44 +0100 Message-ID: <5057a124182d9e56ce2195da586cd4f184dc232f.1659034549.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27aa2d50-3a86-4afc-b818-08da70cb2f9a X-MS-TrafficTypeDiagnostic: CH2PR12MB4022:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lexg5Vdke4gPRWEnD1Ig8PPfkFtkLNRB797Ld2jXdtCDDSxwiQWRXzt5gYtdKJsPMNdcDsy9/0AkVJNM877QnjtYTa2TUh7TWBTHvZRgr+SSCzlfzsLfUuBN2G8bcSqju+ECjmbmqqec8ShLdn62bFBpCJCbhgw2flYiFCS8NvTjoTpuYzlhm9xt13/vVYYhAX8430SaskV/PFKhXGusBdYTBi3I+uodFmE5l8QTqxpeatRH8Wy0MGnj1vgJhje+TN+03o8Jw2kejXrSsP3nBgrdb3aT5Q5jYL6VVld+KD7ehX1CxD7LKT2sO76XDqqyyHe9yN3m3Rksh1HvBnWz5WBimlYnIRT0hv2ZK/AiipOdYi59v4t1jO6XQ8qCpWiC3BANzceeQVvVoIBW6qlpQqMLBEtOf4LTRPuan3U4pgAIsOe04vEdiiQVG7+axWVsyFgGe4OeHrVShSNJvpclKX6pkWRO5L6rMENSamhOyOPGIxGEY3SBvDgvFWUcX3BLpbmQUIKimXElEcDRE1ZtG+4M8nKh/5VHwIJc/1qCzOpDkaxX6MxOtelmUTo4yenBM8U69E+j2pl0tvh9M/ohMmnD2s+poBC/6W8pVMgxipD2G2elq17Zr3unHHM2agtM7N5X1DOMITzsNF62k0RJTEIgOusiiOrP5Idwp0WFTZdJp7Rbaf5tAChPIs0LdryOzDhGj8Elw4ulDMl7/PL0XHNLYbIpYs5DW8O4/4FlSSMn6u5JYOnWyYx0OjtXge4WiVo0IEBh/dqgwYryf+iQZpXrKpqgSXf9Zwsk/iYomtP+IcCugaJe//XXehl2CeGA+0S9ckD1etg4QezzCvQWXA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(39860400002)(376002)(396003)(136003)(46966006)(40470700004)(36840700001)(336012)(47076005)(110136005)(186003)(83380400001)(8676002)(316002)(70586007)(42882007)(70206006)(26005)(36756003)(9686003)(4326008)(54906003)(6666004)(2876002)(41300700001)(2906002)(82310400005)(40460700003)(55446002)(40480700001)(36860700001)(5660300002)(8936002)(81166007)(83170400001)(82740400003)(478600001)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:40.5062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27aa2d50-3a86-4afc-b818-08da70cb2f9a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4022 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree This patch adds the 'bottom half' napi->poll routine for representor RX. See the next patch (with the top half) for an explanation of the 'fake interrupt' scheme used to drive this NAPI context. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.c | 64 ++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/ef100_rep.h | 11 +++++ 2 files changed, 75 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index 102071ed051b..fe45ae963391 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -16,12 +16,16 @@ #define EFX_EF100_REP_DRIVER "efx_ef100_rep" +static int efx_ef100_rep_poll(struct napi_struct *napi, int weight); + static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv, unsigned int i) { efv->parent = efx; efv->idx = i; INIT_LIST_HEAD(&efv->list); + INIT_LIST_HEAD(&efv->rx_list); + spin_lock_init(&efv->rx_lock); efv->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP | NETIF_MSG_RX_ERR | @@ -29,6 +33,25 @@ static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv, return 0; } +static int efx_ef100_rep_open(struct net_device *net_dev) +{ + struct efx_rep *efv = netdev_priv(net_dev); + + netif_napi_add(net_dev, &efv->napi, efx_ef100_rep_poll, + NAPI_POLL_WEIGHT); + napi_enable(&efv->napi); + return 0; +} + +static int efx_ef100_rep_close(struct net_device *net_dev) +{ + struct efx_rep *efv = netdev_priv(net_dev); + + napi_disable(&efv->napi); + netif_napi_del(&efv->napi); + return 0; +} + static netdev_tx_t efx_ef100_rep_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -93,6 +116,8 @@ static void efx_ef100_rep_get_stats64(struct net_device *dev, } static const struct net_device_ops efx_ef100_rep_netdev_ops = { + .ndo_open = efx_ef100_rep_open, + .ndo_stop = efx_ef100_rep_close, .ndo_start_xmit = efx_ef100_rep_xmit, .ndo_get_port_parent_id = efx_ef100_rep_get_port_parent_id, .ndo_get_phys_port_name = efx_ef100_rep_get_phys_port_name, @@ -256,3 +281,42 @@ void efx_ef100_fini_vfreps(struct efx_nic *efx) list_for_each_entry_safe(efv, next, &efx->vf_reps, list) efx_ef100_vfrep_destroy(efx, efv); } + +static int efx_ef100_rep_poll(struct napi_struct *napi, int weight) +{ + struct efx_rep *efv = container_of(napi, struct efx_rep, napi); + unsigned int read_index; + struct list_head head; + struct sk_buff *skb; + bool need_resched; + int spent = 0; + + INIT_LIST_HEAD(&head); + /* Grab up to 'weight' pending SKBs */ + spin_lock_bh(&efv->rx_lock); + read_index = efv->write_index; + while (spent < weight && !list_empty(&efv->rx_list)) { + skb = list_first_entry(&efv->rx_list, struct sk_buff, list); + list_del(&skb->list); + list_add_tail(&skb->list, &head); + spent++; + } + spin_unlock_bh(&efv->rx_lock); + /* Receive them */ + netif_receive_skb_list(&head); + if (spent < weight) + if (napi_complete_done(napi, spent)) { + spin_lock_bh(&efv->rx_lock); + efv->read_index = read_index; + /* If write_index advanced while we were doing the + * RX, then storing our read_index won't re-prime the + * fake-interrupt. In that case, we need to schedule + * NAPI again to consume the additional packet(s). + */ + need_resched = efv->write_index != read_index; + spin_unlock_bh(&efv->rx_lock); + if (need_resched) + napi_schedule(&efv->napi); + } + return spent; +} diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h index d47fd8ff6220..77037ab22052 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.h +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -29,7 +29,13 @@ struct efx_rep_sw_stats { * @msg_enable: log message enable flags * @mport: m-port ID of corresponding VF * @idx: VF index + * @write_index: number of packets enqueued to @rx_list + * @read_index: number of packets consumed from @rx_list + * @rx_pring_size: max length of RX list * @list: entry on efx->vf_reps + * @rx_list: list of SKBs queued for receive in NAPI poll + * @rx_lock: protects @rx_list + * @napi: NAPI control structure * @stats: software traffic counters for netdev stats */ struct efx_rep { @@ -38,7 +44,12 @@ struct efx_rep { u32 msg_enable; u32 mport; unsigned int idx; + unsigned int write_index, read_index; + unsigned int rx_pring_size; struct list_head list; + struct list_head rx_list; + spinlock_t rx_lock; + struct napi_struct napi; struct efx_rep_sw_stats stats; }; From patchwork Thu Jul 28 18:57:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931674 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 513BEC04A68 for ; Thu, 28 Jul 2022 18:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbiG1S6x (ORCPT ); Thu, 28 Jul 2022 14:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbiG1S6r (ORCPT ); Thu, 28 Jul 2022 14:58:47 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 172EF2A71E for ; Thu, 28 Jul 2022 11:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hpvyzVARuo3KhsjkHjgiSYfgHJtW+XDjedG/XQrLaCB+wrhqoIpTn7Lx0CDe3LRJeua+BpCSNMnJZnJVprvmd+ivNTTvYP0Tm4ZBKQLM6DNmI+it9b9NHYESTtgBHcXE/DxpwbPKZLDbj2jJ2oq1EDIZ7vnn/VyTovNt0k83gQo0Vkr2oC7TfrIa7vDg6eacelqTHDOA9LBRAlHQepKj/L++JrzhC0vHvsL6VudF/JIubXC81OAXOMIqVkwmDxM1cf/OHvUJ6ajAJ5yqKkZu51CZd0+2CELmI0Ype29B0s0DxRGWVGTK5WR8SBUCa01yc4oiAbw+AAnaM9w8W6DFaA== 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=g1BOn3ovXjF5eBdA59lopxEnBIhV4f4pluGlLUojo/Q=; b=PxTjV+qY6Yh7TITuwpmpMFkkGUt9GjhVg8cjqH9ztKuVQUFwgkc9Kz4+EFveUc9Uy19Ltnqbo8ka2A89HIWy8rzFdY8seQO7tgr1zQkxvK+KvyW959ysWSOGN6RI2nIw7ibuAx+U0a880jxY6hhqbZniRrB4RPtPbUOiDfd+K2euZrtYg8Yvb+IovsHMkvHaQbEb/niyO5AyQfzt8w9uKpm4882Ww8mgDh3CFccLzoTl+G0Bp5ynHwg6otZLoogBKTyjtThxsDdK7iVRtOp7eupQH0t3KblfyAxDITZwCczqdoF2URKH6ffqtoJweiE8JlvhwfTeOl8blQukdz76wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g1BOn3ovXjF5eBdA59lopxEnBIhV4f4pluGlLUojo/Q=; b=296Zahkuo2fAUErZwku5E5NeMZPrB7fqD2/7tB5S+TxZXElLc18n6bzwVu5CtrVxV7wPo+pfxuI3h1o6w+gTxcVhEKiNj5M/cZ4An7Ya+g+SnoGOZXgcxmrqG444H0Pr7GFFLF1lx10jJ3TGpYuWb4IaOq1WijaK8ZhieEca59XyG76zjOL1EhkeiefMLoKHtZrWZpuSVn1e576F2uIwzRiAp7R9YMXitf4SHxJl1hhVk0sVYLjvsU8x+P9fZRO6y1rEZDKz/T1skARzAp5tpvUMZM/N9e4mMktqjLSzLfnKpmBMpMGSWcaYhXs7tJCuAwxdEKWenzltFXjNH53wZw== Received: from BN9PR03CA0805.namprd03.prod.outlook.com (2603:10b6:408:13f::30) by SJ1PR12MB6242.namprd12.prod.outlook.com (2603:10b6:a03:457::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Thu, 28 Jul 2022 18:58:43 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13f:cafe::33) by BN9PR03CA0805.outlook.office365.com (2603:10b6:408:13f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.7 via Frontend Transport; Thu, 28 Jul 2022 18:58:42 +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=fail action=none header.from=xilinx.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 BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:42 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:41 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:40 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:39 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 03/10] sfc: ef100 representor RX top half Date: Thu, 28 Jul 2022 19:57:45 +0100 Message-ID: <3dd40cb839017241fe29b09c44501f37ee2a29c8.1659034549.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: beb5349a-594d-4fa9-2831-08da70cb30b9 X-MS-TrafficTypeDiagnostic: SJ1PR12MB6242:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RpK+hIyHZV7eTfRR4nMTVmgWLEBiF3sCU6ZUSlkNvyODHprRmK7JVbefTalJ5URDATOAyXi4M3a0ChNigIbKzkOhIJe+f3BVuP1A5cCDXXwaH+lo88QGBXfDSZ22sxt0ZbXHHrKo1wpjr+cgf/NMZ4QZJIhwpU1JxUZ2kIU8vwqa2tuHAyDVheBDfVNzJdb7gXQPZgxqPkhS2+Vp0zDSm2x6AQB88IS9oW8q3Z2PPriCqgTb5SYkCRvq57MOblIIAxf6wr/lE0EtVgqsSVeAHLpm5BqjLHswi6zed270yHemutRKemgRQ0ktdWBbe85pkZuLuq/T3yVtgbqxowf7T/tPjMeJz0tiCzhceRK3fkYNpexzpuASHyYH1UTioU0lz9b9ZgUk3lOs67y3G5U449DLaRnI8NsSjb/E9JLcGdpoQIik1GD4ja8y2XZ7/4o6E6bsUkcKk3MofflU6c5+q1HHJTVWuUVtyh829tGLQZF8H2xvP3aNX+8jTAsPpuEbJ7fMbz4oeIbIXdu23ZEAIm+jOm5U/a29tOsQlgf585A4ToBYtGYrSgiFWhY0FFOF80sMWYyq04gjoaIFovu0YULed7VmAZu3pNO5X3/vEg3V9JpbUmh5g9IlBh5/8iROw47WAT06EBUqfrw5ICkYuryWT+Rqj/TxwFtcJL5JKFbucQ04/IPEw7VXtOH8DNR6RUW9gcTi9wGcCaEcZS4C5+X3f/gL9QjA7elfrxvxscp83zLBHHODwXY3EzaZAPcYnlEMv3pO75rRredPInu+DhKEmtTNg7dVPjBPb7EHBGCbeCfm9pFaij65jBwS+iwRS7d44jUDEhOVTrNZFPD6OA== 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:(13230016)(4636009)(346002)(376002)(136003)(396003)(39860400002)(40470700004)(36840700001)(46966006)(110136005)(55446002)(82310400005)(82740400003)(40460700003)(8936002)(5660300002)(26005)(81166007)(41300700001)(316002)(36860700001)(47076005)(2906002)(6666004)(83170400001)(42882007)(186003)(356005)(336012)(8676002)(54906003)(83380400001)(70206006)(40480700001)(478600001)(9686003)(36756003)(2876002)(4326008)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:42.3678 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: beb5349a-594d-4fa9-2831-08da70cb30b9 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: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6242 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Representor RX uses a NAPI context driven by a 'fake interrupt': when the parent PF receives a packet destined for the representor, it adds it to an SKB list (efv->rx_list), and schedules NAPI if the 'fake interrupt' is primed. The NAPI poll then pulls packets off this list and feeds them to the stack with netif_receive_skb_list(). This scheme allows us to decouple representor RX from the parent PF's RX fast-path. This patch implements the 'top half', which builds an SKB, copies data into it from the RX buffer (which can then be released), adds it to the queue and fires the 'fake interrupt' if necessary. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.c | 55 ++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/ef100_rep.h | 1 + 2 files changed, 56 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index fe45ae963391..e6c6e9e764b2 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -13,9 +13,12 @@ #include "ef100_netdev.h" #include "ef100_nic.h" #include "mae.h" +#include "rx_common.h" #define EFX_EF100_REP_DRIVER "efx_ef100_rep" +#define EFX_REP_DEFAULT_PSEUDO_RING_SIZE 64 + static int efx_ef100_rep_poll(struct napi_struct *napi, int weight); static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv, @@ -198,6 +201,7 @@ static int efx_ef100_configure_rep(struct efx_rep *efv) u32 selector; int rc; + efv->rx_pring_size = EFX_REP_DEFAULT_PSEUDO_RING_SIZE; /* Construct mport selector for corresponding VF */ efx_mae_mport_vf(efx, efv->idx, &selector); /* Look up actual mport ID */ @@ -320,3 +324,54 @@ static int efx_ef100_rep_poll(struct napi_struct *napi, int weight) } return spent; } + +void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf) +{ + u8 *eh = efx_rx_buf_va(rx_buf); + struct sk_buff *skb; + bool primed; + + /* Don't allow too many queued SKBs to build up, as they consume + * GFP_ATOMIC memory. If we overrun, just start dropping. + */ + if (efv->write_index - READ_ONCE(efv->read_index) > efv->rx_pring_size) { + atomic64_inc(&efv->stats.rx_dropped); + if (net_ratelimit()) + netif_dbg(efv->parent, rx_err, efv->net_dev, + "nodesc-dropped packet of length %u\n", + rx_buf->len); + return; + } + + skb = netdev_alloc_skb(efv->net_dev, rx_buf->len); + if (!skb) { + atomic64_inc(&efv->stats.rx_dropped); + if (net_ratelimit()) + netif_dbg(efv->parent, rx_err, efv->net_dev, + "noskb-dropped packet of length %u\n", + rx_buf->len); + return; + } + memcpy(skb->data, eh, rx_buf->len); + __skb_put(skb, rx_buf->len); + + skb_record_rx_queue(skb, 0); /* rep is single-queue */ + + /* Move past the ethernet header */ + skb->protocol = eth_type_trans(skb, efv->net_dev); + + skb_checksum_none_assert(skb); + + atomic64_inc(&efv->stats.rx_packets); + atomic64_add(rx_buf->len, &efv->stats.rx_bytes); + + /* Add it to the rx list */ + spin_lock_bh(&efv->rx_lock); + primed = efv->read_index == efv->write_index; + list_add_tail(&skb->list, &efv->rx_list); + efv->write_index++; + spin_unlock_bh(&efv->rx_lock); + /* Trigger rx work */ + if (primed) + napi_schedule(&efv->napi); +} diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h index 77037ab22052..7d2f15cee8d1 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.h +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -57,4 +57,5 @@ int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i); void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv); void efx_ef100_fini_vfreps(struct efx_nic *efx); +void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf); #endif /* EF100_REP_H */ From patchwork Thu Jul 28 18:57:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931676 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A282DC04A68 for ; Thu, 28 Jul 2022 18:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbiG1S67 (ORCPT ); Thu, 28 Jul 2022 14:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbiG1S6r (ORCPT ); Thu, 28 Jul 2022 14:58:47 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 289497645D for ; Thu, 28 Jul 2022 11:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JdfbdYaU6CW9Llhe1wG+0jVKaXTNeIu/WEyItnF5UJotQ17ASlAdfiotynNoXFcUMZir43uiGeVaNrS6pTtRmhQHBM3tNWz8AlO79Dx48PECuxTHLcnZrKG5zGHDA978KE3fIXRH+Y1cHXncubrSuXNybQ9bwDHorG7QdtXmG8w432aetsNCHsztgN3lnYSTzrggQH2TaZ517wwVe+b9Hz3mQDwcDvqE1s8d67BS7vbBzKUDjAqn4ZvzhkiD/rT774hNls/XW1MuxH2fMZC4+2kR0tYerq0p/Mk1tb2oyXO2TwHpHkJKX4kS8hLGKgTxVWPn3jub5HOd9JGLYARodA== 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=XfdqkurY77O25VPVcelRdCW/iPWMGoqTJUW5RIBF9cc=; b=Mz/AqSX/kxPXo8Fro4i7g1OxhZMxByb4wE91bkM9aEq0mFcxseA9rtxSH1C48uA/ZQlHqMjrL8Mv3/sRK/mriDqXleZVRTbsjnuO2LPas5et5qFHFWTcsU0zrJUa+wEDuVz/01MAuqx1DtZL0mbne+Ov5YVzaCvOstYQ+7nqIFDM5N8OFPJC9UW/qz4PjYpRj+lsNXJbRATg3PmTWJXT5wk+EqPlxUwzPGYA9Qql++/ingFe1dK3XykwUGYy8xv4MWT10smGZY+lPcId2FKBndtmJyIlvSsH0AGxL73w7uPFgMSWchmX1W/6Q9ylOZqPRNgvUmkAfYeTf+Z+cHp2Xw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XfdqkurY77O25VPVcelRdCW/iPWMGoqTJUW5RIBF9cc=; b=t7st1mEXY0r9CBLAwyoYw0Xf09C3eYxeAzUHSAA9BzT/vfN+xEpmINDlUnQthiS1WbIVv0+Pi//kharnrP4uCNdi7LDC2c52h+BQ3bczpktaxran1IDuzc1at2aAx8eQYdktWsH2CG0LWm4qAW3UtaF/dCaI+K5Enz/lQA3ozBE+2XfXsbzt6W3NYhAuZeQW46RREij7ZIyhubvx0Q0Ae6+wRqV0DPZP/OzUXlhXFrkUvs/tW9XyL7o8XNp4xC7PJ6+JxoOpjRHyanLNrmtmvN1bkvfhvrvb3IwXpxjKSKxciKe+7qEDgr4rUSfpeScY8pg8lW2GQ/qgQhfbyl6gNg== Received: from BN1PR12CA0020.namprd12.prod.outlook.com (2603:10b6:408:e1::25) by IA1PR12MB6042.namprd12.prod.outlook.com (2603:10b6:208:3d6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.25; Thu, 28 Jul 2022 18:58:43 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::d) by BN1PR12CA0020.outlook.office365.com (2603:10b6:408:e1::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Thu, 28 Jul 2022 18:58:43 +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=fail action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:43 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:42 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:41 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:40 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 04/10] sfc: determine wire m-port at EF100 PF probe time Date: Thu, 28 Jul 2022 19:57:46 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71cde54d-726d-4e06-2ca3-08da70cb3123 X-MS-TrafficTypeDiagnostic: IA1PR12MB6042:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YpSY4D2TNlj6ZQ9f7PZunFyuIveW8rM1LCqV/AIxxXx5sDbQNre7bAT+SVNjOW1NuSLmgHiUYjQ6M/GDQ6+kq5TTBrIzzUjDb/Xy52462upl57JleSe16o811+nzAne/QZbqi9cgOrtsJnje7+frPdK+sYEDY+509Dnlu3X9rXkHbYSHbjLLlhJHx97y/DSS301tRNEUjFwHALHOCc2gcQFE1CWVhzngA8D+xISeRWG0q25QvtUkgLPzQlFybtROkvt1mjhnhaEweh51iyzPj2IJFqiMiMBmnce36vpBUtXNEEnQay8zd2ESC9vdB4HJfvrQ62K+2GmGzf6ICFeH+5fiuavBfjDcg7ljXZogpUVB9X3FzN/FtmUMW3PgPM0VrdiPRVVGUfrmcVlpx0F56gsQLGO7Kf6Y/jZ9KoEoy3vI4zWf/W6LugoNjmaTJ+PqyF+QleYYFPull5OY2rv3C8gOLewfOGXVJEDUYMO/goVRkmJApGcdNgSjEeIEddho7gLnF3OrdcJlOzZmBxKyrM8bMnVWbJ+jFtr3tcDWyUTzz1bKBIpindwKandzOpTqlp8eJYjy8MZkniMtEaaWGJHpxhAtnBU/7v4pdWGCggM6rWxW72VF4B0yzQL9TwPI8/3tzkRP5HH5NHiv9LSn/w7smKUQXBTjvitVyDVn4XL0OdUEM8ImFV/aQKvfPWZD1jNYPit9VTKl4kYWuGpP8OFGVvWx9TEsyyDeATKfGXAyq5xE1ExWxDCTa3hz2WV13QKbjLAaRZ4GOAfmzJrmJHh1yoLhfOs9eHQ+zVQaF1DU4HqiaGBSZSRDaKe1DH0mDnslVL1yQtsfmSmxeLrnPg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(346002)(136003)(376002)(396003)(40470700004)(36840700001)(46966006)(70586007)(40480700001)(8936002)(9686003)(82740400003)(26005)(36860700001)(54906003)(8676002)(70206006)(81166007)(110136005)(83170400001)(478600001)(41300700001)(42882007)(4326008)(36756003)(55446002)(2876002)(186003)(316002)(82310400005)(5660300002)(40460700003)(336012)(83380400001)(356005)(2906002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:43.0782 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71cde54d-726d-4e06-2ca3-08da70cb3123 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6042 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Traffic delivered to the (MAE admin) PF could be from either the wire or a VF. The INGRESS_MPORT field of the RX prefix distinguishes these; base_mport is the value this field will have for traffic from the wire (which should be delivered to the PF's netdevice, not a representor). Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_nic.c | 37 ++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/ef100_nic.h | 2 ++ drivers/net/ethernet/sfc/mae.c | 10 ++++++++ drivers/net/ethernet/sfc/mae.h | 1 + 4 files changed, 50 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index 4625d35269e6..393d6ca4525c 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -24,6 +24,7 @@ #include "ef100_tx.h" #include "ef100_sriov.h" #include "ef100_netdev.h" +#include "mae.h" #include "rx_common.h" #define EF100_MAX_VIS 4096 @@ -704,6 +705,31 @@ static unsigned int efx_ef100_recycle_ring_size(const struct efx_nic *efx) return 10 * EFX_RECYCLE_RING_SIZE_10G; } +#ifdef CONFIG_SFC_SRIOV +static int efx_ef100_get_base_mport(struct efx_nic *efx) +{ + struct ef100_nic_data *nic_data = efx->nic_data; + u32 selector, id; + int rc; + + /* Construct mport selector for "physical network port" */ + efx_mae_mport_wire(efx, &selector); + /* Look up actual mport ID */ + rc = efx_mae_lookup_mport(efx, selector, &id); + if (rc) + return rc; + /* The ID should always fit in 16 bits, because that's how wide the + * corresponding fields in the RX prefix & TX override descriptor are + */ + if (id >> 16) + netif_warn(efx, probe, efx->net_dev, "Bad base m-port id %#x\n", + id); + nic_data->base_mport = id; + nic_data->have_mport = true; + return 0; +} +#endif + static int compare_versions(const char *a, const char *b) { int a_major, a_minor, a_point, a_patch; @@ -1064,6 +1090,17 @@ int ef100_probe_netdev_pf(struct efx_nic *efx) eth_hw_addr_set(net_dev, net_dev->perm_addr); memcpy(nic_data->port_id, net_dev->perm_addr, ETH_ALEN); + if (!nic_data->grp_mae) + return 0; + +#ifdef CONFIG_SFC_SRIOV + rc = efx_ef100_get_base_mport(efx); + if (rc) { + netif_warn(efx, probe, net_dev, + "Failed to probe base mport rc %d; representors will not function\n", + rc); + } +#endif return 0; fail: diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h index 40f84a275057..0295933145fa 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.h +++ b/drivers/net/ethernet/sfc/ef100_nic.h @@ -72,6 +72,8 @@ struct ef100_nic_data { u8 port_id[ETH_ALEN]; DECLARE_BITMAP(evq_phases, EFX_MAX_CHANNELS); u64 stats[EF100_STAT_COUNT]; + u32 base_mport; + bool have_mport; /* base_mport was populated successfully */ bool grp_mae; /* MAE Privilege */ u16 tso_max_hdr_len; u16 tso_max_payload_num_segs; diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index 011ebd46ada5..0cbcadde6677 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -13,6 +13,16 @@ #include "mcdi.h" #include "mcdi_pcol.h" +void efx_mae_mport_wire(struct efx_nic *efx, u32 *out) +{ + efx_dword_t mport; + + EFX_POPULATE_DWORD_2(mport, + MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_PPORT, + MAE_MPORT_SELECTOR_PPORT_ID, efx->port_num); + *out = EFX_DWORD_VAL(mport); +} + void efx_mae_mport_vf(struct efx_nic *efx __always_unused, u32 vf_id, u32 *out) { efx_dword_t mport; diff --git a/drivers/net/ethernet/sfc/mae.h b/drivers/net/ethernet/sfc/mae.h index 27e69e8a54b6..25c2fd94e158 100644 --- a/drivers/net/ethernet/sfc/mae.h +++ b/drivers/net/ethernet/sfc/mae.h @@ -15,6 +15,7 @@ #include "net_driver.h" +void efx_mae_mport_wire(struct efx_nic *efx, u32 *out); void efx_mae_mport_vf(struct efx_nic *efx, u32 vf_id, u32 *out); int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id); From patchwork Thu Jul 28 18:57:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931675 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA289C04A68 for ; Thu, 28 Jul 2022 18:58:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232396AbiG1S64 (ORCPT ); Thu, 28 Jul 2022 14:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbiG1S6s (ORCPT ); Thu, 28 Jul 2022 14:58:48 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2080.outbound.protection.outlook.com [40.107.101.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AE37646B for ; Thu, 28 Jul 2022 11:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hx/ckODcQ0lyvHYJ9WfOk8QUPmexjPDn4m/xqU2b8PiV5h0v2nEXq48OXs6TtYH6+t93HyV9KMglTi/bhRTNUEIogeICgljz+R3OVN+bzxJj3afpoW/wf4AsZIkpunpk0IhYiib0g0IoCn8YicNCy2P+ufZ/KcBJyrekn7xo1xeIcBfhMCLakfWLIcL9GS3fviO4HWSeTHqwnsVDvVga+Jiwlav2bERpue1C7Y2dYx7Zz5BSLVdn/gRzExgZy5W9EBt+AosYwS9G0vGCxGXrO90DhuPgUWa7CQaQynySvqQI2aRUN2h/QaedpPBq0oCsRJVoNBlJR9zBxis64/AYQw== 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=CHgwljLfdYJ2/mmfLdsSo5WsvB6WAUWcUmPQlYkqf88=; b=MoWvKQ16FKmI33mo4iSJkkLI357PDlzGFI2ztRTYs2EJLHzrU5DHU3GeS4Q4rDVlRqWN7ys8+0ZI3pST7v8Or9lq05MqHHP+Fxh/Wxk6ss/f5aGbiuFcjEMYkQOYPwZdmQHVBaDJ/XZv63kswvvKH6pnfrVbR8TNAbtoHrcMY/X5qVUlR9A/Sd0MNhNwUD10GuprcBjKHryazWhZvRI/9qh8tucbmuhfuENGkS8KkT2Z+bS7a7kzD7d0cDxZ+BogPyR4ldf6/dN/cCQojJunf59aAlP637cLHLgyaSFnecigDR/s8LrevspSLGpuU1CUyrmen+pDbx8DTGpo4xYEnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CHgwljLfdYJ2/mmfLdsSo5WsvB6WAUWcUmPQlYkqf88=; b=Br1nxtHKlJI52eHz+iAeLnI4cjo6hPKgW3GaNCAnFKSasVByFdCD0YGqnGvfv9RvVy93y/FOzCBe8BdaOQE0NyW4wo0F/7JmhCncuN9+8ZqPGoXN+50JBUpqqGfuYN4GaDn7Mj+KlLR7QoA1jjevQc8uUa4bOKM7EO6KEySEZFn86aj/l8E/Q80dRxK7FmgS3C9rMvJR4tK5X3qgmyDPQzTXxX7qfIZzuQa1WA9cPkMo5zZQDsqeHx72JT6Khzqy+CHa9cx2MiGXtY/HYsLx8jdimRiwzkMP9lSi+UZVLoqb0tZLZuI+w5Qan6fASvBFapWLjrmv2olW46PWFFPpkQ== Received: from BN8PR15CA0060.namprd15.prod.outlook.com (2603:10b6:408:80::37) by BY5PR12MB4179.namprd12.prod.outlook.com (2603:10b6:a03:211::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Thu, 28 Jul 2022 18:58:45 +0000 Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::f9) by BN8PR15CA0060.outlook.office365.com (2603:10b6:408:80::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Thu, 28 Jul 2022 18:58:45 +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=fail action=none header.from=xilinx.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 BN8NAM11FT054.mail.protection.outlook.com (10.13.177.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:44 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:43 -0500 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:42 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 05/10] sfc: check ef100 RX packets are from the wire Date: Thu, 28 Jul 2022 19:57:47 +0100 Message-ID: <635300dea9828bef7f1267f68bd73978125d651b.1659034549.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ed1450f-dbbe-4653-e023-08da70cb31d3 X-MS-TrafficTypeDiagnostic: BY5PR12MB4179:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7sl+OhSJoy3nvjP9xY24iJQ1qZorI9Ilge4EIKRnFsDnjCnfCqfG/fYHwM2fWQaZA3j5cNukYQC/P6ITjTOma7SF97H4pi/1RIu4U0j746T/04atR9itnJSnz3NhRv4dl6y7leqsRkMFYRC5HuSBmghaXDNKw6BBEZ+yvTMc3AbE3qofSZxgveDJ3hjcaLxW90LMM4NDxnb+FCskPpWY7QdkCbcpcItuatjjK3tsrycOqn9yWq+zFTDpTzADBDbf8fBePQKuTqkLKwPm2rz3rvPZktMuQuq2AtqsGEuax7DmtSXpLz+HAK1DT+r1CA7DIwZjcU0hzzNcnNy5KnQRtlhYrIjy4LPRxjKSA/SIKNOnEpS89u6DW3WciTPEb4fo3oJA+TtH9StCeB4bCn3V8zysUQ893z5Jca2kSQ/5PZlnm4sIS2HBb3s7iXrEG16Zq9pv6rM57CtVxuIPuhqVovXwmbpTuVEzHJhZqIYWaImjFol3Ns5nMQypJoNG6gp0Lw98D0rlZKCAMlMa+3/S+miN5rLg4y5m4axfXc5UEL7lMuanIQ7GwS/qfdiTN1p1Tu7QWHlkVbM+TFn1fS00f4eGADV344F9lrZNDCHZaXYORioS3HjIx4gBEBwjHdfDL6l4YvCdwwReSpnmt0F7QiPfzq7HXlIhY/gjIPewEUi037B6SOIZM4K6k/iZ6I87hcoonZ0JprWGHRJ705b6Eq2hdlb0VSLrbsEKhkXhc8u5mcT45kG9UV8dN0yjcCkp8aa9XufcyJryU4ekX2bxiy3Wz2ybCzB2ZLJcd2t9SRS3LmIDxtlqvDR8wDuEUBAhG2mQsZDGyPBeBLAjgxf2Sw== 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:(13230016)(4636009)(376002)(136003)(346002)(39860400002)(396003)(36840700001)(40470700004)(46966006)(47076005)(36860700001)(42882007)(36756003)(336012)(5660300002)(186003)(8936002)(2906002)(82310400005)(26005)(2876002)(9686003)(55446002)(70586007)(81166007)(70206006)(110136005)(41300700001)(316002)(54906003)(83170400001)(82740400003)(356005)(478600001)(83380400001)(40460700003)(40480700001)(4326008)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:44.2362 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ed1450f-dbbe-4653-e023-08da70cb31d3 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: BN8NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4179 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree If not, for now drop them and warn. A subsequent patch will look up the source m-port to try and find a representor to deliver them to. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rx.c | 28 ++++++++++++++++++----- drivers/net/ethernet/sfc/ethtool_common.c | 1 + drivers/net/ethernet/sfc/net_driver.h | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_rx.c b/drivers/net/ethernet/sfc/ef100_rx.c index 85207acf7dee..b8da9e3b7bf2 100644 --- a/drivers/net/ethernet/sfc/ef100_rx.c +++ b/drivers/net/ethernet/sfc/ef100_rx.c @@ -55,10 +55,14 @@ static bool ef100_has_fcs_error(struct efx_channel *channel, u32 *prefix) void __ef100_rx_packet(struct efx_channel *channel) { - struct efx_rx_buffer *rx_buf = efx_rx_buffer(&channel->rx_queue, channel->rx_pkt_index); + struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel); + struct efx_rx_buffer *rx_buf = efx_rx_buffer(rx_queue, + channel->rx_pkt_index); struct efx_nic *efx = channel->efx; + struct ef100_nic_data *nic_data; u8 *eh = efx_rx_buf_va(rx_buf); __wsum csum = 0; + u16 ing_port; u32 *prefix; prefix = (u32 *)(eh - ESE_GZ_RX_PKT_PREFIX_LEN); @@ -76,6 +80,19 @@ void __ef100_rx_packet(struct efx_channel *channel) goto out; } + ing_port = le16_to_cpu((__force __le16) PREFIX_FIELD(prefix, INGRESS_MPORT)); + + nic_data = efx->nic_data; + + if (nic_data->have_mport && ing_port != nic_data->base_mport) { + if (net_ratelimit()) + netif_warn(efx, drv, efx->net_dev, + "Unrecognised ing_port %04x (base %04x), dropping\n", + ing_port, nic_data->base_mport); + channel->n_rx_mport_bad++; + goto free_rx_buffer; + } + if (likely(efx->net_dev->features & NETIF_F_RXCSUM)) { if (PREFIX_FIELD(prefix, NT_OR_INNER_L3_CLASS) == 1) { ++channel->n_rx_ip_hdr_chksum_err; @@ -87,17 +104,16 @@ void __ef100_rx_packet(struct efx_channel *channel) } if (channel->type->receive_skb) { - struct efx_rx_queue *rx_queue = - efx_channel_get_rx_queue(channel); - /* no support for special channels yet, so just discard */ WARN_ON_ONCE(1); - efx_free_rx_buffers(rx_queue, rx_buf, 1); - goto out; + goto free_rx_buffer; } efx_rx_packet_gro(channel, rx_buf, channel->rx_pkt_n_frags, eh, csum); + goto out; +free_rx_buffer: + efx_free_rx_buffers(rx_queue, rx_buf, 1); out: channel->rx_pkt_n_frags = 0; } diff --git a/drivers/net/ethernet/sfc/ethtool_common.c b/drivers/net/ethernet/sfc/ethtool_common.c index 58ad9d665805..bc840ede3053 100644 --- a/drivers/net/ethernet/sfc/ethtool_common.c +++ b/drivers/net/ethernet/sfc/ethtool_common.c @@ -91,6 +91,7 @@ static const struct efx_sw_stat_desc efx_sw_stat_desc[] = { EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_bad_drops), EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_tx), EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_redirect), + EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mport_bad), #ifdef CONFIG_RFS_ACCEL EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(rfs_filter_count), EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_succeeded), diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 4cde54cf77b9..6b64ba3a7d36 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -478,6 +478,8 @@ enum efx_sync_events_state { * @n_rx_xdp_bad_drops: Count of RX packets dropped due to XDP errors * @n_rx_xdp_tx: Count of RX packets retransmitted due to XDP * @n_rx_xdp_redirect: Count of RX packets redirected to a different NIC by XDP + * @n_rx_mport_bad: Count of RX packets dropped because their ingress mport was + * not recognised * @rx_pkt_n_frags: Number of fragments in next packet to be delivered by * __efx_rx_packet(), or zero if there is none * @rx_pkt_index: Ring index of first buffer for next packet to be delivered @@ -540,6 +542,7 @@ struct efx_channel { unsigned int n_rx_xdp_bad_drops; unsigned int n_rx_xdp_tx; unsigned int n_rx_xdp_redirect; + unsigned int n_rx_mport_bad; unsigned int rx_pkt_n_frags; unsigned int rx_pkt_index; From patchwork Thu Jul 28 18:57:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931677 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E21BC19F29 for ; Thu, 28 Jul 2022 18:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbiG1S7B (ORCPT ); Thu, 28 Jul 2022 14:59:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbiG1S6t (ORCPT ); Thu, 28 Jul 2022 14:58:49 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2047.outbound.protection.outlook.com [40.107.212.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8845376471 for ; Thu, 28 Jul 2022 11:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJgoCQIZTS9CIbiB7slbejIwEDa/pGaNJk0x7lHeIuxaLEv2cZw36C6A9eRGNfGgR8xGqa0C0pZdZtbRlJvlWnyQGvV3Mi3vLfC/P9iUq+v76iglp1h5qNzKSCOnpDtdN09JHRnZl5pObuBRHJYJPEkNhMmHFKln51ywbdmYj205iAddguGCNFBfQle2A1k0HuKVyVZli3YGzuxF6oguADpuVYOa1EBx9q+R52EOCxHoAuCMpsKq5+DCH2qiRDfYYMm/+5/102hcv6wRgOW5tCC9TNEUKxrVBusIFS3/HA88yGK+BZwwg4cAILQbezkhG1AW0oRCcLkEw7Z119gAkg== 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=ZsxzpVA0evyMd+LHcvf0PtSRKmgHQWQFg5kaQMjSEfA=; b=OCx2sTA3QROcbkePl+v1tsbhtqxSdLES/UHkHSy8qufz0kZyTFrS8QSqHFRSdeL6IP5UPHyBXWQoTujb5AONU6hEdVOY4HqjuCNLCeDmSbNvJcVtZvHJzvvzX8xqaRfbQkmMPLG9lruJC1NEIiMDmATouypUSVFy6tLlLnyolzv2c34dSuj+98M26eAWnsSJD7jwFmax3AcHl4/CW7Anc2+7x/aEjoimsDgV0Ca7un64jNttq2wHKrxz11e2VgsuB53OS5JyFuKQKsZFKKpc5MIZ9/gq202QjLyYjkZg+XxgJR7SYK4kVAz+EA5Qoi2xz+I0tJgIN3AxpM9dQusoDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZsxzpVA0evyMd+LHcvf0PtSRKmgHQWQFg5kaQMjSEfA=; b=rzZPSUTFBdsLf1LDH6AMXWqN04FMpSoKPcpATjE9peZhzdHRTfkQAIxnqhyIrdusRERrclOQG0wGhpYcOog+xpATMg8noMwYYQ/kY1RCP8ScMf0bH1eKSmVs46ydEBEaiQ6fGou0e84xOuWGTUKrzHLmBCcSQDv0M+Szq8M/kSJALhtsIeRYA/pDWp+cm7lnGglktX5pqHPK2fbWEIvWv9ACGpgC3Umd2HzDYwwWoHmo//210C843A51jKNoz58zYiPy3elmyQ7miinDFOowHalRGTPgFi/GC/PlKWmPOQJbZAO+08HL7uyjIbYK8Lho+59FpJbDI6kGy21t6kHvew== Received: from BN8PR15CA0048.namprd15.prod.outlook.com (2603:10b6:408:80::25) by PH7PR12MB5757.namprd12.prod.outlook.com (2603:10b6:510:1d0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Thu, 28 Jul 2022 18:58:46 +0000 Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::34) by BN8PR15CA0048.outlook.office365.com (2603:10b6:408:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.23 via Frontend Transport; Thu, 28 Jul 2022 18:58:45 +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=fail action=none header.from=xilinx.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 BN8NAM11FT054.mail.protection.outlook.com (10.13.177.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:45 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:44 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:44 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:43 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 06/10] sfc: receive packets from EF100 VFs into representors Date: Thu, 28 Jul 2022 19:57:48 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b375b239-4334-415e-d42d-08da70cb328d X-MS-TrafficTypeDiagnostic: PH7PR12MB5757:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mlQpvH/AfDTcuFEN3AzeXl5ymamQq431y9zZbgIJ+VPH17PjNxMfJIu6+aP2GFKmpLWP5yeTg7cVxj5JVRr5LAmJuyhg5HlMDT8BQw3Lzw/dJnEH68t384jvULEJJEE1OYbotz6uJHb3RsKFIAp1j2aKvEebmtv1ky2yzwAc0v4uDi0chsfjrpdUoIwzurmjPbi8yNkTGtX0QhcMwaTxfeP2UZCmfykvMu1OHiemVkGAlpZXUO8I1iQXz8jHsp9/OHUYf+9v8MDDTXiPvZDXPW3MzgPF6XZuixR5/GPkVynEJXVzymTBlg4Rq9DIbveUg6wI6IJH6G9cOfRYxyU1aqYPlZRZV7IhSdYKyYNVKIgpKeeYAeNA8byP7IIJ5v1v/7Rbr8sWvanIS5UKVkyEjwTxdZljWHVggWcQJyMl4eErht703CRQBy//g+PEujzbGPzyCWl6osRsJx4qULBh5xRwnqy8PwieylcNHRxbZ3Thh3Mt4dn7l1OAgs7ju6dx30K7FLgp2QtapvIeMQ81x8Pru7yMD7Z3/XbTDpcmYCPHZwsAm2G/cf6mSq6R8DxLLwL2x0/os0YrkIzT7N1zJVTjEv+r98FTm2eIY0GRwDiOXc1wD4LxpXPO7EfSUbeeeUI58VAEiDMovF2BR8ZTLMLJeDBT76lHP2xOoVgOzeFiw2j1uUgr1Vsy+e9UVg/A+eu4rq5cFAy0gg1OP0oy3OhaHoJn1zXS+vLThqwMMw1g8UuF13MspyYxVxEx5N+Ci/hHrJkUTQQsRcf+dw/M3UfFbbAI0cMmV6Vx59AjDHgXwCD/DSv0J+L7WUXv3tZT+LWlej0wa6Y28youWbzfnA== 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:(13230016)(4636009)(346002)(39860400002)(376002)(136003)(396003)(40470700004)(36840700001)(46966006)(336012)(82740400003)(70206006)(2876002)(478600001)(26005)(70586007)(4326008)(47076005)(40460700003)(186003)(8676002)(42882007)(8936002)(2906002)(356005)(54906003)(81166007)(9686003)(83170400001)(5660300002)(40480700001)(83380400001)(82310400005)(41300700001)(110136005)(36860700001)(316002)(36756003)(55446002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:45.4549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b375b239-4334-415e-d42d-08da70cb328d 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: BN8NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5757 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree If the source m-port of a packet in __ef100_rx_packet() is a VF, hand off the packet to the corresponding representor with efx_ef100_rep_rx_packet(). Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.c | 19 +++++++++++++++++++ drivers/net/ethernet/sfc/ef100_rep.h | 5 +++++ drivers/net/ethernet/sfc/ef100_rx.c | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index e6c6e9e764b2..c0bc12b9e348 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -224,6 +224,7 @@ static void efx_ef100_rep_destroy_netdev(struct efx_rep *efv) list_del(&efv->list); spin_unlock_bh(&efx->vf_reps_lock); rtnl_unlock(); + synchronize_rcu(); free_netdev(efv->net_dev); } @@ -375,3 +376,21 @@ void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf) if (primed) napi_schedule(&efv->napi); } + +struct efx_rep *efx_ef100_find_rep_by_mport(struct efx_nic *efx, u16 mport) +{ + struct efx_rep *efv, *out = NULL; + + /* spinlock guards against list mutation while we're walking it; + * but caller must also hold rcu_read_lock() to ensure the netdev + * isn't freed after we drop the spinlock. + */ + spin_lock_bh(&efx->vf_reps_lock); + list_for_each_entry(efv, &efx->vf_reps, list) + if (efv->mport == mport) { + out = efv; + break; + } + spin_unlock_bh(&efx->vf_reps_lock); + return out; +} diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h index 7d2f15cee8d1..f3787133f793 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.h +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -58,4 +58,9 @@ void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv); void efx_ef100_fini_vfreps(struct efx_nic *efx); void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf); +/* Returns the representor corresponding to a VF m-port, or NULL + * @mport is an m-port label, *not* an m-port ID! + * Caller must hold rcu_read_lock(). + */ +struct efx_rep *efx_ef100_find_rep_by_mport(struct efx_nic *efx, u16 mport); #endif /* EF100_REP_H */ diff --git a/drivers/net/ethernet/sfc/ef100_rx.c b/drivers/net/ethernet/sfc/ef100_rx.c index b8da9e3b7bf2..65bbe37753e6 100644 --- a/drivers/net/ethernet/sfc/ef100_rx.c +++ b/drivers/net/ethernet/sfc/ef100_rx.c @@ -85,6 +85,24 @@ void __ef100_rx_packet(struct efx_channel *channel) nic_data = efx->nic_data; if (nic_data->have_mport && ing_port != nic_data->base_mport) { +#ifdef CONFIG_SFC_SRIOV + struct efx_rep *efv; + + rcu_read_lock(); + efv = efx_ef100_find_rep_by_mport(efx, ing_port); + if (efv) { + if (efv->net_dev->flags & IFF_UP) + efx_ef100_rep_rx_packet(efv, rx_buf); + rcu_read_unlock(); + /* Representor Rx doesn't care about PF Rx buffer + * ownership, it just makes a copy. So, we are done + * with the Rx buffer from PF point of view and should + * free it. + */ + goto free_rx_buffer; + } + rcu_read_unlock(); +#endif if (net_ratelimit()) netif_warn(efx, drv, efx->net_dev, "Unrecognised ing_port %04x (base %04x), dropping\n", From patchwork Thu Jul 28 18:57:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931680 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE333C19F2B for ; Thu, 28 Jul 2022 18:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbiG1S7S (ORCPT ); Thu, 28 Jul 2022 14:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232681AbiG1S67 (ORCPT ); Thu, 28 Jul 2022 14:58:59 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F547645D for ; Thu, 28 Jul 2022 11:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P1LzbYlAhsEiD1Kz7ipAVRvkCVNYwDpcfTAS/cAweg6QpbGfxmYbn8E/zeeeknJLMGM7EPibe5SLZfSLQV9D5gyCKty5u9vCPwIa4jnPGsN7W5ZWWloJNJgwUObgIwWrtzqPfpZhbVDzUKmHGCfZoW2ipfNfUxEQ2F/vSUM57COGQPVKhZktw0X49rangqHDlHrjnVPfOw9ba/J2WBzmY0fMpG0YwIE06hhmg32APGO2GIgQ+XAW+6enCSxFl2UHYaBa5OJGG3rQp9+YtHEBec/+7bwY2qntFxVBQGx3zehHTLY/T6zpmgMnEA98ySQ+PsHvEpWHzW7oD/GAGvtJww== 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=nh1OfmGAQFZNa3emMqCs8K34bnNisgd/RXB3eEa2bV4=; b=RxQQfWYDwpyVn9uQQH4z8uNIH+ewvz2Fp7DeJw3HzAHgPQkUXbD6vPYejG33hN5c5UK3ak8gIovSMgbvPuddThnZrmrR4WAqgxRiyMmGnhHEcj8aT9P38hYP7IBNcJqvBV+MdkWIPCNGbTBkMFIKkq3nJoJeLwJtE7rrvwmaJzrVc3B/eBQMzpfigO1uPYcnZ2W4mnYTYuW9jJlOzVamPzmpH+0FcMRWUNmXuWHK6SyouZKTn5VR0WotS/vWXI6nDwSkaBtzdUc1N1NNDSEGgaBtTSph1mfT9IvrsK/uz+zKC+ohGfj516t1lZfn9jxNqdEWN1LZIvvg0UXiW/mvhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nh1OfmGAQFZNa3emMqCs8K34bnNisgd/RXB3eEa2bV4=; b=v8P7WGDG5OUjxynWTwtz1k2XmUplEj9rtDwpdKGudDa6VRfMiA4FPSA0OhZUT4/cY/O06fuy6k1QSCmZoeNT8QjQveDkkjP8RVVpL0mL8CzW9LcpwUeIhxp+VSV/DeIxlVLfa4GMEzPJN6BDpfwENKQqBYrOgxXOdHmv/vNYoeKMCh0ureiR/4bhrQI4vncX6IDdXrSVkQu8DVIRAmvkEjxjKQ/7Or1g7jFbgXI+noVIn+jWpSV4jjqSGGWvubfx0PB4bRPDE4B54YZWxok43aUwTi0fflp3fMCxKQfFPRNPX1+Oo2LcV/ryXHEu/wzvrcFz0QTQlBkSEZuMmOyUxQ== Received: from BN9PR03CA0428.namprd03.prod.outlook.com (2603:10b6:408:113::13) by MW4PR12MB5603.namprd12.prod.outlook.com (2603:10b6:303:16a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.25; Thu, 28 Jul 2022 18:58:48 +0000 Received: from BN8NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:408:113:cafe::19) by BN9PR03CA0428.outlook.office365.com (2603:10b6:408:113::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.24 via Frontend Transport; Thu, 28 Jul 2022 18:58:48 +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=fail action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT065.mail.protection.outlook.com (10.13.177.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:47 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:46 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:45 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:44 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 07/10] sfc: insert default MAE rules to connect VFs to representors Date: Thu, 28 Jul 2022 19:57:49 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64f52c55-d3f0-41cc-9390-08da70cb3399 X-MS-TrafficTypeDiagnostic: MW4PR12MB5603:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j35g4/W96uA6udpj5v8s2bn09RaWHgcHx81yDkLUJPZIG1eJqDViioPFAeZHyiHs03qH2+bnY2kYLqoCiFIQWu/IOemHHVSnYONHM8FKTutoNLxYsnd0yeN4+eSIh8nfBfeUAvHWH3N8YyE4NT915HrFGBhOKPweynLM0h8A6afzWpGaEoYjGWemCuEgiJKYvNlqOSoaBM+7b+xluXxiXlsGRYYoPnTgDIjOQgHYYmjcOW+QnCMY6xJRGMdDYaojmUW0DWNA4uespALaKSik5zFE++DKK3uhw3MlHgBTuNC3GH5EfJN8C3Q7trCAs+l0ZW6UxLPg61meb0yv0GELum+AT/EMKzb5JCHbANsbXQ80BVlpXT/0Wbi/kK/VkDCRCI+miyL8eP6gDRRNxVyHKSxIe8j600WKQqnjFkU8fgLE7J8fXI7XXTk00PzCfZIAPSGa1jfCH56xxqqn2THCal6SE1X+JspkAMLwlZ75csOQZAyDy9MlMQs1WA6nh0HHcd0vz1zmg0mqolv5AzZ4S7/lc1Q39rNcZfVzfAgKBCq0s8kfjfm2/rHiqp0QG45nu5ijF5q4Rf/txzP/mXoJe0hogY7AYhkQAmTFAot9MES8E27nt/RqUcPfjwiDgb/TAuspZ1xoSm11buVwwjJkQ3fxhc+QPqfCgw/4aa3Gg4zUclvifnHzc3MlL82EVmkak7139+2tm1vm4YvxT1CWphwZJWMqC04Md36kBxPJrjymo619kZn+PUxDsZdH9/pc8PtZXBS31Kq8Jl15nDJc0gd2ZGBUT0LOgbxKKPEq1acqeAAKRjeQ5gB4ZA0FS7dmDyb+H0F1QxQSxgtBQLFAtGF0Bt99N8P2fn1WqMuKR28= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(376002)(346002)(136003)(396003)(36840700001)(40470700004)(46966006)(186003)(336012)(54906003)(110136005)(356005)(9686003)(30864003)(41300700001)(47076005)(26005)(42882007)(2906002)(2876002)(83380400001)(55446002)(36756003)(70206006)(40480700001)(5660300002)(83170400001)(316002)(478600001)(82310400005)(82740400003)(8676002)(81166007)(70586007)(40460700003)(4326008)(8936002)(36860700001)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:47.2096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64f52c55-d3f0-41cc-9390-08da70cb3399 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5603 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Default rules are low-priority switching rules which the hardware uses in the absence of higher-priority rules. Each representor requires a corresponding rule matching traffic from its representee VF and delivering to the PF (where a check on INGRESS_MPORT in __ef100_rx_packet() will direct it to the representor). No rule is required in the reverse direction, because representor TX uses a TX override descriptor to bypass the MAE and deliver directly to the VF. Since inserting any rule into the MAE disables the firmware's own default rules, also insert a pair of rules to connect the PF to the physical network port and vice-versa. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/Makefile | 3 +- drivers/net/ethernet/sfc/ef100.c | 3 + drivers/net/ethernet/sfc/ef100_netdev.c | 4 + drivers/net/ethernet/sfc/ef100_nic.c | 17 ++ drivers/net/ethernet/sfc/ef100_rep.c | 20 +- drivers/net/ethernet/sfc/ef100_rep.h | 3 + drivers/net/ethernet/sfc/mae.c | 257 ++++++++++++++++++++++- drivers/net/ethernet/sfc/mae.h | 16 ++ drivers/net/ethernet/sfc/mcdi.h | 4 + drivers/net/ethernet/sfc/mcdi_pcol_mae.h | 24 +++ drivers/net/ethernet/sfc/net_driver.h | 2 + drivers/net/ethernet/sfc/tc.c | 183 ++++++++++++++++ drivers/net/ethernet/sfc/tc.h | 76 +++++++ 13 files changed, 606 insertions(+), 6 deletions(-) create mode 100644 drivers/net/ethernet/sfc/mcdi_pcol_mae.h create mode 100644 drivers/net/ethernet/sfc/tc.c create mode 100644 drivers/net/ethernet/sfc/tc.h diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile index 4c759488fc77..bb06fa228367 100644 --- a/drivers/net/ethernet/sfc/Makefile +++ b/drivers/net/ethernet/sfc/Makefile @@ -8,7 +8,8 @@ sfc-y += efx.o efx_common.o efx_channels.o nic.o \ ef100.o ef100_nic.o ef100_netdev.o \ ef100_ethtool.o ef100_rx.o ef100_tx.o sfc-$(CONFIG_SFC_MTD) += mtd.o -sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o mae.o +sfc-$(CONFIG_SFC_SRIOV) += sriov.o ef10_sriov.o ef100_sriov.o ef100_rep.o \ + mae.o tc.o obj-$(CONFIG_SFC) += sfc.o diff --git a/drivers/net/ethernet/sfc/ef100.c b/drivers/net/ethernet/sfc/ef100.c index 425017fbcb25..71aab3d0480f 100644 --- a/drivers/net/ethernet/sfc/ef100.c +++ b/drivers/net/ethernet/sfc/ef100.c @@ -431,6 +431,9 @@ static void ef100_pci_remove(struct pci_dev *pci_dev) probe_data = container_of(efx, struct efx_probe_data, efx); ef100_remove_netdev(probe_data); +#ifdef CONFIG_SFC_SRIOV + efx_fini_struct_tc(efx); +#endif ef100_remove(efx); efx_fini_io(efx); diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c index 9e65de1ab889..17b9d37218cb 100644 --- a/drivers/net/ethernet/sfc/ef100_netdev.c +++ b/drivers/net/ethernet/sfc/ef100_netdev.c @@ -329,6 +329,10 @@ void ef100_remove_netdev(struct efx_probe_data *probe_data) ef100_unregister_netdev(efx); +#ifdef CONFIG_SFC_SRIOV + efx_fini_tc(efx); +#endif + down_write(&efx->filter_sem); efx_mcdi_filter_table_remove(efx); up_write(&efx->filter_sem); diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index 393d6ca4525c..25cd43e3fcf7 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -1094,12 +1094,29 @@ int ef100_probe_netdev_pf(struct efx_nic *efx) return 0; #ifdef CONFIG_SFC_SRIOV + rc = efx_init_struct_tc(efx); + if (rc) + return rc; + rc = efx_ef100_get_base_mport(efx); if (rc) { netif_warn(efx, probe, net_dev, "Failed to probe base mport rc %d; representors will not function\n", rc); } + + rc = efx_init_tc(efx); + if (rc) { + /* Either we don't have an MAE at all (i.e. legacy v-switching), + * or we do but we failed to probe it. In the latter case, we + * may not have set up default rules, in which case we won't be + * able to pass any traffic. However, we don't fail the probe, + * because the user might need to use the netdevice to apply + * configuration changes to fix whatever's wrong with the MAE. + */ + netif_warn(efx, probe, net_dev, "Failed to probe MAE rc %d\n", + rc); + } #endif return 0; diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index c0bc12b9e348..eac932710c63 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -27,6 +27,8 @@ static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv, efv->parent = efx; efv->idx = i; INIT_LIST_HEAD(&efv->list); + efv->dflt.fw_id = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL; + INIT_LIST_HEAD(&efv->dflt.acts.list); INIT_LIST_HEAD(&efv->rx_list); spin_lock_init(&efv->rx_lock); efv->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE | @@ -212,7 +214,14 @@ static int efx_ef100_configure_rep(struct efx_rep *efv) /* mport label should fit in 16 bits */ WARN_ON(efv->mport >> 16); - return 0; + return efx_tc_configure_default_rule_rep(efv); +} + +static void efx_ef100_deconfigure_rep(struct efx_rep *efv) +{ + struct efx_nic *efx = efv->parent; + + efx_tc_deconfigure_default_rule(efx, &efv->dflt); } static void efx_ef100_rep_destroy_netdev(struct efx_rep *efv) @@ -246,19 +255,21 @@ int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i) pci_err(efx->pci_dev, "Failed to configure representor for VF %d, rc %d\n", i, rc); - goto fail; + goto fail1; } rc = register_netdev(efv->net_dev); if (rc) { pci_err(efx->pci_dev, "Failed to register representor for VF %d, rc %d\n", i, rc); - goto fail; + goto fail2; } pci_dbg(efx->pci_dev, "Representor for VF %d is %s\n", i, efv->net_dev->name); return 0; -fail: +fail2: + efx_ef100_deconfigure_rep(efv); +fail1: efx_ef100_rep_destroy_netdev(efv); return rc; } @@ -272,6 +283,7 @@ void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv) return; netif_dbg(efx, drv, rep_dev, "Removing VF representor\n"); unregister_netdev(rep_dev); + efx_ef100_deconfigure_rep(efv); efx_ef100_rep_destroy_netdev(efv); } diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h index f3787133f793..070f700893c1 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.h +++ b/drivers/net/ethernet/sfc/ef100_rep.h @@ -14,6 +14,7 @@ #define EF100_REP_H #include "net_driver.h" +#include "tc.h" struct efx_rep_sw_stats { atomic64_t rx_packets, tx_packets; @@ -32,6 +33,7 @@ struct efx_rep_sw_stats { * @write_index: number of packets enqueued to @rx_list * @read_index: number of packets consumed from @rx_list * @rx_pring_size: max length of RX list + * @dflt: default-rule for MAE switching * @list: entry on efx->vf_reps * @rx_list: list of SKBs queued for receive in NAPI poll * @rx_lock: protects @rx_list @@ -46,6 +48,7 @@ struct efx_rep { unsigned int idx; unsigned int write_index, read_index; unsigned int rx_pring_size; + struct efx_tc_flow_rule dflt; struct list_head list; struct list_head rx_list; spinlock_t rx_lock; diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index 0cbcadde6677..ea87ec83e618 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -11,7 +11,7 @@ #include "mae.h" #include "mcdi.h" -#include "mcdi_pcol.h" +#include "mcdi_pcol_mae.h" void efx_mae_mport_wire(struct efx_nic *efx, u32 *out) { @@ -23,6 +23,17 @@ void efx_mae_mport_wire(struct efx_nic *efx, u32 *out) *out = EFX_DWORD_VAL(mport); } +void efx_mae_mport_uplink(struct efx_nic *efx __always_unused, u32 *out) +{ + efx_dword_t mport; + + EFX_POPULATE_DWORD_3(mport, + MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_FUNC, + MAE_MPORT_SELECTOR_FUNC_PF_ID, MAE_MPORT_SELECTOR_FUNC_PF_ID_CALLER, + MAE_MPORT_SELECTOR_FUNC_VF_ID, MAE_MPORT_SELECTOR_FUNC_VF_ID_NULL); + *out = EFX_DWORD_VAL(mport); +} + void efx_mae_mport_vf(struct efx_nic *efx __always_unused, u32 vf_id, u32 *out) { efx_dword_t mport; @@ -34,6 +45,17 @@ void efx_mae_mport_vf(struct efx_nic *efx __always_unused, u32 vf_id, u32 *out) *out = EFX_DWORD_VAL(mport); } +/* Constructs an mport selector from an mport ID, because they're not the same */ +void efx_mae_mport_mport(struct efx_nic *efx __always_unused, u32 mport_id, u32 *out) +{ + efx_dword_t mport; + + EFX_POPULATE_DWORD_2(mport, + MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_MPORT_ID, + MAE_MPORT_SELECTOR_MPORT_ID, mport_id); + *out = EFX_DWORD_VAL(mport); +} + /* id is really only 24 bits wide */ int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id) { @@ -52,3 +74,236 @@ int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id) *id = MCDI_DWORD(outbuf, MAE_MPORT_LOOKUP_OUT_MPORT_ID); return 0; } + +static bool efx_mae_asl_id(u32 id) +{ + return !!(id & BIT(31)); +} + +int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act) +{ + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_SET_ALLOC_OUT_LEN); + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_ACTION_SET_ALLOC_IN_LEN); + size_t outlen; + int rc; + + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_ALLOC_IN_SRC_MAC_ID, + MC_CMD_MAE_MAC_ADDR_ALLOC_OUT_MAC_ID_NULL); + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_ALLOC_IN_DST_MAC_ID, + MC_CMD_MAE_MAC_ADDR_ALLOC_OUT_MAC_ID_NULL); + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_ALLOC_IN_COUNTER_ID, + MC_CMD_MAE_COUNTER_ALLOC_OUT_COUNTER_ID_NULL); + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_ALLOC_IN_COUNTER_LIST_ID, + MC_CMD_MAE_COUNTER_LIST_ALLOC_OUT_COUNTER_LIST_ID_NULL); + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_ALLOC_IN_ENCAP_HEADER_ID, + MC_CMD_MAE_ENCAP_HEADER_ALLOC_OUT_ENCAP_HEADER_ID_NULL); + if (act->deliver) + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_ALLOC_IN_DELIVER, + act->dest_mport); + BUILD_BUG_ON(MAE_MPORT_SELECTOR_NULL); + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_ACTION_SET_ALLOC, inbuf, sizeof(inbuf), + outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < sizeof(outbuf)) + return -EIO; + act->fw_id = MCDI_DWORD(outbuf, MAE_ACTION_SET_ALLOC_OUT_AS_ID); + /* We rely on the high bit of AS IDs always being clear. + * The firmware API guarantees this, but let's check it ourselves. + */ + if (WARN_ON_ONCE(efx_mae_asl_id(act->fw_id))) { + efx_mae_free_action_set(efx, act->fw_id); + return -EIO; + } + return 0; +} + +int efx_mae_free_action_set(struct efx_nic *efx, u32 fw_id) +{ + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_SET_FREE_OUT_LEN(1)); + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_ACTION_SET_FREE_IN_LEN(1)); + size_t outlen; + int rc; + + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_FREE_IN_AS_ID, fw_id); + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_ACTION_SET_FREE, inbuf, sizeof(inbuf), + outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < sizeof(outbuf)) + return -EIO; + /* FW freed a different ID than we asked for, should never happen. + * Warn because it means we've now got a different idea to the FW of + * what action-sets exist, which could cause mayhem later. + */ + if (WARN_ON(MCDI_DWORD(outbuf, MAE_ACTION_SET_FREE_OUT_FREED_AS_ID) != fw_id)) + return -EIO; + return 0; +} + +int efx_mae_alloc_action_set_list(struct efx_nic *efx, + struct efx_tc_action_set_list *acts) +{ + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_LEN); + struct efx_tc_action_set *act; + size_t inlen, outlen, i = 0; + efx_dword_t *inbuf; + int rc; + + list_for_each_entry(act, &acts->list, list) + i++; + if (i == 0) + return -EINVAL; + if (i == 1) { + /* Don't wrap an ASL around a single AS, just use the AS_ID + * directly. ASLs are a more limited resource. + */ + act = list_first_entry(&acts->list, struct efx_tc_action_set, list); + acts->fw_id = act->fw_id; + return 0; + } + if (i > MC_CMD_MAE_ACTION_SET_LIST_ALLOC_IN_AS_IDS_MAXNUM_MCDI2) + return -EOPNOTSUPP; /* Too many actions */ + inlen = MC_CMD_MAE_ACTION_SET_LIST_ALLOC_IN_LEN(i); + inbuf = kzalloc(inlen, GFP_KERNEL); + if (!inbuf) + return -ENOMEM; + i = 0; + list_for_each_entry(act, &acts->list, list) { + MCDI_SET_ARRAY_DWORD(inbuf, MAE_ACTION_SET_LIST_ALLOC_IN_AS_IDS, + i, act->fw_id); + i++; + } + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_LIST_ALLOC_IN_COUNT, i); + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_ACTION_SET_LIST_ALLOC, inbuf, inlen, + outbuf, sizeof(outbuf), &outlen); + if (rc) + goto out_free; + if (outlen < sizeof(outbuf)) { + rc = -EIO; + goto out_free; + } + acts->fw_id = MCDI_DWORD(outbuf, MAE_ACTION_SET_LIST_ALLOC_OUT_ASL_ID); + /* We rely on the high bit of ASL IDs always being set. + * The firmware API guarantees this, but let's check it ourselves. + */ + if (WARN_ON_ONCE(!efx_mae_asl_id(acts->fw_id))) { + efx_mae_free_action_set_list(efx, acts); + rc = -EIO; + } +out_free: + kfree(inbuf); + return rc; +} + +int efx_mae_free_action_set_list(struct efx_nic *efx, + struct efx_tc_action_set_list *acts) +{ + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_SET_LIST_FREE_OUT_LEN(1)); + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_ACTION_SET_LIST_FREE_IN_LEN(1)); + size_t outlen; + int rc; + + /* If this is just an AS_ID with no ASL wrapper, then there is + * nothing for us to free. (The AS will be freed later.) + */ + if (efx_mae_asl_id(acts->fw_id)) { + MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_LIST_FREE_IN_ASL_ID, + acts->fw_id); + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_ACTION_SET_LIST_FREE, inbuf, + sizeof(inbuf), outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < sizeof(outbuf)) + return -EIO; + /* FW freed a different ID than we asked for, should never happen. + * Warn because it means we've now got a different idea to the FW of + * what action-set-lists exist, which could cause mayhem later. + */ + if (WARN_ON(MCDI_DWORD(outbuf, MAE_ACTION_SET_LIST_FREE_OUT_FREED_ASL_ID) != acts->fw_id)) + return -EIO; + } + /* We're probably about to free @acts, but let's just make sure its + * fw_id is blatted so that it won't look valid if it leaks out. + */ + acts->fw_id = MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_ACTION_SET_LIST_ID_NULL; + return 0; +} + +static int efx_mae_populate_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit), + const struct efx_tc_match *match) +{ + if (match->mask.ingress_port) { + if (~match->mask.ingress_port) + return -EOPNOTSUPP; + MCDI_STRUCT_SET_DWORD(match_crit, + MAE_FIELD_MASK_VALUE_PAIRS_V2_INGRESS_MPORT_SELECTOR, + match->value.ingress_port); + } + MCDI_STRUCT_SET_DWORD(match_crit, MAE_FIELD_MASK_VALUE_PAIRS_V2_INGRESS_MPORT_SELECTOR_MASK, + match->mask.ingress_port); + return 0; +} + +int efx_mae_insert_rule(struct efx_nic *efx, const struct efx_tc_match *match, + u32 prio, u32 acts_id, u32 *id) +{ + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_ACTION_RULE_INSERT_IN_LEN(MAE_FIELD_MASK_VALUE_PAIRS_V2_LEN)); + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_RULE_INSERT_OUT_LEN); + MCDI_DECLARE_STRUCT_PTR(match_crit); + MCDI_DECLARE_STRUCT_PTR(response); + size_t outlen; + int rc; + + if (!id) + return -EINVAL; + + match_crit = _MCDI_DWORD(inbuf, MAE_ACTION_RULE_INSERT_IN_MATCH_CRITERIA); + response = _MCDI_DWORD(inbuf, MAE_ACTION_RULE_INSERT_IN_RESPONSE); + if (efx_mae_asl_id(acts_id)) { + MCDI_STRUCT_SET_DWORD(response, MAE_ACTION_RULE_RESPONSE_ASL_ID, acts_id); + MCDI_STRUCT_SET_DWORD(response, MAE_ACTION_RULE_RESPONSE_AS_ID, + MC_CMD_MAE_ACTION_SET_ALLOC_OUT_ACTION_SET_ID_NULL); + } else { + /* We only had one AS, so we didn't wrap it in an ASL */ + MCDI_STRUCT_SET_DWORD(response, MAE_ACTION_RULE_RESPONSE_ASL_ID, + MC_CMD_MAE_ACTION_SET_LIST_ALLOC_OUT_ACTION_SET_LIST_ID_NULL); + MCDI_STRUCT_SET_DWORD(response, MAE_ACTION_RULE_RESPONSE_AS_ID, acts_id); + } + MCDI_SET_DWORD(inbuf, MAE_ACTION_RULE_INSERT_IN_PRIO, prio); + rc = efx_mae_populate_match_criteria(match_crit, match); + if (rc) + return rc; + + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_ACTION_RULE_INSERT, inbuf, sizeof(inbuf), + outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < sizeof(outbuf)) + return -EIO; + *id = MCDI_DWORD(outbuf, MAE_ACTION_RULE_INSERT_OUT_AR_ID); + return 0; +} + +int efx_mae_delete_rule(struct efx_nic *efx, u32 id) +{ + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_ACTION_RULE_DELETE_OUT_LEN(1)); + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_ACTION_RULE_DELETE_IN_LEN(1)); + size_t outlen; + int rc; + + MCDI_SET_DWORD(inbuf, MAE_ACTION_RULE_DELETE_IN_AR_ID, id); + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_ACTION_RULE_DELETE, inbuf, sizeof(inbuf), + outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < sizeof(outbuf)) + return -EIO; + /* FW freed a different ID than we asked for, should also never happen. + * Warn because it means we've now got a different idea to the FW of + * what rules exist, which could cause mayhem later. + */ + if (WARN_ON(MCDI_DWORD(outbuf, MAE_ACTION_RULE_DELETE_OUT_DELETED_AR_ID) != id)) + return -EIO; + return 0; +} diff --git a/drivers/net/ethernet/sfc/mae.h b/drivers/net/ethernet/sfc/mae.h index 25c2fd94e158..e9651f611750 100644 --- a/drivers/net/ethernet/sfc/mae.h +++ b/drivers/net/ethernet/sfc/mae.h @@ -14,10 +14,26 @@ /* MCDI interface for the ef100 Match-Action Engine */ #include "net_driver.h" +#include "tc.h" +#include "mcdi_pcol.h" /* needed for various MC_CMD_MAE_*_NULL defines */ void efx_mae_mport_wire(struct efx_nic *efx, u32 *out); +void efx_mae_mport_uplink(struct efx_nic *efx, u32 *out); void efx_mae_mport_vf(struct efx_nic *efx, u32 vf_id, u32 *out); +void efx_mae_mport_mport(struct efx_nic *efx, u32 mport_id, u32 *out); int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id); +int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act); +int efx_mae_free_action_set(struct efx_nic *efx, u32 fw_id); + +int efx_mae_alloc_action_set_list(struct efx_nic *efx, + struct efx_tc_action_set_list *acts); +int efx_mae_free_action_set_list(struct efx_nic *efx, + struct efx_tc_action_set_list *acts); + +int efx_mae_insert_rule(struct efx_nic *efx, const struct efx_tc_match *match, + u32 prio, u32 acts_id, u32 *id); +int efx_mae_delete_rule(struct efx_nic *efx, u32 id); + #endif /* EF100_MAE_H */ diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h index f74f6ce8b27d..26bc69f76801 100644 --- a/drivers/net/ethernet/sfc/mcdi.h +++ b/drivers/net/ethernet/sfc/mcdi.h @@ -205,6 +205,8 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); ((_ofst) + BUILD_BUG_ON_ZERO((_ofst) & (_align - 1))) #define _MCDI_DWORD(_buf, _field) \ ((_buf) + (_MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, 4) >> 2)) +#define _MCDI_STRUCT_DWORD(_buf, _field) \ + ((_buf) + (_MCDI_CHECK_ALIGN(_field ## _OFST, 4) >> 2)) #define MCDI_BYTE(_buf, _field) \ ((void)BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 1), \ @@ -214,6 +216,8 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); le16_to_cpu(*(__force const __le16 *)MCDI_PTR(_buf, _field))) #define MCDI_SET_DWORD(_buf, _field, _value) \ EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0, _value) +#define MCDI_STRUCT_SET_DWORD(_buf, _field, _value) \ + EFX_POPULATE_DWORD_1(*_MCDI_STRUCT_DWORD(_buf, _field), EFX_DWORD_0, _value) #define MCDI_DWORD(_buf, _field) \ EFX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0) #define MCDI_POPULATE_DWORD_1(_buf, _field, _name1, _value1) \ diff --git a/drivers/net/ethernet/sfc/mcdi_pcol_mae.h b/drivers/net/ethernet/sfc/mcdi_pcol_mae.h new file mode 100644 index 000000000000..ff6d80c8e486 --- /dev/null +++ b/drivers/net/ethernet/sfc/mcdi_pcol_mae.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2019 Solarflare Communications Inc. + * Copyright 2019-2022 Xilinx, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#ifndef MCDI_PCOL_MAE_H +#define MCDI_PCOL_MAE_H +/* MCDI definitions for Match-Action Engine functionality, that are + * missing from the main mcdi_pcol.h + */ + +/* MC_CMD_MAE_COUNTER_LIST_ALLOC is not (yet) a released API, but the + * following value is needed as an argument to MC_CMD_MAE_ACTION_SET_ALLOC. + */ +/* enum: A counter ID that is guaranteed never to represent a real counter */ +#define MC_CMD_MAE_COUNTER_LIST_ALLOC_OUT_COUNTER_LIST_ID_NULL 0xffffffff + +#endif /* MCDI_PCOL_MAE_H */ diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 6b64ba3a7d36..7ef823d7a89a 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h @@ -978,6 +978,7 @@ enum efx_xdp_tx_queues_mode { * @xdp_rxq_info_failed: Have any of the rx queues failed to initialise their * xdp_rxq_info structures? * @netdev_notifier: Netdevice notifier. + * @tc: state for TC offload (EF100). * @mem_bar: The BAR that is mapped into membase. * @reg_base: Offset from the start of the bar to the function control window. * @monitor_work: Hardware monitor workitem @@ -1161,6 +1162,7 @@ struct efx_nic { bool xdp_rxq_info_failed; struct notifier_block netdev_notifier; + struct efx_tc_state *tc; unsigned int mem_bar; u32 reg_base; diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c new file mode 100644 index 000000000000..0fb01f73c56e --- /dev/null +++ b/drivers/net/ethernet/sfc/tc.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0-only +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2019 Solarflare Communications Inc. + * Copyright 2020-2022 Xilinx Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#include "tc.h" +#include "mae.h" +#include "ef100_rep.h" + +static void efx_tc_free_action_set(struct efx_nic *efx, + struct efx_tc_action_set *act, bool in_hw) +{ + /* Failure paths calling this on the 'running action' set in_hw=false, + * because if the alloc had succeeded we'd've put it in acts.list and + * not still have it in act. + */ + if (in_hw) { + efx_mae_free_action_set(efx, act->fw_id); + /* in_hw is true iff we are on an acts.list; make sure to + * remove ourselves from that list before we are freed. + */ + list_del(&act->list); + } + kfree(act); +} + +static void efx_tc_free_action_set_list(struct efx_nic *efx, + struct efx_tc_action_set_list *acts, + bool in_hw) +{ + struct efx_tc_action_set *act, *next; + + /* Failure paths set in_hw=false, because usually the acts didn't get + * to efx_mae_alloc_action_set_list(); if they did, the failure tree + * has a separate efx_mae_free_action_set_list() before calling us. + */ + if (in_hw) + efx_mae_free_action_set_list(efx, acts); + /* Any act that's on the list will be in_hw even if the list isn't */ + list_for_each_entry_safe(act, next, &acts->list, list) + efx_tc_free_action_set(efx, act, true); + /* Don't kfree, as acts is embedded inside a struct efx_tc_flow_rule */ +} + +static void efx_tc_delete_rule(struct efx_nic *efx, struct efx_tc_flow_rule *rule) +{ + efx_mae_delete_rule(efx, rule->fw_id); + + /* Release entries in subsidiary tables */ + efx_tc_free_action_set_list(efx, &rule->acts, true); + rule->fw_id = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL; +} + +static int efx_tc_configure_default_rule(struct efx_nic *efx, u32 ing_port, + u32 eg_port, struct efx_tc_flow_rule *rule) +{ + struct efx_tc_action_set_list *acts = &rule->acts; + struct efx_tc_match *match = &rule->match; + struct efx_tc_action_set *act; + int rc; + + match->value.ingress_port = ing_port; + match->mask.ingress_port = ~0; + act = kzalloc(sizeof(*act), GFP_KERNEL); + if (!act) + return -ENOMEM; + act->deliver = 1; + act->dest_mport = eg_port; + rc = efx_mae_alloc_action_set(efx, act); + if (rc) + goto fail1; + EFX_WARN_ON_PARANOID(!list_empty(&acts->list)); + list_add_tail(&act->list, &acts->list); + rc = efx_mae_alloc_action_set_list(efx, acts); + if (rc) + goto fail2; + rc = efx_mae_insert_rule(efx, match, EFX_TC_PRIO_DFLT, + acts->fw_id, &rule->fw_id); + if (rc) + goto fail3; + return 0; +fail3: + efx_mae_free_action_set_list(efx, acts); +fail2: + list_del(&act->list); + efx_mae_free_action_set(efx, act->fw_id); +fail1: + kfree(act); + return rc; +} + +static int efx_tc_configure_default_rule_pf(struct efx_nic *efx) +{ + struct efx_tc_flow_rule *rule = &efx->tc->dflt.pf; + u32 ing_port, eg_port; + + efx_mae_mport_uplink(efx, &ing_port); + efx_mae_mport_wire(efx, &eg_port); + return efx_tc_configure_default_rule(efx, ing_port, eg_port, rule); +} + +static int efx_tc_configure_default_rule_wire(struct efx_nic *efx) +{ + struct efx_tc_flow_rule *rule = &efx->tc->dflt.wire; + u32 ing_port, eg_port; + + efx_mae_mport_wire(efx, &ing_port); + efx_mae_mport_uplink(efx, &eg_port); + return efx_tc_configure_default_rule(efx, ing_port, eg_port, rule); +} + +int efx_tc_configure_default_rule_rep(struct efx_rep *efv) +{ + struct efx_tc_flow_rule *rule = &efv->dflt; + struct efx_nic *efx = efv->parent; + u32 ing_port, eg_port; + + efx_mae_mport_mport(efx, efv->mport, &ing_port); + efx_mae_mport_uplink(efx, &eg_port); + return efx_tc_configure_default_rule(efx, ing_port, eg_port, rule); +} + +void efx_tc_deconfigure_default_rule(struct efx_nic *efx, + struct efx_tc_flow_rule *rule) +{ + if (rule->fw_id != MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL) + efx_tc_delete_rule(efx, rule); + rule->fw_id = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL; +} + +int efx_init_tc(struct efx_nic *efx) +{ + int rc; + + rc = efx_tc_configure_default_rule_pf(efx); + if (rc) + return rc; + return efx_tc_configure_default_rule_wire(efx); +} + +void efx_fini_tc(struct efx_nic *efx) +{ + /* We can get called even if efx_init_struct_tc() failed */ + if (!efx->tc) + return; + efx_tc_deconfigure_default_rule(efx, &efx->tc->dflt.pf); + efx_tc_deconfigure_default_rule(efx, &efx->tc->dflt.wire); +} + +int efx_init_struct_tc(struct efx_nic *efx) +{ + if (efx->type->is_vf) + return 0; + + efx->tc = kzalloc(sizeof(*efx->tc), GFP_KERNEL); + if (!efx->tc) + return -ENOMEM; + + INIT_LIST_HEAD(&efx->tc->dflt.pf.acts.list); + efx->tc->dflt.pf.fw_id = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL; + INIT_LIST_HEAD(&efx->tc->dflt.wire.acts.list); + efx->tc->dflt.wire.fw_id = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL; + return 0; +} + +void efx_fini_struct_tc(struct efx_nic *efx) +{ + if (!efx->tc) + return; + + EFX_WARN_ON_PARANOID(efx->tc->dflt.pf.fw_id != + MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL); + EFX_WARN_ON_PARANOID(efx->tc->dflt.wire.fw_id != + MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL); + kfree(efx->tc); + efx->tc = NULL; +} diff --git a/drivers/net/ethernet/sfc/tc.h b/drivers/net/ethernet/sfc/tc.h new file mode 100644 index 000000000000..46c5101eaa8d --- /dev/null +++ b/drivers/net/ethernet/sfc/tc.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/**************************************************************************** + * Driver for Solarflare network controllers and boards + * Copyright 2019 Solarflare Communications Inc. + * Copyright 2020-2022 Xilinx Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, incorporated herein by reference. + */ + +#ifndef EFX_TC_H +#define EFX_TC_H +#include "net_driver.h" + +struct efx_tc_action_set { + u16 deliver:1; + u32 dest_mport; + u32 fw_id; /* index of this entry in firmware actions table */ + struct list_head list; +}; + +struct efx_tc_match_fields { + /* L1 */ + u32 ingress_port; +}; + +struct efx_tc_match { + struct efx_tc_match_fields value; + struct efx_tc_match_fields mask; +}; + +struct efx_tc_action_set_list { + struct list_head list; + u32 fw_id; +}; + +struct efx_tc_flow_rule { + struct efx_tc_match match; + struct efx_tc_action_set_list acts; + u32 fw_id; +}; + +enum efx_tc_rule_prios { + EFX_TC_PRIO_DFLT, /* Default switch rule; one of efx_tc_default_rules */ + EFX_TC_PRIO__NUM +}; + +/** + * struct efx_tc_state - control plane data for TC offload + * + * @dflt: Match-action rules for default switching; at priority + * %EFX_TC_PRIO_DFLT. Named by *ingress* port + * @dflt.pf: rule for traffic ingressing from PF (egresses to wire) + * @dflt.wire: rule for traffic ingressing from wire (egresses to PF) + */ +struct efx_tc_state { + struct { + struct efx_tc_flow_rule pf; + struct efx_tc_flow_rule wire; + } dflt; +}; + +struct efx_rep; + +int efx_tc_configure_default_rule_rep(struct efx_rep *efv); +void efx_tc_deconfigure_default_rule(struct efx_nic *efx, + struct efx_tc_flow_rule *rule); + +int efx_init_tc(struct efx_nic *efx); +void efx_fini_tc(struct efx_nic *efx); + +int efx_init_struct_tc(struct efx_nic *efx); +void efx_fini_struct_tc(struct efx_nic *efx); + +#endif /* EFX_TC_H */ From patchwork Thu Jul 28 18:57:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931678 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE72FC04A68 for ; Thu, 28 Jul 2022 18:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbiG1S7D (ORCPT ); Thu, 28 Jul 2022 14:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbiG1S64 (ORCPT ); Thu, 28 Jul 2022 14:58:56 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D2D27646E for ; Thu, 28 Jul 2022 11:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Obxew2N7ashHVPce8P3pLgXsvCsSkjLRjlerAAKYAZao1fulPWU4ROr8VEsFa6ma3BZnOE/eImgKpk2yNRA1kJm49B3Ar6knogLeRmgvVxRIxKIfNWx1gRMi10F1FM8dOrqDSf4E7VD02zG5Tc3gNz68oYzDxGP7hOXZp9r6I4Sx0TAy7xXXkguwsbXJ+ITRpYu/PmaBgwAGhyz5FxV/1IgztclU0I1PNVsH4ihQVly2gCO5PfHKKFGtjC4aN1pEzhN+Vg/YjWvvfeHIBBNPlb8YKaCRoDA52PF2ihggiDc/rFgX+wH2GF4hHAkc4DPCurtzi634rLVLmaSmgAk46Q== 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=t4W+4odoY71AQ9d30OzFH807MgvxUuKYI8TjDvPkgYY=; b=DCebOCwEEe9KbS7YzWEaxZk4MbhaPve7XZL7vtzHQqWa5pQTugMAzYOM9NO5avXx8tgooYSJDr5FihfjnfERYMcX5hIowCCYqwLxa1rPqa+Zw4nEvhTKRPvlOC0pdnJXoVV+hPXIP/mVCQdIAQz21fySZBhmmiYUqSG0qGayDLLgvQxMlJdGMLxcYNOAkdJOXKKO071JvOf0u8QyMvvzy/UuYQQVi9dYB2AeEqNi92PUkLZ6N6ipaVzaJp3KVtBURYUkpoMpBOB7LxCQl7bm9YFbjHe8Y+TARzYY8qjayvYT8fsVnTvdV87zKLh93KQewQf7dPJcq4GmGHHkN2YVrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t4W+4odoY71AQ9d30OzFH807MgvxUuKYI8TjDvPkgYY=; b=B5QKO/w/hJyjK9U4oaBunNEdIH3JVu1tv8ST4G1bpsnmiMONJLayJfag1Ys+TBM4wgabd6jtGNxxpQU69lTgzSsBDtk0/g3H+FxTxh6kEUwFVhC6QjporUlS4R8v37s1IbbAXSQ5UYZ3YSS0TPzBfsxD5dTwIgYNr3ClSYgxyl6mzDM3M6dRKIgsAw+G6hAg/XJe68WIBgLkHb/vS6jiQctkIHsMFK4BHDnkTjyJOZnd+tSxiPwVsUFS0/61pqi0M0UqSeyS6aXQrAlXr20tE1DvG2RjRAzKB9xQn8B4ju9j7KuluiHfWI29j07/hvVOvsO8uQjjsEDyEod/5cxbfw== Received: from BN8PR04CA0038.namprd04.prod.outlook.com (2603:10b6:408:d4::12) by PH8PR12MB6964.namprd12.prod.outlook.com (2603:10b6:510:1bf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.25; Thu, 28 Jul 2022 18:58:48 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::59) by BN8PR04CA0038.outlook.office365.com (2603:10b6:408:d4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23 via Frontend Transport; Thu, 28 Jul 2022 18:58:48 +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=fail action=none header.from=xilinx.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 BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:48 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:47 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:47 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:46 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 08/10] sfc: move table locking into filter_table_{probe,remove} methods Date: Thu, 28 Jul 2022 19:57:50 +0100 Message-ID: <68c21e41ad5193b60939ce1cf40faa6b97bd04b2.1659034549.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62cdf517-2c62-4dea-fee3-08da70cb341f X-MS-TrafficTypeDiagnostic: PH8PR12MB6964:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lqtw6HIVqiiZi6DMq0AULIKc6koe+hvYVNfQCx4QLgf04xRefi506/CuZ3xWZNb56c3AGDIrPQ2oBKA7UcQme3kMqTomrJvlqzAZ+HAYpzRf+Q76QSDB3L1lA6oagwP4qTOa6WVGbkEElIdq5Dkayvl2tbNdy/WMfUcdGZ8hxg3Eyfd+nKt9u9nPB/egh5xaPHBoeetnRnP5ExC/wPEH3ubv5BFZfyjqm9lDOwPU5pf5oILai5HyE2mrQcupNFrTeSJ50OA7EBzA8p1IK8ZOc6s4r5NAT8XFCQBtB2GodtVmoLmCbuAw1u0gnRmZhrB1fpM2GMu5xXzlP9Z4aXOSQxYa/dEaXn6D/8JQcwLxWJIlJzySWbhhrv6JnyElcizyqgQ3eJ/ECv/SS9lBiHHXBN/ZBVUuVWthL2+KJZ2A08lrA6T2tBxitNz3NqO4WJ3sTPbBlhL9zZl8kOSp/04LBwBMH/FFcuz7sGVvwi1lBzvNGt/JX/A6j8uT8JAcgD/QP1cggayLyWP+u2xQtxA4yaEZ6GLaTLL/DNpO3xDu2uELEDmndHiDJeLxq8oB/jYTm2+xGF7sQ3xwVnSqgwWJVjOiOELy0c8OUl/lKCFfhTMownqGLOMTATZsqZnJdMZ/nfZgXoXUEMXknafLTj1ZE4p7+jH7JPKb4/5bCV0pBrogir1ffGCBFKiibH+LJwyq9JWgSZshSLUBOIqORiba4gy/sYVCLVQma89bhKCmqBYApda8n4yJR9bqrBtoilSHSbeMOpKZ/gdfJg9jE/bf8GBadJjkZHDm5g7Ey2QgWqj8KQh6+6SPKWzEEioVZKGjvwGpgWb8q9SKs7WvLkWOKA== 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:(13230016)(4636009)(39860400002)(396003)(376002)(136003)(346002)(40470700004)(46966006)(36840700001)(41300700001)(70586007)(70206006)(82310400005)(40460700003)(478600001)(8676002)(6666004)(81166007)(5660300002)(82740400003)(356005)(4326008)(8936002)(83170400001)(2876002)(110136005)(36756003)(2906002)(47076005)(55446002)(186003)(83380400001)(36860700001)(42882007)(316002)(26005)(9686003)(54906003)(40480700001)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:48.0436 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62cdf517-2c62-4dea-fee3-08da70cb341f 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: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6964 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree We need to be able to drop the efx->filter_sem in ef100_filter_table_up() so that we can call functions that insert filters (and thus take that rwsem for read), which means the efx->type->filter_table_probe method needs to be responsible for taking the lock in the first place. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef10.c | 26 ++++++++++++++----------- drivers/net/ethernet/sfc/ef100_nic.c | 22 +++++++++++++-------- drivers/net/ethernet/sfc/ef10_sriov.c | 16 +++------------ drivers/net/ethernet/sfc/mcdi_filters.h | 1 + drivers/net/ethernet/sfc/rx_common.c | 4 ---- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index ab979fd11133..ee734b69150f 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -2538,23 +2538,33 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx) if (rc) return rc; + down_write(&efx->filter_sem); rc = efx_mcdi_filter_table_probe(efx, nic_data->workaround_26807); if (rc) - return rc; + goto out_unlock; list_for_each_entry(vlan, &nic_data->vlan_list, list) { rc = efx_mcdi_filter_add_vlan(efx, vlan->vid); if (rc) goto fail_add_vlan; } - return 0; + goto out_unlock; fail_add_vlan: efx_mcdi_filter_table_remove(efx); +out_unlock: + up_write(&efx->filter_sem); return rc; } +static void efx_ef10_filter_table_remove(struct efx_nic *efx) +{ + down_write(&efx->filter_sem); + efx_mcdi_filter_table_remove(efx); + up_write(&efx->filter_sem); +} + /* This creates an entry in the RX descriptor queue */ static inline void efx_ef10_build_rx_desc(struct efx_rx_queue *rx_queue, unsigned int index) @@ -3211,9 +3221,7 @@ static int efx_ef10_vport_set_mac_address(struct efx_nic *efx) efx_device_detach_sync(efx); efx_net_stop(efx->net_dev); - down_write(&efx->filter_sem); - efx_mcdi_filter_table_remove(efx); - up_write(&efx->filter_sem); + efx_ef10_filter_table_remove(efx); rc = efx_ef10_vadaptor_free(efx, efx->vport_id); if (rc) @@ -3243,9 +3251,7 @@ static int efx_ef10_vport_set_mac_address(struct efx_nic *efx) if (rc2) goto reset_nic; restore_filters: - down_write(&efx->filter_sem); rc2 = efx_ef10_filter_table_probe(efx); - up_write(&efx->filter_sem); if (rc2) goto reset_nic; @@ -3275,8 +3281,7 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx) efx_net_stop(efx->net_dev); mutex_lock(&efx->mac_lock); - down_write(&efx->filter_sem); - efx_mcdi_filter_table_remove(efx); + efx_ef10_filter_table_remove(efx); ether_addr_copy(MCDI_PTR(inbuf, VADAPTOR_SET_MAC_IN_MACADDR), efx->net_dev->dev_addr); @@ -3286,7 +3291,6 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx) sizeof(inbuf), NULL, 0, NULL); efx_ef10_filter_table_probe(efx); - up_write(&efx->filter_sem); mutex_unlock(&efx->mac_lock); if (was_enabled) @@ -4092,7 +4096,7 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = { .ev_test_generate = efx_ef10_ev_test_generate, .filter_table_probe = efx_ef10_filter_table_probe, .filter_table_restore = efx_mcdi_filter_table_restore, - .filter_table_remove = efx_mcdi_filter_table_remove, + .filter_table_remove = efx_ef10_filter_table_remove, .filter_update_rx_scatter = efx_mcdi_update_rx_scatter, .filter_insert = efx_mcdi_filter_insert, .filter_remove_safe = efx_mcdi_filter_remove_safe, diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index 25cd43e3fcf7..5fe18b383e20 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -375,26 +375,32 @@ static int ef100_filter_table_up(struct efx_nic *efx) { int rc; + down_write(&efx->filter_sem); rc = efx_mcdi_filter_add_vlan(efx, EFX_FILTER_VID_UNSPEC); - if (rc) { - efx_mcdi_filter_table_down(efx); - return rc; - } + if (rc) + goto fail_unspec; rc = efx_mcdi_filter_add_vlan(efx, 0); - if (rc) { - efx_mcdi_filter_del_vlan(efx, EFX_FILTER_VID_UNSPEC); - efx_mcdi_filter_table_down(efx); - } + if (rc) + goto fail_vlan0; + up_write(&efx->filter_sem); + return 0; +fail_vlan0: + efx_mcdi_filter_del_vlan(efx, EFX_FILTER_VID_UNSPEC); +fail_unspec: + efx_mcdi_filter_table_down(efx); + up_write(&efx->filter_sem); return rc; } static void ef100_filter_table_down(struct efx_nic *efx) { + down_write(&efx->filter_sem); efx_mcdi_filter_del_vlan(efx, 0); efx_mcdi_filter_del_vlan(efx, EFX_FILTER_VID_UNSPEC); efx_mcdi_filter_table_down(efx); + up_write(&efx->filter_sem); } /* Other diff --git a/drivers/net/ethernet/sfc/ef10_sriov.c b/drivers/net/ethernet/sfc/ef10_sriov.c index 92550c7e85ce..9aae0d8b713f 100644 --- a/drivers/net/ethernet/sfc/ef10_sriov.c +++ b/drivers/net/ethernet/sfc/ef10_sriov.c @@ -501,14 +501,11 @@ int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, const u8 *mac) efx_device_detach_sync(vf->efx); efx_net_stop(vf->efx->net_dev); - down_write(&vf->efx->filter_sem); vf->efx->type->filter_table_remove(vf->efx); rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); - if (rc) { - up_write(&vf->efx->filter_sem); + if (rc) return rc; - } } rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); @@ -539,12 +536,9 @@ int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, const u8 *mac) if (vf->efx) { /* VF cannot use the vport_id that the PF created */ rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); - if (rc) { - up_write(&vf->efx->filter_sem); + if (rc) return rc; - } vf->efx->type->filter_table_probe(vf->efx); - up_write(&vf->efx->filter_sem); efx_net_open(vf->efx->net_dev); efx_device_attach_if_not_resetting(vf->efx); } @@ -580,7 +574,6 @@ int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, efx_net_stop(vf->efx->net_dev); mutex_lock(&vf->efx->mac_lock); - down_write(&vf->efx->filter_sem); vf->efx->type->filter_table_remove(vf->efx); rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); @@ -654,7 +647,6 @@ int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, if (rc2) goto reset_nic_up_write; - up_write(&vf->efx->filter_sem); mutex_unlock(&vf->efx->mac_lock); rc2 = efx_net_open(vf->efx->net_dev); @@ -666,10 +658,8 @@ int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, return rc; reset_nic_up_write: - if (vf->efx) { - up_write(&vf->efx->filter_sem); + if (vf->efx) mutex_unlock(&vf->efx->mac_lock); - } reset_nic: if (vf->efx) { netif_err(efx, drv, efx->net_dev, diff --git a/drivers/net/ethernet/sfc/mcdi_filters.h b/drivers/net/ethernet/sfc/mcdi_filters.h index 06426aa9f2f3..c0d6558b9fd2 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.h +++ b/drivers/net/ethernet/sfc/mcdi_filters.h @@ -89,6 +89,7 @@ struct efx_mcdi_filter_table { */ bool mc_chaining; bool vlan_filter; + /* Entries on the vlan_list are added/removed under filter_sem */ struct list_head vlan_list; }; diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c index bd21d6ac778a..4826e6a7e4ce 100644 --- a/drivers/net/ethernet/sfc/rx_common.c +++ b/drivers/net/ethernet/sfc/rx_common.c @@ -793,7 +793,6 @@ int efx_probe_filters(struct efx_nic *efx) int rc; mutex_lock(&efx->mac_lock); - down_write(&efx->filter_sem); rc = efx->type->filter_table_probe(efx); if (rc) goto out_unlock; @@ -830,7 +829,6 @@ int efx_probe_filters(struct efx_nic *efx) } #endif out_unlock: - up_write(&efx->filter_sem); mutex_unlock(&efx->mac_lock); return rc; } @@ -846,9 +844,7 @@ void efx_remove_filters(struct efx_nic *efx) channel->rps_flow_id = NULL; } #endif - down_write(&efx->filter_sem); efx->type->filter_table_remove(efx); - up_write(&efx->filter_sem); } #ifdef CONFIG_RFS_ACCEL From patchwork Thu Jul 28 18:57:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931681 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98323C04A68 for ; Thu, 28 Jul 2022 18:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232308AbiG1S7T (ORCPT ); Thu, 28 Jul 2022 14:59:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232792AbiG1S67 (ORCPT ); Thu, 28 Jul 2022 14:58:59 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2045.outbound.protection.outlook.com [40.107.237.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B830C76477 for ; Thu, 28 Jul 2022 11:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iJ53ajsGkSJRAivGWiOG55q8OgrPCMTWSoEcezE00ouvEMlWI2R95vRDaG+BoVNjNIyDw4YSPfOiBLhM+Kp3Oiwmjh+RctPG8gTs/Uy3AHJo95HsD57YW8lghmbz19QgInXpzhb6jw3b30tjobk1dIYMD2w6d3WuHnTQGB/znJWyhi88xiMLSWBxJlrQtBnVSgAnV4BeHmG88y2iQQlYo3U/Jsnzmxrd/YdUt7V2ST5os/pvVTwUxb7/5wvjK7Ye5ClIEsxi3B1ErJpfi/PSbFEUVeTOLD3K3OzEZ8WiPFNl+oNGIIoWv550KYZVW9PoNC458YghMxv4DeZJmwO2tA== 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=lMPr9Fl3YWUHRNFnahr9oUyJUR/b3j10n+XqZiNlyV8=; b=flDrshT6ZrRs63ecTCX/oeig8fKU8fOZ6OcCx0Y8XRAC9u/glSOdrhb+x1e25nuxelbDg0YUZ7reBMSpuu5ne9nwkOyH0hhpjO/9JOLJT4sS1rxrF9rYFLlMeafHvN8ryN6/9Pv3ftUlpmxxZ9wlCiX1AH7Nm2vR6o+KiksESoyZFLIaYsej5l5csVwf8//wjzRCqzrjnvkiNsLyMhCWbJwtKtUQ+mYJQXUjyrr/3kDdvbD5f1s8xGnj30FyO9ZSh6XCHrm1jIGbR1PqGmO0/nnuFDuNaM0W9IA8d7U+PJDFl3Hf91Rs9fEOnc2frxP1SHOeXe8jPMS36Uc2quu6oQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lMPr9Fl3YWUHRNFnahr9oUyJUR/b3j10n+XqZiNlyV8=; b=SJyHhDFoVMfhl72jT9nyFAPLbmaWeeNumPAM33JRg4MeZ5ALwZ0yNzNBYosJruhXWXGzYA3VBA/5eM7qN3tl2QGf5a4e1dsH61+xSrTyq6fc3xJTHnDbVvzRHL2DOHeTyNFJYakN5yeAnE0OuW3VetxxwsYq811eNvBoBQasvM/I/OWO61WiIPG277WoWX/UtgcOPqFLnddsSfMeqgGMjj508ya8NWgNEzkaeIzbUwkBdm/scqJqD4G8weMXKKcxT6spcaRyLabbr615gc/EAbjLEasE8JpxJwhYJrS3OS9CTqOEul8u0XIXohSVdPWFrNa6bQQzW2tDZWuBdafpPg== Received: from BN9PR03CA0969.namprd03.prod.outlook.com (2603:10b6:408:109::14) by BYAPR12MB3414.namprd12.prod.outlook.com (2603:10b6:a03:aa::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Thu, 28 Jul 2022 18:58:51 +0000 Received: from BN8NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::55) by BN9PR03CA0969.outlook.office365.com (2603:10b6:408:109::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19 via Frontend Transport; Thu, 28 Jul 2022 18:58:49 +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=fail action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT061.mail.protection.outlook.com (10.13.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:49 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:48 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:48 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:47 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 09/10] sfc: use a dynamic m-port for representor RX and set it promisc Date: Thu, 28 Jul 2022 19:57:51 +0100 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1b1f4578-c978-4cb4-b93c-08da70cb34e0 X-MS-TrafficTypeDiagnostic: BYAPR12MB3414:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i0L3BgkEdTtc8mHuZRr1+Yj5xogY4Zj4MhPa4PtCt+N9GQLBq8RmP4BY+hg1xGpG/iYsny3WTTVcH7NXdGwETewRIq5y9TQD7lBdfLbsjneoJ049DsAq3hArT5sv7br3IQoD83RYxGrXd6fWg+3puPcrixNtOC1OpkfDDZn0xSnBRwh6YSKBkvqKalsMBmizTYazQdLK9Uyh/MXOlnk4nS1HNjZphrpQtKsWU6YgrZ+WouXBxQBH/wKi1OIXO4gmf2forbDFT5ZKbrA9yxICD8Np/uulAU0Ns6/8K+ag0+/2s5zncA64xwCEm5gi1DAsa6t7UuC7bJkqWBySoi4wtowOc763ztS7wY1O4NZa772KCs3lUujji3U/a0Ahxh70PmVSDhMKZam5BMGT+m+pUQZJSQKOwCBQ2JPqPrmXmzmF9oj5UYLPc0TBkjpYeclNw8ti5MVF6uqU1vi739//IBa61ObZv9DNIC++c/s9cyjBgslr+8oSQ3d1hOeC6y1AC16DA67PTeqh4QH9wSsHQ6yIelkDZaSMlQGJvBCuJr68wOpUHEZvQNqcPVOOWvDgoHpbkkyTIuzFHU05+L+v/2bKxplhDlN5Ef0XsSqFJDxDRdqCObkqzJBNZGXsmoEo+nhNeC9gL2qh/Xh7mjYX4d0HvNs+tUs0/WIotnyh2+fmZWZVM2x9dCKKP+M0lB68TdBBS32MM0U5VsBvMP/IJ5JIIQsZkKk4hmooVgehZCUn2jXy49kWxiIN+5WhlSdCRDEt6XOR/zARuIWajAVHzDR6jzahTn6omGoOLJ1asO27thoWcMLfiQM8/v8bUj/LqjU5Ii39iYFbHLce+gkzsw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(36840700001)(40470700004)(46966006)(47076005)(36860700001)(336012)(30864003)(36756003)(5660300002)(42882007)(186003)(8936002)(2906002)(26005)(82310400005)(2876002)(9686003)(6666004)(70586007)(81166007)(70206006)(83170400001)(41300700001)(316002)(54906003)(110136005)(55446002)(356005)(40460700003)(40480700001)(83380400001)(82740400003)(478600001)(4326008)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:49.3536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b1f4578-c978-4cb4-b93c-08da70cb34e0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3414 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree Representors do not want to be subject to the PF's Ethernet address filters, since traffic from VFs will typically have a destination either elsewhere on the link segment or on an overlay network. So, create a dynamic m-port with promiscuous and all-multicast filters, and set it as the egress port of representor default rules. Since the m-port is an alias of the calling PF's own m-port, traffic will still be delivered to the PF's RXQs, but it will be subject to the VNRX filter rules installed on the dynamic m-port (specified by the v-port ID field of the filter spec). Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_nic.c | 15 +++++ drivers/net/ethernet/sfc/filter.h | 18 ++++++ drivers/net/ethernet/sfc/mae.c | 37 +++++++++++++ drivers/net/ethernet/sfc/mae.h | 3 + drivers/net/ethernet/sfc/mcdi_filters.c | 6 +- drivers/net/ethernet/sfc/tc.c | 73 ++++++++++++++++++++++++- drivers/net/ethernet/sfc/tc.h | 9 +++ 7 files changed, 158 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c index 5fe18b383e20..8061efdaf82c 100644 --- a/drivers/net/ethernet/sfc/ef100_nic.c +++ b/drivers/net/ethernet/sfc/ef100_nic.c @@ -24,6 +24,7 @@ #include "ef100_tx.h" #include "ef100_sriov.h" #include "ef100_netdev.h" +#include "tc.h" #include "mae.h" #include "rx_common.h" @@ -383,7 +384,18 @@ static int ef100_filter_table_up(struct efx_nic *efx) rc = efx_mcdi_filter_add_vlan(efx, 0); if (rc) goto fail_vlan0; + /* Drop the lock: we've finished altering table existence, and + * filter insertion will need to take the lock for read. + */ up_write(&efx->filter_sem); +#ifdef CONFIG_SFC_SRIOV + rc = efx_tc_insert_rep_filters(efx); + /* Rep filter failure is nonfatal */ + if (rc) + netif_warn(efx, drv, efx->net_dev, + "Failed to insert representor filters, rc %d\n", + rc); +#endif return 0; fail_vlan0: @@ -396,6 +408,9 @@ static int ef100_filter_table_up(struct efx_nic *efx) static void ef100_filter_table_down(struct efx_nic *efx) { +#ifdef CONFIG_SFC_SRIOV + efx_tc_remove_rep_filters(efx); +#endif down_write(&efx->filter_sem); efx_mcdi_filter_del_vlan(efx, 0); efx_mcdi_filter_del_vlan(efx, EFX_FILTER_VID_UNSPEC); diff --git a/drivers/net/ethernet/sfc/filter.h b/drivers/net/ethernet/sfc/filter.h index 40b2af8bfb81..4d928839d292 100644 --- a/drivers/net/ethernet/sfc/filter.h +++ b/drivers/net/ethernet/sfc/filter.h @@ -88,6 +88,7 @@ enum efx_filter_priority { * the automatic filter in its place. * @EFX_FILTER_FLAG_RX: Filter is for RX * @EFX_FILTER_FLAG_TX: Filter is for TX + * @EFX_FILTER_FLAG_VPORT_ID: Virtual port ID for adapter switching. */ enum efx_filter_flags { EFX_FILTER_FLAG_RX_RSS = 0x01, @@ -95,6 +96,7 @@ enum efx_filter_flags { EFX_FILTER_FLAG_RX_OVER_AUTO = 0x04, EFX_FILTER_FLAG_RX = 0x08, EFX_FILTER_FLAG_TX = 0x10, + EFX_FILTER_FLAG_VPORT_ID = 0x20, }; /** enum efx_encap_type - types of encapsulation @@ -127,6 +129,9 @@ enum efx_encap_type { * MCFW context_id. * @dmaq_id: Source/target queue index, or %EFX_FILTER_RX_DMAQ_ID_DROP for * an RX drop filter + * @vport_id: Virtual port ID associated with RX queue, for adapter switching, + * if %EFX_FILTER_FLAG_VPORT_ID is set. This is an MCFW vport_id, or on + * EF100 an mport selector. * @outer_vid: Outer VLAN ID to match, if %EFX_FILTER_MATCH_OUTER_VID is set * @inner_vid: Inner VLAN ID to match, if %EFX_FILTER_MATCH_INNER_VID is set * @loc_mac: Local MAC address to match, if %EFX_FILTER_MATCH_LOC_MAC or @@ -156,6 +161,7 @@ struct efx_filter_spec { u32 priority:2; u32 flags:6; u32 dmaq_id:12; + u32 vport_id; u32 rss_context; __be16 outer_vid __aligned(4); /* allow jhash2() of match values */ __be16 inner_vid; @@ -292,6 +298,18 @@ static inline int efx_filter_set_mc_def(struct efx_filter_spec *spec) return 0; } +/** + * efx_filter_set_vport_id - override virtual port id relating to filter + * @spec: Specification to initialise + * @vport_id: firmware ID of the virtual port + */ +static inline void efx_filter_set_vport_id(struct efx_filter_spec *spec, + u32 vport_id) +{ + spec->flags |= EFX_FILTER_FLAG_VPORT_ID; + spec->vport_id = vport_id; +} + static inline void efx_filter_set_encap_type(struct efx_filter_spec *spec, enum efx_encap_type encap_type) { diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c index ea87ec83e618..97627f5e3674 100644 --- a/drivers/net/ethernet/sfc/mae.c +++ b/drivers/net/ethernet/sfc/mae.c @@ -13,6 +13,43 @@ #include "mcdi.h" #include "mcdi_pcol_mae.h" +int efx_mae_allocate_mport(struct efx_nic *efx, u32 *id, u32 *label) +{ + MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_MPORT_ALLOC_ALIAS_OUT_LEN); + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_MPORT_ALLOC_ALIAS_IN_LEN); + size_t outlen; + int rc; + + if (WARN_ON_ONCE(!id)) + return -EINVAL; + if (WARN_ON_ONCE(!label)) + return -EINVAL; + + MCDI_SET_DWORD(inbuf, MAE_MPORT_ALLOC_ALIAS_IN_TYPE, + MC_CMD_MAE_MPORT_ALLOC_ALIAS_IN_MPORT_TYPE_ALIAS); + MCDI_SET_DWORD(inbuf, MAE_MPORT_ALLOC_ALIAS_IN_DELIVER_MPORT, + MAE_MPORT_SELECTOR_ASSIGNED); + rc = efx_mcdi_rpc(efx, MC_CMD_MAE_MPORT_ALLOC, inbuf, sizeof(inbuf), + outbuf, sizeof(outbuf), &outlen); + if (rc) + return rc; + if (outlen < sizeof(outbuf)) + return -EIO; + *id = MCDI_DWORD(outbuf, MAE_MPORT_ALLOC_ALIAS_OUT_MPORT_ID); + *label = MCDI_DWORD(outbuf, MAE_MPORT_ALLOC_ALIAS_OUT_LABEL); + return 0; +} + +int efx_mae_free_mport(struct efx_nic *efx, u32 id) +{ + MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_MPORT_FREE_IN_LEN); + + BUILD_BUG_ON(MC_CMD_MAE_MPORT_FREE_OUT_LEN); + MCDI_SET_DWORD(inbuf, MAE_MPORT_FREE_IN_MPORT_ID, id); + return efx_mcdi_rpc(efx, MC_CMD_MAE_MPORT_FREE, inbuf, sizeof(inbuf), + NULL, 0, NULL); +} + void efx_mae_mport_wire(struct efx_nic *efx, u32 *out) { efx_dword_t mport; diff --git a/drivers/net/ethernet/sfc/mae.h b/drivers/net/ethernet/sfc/mae.h index e9651f611750..0369be4d8983 100644 --- a/drivers/net/ethernet/sfc/mae.h +++ b/drivers/net/ethernet/sfc/mae.h @@ -17,6 +17,9 @@ #include "tc.h" #include "mcdi_pcol.h" /* needed for various MC_CMD_MAE_*_NULL defines */ +int efx_mae_allocate_mport(struct efx_nic *efx, u32 *id, u32 *label); +int efx_mae_free_mport(struct efx_nic *efx, u32 id); + void efx_mae_mport_wire(struct efx_nic *efx, u32 *out); void efx_mae_mport_uplink(struct efx_nic *efx, u32 *out); void efx_mae_mport_vf(struct efx_nic *efx, u32 vf_id, u32 *out); diff --git a/drivers/net/ethernet/sfc/mcdi_filters.c b/drivers/net/ethernet/sfc/mcdi_filters.c index 1523be77b9db..4ff6586116ee 100644 --- a/drivers/net/ethernet/sfc/mcdi_filters.c +++ b/drivers/net/ethernet/sfc/mcdi_filters.c @@ -221,7 +221,10 @@ static void efx_mcdi_filter_push_prep(struct efx_nic *efx, efx_mcdi_filter_push_prep_set_match_fields(efx, spec, inbuf); } - MCDI_SET_DWORD(inbuf, FILTER_OP_IN_PORT_ID, efx->vport_id); + if (flags & EFX_FILTER_FLAG_VPORT_ID) + MCDI_SET_DWORD(inbuf, FILTER_OP_IN_PORT_ID, spec->vport_id); + else + MCDI_SET_DWORD(inbuf, FILTER_OP_IN_PORT_ID, efx->vport_id); MCDI_SET_DWORD(inbuf, FILTER_OP_IN_RX_DEST, spec->dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP ? MC_CMD_FILTER_OP_IN_RX_DEST_DROP : @@ -488,6 +491,7 @@ static s32 efx_mcdi_filter_insert_locked(struct efx_nic *efx, saved_spec->flags |= spec->flags; saved_spec->rss_context = spec->rss_context; saved_spec->dmaq_id = spec->dmaq_id; + saved_spec->vport_id = spec->vport_id; } } else if (!replacing) { kfree(saved_spec); diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c index 0fb01f73c56e..0c0aeb91f500 100644 --- a/drivers/net/ethernet/sfc/tc.c +++ b/drivers/net/ethernet/sfc/tc.c @@ -12,6 +12,7 @@ #include "tc.h" #include "mae.h" #include "ef100_rep.h" +#include "efx.h" static void efx_tc_free_action_set(struct efx_nic *efx, struct efx_tc_action_set *act, bool in_hw) @@ -122,7 +123,7 @@ int efx_tc_configure_default_rule_rep(struct efx_rep *efv) u32 ing_port, eg_port; efx_mae_mport_mport(efx, efv->mport, &ing_port); - efx_mae_mport_uplink(efx, &eg_port); + efx_mae_mport_mport(efx, efx->tc->reps_mport_id, &eg_port); return efx_tc_configure_default_rule(efx, ing_port, eg_port, rule); } @@ -134,6 +135,68 @@ void efx_tc_deconfigure_default_rule(struct efx_nic *efx, rule->fw_id = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL; } +static int efx_tc_configure_rep_mport(struct efx_nic *efx) +{ + u32 rep_mport_label; + int rc; + + rc = efx_mae_allocate_mport(efx, &efx->tc->reps_mport_id, &rep_mport_label); + if (rc) + return rc; + pci_dbg(efx->pci_dev, "created rep mport 0x%08x (0x%04x)\n", + efx->tc->reps_mport_id, rep_mport_label); + /* Use mport *selector* as vport ID */ + efx_mae_mport_mport(efx, efx->tc->reps_mport_id, + &efx->tc->reps_mport_vport_id); + return 0; +} + +static void efx_tc_deconfigure_rep_mport(struct efx_nic *efx) +{ + efx_mae_free_mport(efx, efx->tc->reps_mport_id); + efx->tc->reps_mport_id = MAE_MPORT_SELECTOR_NULL; +} + +int efx_tc_insert_rep_filters(struct efx_nic *efx) +{ + struct efx_filter_spec promisc, allmulti; + int rc; + + if (efx->type->is_vf) + return 0; + if (!efx->tc) + return 0; + efx_filter_init_rx(&promisc, EFX_FILTER_PRI_REQUIRED, 0, 0); + efx_filter_set_uc_def(&promisc); + efx_filter_set_vport_id(&promisc, efx->tc->reps_mport_vport_id); + rc = efx_filter_insert_filter(efx, &promisc, false); + if (rc < 0) + return rc; + efx->tc->reps_filter_uc = rc; + efx_filter_init_rx(&allmulti, EFX_FILTER_PRI_REQUIRED, 0, 0); + efx_filter_set_mc_def(&allmulti); + efx_filter_set_vport_id(&allmulti, efx->tc->reps_mport_vport_id); + rc = efx_filter_insert_filter(efx, &allmulti, false); + if (rc < 0) + return rc; + efx->tc->reps_filter_mc = rc; + return 0; +} + +void efx_tc_remove_rep_filters(struct efx_nic *efx) +{ + if (efx->type->is_vf) + return; + if (!efx->tc) + return; + if (efx->tc->reps_filter_mc >= 0) + efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, efx->tc->reps_filter_mc); + efx->tc->reps_filter_mc = -1; + if (efx->tc->reps_filter_uc >= 0) + efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, efx->tc->reps_filter_uc); + efx->tc->reps_filter_uc = -1; +} + int efx_init_tc(struct efx_nic *efx) { int rc; @@ -141,7 +204,10 @@ int efx_init_tc(struct efx_nic *efx) rc = efx_tc_configure_default_rule_pf(efx); if (rc) return rc; - return efx_tc_configure_default_rule_wire(efx); + rc = efx_tc_configure_default_rule_wire(efx); + if (rc) + return rc; + return efx_tc_configure_rep_mport(efx); } void efx_fini_tc(struct efx_nic *efx) @@ -149,6 +215,7 @@ void efx_fini_tc(struct efx_nic *efx) /* We can get called even if efx_init_struct_tc() failed */ if (!efx->tc) return; + efx_tc_deconfigure_rep_mport(efx); efx_tc_deconfigure_default_rule(efx, &efx->tc->dflt.pf); efx_tc_deconfigure_default_rule(efx, &efx->tc->dflt.wire); } @@ -162,6 +229,8 @@ int efx_init_struct_tc(struct efx_nic *efx) if (!efx->tc) return -ENOMEM; + efx->tc->reps_filter_uc = -1; + efx->tc->reps_filter_mc = -1; INIT_LIST_HEAD(&efx->tc->dflt.pf.acts.list); efx->tc->dflt.pf.fw_id = MC_CMD_MAE_ACTION_RULE_INSERT_OUT_ACTION_RULE_ID_NULL; INIT_LIST_HEAD(&efx->tc->dflt.wire.acts.list); diff --git a/drivers/net/ethernet/sfc/tc.h b/drivers/net/ethernet/sfc/tc.h index 46c5101eaa8d..309123c6b386 100644 --- a/drivers/net/ethernet/sfc/tc.h +++ b/drivers/net/ethernet/sfc/tc.h @@ -49,12 +49,18 @@ enum efx_tc_rule_prios { /** * struct efx_tc_state - control plane data for TC offload * + * @reps_mport_id: MAE port allocated for representor RX + * @reps_filter_uc: VNIC filter for representor unicast RX (promisc) + * @reps_filter_mc: VNIC filter for representor multicast RX (allmulti) + * @reps_mport_vport_id: vport_id for representor RX filters * @dflt: Match-action rules for default switching; at priority * %EFX_TC_PRIO_DFLT. Named by *ingress* port * @dflt.pf: rule for traffic ingressing from PF (egresses to wire) * @dflt.wire: rule for traffic ingressing from wire (egresses to PF) */ struct efx_tc_state { + u32 reps_mport_id, reps_mport_vport_id; + s32 reps_filter_uc, reps_filter_mc; struct { struct efx_tc_flow_rule pf; struct efx_tc_flow_rule wire; @@ -67,6 +73,9 @@ int efx_tc_configure_default_rule_rep(struct efx_rep *efv); void efx_tc_deconfigure_default_rule(struct efx_nic *efx, struct efx_tc_flow_rule *rule); +int efx_tc_insert_rep_filters(struct efx_nic *efx); +void efx_tc_remove_rep_filters(struct efx_nic *efx); + int efx_init_tc(struct efx_nic *efx); void efx_fini_tc(struct efx_nic *efx); From patchwork Thu Jul 28 18:57:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ecree@xilinx.com X-Patchwork-Id: 12931679 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF57C04A68 for ; Thu, 28 Jul 2022 18:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232852AbiG1S7Q (ORCPT ); Thu, 28 Jul 2022 14:59:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232051AbiG1S67 (ORCPT ); Thu, 28 Jul 2022 14:58:59 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2047.outbound.protection.outlook.com [40.107.95.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A5BC76470 for ; Thu, 28 Jul 2022 11:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fQhKEdRo9mCDC8SXYrWrQirTHxettkM6gPzp95NL7LYDbFCg3O8hR+t7cFUkUh7H3QZrmlVyThsewmH+ik4uXvhbbAe3pXdu1nMlI0zN2AjZ3jDeNGO/EJxF7h366s1oz2Dw7X8nL5fcdGb/LHc554hMk50Uk38RR97Ahw3CapZ3UE0I2OWJl1mTVKxdfGQ2kXYhL4KsXdchiTz//P+lGQ+xjIpPobqcJnTcXbJdhFPJRY4b3kgKCyYIVveLE2v0l35FffA5gTfR8KwRPziswurayhJLGRJyfvKjAL7tBfO8rcBp0CsE3IQfXMGAABmERFo58sooE5UmaoMoaikekg== 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=oUvhpgeqo4K+PG3bnTrXMeliTjFrNCpCxb8Dlw5WRWM=; b=YMuSn2FIIbqZ6FDO3lG+YBcoIH17e8mUUSj0bMV63ae46lIDE5l775Esm54fFo3Ejve6lB/hu5zWnCLQwNhyKyLUhKjbP19Z8n30W/HhmBB9Zyn0wH/rqUnIb1G64Lb7E6wNLduwmtf+sf0nIaKWvedKOz0SWTaja0Qraxs9PdL9vEysTa05jI1l88/dP/HogY5ZFprDS7/3+2NHPP3BuG9eyFS/+vbFWpR/4HmSYVXBXyrACh0j4PHm947F4Z7orQBCkeZSr7cNRtbZ+3fbNvR0S/st3POPSXiMqEXdKVSn8Yxk5Bp9sty34J20voNx6o2bULeI2UvbEjnKClLy8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=davemloft.net smtp.mailfrom=amd.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oUvhpgeqo4K+PG3bnTrXMeliTjFrNCpCxb8Dlw5WRWM=; b=PH1ZEGCjSyeZ3ul99nCEr9x5xt03NY557GarQdRYaOhedogGrnSm6DD8o6A4uk9Nk6dWkXVSQrEdaYY4L26BClixZw21B9Z8iuKFMZax1BzG/k6yH/J6MFIR/lAPAjLy81HrKUPejz7YgZV8ilyaUj5qe9aTK969aWrXZCL39/bacmHgXQdOLveuYvuQu9X/F6iyoS706t/i8ziVNMULyO7kKOq1dKXNo6orU7B3wO3sS9ErZkMjV16/SmxjdhXpb1zfBVefcd/Z31RIixIbZCkdKr7SCsEZNRWF+PGuqjbmnMeIYlLux0vjdwI+2fHhIhURTfl/oaubAw9xPhRf1g== Received: from BN1PR12CA0006.namprd12.prod.outlook.com (2603:10b6:408:e1::11) by PH8PR12MB6794.namprd12.prod.outlook.com (2603:10b6:510:1c5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.20; Thu, 28 Jul 2022 18:58:51 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::72) by BN1PR12CA0006.outlook.office365.com (2603:10b6:408:e1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18 via Frontend Transport; Thu, 28 Jul 2022 18:58:51 +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=fail action=none header.from=xilinx.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 BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Thu, 28 Jul 2022 18:58:51 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 13:58:50 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 28 Jul 2022 11:58:49 -0700 Received: from xcbecree41x.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 28 Jul 2022 13:58:48 -0500 From: To: , , , CC: , Edward Cree Subject: [PATCH net-next v3 10/10] sfc: implement ethtool get/set RX ring size for EF100 reps Date: Thu, 28 Jul 2022 19:57:52 +0100 Message-ID: <294be9ed0dd09b800f764a7801ae929169009def.1659034549.git.ecree.xilinx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1cf0c11f-3b80-4bf7-97f7-08da70cb35ec X-MS-TrafficTypeDiagnostic: PH8PR12MB6794:EE_ X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NvXFzfrqAkh6YNvN8vKjGuhRM9z/H8MzXDtTvqieRmVcYd3ME1FL+NQkbHYehNAvE9TEd7Ov+bsPmxK+9j0FZtfzU8ToB8wI2SDI4aZKJ/UWtqd5A7Kk8l1zXtK2NQr3L+ChH6FN+j8isTKdljOI4P3y3JYiGOhMwx3WjeXipv6wZz0yNqcTtV0df7SKUb5PCYUcNBVZwVYyMndZUCoMQBeMDJLx9ETSzcQSjuhBBs6ksHhQCI++WvUtdu0Nmsh2zpBOgwUnYVfTrvN8fJ2kFdokQgWxLZynCbGE5BmOa7TEptzThzxCqodZ9oJqJYpmjQK8hFtcONTUyGQRC4mkkNGSABvicomVj2TB7U7ntRlS0OT1WU5ckR8P74mgNgQeKdhr8jjeCJk3F+dJjSc+EciIEBy3EVe2hhiKeyUCMCoLqr36/NTcDxiKm8738Q94uq5pI15M0+xKICRJy445ypXgYBRTnrlJotn4I1HfMPTljG78qsHYdqjrMNYJ1ixHUtdtBGSPyUVKfQvOD5EusKy3o8Mzrt/nm7S9a1mMxhfieM+vrWadkDk+TtecTa4vRJzblSiglFOhYXin9PJc9T5b7ML+s/1KWjQq386y0YrKFh4SkjBDkFBrnBzOKJHn0nBFEfKMq0cNvigz/ai6ubNsv2FsB4pH4O1KZF9yirZQXjODxWCrmVCByrXckCwG6XThpVN01ze5JBqKRYjPl8AVPeBHQwZ6/ia0CBH27grr9PqaPgmHdaE/tKhXh2iwvBkQrXgegqe7+PaA3AOtZMqy3mIwyQECG+JNO2nqWMeF1NhtmVPvp+a8RFtNEMyPHBWtzkQy4ZvFGZS4zvAz2A== 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:(13230016)(4636009)(39860400002)(376002)(346002)(396003)(136003)(36840700001)(46966006)(40470700004)(81166007)(83170400001)(40460700003)(8936002)(6666004)(5660300002)(316002)(2876002)(36756003)(356005)(70586007)(8676002)(4326008)(40480700001)(82740400003)(2906002)(478600001)(186003)(55446002)(36860700001)(82310400005)(47076005)(336012)(110136005)(42882007)(70206006)(26005)(54906003)(41300700001)(9686003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 18:58:51.0935 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cf0c11f-3b80-4bf7-97f7-08da70cb35ec 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: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6794 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Edward Cree It's not truly a ring, but the maximum length of the list of queued RX SKBs is analogous to an RX ring size, so use that API to configure it. Signed-off-by: Edward Cree --- drivers/net/ethernet/sfc/ef100_rep.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c index eac932710c63..73ae4656a6e7 100644 --- a/drivers/net/ethernet/sfc/ef100_rep.c +++ b/drivers/net/ethernet/sfc/ef100_rep.c @@ -150,10 +150,37 @@ static void efx_ef100_rep_ethtool_set_msglevel(struct net_device *net_dev, efv->msg_enable = msg_enable; } +static void efx_ef100_rep_ethtool_get_ringparam(struct net_device *net_dev, + struct ethtool_ringparam *ring, + struct kernel_ethtool_ringparam *kring, + struct netlink_ext_ack *ext_ack) +{ + struct efx_rep *efv = netdev_priv(net_dev); + + ring->rx_max_pending = U32_MAX; + ring->rx_pending = efv->rx_pring_size; +} + +static int efx_ef100_rep_ethtool_set_ringparam(struct net_device *net_dev, + struct ethtool_ringparam *ring, + struct kernel_ethtool_ringparam *kring, + struct netlink_ext_ack *ext_ack) +{ + struct efx_rep *efv = netdev_priv(net_dev); + + if (ring->rx_mini_pending || ring->rx_jumbo_pending || ring->tx_pending) + return -EINVAL; + + efv->rx_pring_size = ring->rx_pending; + return 0; +} + static const struct ethtool_ops efx_ef100_rep_ethtool_ops = { .get_drvinfo = efx_ef100_rep_get_drvinfo, .get_msglevel = efx_ef100_rep_ethtool_get_msglevel, .set_msglevel = efx_ef100_rep_ethtool_set_msglevel, + .get_ringparam = efx_ef100_rep_ethtool_get_ringparam, + .set_ringparam = efx_ef100_rep_ethtool_set_ringparam, }; static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx,