From patchwork Fri Apr 26 12:42:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13644731 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2081.outbound.protection.outlook.com [40.107.93.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81946144D3E for ; Fri, 26 Apr 2024 12:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135510; cv=fail; b=NkbhSOF0Nc8YrPxyUTGKWmp46kw1w9rhkFVqyMxd3QuO5+Kj/12jqjUSAKkN1VibXAMmv2KgI31A3L9uxh7UZBAimQYu5b1fmezCwJmBkJebFMAafxvflLrFLMFJMhX+0L8ICEiNWyjPkqd4F9ULvR2dI5SFvY4+dYxdwQM+qig= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135510; c=relaxed/simple; bh=hqO+JFWgLgPNFSMlvvAmT0NVOfhDZ7hrXCZAl7lAGfo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hwUMUwhqqkzvoiQSkyLTp81Hq5t63d/0RjZdj76qKwLzR83Ujlg5IIUz3afM1YAFxS4fCh8/Jy41JCczZv5UUKEPjcdt5OqSlx2GnJX16ODcojNECdei56p99qOujNRcrwHUNkeP68CIvUy2QekwExdd2Ev/9OnLrH3KGANElow= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=JGhQUQM1; arc=fail smtp.client-ip=40.107.93.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="JGhQUQM1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G1d+vSHsEgKTpJ0XvR6yAbITuVPMoQF315Li7aG/diNqjxdPv8SHOwWSrzEnli6nJxBBJelh1Vca8+MMwrNW8y3paovFBP/PvMdBMzHZazj238bNTMzKS+NweFxjblAtEKVRDwasc3sqRJ0bJPEothkzyf7SQDXk93m0vqWafDIrMH4d3F6qVawWF9ZAIuJFC5rVMMbQGm9BfcrlesDHNU4RLEvvjjSAEt/rlzC5SGi8yT8fsZHwYIILD/8MQiTUHTt+et0AhSyRlvWCtQI2GkNZZSNFGwsOJhDlWzYZL1eKlOfyTfxnQCzjNOjUzdH3j8d7KQrrzkwyPKXZu+QW6g== 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=eRcnLGHqMK3tALLYnNtnQN8usEwqYZ12lSD2nA0MdOc=; b=eQFXXqWsnQ9Gwut9BRWoCEsDlXKITarhrjzhDZFz/fhAJElG4Cx4VlLixkhigu/5xCBqpILRBykLn8oekcTiohzh36BDLeLXT/sudu9roZwjNn4edf+xQd5P6v0wuxhuHbbtmLlehHBgIKr/PKmp4ZnO/SrMPTKMJA/XWBbDgejXkxTCrCnNZhuDg2jEKQUCT6ZU9jGax7QsQEUCFqOXK6oXMiz919JV7qSQGiV7lrICVs7M1ZDeu29VTwUvPbZ8IoWSbPGNqRqo1SyseC2cDOJ+4NEOImthEsN2TnEbErRb8ECaljSwu0dlQ0GMxMYSkZ24xirKoYtAZs/5e2msEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eRcnLGHqMK3tALLYnNtnQN8usEwqYZ12lSD2nA0MdOc=; b=JGhQUQM1OVxjvtRtekvIyLGRXHUy/CapEJGS4Jaso2EqVdifBjn0td7bPmCT2IPsDTwJUSX9WyHiEB0gNcxsG8FZYAEx7zOfnDMlMAzZbA/QeD3Jm+eA8weciO29/rwDxP1fycd6MTEczm462OkbC8MjFXuekJ0sCtpxQxZpDe3EoC4bUUCKSDaEsEol7PhLbrOj9OH7wP5kM5OENJAA/KU8ZmUM5NntbOyV8Gl4rmOutGdhS/fXkY6X9kVaniBwzvtKZbbQINe91chkyEkl2GoSl5Tqedb4L/QPJQedyWNpOHlW/2jHCuWD28SSBLo5BvdHAxrSKIub7lcghVBONA== Received: from CY5PR18CA0009.namprd18.prod.outlook.com (2603:10b6:930:5::24) by DM6PR12MB4042.namprd12.prod.outlook.com (2603:10b6:5:215::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Fri, 26 Apr 2024 12:45:06 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:930:5:cafe::46) by CY5PR18CA0009.outlook.office365.com (2603:10b6:930:5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.31 via Frontend Transport; Fri, 26 Apr 2024 12:45:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Fri, 26 Apr 2024 12:45:05 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:44:53 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:44:48 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 1/5] mlxsw: pci: Handle up to 64 Rx completions in tasklet Date: Fri, 26 Apr 2024 14:42:22 +0200 Message-ID: <5381c00c284ddc62d90dc88f3b080bf701544d94.1714134205.git.petrm@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|DM6PR12MB4042:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e69572b-4c9f-4532-4a73-08dc65eeb2fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|82310400014|376005; X-Microsoft-Antispam-Message-Info: kIeAquW/XoeahTwGb/PFRUCf0VflQf6cX4o7/FwVY75IqcfuW5tZbw/ULFyBUEkqsm7tDX4UDAwtCl8dBCtddZEtSAqPQDT9P/8/P+q+5mrnNgBC10S0TGm047lRX1dF7+VYluXX7nA+ccME0/PZLoDppO7VyLKXwW2T/rCutI7kCJ/kWe4dJKU7ox4ZK9WEfcb/5m0L6ocOqzHBENr/emCh/1HODD9QgxklfHi8dilDEPNty2sv6vZwajsLHQE5RaH80XGFQBqtdjEkVkpT9WTQq1p8vxUCvv6OiQx9Oh8dX9tTp+4p62uWJP619fZMZlUinqRggMHbTGSSTOqwnGZDXZGI/RQGBUsSd7IyY7H+yGBFW4HKpTX7Vy5FNL3uyYiLSOjwvXuMi4Up7CADCBxmDzVzcn9GPuvXBh2o83SBbRdEktf2QdxsbeyMt/O3KXVAxmEBmrjbyX0D2/+UuRJ6gCGLu0ruVravDqUjNEYrH2hWj6topaSYJMLV70sv6C75CnyC8VLpkQAoeYp/kWsRAPZdIjeIo1yqFCIo5vNyOfUUiaxS2zL0XeeHTvpA0r7qT4C/ucecol/nNOyAd5bMlAB6LwQNV9epV/CMZzUn2/1WCWmWIQ9ld3dzj/EnAYStcQTiM36+BGKUDQ0ykKQcKFz70X6AwezG0JNpZpQ0g84jjIQSb63OnM0dfHZymth+BhsPzn9DIUGk5XoJn6jmFbUpE15FOUpRdJtNg+XXK9GARrozNAwWo6ZWDxO1nLguQnXkBr9nue3T2djT5epJq22epXt84joHQN11S2d47yKRV4i3v+d3bN5houfOzDutJCDyS2qkAP9tpoGaUijz7XU50Cep8wVC1Rh17oUO9HuNZ2TrW45MzeQ80o0nJ34IiMkpdPAaw5rmU4a+i/6yovCGFNKsYFuHzatd/tmAIERn5IWqTgP2b16q7Ky7851jNR2bWGMlHciAY8j86jYzJ1o9weRCwKImsOa26GlhfzbB82QCfe2l0dE9DM1Ibyd0l3KhocXZTXe0gBuKeBXt1E29rWCwDu1lYBeA6HZXsfOt00rFLM6/6zFjDDpbc7SD4YJhDhOFYKFwQFPSp/P/niCYfVTJKASQgkiGpaTMxoNpXW3N4E5OTLAPQBgeZ/x5GlVzOmw9DG+8xMOh42Oecc3N3im9y0tqtgLnHH5e1FFTTlFPV9ZuXK/6KPH8V9Qrl/hHnE526cvCaTtqxO+4sGduPzSGD3Juz/WXN6CiMECqPML2q7omsbxodm3IBA4bpVkw+qymSmydpgZuW6BVhhgC+yM89UF4d2N/tWVaBAaIYDXQaB0Ermoyi9yQexQqEaBrJK+vXWDfQcotshwUEzH2wQVFV2UCmOUylzjyPvVLrayPQOqc5FU7PwQ+ X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 12:45:05.8305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e69572b-4c9f-4532-4a73-08dc65eeb2fe X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4042 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen We can get many completions in one interrupt. Currently, the CQ tasklet handles up to half queue size completions, and then arms the hardware to generate additional events, which means that in case that there were additional completions that we did not handle, we will get immediately an additional interrupt to handle the rest. The decision to handle up to half of the queue size is arbitrary and was determined in 2015, when mlxsw driver was added to the kernel. One additional fact that should be taken into account is that while WQEs from RDQ are handled, the CPU that handles the tasklet is dedicated for this task, which means that we might hold the CPU for a long time. Handle WQEs in smaller chucks, then arm CQ doorbell to notify the hardware to send additional notifications. Set the chunk size to 64 as this number is recommended using NAPI and the driver will use NAPI in a next patch. Note that for now we use ARM doorbell to retrigger CQ tasklet, but with NAPI it will be more efficient as software will reschedule the poll method and we will not involve hardware for that. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 13fd067c39ed..8668947400ab 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -652,12 +652,13 @@ static char *mlxsw_pci_cq_sw_cqe_get(struct mlxsw_pci_queue *q) return elem; } +#define MLXSW_PCI_CQ_MAX_HANDLE 64 + static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) { struct mlxsw_pci_queue *q = from_tasklet(q, t, tasklet); struct mlxsw_pci_queue *rdq = q->cq.dq; struct mlxsw_pci *mlxsw_pci = q->pci; - int credits = q->count >> 1; int items = 0; char *cqe; @@ -683,7 +684,7 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) mlxsw_pci_cqe_rdq_handle(mlxsw_pci, rdq, wqe_counter, q->cq.v, ncqe); - if (++items == credits) + if (++items == MLXSW_PCI_CQ_MAX_HANDLE) break; } From patchwork Fri Apr 26 12:42:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13644732 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2063.outbound.protection.outlook.com [40.107.236.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F139B144D3E for ; Fri, 26 Apr 2024 12:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135515; cv=fail; b=JTbUTio4fHz1gdHeGKtW9XO7NNjUKStNQAWiTPIu/b3pF7/TlJtjrY5aJ1OXJNLqpCMAo3KwposZaeJzwCtS0NNIF24lxVVRSaVZDy76kuPGjzowpYT9TnGsqwl4ze+bD3bihwrb21JnxKM3MgOUPJzfmTOV9rjNPVF9qRilyZ4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135515; c=relaxed/simple; bh=c92LoBSTAG/0oIwjQHG/KRD/CJ82kg+UiutQGmRDkPY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l2s+QxbUcVUieYrUgujo/clPDev08DaeRHt1zvLDqAOwpcCJhvaHPxQRdM6kYiSZaIDm+YvCT9bmtvF+tObVGPIRp4wPzVG2kvgRlLgcE1QHiOJuxWHJr4dkt35+fOsAqYgSjn6L3mvihu/GGmpQg4poQFhC32kGof69WcMyLgQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=U+MUs2GA; arc=fail smtp.client-ip=40.107.236.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="U+MUs2GA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k3JIrmmooZQG3125tHIE8xWRK+OP5oXLD8wOzNMa2LU6HbDSMickRYxNbKtElx6dHHA1ByA73eSOgs5DnouSNCH2vkZKqTSpT8YJYOPDlsh3QZchxGtMoRJuBIM+VjNsjHFBI8upYF1ZUDKP2WcOcU6ctW0JUr++BZZjnkkTIRW73ZEkDjFxHJlW5vaMWR4dXF0++fK6q04fOKiWXrTkixSmp7FakMoXBh4dXTRaaFBLiIhYkxTH93CPcctitw7MW8YcUTR+VzSzA1L+mMNi4ix3jzen2icug8lHEeaVAKs8wF41Yo9WvXpJLwxOc4pUgwlJtCdaiLAP9VI2yeZN/A== 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=Zhux23mQ3KaoT+53+k/UNnUETv/sjcc2yeYXR2EUi+Q=; b=cujig0b/psPAlGNKG5gwi5pHGAqSdQXu90ofm3UI0Jq4VGbcSDWHlMcIOVkVgBSsrAStwFpeXuqXDupQBDWf9OYMX1KkAK8+ZyMuZEP+HoTpbJkC9QLWWIMKD+yfTlSpU+IaxESxcbmqNMntxP+lz/7KE4Jt8TMTU2LZGQXvtzpKbutrOI9vv56kPU5BYMbOwHLzlwlxYrTwdhJXgUTrLpRHw3yMr32w7gAGx+repniMoo8i9tPNOM0Y0wAa7Irf2iE/6w/w5YGIixEvU+HY66PWXK23d8Dhu5fEPq+PNysu7hh4Gw4M0vp2YiIetpMEZ5TmtEaxTE1g6WGwF/gGXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zhux23mQ3KaoT+53+k/UNnUETv/sjcc2yeYXR2EUi+Q=; b=U+MUs2GAl8ynLHpPLaEKqM5WohCecGGMTXnTu9pzLw05+HPe/bcM6vCkpE9fvxbRVOrQVhwcyu1ig50Bsvkk5yx25f06aCOeWYkU2sW0QvIysT1f6Tq5eJzGE1Uz0khnWT93ay6jnuOyHEE3hr/TRQ18PHZpgRu67JOikSOhQLONGI4eA7dWIBh72WMGnItDt/JCdF/zbbstk869f7/3xrv7PBABUaeu2mHDknZkJQmvEnl37tr/OLJ3ByHt82MN2owwmeLWD0vjPbMTlFK9NgFOzxU5dnXQDHLZ4SNeg+Q9dkMWLsoH/BA33ZX44i2u9VxFD+gpMAUwNHHCrVQ1/A== Received: from PH8PR05CA0024.namprd05.prod.outlook.com (2603:10b6:510:2cc::12) by DM4PR12MB7624.namprd12.prod.outlook.com (2603:10b6:8:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Fri, 26 Apr 2024 12:45:09 +0000 Received: from SN1PEPF00036F40.namprd05.prod.outlook.com (2603:10b6:510:2cc:cafe::74) by PH8PR05CA0024.outlook.office365.com (2603:10b6:510:2cc::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.18 via Frontend Transport; Fri, 26 Apr 2024 12:45:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF00036F40.mail.protection.outlook.com (10.167.248.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Fri, 26 Apr 2024 12:45:08 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:44:57 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:44:53 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 2/5] mlxsw: pci: Ring RDQ and CQ doorbells once per several completions Date: Fri, 26 Apr 2024 14:42:23 +0200 Message-ID: <82bebf03f3b33a50ea9f5a81048f29ddea5247af.1714134205.git.petrm@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F40:EE_|DM4PR12MB7624:EE_ X-MS-Office365-Filtering-Correlation-Id: a2269321-4c4b-445a-36f3-08dc65eeb46b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SHizurUsytgdYWZbhZj+VlqTT/EYNYuSeTjEP5D5fZue7DnbKu9abU+7zcNnJX5Z2IF1gkumYsBykyA+agU7x1L9GsidT2UM+7Di9Vmx0p2W55tVNyHs/D59gXkDjxkWEBbsWjpSa31wc8nkTn6dqGzlcPRFhL/83q8nvOAbVbgadjuEu8lZV2VYebGYWBWUhSQDCuxg8bRj67d1/W7RkspMIfUKLPURMNYjoQxN9Tgd5aQ/5AyCy7XnBAjHl9czOMsS3E/YnXbl0U6mIPp7kCu+OAy+f0Mck3jwM0aO7VyMg6wBtteOT2F2BDupMd1l0L4SjG3mPW3LIEF7Q5mB0gb6quqoU+3/xAfuEFOQKCOLFvxhOrW6CK54BPNlfutozVflW6WpDYmBIi2YA3xPpXP6wOun52O3xx5aw7ZYvp/P/6EIjacvmxbtrMskZLoAV/9fdBuFyjnDnS9UDed65c9FkzG7RZ0cuuyelbwXp4hqltZTy55fXsw7cROL8K/i/a2p2izKZAkbvrWOrcNBfQQvQthA1E3RJr48vEq9wX/A/X2leqxU+Pqb1SSKmiCNA7lxfZTk8a7lff7YVZEm1z66vQjo4VCxBEvsv2bnMVvvCOMcwQCNWVQ9nvR5Ztx/+UxH7ydoyAEefX6Mw98kysHd8dvADEPkGQrvWd5+vBqce3yWpkAwoeE4lHF72CdV9SYUVraI6+KHnN60ClFYMR1Xay+XU79mPB7XOjWVLRzGhvtQaV02P23iwGRPnCp5UfsY3J63C51OVwGSuGuCVfLwK3ePOcvEZBVqCrcGDp6IfHhle6o+1qnQSq7BfytzUwNQi2REYEZ5sinDExQi/Rro7tAHdpuTJgpLeYeXWZ0nCp/AlAv99prm2FLqGR54Fs/IofFc8fcEG3nQZ+Csi60j9JSsWs5qlqTfAdvdBdKfETFd3V2xOXjHkJ8RKI3R10LyRlCmF1DSeWRTrbMAaSq1P90rFOD66c6dFARFyqF2mRlQs8bJrcE5MCzpxonqgB6Y6tEC6ZzvjGgjS/TjgR2qYpOrYvpr0H9RIVQi7GcyxjJX8AMzJp7fdQsLgeOcEl9bA1jX1l0Z7uZk2bEerffPqGw4JGuPTQMbFwTSit3k+dxv4Rsc8PzlXTbW1whGYxWElVQA5st1qsQ0K5pgyHOCKdTH1g2R0NK/HntmnZULb2js64WASk0Th7yVVdJtzP4MFKd/Y1+yq1sG6mXTuxb7L/bhTPZRonn077RK27TCZ7HTbynBqtCoCn8g+S5Bf9GWbNF4Zp0W6jSGsnaQS2Q++A+MMB5LI3hFf07h499VSptORaTz9GdqgpY0MXoUW8dssRUPZ8NEqFLLEPBkUHCD+N/i1ixG0S4JCUcsN9v/9KoAewn4tBK0WIrKBETd X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(1800799015)(82310400014)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 12:45:08.1908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2269321-4c4b-445a-36f3-08dc65eeb46b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F40.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7624 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Currently, for each CQE in CQ, we ring CQ doorbell, then handle RDQ and ring RDQ doorbell. Finally we ring CQ arm doorbell - once per CQ tasklet. The idea of ringing CQ doorbell before RDQ doorbell, is to be sure that when we post new WQE (after RDQ is handled), there is an available CQE. This was done because of a hardware bug as part of commit c9ebea04cb1b ("mlxsw: pci: Ring CQ's doorbell before RDQ's"). There is no real reason to ring RDQ and CQ doorbells for each completion, it is better to handle several completions and reduce number of ringings, as access to hardware is expensive (time wise) and might take time because of memory barriers. A previous patch changed CQ tasklet to handle up to 64 Rx packets. With this limitation, we can ring CQ and RDQ doorbells once per CQ tasklet. The counters of the doorbells are increased by the amount of packets that we handled, then the device will know for which completion to send an additional event. To avoid reordering CQ and RDQ doorbells' ring, let the tasklet to ring also RDQ doorbell, mlxsw_pci_cqe_rdq_handle() handles the counter but does not ring the doorbell. Note that with this change there is no need to copy the CQE, as we ring CQ doorbell only after Rx packet processing (which uses the CQE) is done. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 8668947400ab..2094b802d8d5 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -630,9 +630,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci, mlxsw_core_skb_receive(mlxsw_pci->core, skb, &rx_info); out: - /* Everything is set up, ring doorbell to pass elem to HW */ q->producer_counter++; - mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, q); return; } @@ -666,7 +664,6 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) u16 wqe_counter = mlxsw_pci_cqe_wqe_counter_get(cqe); u8 sendq = mlxsw_pci_cqe_sr_get(q->cq.v, cqe); u8 dqn = mlxsw_pci_cqe_dqn_get(q->cq.v, cqe); - char ncqe[MLXSW_PCI_CQE_SIZE_MAX]; if (unlikely(sendq)) { WARN_ON_ONCE(1); @@ -678,16 +675,15 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) continue; } - memcpy(ncqe, cqe, q->elem_size); - mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); - mlxsw_pci_cqe_rdq_handle(mlxsw_pci, rdq, - wqe_counter, q->cq.v, ncqe); + wqe_counter, q->cq.v, cqe); if (++items == MLXSW_PCI_CQ_MAX_HANDLE) break; } + mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); + mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, rdq); mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q); } From patchwork Fri Apr 26 12:42:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13644733 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2080.outbound.protection.outlook.com [40.107.95.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D077146A95 for ; Fri, 26 Apr 2024 12:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135515; cv=fail; b=jaqgAyoZaWiMbjacIjJSwSl6MrFesAnLfLc2Go3l0SgHhtnNjcM2Dmc92fbmKBtdZnCZqNn96nURE1stOeEzwr9OTa167y+pWl5yTL+umycWjsrZAg+oZafelR/RA5PI3vKI4/fqTD7nHIwE/xe5m+ptDAbidmTEX9vfEsXrlVw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135515; c=relaxed/simple; bh=cDOQxacCcSlk/1rnqv3Uw3u59mz0QAUVigsJS9i0bJY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IcIDu8T6Db6XtCUMAjFy6ndmGjQPmmGoS9c++rXbpl2O9ZnjQVay0mhS7ihyKrK/3qD06UJIeRPPCn5M8hJBQnY6IlgUAVaSZMeJxJ8HH3kt4oJy/xpYQTiYNyVK4EV4GfnBFOvTSSAQNm33LjxJHsrq+bNikDQJgY/kASKns+0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ASfvpkad; arc=fail smtp.client-ip=40.107.95.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ASfvpkad" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jQqUA0m8l0tWT2uuDq1LnUtW4v/PkcQf4VGyOQ/nOk6h6mutT0g1hLACgsc1c29pwAEfimE2PzdF+F2ZfzpAIpanhc6PVyIyQTEXCHpN975PdgxNaik+exozqLwh0pScZ52gpWN0s2AyqUKjltiHToboBmom9gFxspE1N1MI8y/eNbFug4BhmOJuGgkHqV/e8REwVQBsTGSPuH3sDhCoNXTvlNySMhXYVju0r4rayAvUEcrhUOkwwc44+8ovdgHqwlkDF00HD36MDIcobjAuvBl6nkgLqyaRQVF+Zoz/Th9LqFvUMTD+Kc6gwa2FShSTIgKwIyttENqc13XFGFkpGQ== 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=BENPOsAkR8tSkvkTUWjharxyEuFaq1d92x63rW+42so=; b=kACfV1r+nF0NTdBMn8CCWPBGRq95AW9NGRRioQMGqnTNU/jcdtJrrkT7KPI29jJ0+orRDTgzQxHjERCchSnv9AwM4e4LiU+ZAU7VTsaHkvGHA7fKDK0pInzLtIZSkTkbA36iq5+BB0QyWCrVMamYZmWvefGh0yN+wGOFz80jIdfPZnHcUQ41GjitYhMAa6727C+ypQhZap6n8zktp8DA1aTTCXDxGEQtHife4vJQUbRxy2aJ+3weignTW/FWiHjFtfYHldBr7ttki2TAkpB0qqUKw0xOS0EGQ1Uz2nQXfZOJVMlN0jZ8tEKn6p8ZQVL565BXo2a0O+MAghenjO8qxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BENPOsAkR8tSkvkTUWjharxyEuFaq1d92x63rW+42so=; b=ASfvpkade96PwZaT72cPMsNLQtcd5Z4JdgLQsupoGUWQ7i8Z2orWaBNUrr+Ro8vqklOWc3fiZFvFKtUVinqkcLSh5mW7ni85kS9wg0aizOXYTRz7KsyPo8adq2mTKQ8MnJUPLd++w4Xp1VG1qd4VFOxQAdSu3qrgS/3TmxTsYxAWPy6hkxu50DIc/ifhhwTpcad813GcUEmzPDkuFT0GkYgSZ4gSP4LACC5Ah2TC9W4aGqORIJNp4XV3f5lAC+YOO2qh2PkHYfyVpyYl6PcSMTWFp+JKyd5YBT70zIWexyF4CUhGTz/hu0tl0swUwCmonLahiCTOxjcCD5NKNaf4FQ== Received: from CY5PR18CA0004.namprd18.prod.outlook.com (2603:10b6:930:5::7) by MN2PR12MB4239.namprd12.prod.outlook.com (2603:10b6:208:1d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.24; Fri, 26 Apr 2024 12:45:10 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:930:5:cafe::62) by CY5PR18CA0004.outlook.office365.com (2603:10b6:930:5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.29 via Frontend Transport; Fri, 26 Apr 2024 12:45:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Fri, 26 Apr 2024 12:45:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:45:01 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:44:57 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 3/5] mlxsw: pci: Initialize dummy net devices for NAPI Date: Fri, 26 Apr 2024 14:42:24 +0200 Message-ID: <025aeb3d5b1c4f25b39d9a041556e1d703615e8f.1714134205.git.petrm@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|MN2PR12MB4239:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e0d7708-3117-45ee-69ba-08dc65eeb584 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|36860700004|1800799015|82310400014; X-Microsoft-Antispam-Message-Info: Ef2kcV8MPc2dr8yUQ7EFXS/sYHUF1MVEfiS1lGUmfmgPQNOtpFTfq7Z3Evupsy43bVTwA9S9LMk0sWGdPkvKwgk+53Qbcbs0YLGsUi/3jZJX7yFUX8F+inrzcsh73XYnu81kbYfyX8ZmYS7pMzWgSkycRYSbob7Ckt6xaq5fXHWf8TOooa29obu1soNP5Oj1maeE0Ol1C/2wL8FAHmVuP9QYECJYghwtFjB6d8n72zTkjt1/FvRFD6TLNZaRRZj/uuNMkwTpUcia1pokd+qwdv+WtG5Y/HGFw0LholDQrSg70AZRyzo1At1jxhoFVpXg0o6hJzy16swfN1wfJhAmIZ4SKhpewWswWznhDoKpToFZDqoUmTkGUbLYcReWDAh5eFYqYLDmNOBh9NHjZieNsOUmWb7PguBtGydWhl5qZ3lG1LuwQOrvIBX/FZUrRiX3jVdvIT+72ewcd7cfGZGuHeCKuAKpXpHaWQ97GA2CLZc7BVhbylUpauuDDOFaPS9mriQZCPVBOBgHHdkiZd4bm2mZvOlKvcnjN5+5T6ILotNZRhQaeh4Mx0imxFVED3tzbT48cTZHG6lfW5Kv+YN3be3zcafPyOmQLBYKr+kiXXk+urePgT/ijPEF6hrHIMLQeah0A0xpqbYtu6JqVVVwWYI5oIvJpW4BbfYzLdYsBtpOsvYMk65Iq/w84xe2WwvtGxkgVuEn4xccOnOkywf8Ru47i6lNhPkZzc2hIx8HzPI76YE17w0eubOkdxvgrSnTVHs4FpxNvIyCG+ubLOW59hplHMZtlh/YSy81Tv8vkfF+eRWeH+cwbD3weGp2YE9iMv0uwgdy492klIIzcqjpSDwRVSKd2o+lM3C549CyDKMPYpC93al0DeaP//UQ1PavmwHr4SnbdlJHWPU+3ihLqyMaR1Gn9yhY69/mKWZ5V/yMTWnTqQtRh81kkCuyIKzqsfbgHU6Z2BpUuj5CkmWQhrT1InMpW4xNDylDvfaRuCvlO6HDGxmqyFfbt/gTJhKP/YjfUhWFKEshnAT3wMT/WP3OxP7S5a88ayK2BD2VxSDp8J0IR4djJCKlsQh/4+SX4kERCXAbArIUMEWfOOpNl/V8dT88EE++WA74Gz6fBeM3N1nf+bRNoyXLJ1izwnaOmHsCYx9IrDKTjZSvQv9wGrKNBjnJ3euSgIXAhjxcyUxZNn+tZbxBMGSDCRR34/fFhGrjB4HninJac4VzS2/HPskls8l6+5UQ0f3i8sVqS8/gsA5HlPa9X4VOtmpGsJGtvjC+/rVeke8M+HFEYhDnivZSby5rWnm4SClNvN52PXctvPzmhWd7+YrBP1qqz2zYMXa+PwivG2zNdKfkk2z8nbeJhhh8ktJS/Z0TN9m9opE= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(36860700004)(1800799015)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 12:45:10.0649 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e0d7708-3117-45ee-69ba-08dc65eeb584 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4239 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen mlxsw will use NAPI for event processing in a next patch. As preparation, add two dummy net devices and initialize them. NAPI instance should be attached to net device. Usually each queue is used by a single net device in network drivers, so the mapping between net device to NAPI instance is intuitive. In our case, Rx queues are not per port, they are per trap-group. Tx queues are mapped to net devices, but we do not have a separate queue for each local port, several ports share the same queue. Use init_dummy_netdev() to initialize dummy net devices for NAPI. To run NAPI poll method in a kernel thread, the net device which NAPI instance is attached to should be marked as 'threaded'. It is recommended to handle Tx packets in softIRQ context, as usually this is a short task - just free the Tx packet which has been transmitted. Rx packets handling is more complicated task, so drivers can use a dedicated kernel thread to process them. It allows processing packets from different Rx queues in parallel. We would like to handle only Rx packets in kernel threads, which means that we will use two dummy net devices (one for Rx and one for Tx). Set only one of them with 'threaded' as it will be used for Rx processing. Do not fail in case that setting 'threaded' fails, as it is better to use regular softIRQ NAPI rather than preventing the driver from loading. Note that the net devices are initialized with init_dummy_netdev(), so they are not registered, which means that they will not be visible to user. It will not be possible to change 'threaded' configuration from user space, but it is reasonable in our case, as there is no another configuration which makes sense, considering that user has no influence on the usage of each queue. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 2094b802d8d5..ec54b876dfd9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -127,8 +127,42 @@ struct mlxsw_pci { u8 num_cqs; /* Number of CQs */ u8 num_sdqs; /* Number of SDQs */ bool skip_reset; + struct net_device *napi_dev_tx; + struct net_device *napi_dev_rx; }; +static int mlxsw_pci_napi_devs_init(struct mlxsw_pci *mlxsw_pci) +{ + int err; + + mlxsw_pci->napi_dev_tx = alloc_netdev_dummy(0); + if (!mlxsw_pci->napi_dev_tx) + return -ENOMEM; + strscpy(mlxsw_pci->napi_dev_tx->name, "mlxsw_tx", + sizeof(mlxsw_pci->napi_dev_tx->name)); + + mlxsw_pci->napi_dev_rx = alloc_netdev_dummy(0); + if (!mlxsw_pci->napi_dev_rx) { + err = -ENOMEM; + goto err_alloc_rx; + } + strscpy(mlxsw_pci->napi_dev_rx->name, "mlxsw_rx", + sizeof(mlxsw_pci->napi_dev_rx->name)); + dev_set_threaded(mlxsw_pci->napi_dev_rx, true); + + return 0; + +err_alloc_rx: + free_netdev(mlxsw_pci->napi_dev_tx); + return err; +} + +static void mlxsw_pci_napi_devs_fini(struct mlxsw_pci *mlxsw_pci) +{ + free_netdev(mlxsw_pci->napi_dev_rx); + free_netdev(mlxsw_pci->napi_dev_tx); +} + static void mlxsw_pci_queue_tasklet_schedule(struct mlxsw_pci_queue *q) { tasklet_schedule(&q->tasklet); @@ -1721,6 +1755,10 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core, if (err) goto err_requery_resources; + err = mlxsw_pci_napi_devs_init(mlxsw_pci); + if (err) + goto err_napi_devs_init; + err = mlxsw_pci_aqs_init(mlxsw_pci, mbox); if (err) goto err_aqs_init; @@ -1738,6 +1776,8 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core, err_request_eq_irq: mlxsw_pci_aqs_fini(mlxsw_pci); err_aqs_init: + mlxsw_pci_napi_devs_fini(mlxsw_pci); +err_napi_devs_init: err_requery_resources: err_config_profile: err_cqe_v_check: @@ -1765,6 +1805,7 @@ static void mlxsw_pci_fini(void *bus_priv) free_irq(pci_irq_vector(mlxsw_pci->pdev, 0), mlxsw_pci); mlxsw_pci_aqs_fini(mlxsw_pci); + mlxsw_pci_napi_devs_fini(mlxsw_pci); mlxsw_pci_fw_area_fini(mlxsw_pci); mlxsw_pci_free_irq_vectors(mlxsw_pci); } From patchwork Fri Apr 26 12:42:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13644734 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2055.outbound.protection.outlook.com [40.107.236.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F80F13E88A for ; Fri, 26 Apr 2024 12:45:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135526; cv=fail; b=iI6TmoamIAU+yJW3o9E7Unykxd5D1M1+L8ZqsgQCD7tHyu54fnmBXZ/dfswr/7doBvPDpqRCE+IaLjB5d0Za9k7LS+keeUQrDSd0jejVPbxg62HwPvaahE6Kz5xg07FXQO7tMYCIummvsiNARk3GOJX5YO+3DAcLQwORmS5JtbA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135526; c=relaxed/simple; bh=s5xWj13mSXJoRBkP+HWjgyPE1pUqb7nBa5rhi3g6U1I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=po/5iHQSopzEuFWElYbooEH4E3CXCpv7LBdxbQV5o9hRhUZVqSTXf4UEJDaM0UhZxZ2FJ914KEuy466c7FGR5dOr2iqpEuYvC+ilB7wRWmwA3X8r/6PD37aKvX/lBbdWVEMTR+fVfbmERVIBvPSrDJcj345sM74hXatkWjeeg0M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=O4Lz8uh9; arc=fail smtp.client-ip=40.107.236.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="O4Lz8uh9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VrUD2rGoISwtRfloJIpeMut8+EUEaVtvC2jyZbz4pNzSi0D7wRHtk6SM6QkUlrcS+5YKVy5b+qcrUkfSzHp24HxnYpdcRG6rtLEnloehoTuJU7EqW86jKLBKerF0gPKDojqYR0U8Y1VgnZr69TRJx81p/8LfhOIcxzS/OzDD1sXrhOP0XeWXa/5IhkBeWkLSZXTxHgVKk8w5WHzCPMIENV41HnJ/YE/kS7/O+SwhD19B6DpgNA+1Wo+QLXDlaxVcCvfRGYgWXsDTM4JwXOzZicdOWNzW8cJdbkmhP0UxQTIG2pxzKwiXMWl/7+f51PXYQct+AquSkOAyOm8wKF63Uw== 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=Wgby1dwSiXEqNYHnXUnGxlLMpmPgfLHf4F20unMxBbg=; b=MwKWBRTyZo5ew/Td+gtkMvlkpMsw9qz/LXka+IEihceC2uICiqWJwGjnGngTmsIveS4yu/Zp1xDQhw4bv1ZJTzpVVmEaVNCEQ5DAHi/4SLOBNHo9kmdvYZW0H0SCc14k+9SQAcDgq7LhIlkI3pSH3cmRW2GDtGjoX8hLW1DzyqBWa6v6YA9BoEB5SPDpuOB7yjUQ6pkj3G4LTm+XtmljSVSPxPAei/Mjt/wN1RxwY2cc+LK7EYnfmrUeQYRO4TTRAZfQ0q+2PiwrbacZiBbeNrBO3RfmudL4YuUjiCC20MBidiBZ7QfCwJjcyhX6M3/AOL0AOgDvqesGN7wA5l1CKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wgby1dwSiXEqNYHnXUnGxlLMpmPgfLHf4F20unMxBbg=; b=O4Lz8uh9fMe3uAPolYn6Ni5885fq5EixRSv+RtEX2Rn6lYDk1AtLnesup82stVjf9iR3vhdoHaZTFfGp13pHG0yahZ4b86DMRiiJhvmcgNAQQjcP5MrA1p9qzBw7zHKRcap13FkhE8PaX1c9QbkD1Se+4YeBdgiELSudBTcUpAmWf6CkL8nfXvhazBS2+UQlByN5yZtLJmV/5Guztesjs/FzvjFsKJdoDHwiQvGQndzn2gy5RBXYnM+BuufieY0l+lQlNMPJnZ8nXFB/aEALA5HX17mHnrBlNetdcvRJzyw/5by4WAbioENKthuFVGhJ20v+9XUy4Gr1HdDpvIGCpg== Received: from SA9PR13CA0015.namprd13.prod.outlook.com (2603:10b6:806:21::20) by IA0PR12MB8932.namprd12.prod.outlook.com (2603:10b6:208:492::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Fri, 26 Apr 2024 12:45:20 +0000 Received: from SN1PEPF00036F43.namprd05.prod.outlook.com (2603:10b6:806:21:cafe::a) by SA9PR13CA0015.outlook.office365.com (2603:10b6:806:21::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.13 via Frontend Transport; Fri, 26 Apr 2024 12:45:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF00036F43.mail.protection.outlook.com (10.167.248.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Fri, 26 Apr 2024 12:45:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:45:05 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:45:01 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 4/5] mlxsw: pci: Reorganize 'mlxsw_pci_queue' structure Date: Fri, 26 Apr 2024 14:42:25 +0200 Message-ID: <467009f0dfdbd1885522ef0c51711b89b7b46b74.1714134205.git.petrm@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F43:EE_|IA0PR12MB8932:EE_ X-MS-Office365-Filtering-Correlation-Id: cf44b712-5e83-4e59-8296-08dc65eebabb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E7i9KbOjYoSb631SBUgmYmZbutnOrsJmIHVFkug5gjtIq/uwbxNV5ltYu6+CbJWkKkERHw+W0OBEb+GAQtUfP84sDt8xdxqgL1JpJDApwrIGTXp0T8dXlHII+6LSGzfVTi9ZxQoivDmUCQ9O/NKkLtyD+IovIXaYVT+dShtmpCImYfOOHGNce6E8qSiUspcHZ9Hrf6685/P93EeCq1/Dc9kuVznvBoilwMg3nQnZhO5GIRJEhmvMfZe2H5sundoHdP7lP8q5XBgHtNDWOyVbl3JWEHeDcdC8E2Ou6WHS0k/b5Pa9yI4jU1A4iGLB7N5ynR4+2/W5wDgld6B9FDp5lS0dqWjOZGpeG7n7dtrbkSJc8Q4/hDxvugcWWe7ZQ56u0QRWbOOYakVH279SawOFZkVg5do4zYlbyTXbUsjeOsLC5nQ9EtuYz91Uz/i+b6/Z/a+Erq9pPXpZsOZPGqHJcB6o2fnkx4u4DHH38Dye/oQ5hXZOM4qG2YtOKmGrGNblK5+oGNlFc25fzhmfvuThcbCbQszpTUBXTDtu6pa046Ped7nTK6Sg/9Q6Xbr+tAAqYrhpyFS1ny/TdXB9chuoVLOErOd2M+dgdrh9Gs03nNeXTz2H73FzwfMR2yCEl0eFTX0MqVHFN2NJNBclhvBldV/kvtEdLcEjJ08wBZSwgYJ6JSlXAPQpkFLptjyx8GHXuYrONOJ5PqGXxyzxM1TPHn8Jnyv7T7Hxm1HTdzxQPOFXMaTB7fT2KMErhJGOEswOA8ZuJNOESarFnwwzHVtXmw4CxjrwpC/W9LXTdZ6lEEPaLxKR5mPheikYxZPFgspzchDgSq3RkVnajHBuvzphqPXQyPgb7lDpnPJsY9ucgi7qgggSE+YlG5hd18avWlx7bLHH6lS8rjYczO0fpciwuG665cuDd1ptBOmpivHmIiKZDAV/SgLMYKU+fEQ7dPDAJl1rlhk7c6L6gj8/CfiAPnrI9uhoXjM1fRlOjCDQi1u5ttdTdRucT3RlGHE3lIZuC9VE0IgQ9hwad1i3fLfQmGIndn3GCiIKIHr/MhXqvQ/IWk5Pxjerq6cER18XAROPSNWvADeWsQZMZc2W3+wZr59v7aWUpj4vWSq4IX9XRaQTTbPo19LpFDldHR+Aen4qlbzfJVuwEat0umD44Ws53pw159hrtTioitjV99/WF7pepRF7Xm/QPv4qtqPhOIJLzGLmRDJHylwyNk+GvXaAv8Mp2xY4pl2uG84mF4rjjwsuMOvXvoEJ3OUnU2BCUqHZ+b7NlAManpfQvlr0OPjCTmiqTK3Fp4yJSp6InMJ0XVENGeQ3vrV+YeCCI8HpLT04shczoTQNwN65LAtTip4S2PxZVeQ+JaQYLlf088yiPQQ= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(376005)(36860700004)(82310400014)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 12:45:18.7834 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf44b712-5e83-4e59-8296-08dc65eebabb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00036F43.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8932 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen The next patch will set the driver to use NAPI for event processing. Then tasklet mechanism will be used only for EQ. Reorganize 'mlxsw_pci_queue' to hold EQ and CQ attributes in a union. For now, add tasklet for both EQ and CQ. This will be changed in the next patch, as 'tasklet_struct' will be replaced with NAPI instance. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 76 +++++++++++------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index ec54b876dfd9..7724f9a61479 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -82,12 +82,17 @@ struct mlxsw_pci_queue { u8 num; /* queue number */ u8 elem_size; /* size of one element */ enum mlxsw_pci_queue_type type; - struct tasklet_struct tasklet; /* queue processing tasklet */ struct mlxsw_pci *pci; - struct { - enum mlxsw_pci_cqe_v v; - struct mlxsw_pci_queue *dq; - } cq; + union { + struct { + enum mlxsw_pci_cqe_v v; + struct mlxsw_pci_queue *dq; + struct tasklet_struct tasklet; + } cq; + struct { + struct tasklet_struct tasklet; + } eq; + } u; }; struct mlxsw_pci_queue_type_group { @@ -163,11 +168,6 @@ static void mlxsw_pci_napi_devs_fini(struct mlxsw_pci *mlxsw_pci) free_netdev(mlxsw_pci->napi_dev_tx); } -static void mlxsw_pci_queue_tasklet_schedule(struct mlxsw_pci_queue *q) -{ - tasklet_schedule(&q->tasklet); -} - static char *__mlxsw_pci_queue_elem_get(struct mlxsw_pci_queue *q, size_t elem_size, int elem_index) { @@ -324,7 +324,7 @@ static int mlxsw_pci_sdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, return err; cq = mlxsw_pci_cq_get(mlxsw_pci, cq_num); - cq->cq.dq = q; + cq->u.cq.dq = q; mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, q); return 0; } @@ -433,7 +433,7 @@ static int mlxsw_pci_rdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, return err; cq = mlxsw_pci_cq_get(mlxsw_pci, cq_num); - cq->cq.dq = q; + cq->u.cq.dq = q; mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, q); @@ -455,7 +455,7 @@ static int mlxsw_pci_rdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, elem_info = mlxsw_pci_queue_elem_info_get(q, i); mlxsw_pci_rdq_skb_free(mlxsw_pci, elem_info); } - cq->cq.dq = NULL; + cq->u.cq.dq = NULL; mlxsw_cmd_hw2sw_rdq(mlxsw_pci->core, q->num); return err; @@ -477,12 +477,12 @@ static void mlxsw_pci_rdq_fini(struct mlxsw_pci *mlxsw_pci, static void mlxsw_pci_cq_pre_init(struct mlxsw_pci *mlxsw_pci, struct mlxsw_pci_queue *q) { - q->cq.v = mlxsw_pci->max_cqe_ver; + q->u.cq.v = mlxsw_pci->max_cqe_ver; - if (q->cq.v == MLXSW_PCI_CQE_V2 && + if (q->u.cq.v == MLXSW_PCI_CQE_V2 && q->num < mlxsw_pci->num_sdqs && !mlxsw_core_sdq_supports_cqe_v2(mlxsw_pci->core)) - q->cq.v = MLXSW_PCI_CQE_V1; + q->u.cq.v = MLXSW_PCI_CQE_V1; } static unsigned int mlxsw_pci_read32_off(struct mlxsw_pci *mlxsw_pci, @@ -676,7 +676,7 @@ static char *mlxsw_pci_cq_sw_cqe_get(struct mlxsw_pci_queue *q) elem_info = mlxsw_pci_queue_elem_info_consumer_get(q); elem = elem_info->elem; - owner_bit = mlxsw_pci_cqe_owner_get(q->cq.v, elem); + owner_bit = mlxsw_pci_cqe_owner_get(q->u.cq.v, elem); if (mlxsw_pci_elem_hw_owned(q, owner_bit)) return NULL; q->consumer_counter++; @@ -688,16 +688,16 @@ static char *mlxsw_pci_cq_sw_cqe_get(struct mlxsw_pci_queue *q) static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) { - struct mlxsw_pci_queue *q = from_tasklet(q, t, tasklet); - struct mlxsw_pci_queue *rdq = q->cq.dq; + struct mlxsw_pci_queue *q = from_tasklet(q, t, u.cq.tasklet); + struct mlxsw_pci_queue *rdq = q->u.cq.dq; struct mlxsw_pci *mlxsw_pci = q->pci; int items = 0; char *cqe; while ((cqe = mlxsw_pci_cq_sw_cqe_get(q))) { u16 wqe_counter = mlxsw_pci_cqe_wqe_counter_get(cqe); - u8 sendq = mlxsw_pci_cqe_sr_get(q->cq.v, cqe); - u8 dqn = mlxsw_pci_cqe_dqn_get(q->cq.v, cqe); + u8 sendq = mlxsw_pci_cqe_sr_get(q->u.cq.v, cqe); + u8 dqn = mlxsw_pci_cqe_dqn_get(q->u.cq.v, cqe); if (unlikely(sendq)) { WARN_ON_ONCE(1); @@ -710,7 +710,7 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) } mlxsw_pci_cqe_rdq_handle(mlxsw_pci, rdq, - wqe_counter, q->cq.v, cqe); + wqe_counter, q->u.cq.v, cqe); if (++items == MLXSW_PCI_CQ_MAX_HANDLE) break; @@ -723,8 +723,8 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) static void mlxsw_pci_cq_tx_tasklet(struct tasklet_struct *t) { - struct mlxsw_pci_queue *q = from_tasklet(q, t, tasklet); - struct mlxsw_pci_queue *sdq = q->cq.dq; + struct mlxsw_pci_queue *q = from_tasklet(q, t, u.cq.tasklet); + struct mlxsw_pci_queue *sdq = q->u.cq.dq; struct mlxsw_pci *mlxsw_pci = q->pci; int credits = q->count >> 1; int items = 0; @@ -732,8 +732,8 @@ static void mlxsw_pci_cq_tx_tasklet(struct tasklet_struct *t) while ((cqe = mlxsw_pci_cq_sw_cqe_get(q))) { u16 wqe_counter = mlxsw_pci_cqe_wqe_counter_get(cqe); - u8 sendq = mlxsw_pci_cqe_sr_get(q->cq.v, cqe); - u8 dqn = mlxsw_pci_cqe_dqn_get(q->cq.v, cqe); + u8 sendq = mlxsw_pci_cqe_sr_get(q->u.cq.v, cqe); + u8 dqn = mlxsw_pci_cqe_dqn_get(q->u.cq.v, cqe); char ncqe[MLXSW_PCI_CQE_SIZE_MAX]; if (unlikely(!sendq)) { @@ -750,7 +750,7 @@ static void mlxsw_pci_cq_tx_tasklet(struct tasklet_struct *t) mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); mlxsw_pci_cqe_sdq_handle(mlxsw_pci, sdq, - wqe_counter, q->cq.v, ncqe); + wqe_counter, q->u.cq.v, ncqe); if (++items == credits) break; @@ -777,10 +777,10 @@ static void mlxsw_pci_cq_tasklet_setup(struct mlxsw_pci_queue *q, { switch (cq_type) { case MLXSW_PCI_CQ_SDQ: - tasklet_setup(&q->tasklet, mlxsw_pci_cq_tx_tasklet); + tasklet_setup(&q->u.cq.tasklet, mlxsw_pci_cq_tx_tasklet); break; case MLXSW_PCI_CQ_RDQ: - tasklet_setup(&q->tasklet, mlxsw_pci_cq_rx_tasklet); + tasklet_setup(&q->u.cq.tasklet, mlxsw_pci_cq_rx_tasklet); break; } } @@ -796,13 +796,13 @@ static int mlxsw_pci_cq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, for (i = 0; i < q->count; i++) { char *elem = mlxsw_pci_queue_elem_get(q, i); - mlxsw_pci_cqe_owner_set(q->cq.v, elem, 1); + mlxsw_pci_cqe_owner_set(q->u.cq.v, elem, 1); } - if (q->cq.v == MLXSW_PCI_CQE_V1) + if (q->u.cq.v == MLXSW_PCI_CQE_V1) mlxsw_cmd_mbox_sw2hw_cq_cqe_ver_set(mbox, MLXSW_CMD_MBOX_SW2HW_CQ_CQE_VER_1); - else if (q->cq.v == MLXSW_PCI_CQE_V2) + else if (q->u.cq.v == MLXSW_PCI_CQE_V2) mlxsw_cmd_mbox_sw2hw_cq_cqe_ver_set(mbox, MLXSW_CMD_MBOX_SW2HW_CQ_CQE_VER_2); @@ -831,13 +831,13 @@ static void mlxsw_pci_cq_fini(struct mlxsw_pci *mlxsw_pci, static u16 mlxsw_pci_cq_elem_count(const struct mlxsw_pci_queue *q) { - return q->cq.v == MLXSW_PCI_CQE_V2 ? MLXSW_PCI_CQE2_COUNT : + return q->u.cq.v == MLXSW_PCI_CQE_V2 ? MLXSW_PCI_CQE2_COUNT : MLXSW_PCI_CQE01_COUNT; } static u8 mlxsw_pci_cq_elem_size(const struct mlxsw_pci_queue *q) { - return q->cq.v == MLXSW_PCI_CQE_V2 ? MLXSW_PCI_CQE2_SIZE : + return q->u.cq.v == MLXSW_PCI_CQE_V2 ? MLXSW_PCI_CQE2_SIZE : MLXSW_PCI_CQE01_SIZE; } @@ -860,7 +860,7 @@ static char *mlxsw_pci_eq_sw_eqe_get(struct mlxsw_pci_queue *q) static void mlxsw_pci_eq_tasklet(struct tasklet_struct *t) { unsigned long active_cqns[BITS_TO_LONGS(MLXSW_PCI_CQS_MAX)]; - struct mlxsw_pci_queue *q = from_tasklet(q, t, tasklet); + struct mlxsw_pci_queue *q = from_tasklet(q, t, u.eq.tasklet); struct mlxsw_pci *mlxsw_pci = q->pci; int credits = q->count >> 1; u8 cqn, cq_count; @@ -886,7 +886,7 @@ static void mlxsw_pci_eq_tasklet(struct tasklet_struct *t) cq_count = mlxsw_pci->num_cqs; for_each_set_bit(cqn, active_cqns, cq_count) { q = mlxsw_pci_cq_get(mlxsw_pci, cqn); - mlxsw_pci_queue_tasklet_schedule(q); + tasklet_schedule(&q->u.cq.tasklet); } } @@ -922,7 +922,7 @@ static int mlxsw_pci_eq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, err = mlxsw_cmd_sw2hw_eq(mlxsw_pci->core, mbox, q->num); if (err) return err; - tasklet_setup(&q->tasklet, mlxsw_pci_eq_tasklet); + tasklet_setup(&q->u.eq.tasklet, mlxsw_pci_eq_tasklet); mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q); return 0; @@ -1483,7 +1483,7 @@ static irqreturn_t mlxsw_pci_eq_irq_handler(int irq, void *dev_id) struct mlxsw_pci_queue *q; q = mlxsw_pci_eq_get(mlxsw_pci); - mlxsw_pci_queue_tasklet_schedule(q); + tasklet_schedule(&q->u.eq.tasklet); return IRQ_HANDLED; } From patchwork Fri Apr 26 12:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13644735 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AFE2146D56 for ; Fri, 26 Apr 2024 12:45:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135528; cv=fail; b=XEVDRCEjhGtQ3tiNdS6pFkWDB9clqmSkDPcfZmwgyrTmceX8NKIEnbdLO9XGuMrU+C+pcvtYiHmN5oXAryCQkhOHGS8yPGMtRE4DlO0S3jLZViujkfoK4t2LhY29DvKIwbm5wsAqtSOzhW6vQJAdCdw4haI/SBBqjRtCsL3ulkE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714135528; c=relaxed/simple; bh=0yNNiBz6xLcjkxQn1YB0G6KQ2U0V1Uimu+d5ZOD59Qc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GrMrdtIjkOEFY7F+RHnKrAc7rM6fW3gU6CjT3vkpF1nVRWyxVoPvwUTWBZeKPpCdGBKeNXgJA8X2I58C8mJK4B0eK/I/4eKRv3YrCrImDrVTCal0OUsHgttXYo/moAaJOEuTBeEWQVcjpL7BCBwUM0OY9aQ763NBZreTUYCexsM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=YM/3lndi; arc=fail smtp.client-ip=40.107.223.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="YM/3lndi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JKWYDDLhrKasFEj1G5nRr53sdggFzx/dqccnHn3w8jxh2aRAVHBQi9AtWqltLc3Y0+XwvjwLXWPTfCE23ydIzhbr3VtQ3tSIMW4TTxTspSO3Pdz+CkNVGgMOVJTIcD+VAtAiNj26w9zy3omfgUI9LXSXYnxECn1iU/Zop6yUlibo35qTGKaszk8pXYHjZV5E84EqNhJW9H9lkw0cGVBtOExR3vJun/2bwJLxoCRa1M1Ns46ktxAdvl7RTiCHEesRJTpkn1YsZuxKuJquN5WM75POchzRRxyfhIQVAIr1pDqNIcTYGFFahYgnQhoy1Sou1HRrz+rX2NseM495MIQtVQ== 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=ziKXYr6xWxeHSGFh7kZvwT7sSJL7jrsnVBM83uPjdZY=; b=IC02urM09w8O2I3GcNCqDES+KdDd7nztDwgZWah50gZcaMY45m98yqVoDO7ucFmWtwQz7w5LnIeUbUAaazBkxntkSdeKuRP8dzbWk95+77zSOhmz00Y3AE2uFQmDqzCzU892JXGPZXwfDxRHz+Q8+nhTxLZsLfznNLslgwMR1HhteOqfYfdc/gi9FWUTGVL3YEjNyzWu8ZhcWZqnCScdruNknCYfH3dsVVCtGo/5mQdLZTKiJuTy6o+I7+KgJplTXXuxdPQXuSJeaDVLk8I+GG3em4Np/H5s2vWPDfsBx/QoxHNqCMLXW81cNKVYYcSfAtQYoQKcGCYK/VjJw8rhPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ziKXYr6xWxeHSGFh7kZvwT7sSJL7jrsnVBM83uPjdZY=; b=YM/3lndifk6PtOH6RsoLXQzOs+95QY1Fx7n+3wp/yJa+CbAmlkNDbnoQqBKeI2JhovCdDCLshjruiv2bWtcolGGmQuhRSVVBGSRENiJpbA/CqIoX/2rxIDAor6jklmZrzUjpACY4sBcUNjG/pUE/fq3iCOWy2TQvMpIf+Z8Wg6Fvygc4zD/rEDLyPf93tbl5t6Kg0Bv4Jp6mE/I+cDdk1F9UPsoydxJij0jJZLIAdafesLIjwMhTcvjdFCiubLtePDHJM2uD4f+ZK0ylpM0FoVQyXdeMl5FXaahdBOgXUQ68LDUgFIs6U1WPTBFqh9EWJVjHDR+49+awYzbyj3Y9mg== Received: from PH8PR20CA0001.namprd20.prod.outlook.com (2603:10b6:510:23c::15) by SA1PR12MB6800.namprd12.prod.outlook.com (2603:10b6:806:25c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Fri, 26 Apr 2024 12:45:23 +0000 Received: from CY4PEPF0000EE3B.namprd03.prod.outlook.com (2603:10b6:510:23c:cafe::38) by PH8PR20CA0001.outlook.office365.com (2603:10b6:510:23c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.31 via Frontend Transport; Fri, 26 Apr 2024 12:45:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000EE3B.mail.protection.outlook.com (10.167.242.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Fri, 26 Apr 2024 12:45:22 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:45:09 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 26 Apr 2024 05:45:05 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 5/5] mlxsw: pci: Use NAPI for event processing Date: Fri, 26 Apr 2024 14:42:26 +0200 Message-ID: <2a2eeac12c4d70b366f4e4afdfabdf133359acd2.1714134205.git.petrm@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3B:EE_|SA1PR12MB6800:EE_ X-MS-Office365-Filtering-Correlation-Id: f7e8bf69-4d4a-4c41-d5ed-08dc65eebd07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b7UYs3me7su+m5lBvju6Su2VXqeo+2PSEPH6kRHrhTeqPW/EY3RyICNxcoAM2H1CjTSPJ7Bxnz7SwU2O2A9hh4KUV9pvHiyO1yOFzOA9FEvz3Vxj8E3YTauIPMOlWfwXVLSzmJCNX7gvVeMP9Pb3C1+qQySwAVyugayV5o6G195qadAaOlS8MNKHMLPShR7pxoCA/jNwlZbRYebxQd2Tkb7aiRQsJJb2FD+iPFIkfxG0rgfhsFXMCyrYdsHwuitO7KpID+0CWoxK2xczI7eoTBGVQlfgH3KkDb6ybuD8Oq3Xr+cXHrMBSV892mQx4ohXnHsJoSmHcD4UWyuBZzXZsUnxfk0HOTNSI+CHnvBH5Cop+uhpWH1sVzdovHNc6hRbP4nJnAw2dhpVtC/h7Rk7VerL97qnU3xvJVX+/25JiVWwphg35vzQY8geB8vi895ksA28xWa2Ets7jDlHyWn/gEvTjtEU6azNLeVDcVqanANBSSjea7wWlQVjNrqAUCRXRfKgNfCCg8E3BmR6uLviNHWNdZZW4G14g1dBuB9sUozo3MAKcc0TL+DpU4CBX5cDRH/A3rqp2YQuKREkiktDJ76Tf1TM6zOSlVqyM98uJ292Lk4Kv1R46V/zSi2CZ4Y26Jd2h22R6CC4DZPhgbdESJ6vK0b1IC6AyRQZ4R7cG9M5AsLG3dkpClwYrUN+QowmT4N++xYeDWJe5jOupfR4HRGNIbLVNeMMNfdaU1JEoYhIKEiieZlm0YXF16fv9aUJMkp4YV1bEekVbvhPOEIjDPpchrQwZ2hjPRFUn1dXv+xlggTW/eaRJVyMGIQuuBPC329ZGm7Ua3Lo3yi1f4z5xth148FBWGIaBfjCCkwNs1VIOC5wZZlFwf3xqFbC1lm+GtF6zgC1FD665+DtLon+W41QztOEWwekV9B8QBsV4lE9gkr45YTr0iGU1vh1VoeCL53KpPzpbmjBVgz6j9+dd7zHYdo1pNgUv8SX0xFpxrL9ao3koNJTLWEJzpWJqRs2hCFPMVRujY0CJQoX7soS17j5Vk7wWk7XDQv1lgcjw7uZvBdoxTbQvDJY1cz+kEhuGXu5CRolNZbSBLuHO9fNCb1ltSQRxIqYnkpy4gcjS06o+XkmUBM2OtYuOLPdu9tBD1bjTY4d4EIKiKTg3LLfB/qrq0K3z/sQjfDJ/+zxnxrtm87ai6Rlpw8O5YR/mCw8YLaWR7MOZz6mJM7Uupcf7WSZzeztWTpwFLY3pLQDzmt5x7dr0FHtveWsFepAi8SRX1w2lYJO9TcNSKwRfRxI8x9bDSQ9DkmVDcn3oMXDIvspiSE5Yd3MEmY5R3ap5Hw67NuaNgBn0y/FjbkL+Gk2mqug5tJwEDpfFO3v27MRs4vkLvegsLLmY+PLXUaG0+FV X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(82310400014)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 12:45:22.6703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7e8bf69-4d4a-4c41-d5ed-08dc65eebd07 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE3B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6800 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Spectrum ASICs only support a single interrupt, that means that all the events are handled by one IRQ (interrupt request) handler. Once an interrupt is received, we schedule tasklet to handle events from EQ and then schedule tasklets to handle completions from CQs. Tasklet runs in softIRQ (software IRQ) context, and will be run on the same CPU which scheduled it. That means that today we use only one CPU to handle all the packets (both network packets and EMADs) from hardware. This can be improved using NAPI. The idea is to use NAPI instance per CQ, which is mapped 1:1 to DQ (RDQ or SDQ). NAPI poll method can be run in kernel thread, so then the driver will be able to handle WQEs in several CPUs. Convert the existing code to use NAPI APIs. Add NAPI instance as part of 'struct mlxsw_pci_queue' and initialize it as part of CQs initialization. Set the appropriate poll method and dummy net device, according to queue number, similar to tasklet setup. For CQs which are used for completions of RDQ, use Rx poll method and 'napi_dev_rx', which is set as 'threaded'. It means that Rx poll method will run in kernel context, so several RDQs will be handled in parallel. For CQs which are used for completions of SDQ, use Tx poll method and 'napi_dev_tx', this method will run in softIRQ context, as it is recommended in NAPI documentation, as Tx packets' processing is short task. Convert mlxsw_pci_cq_{rx,tx}_tasklet() to poll methods. Handle 'budget' argument - ignore it in Tx poll method, as it is recommended to not limit Tx processing. For Rx processing, handle up to 'budget' completions. Return 'work_done' which is the amount of completions that were handled. Handle the following cases: 1. After processing 'budget' completions, the driver still has work to do: Return work-done = budget. In that case, the NAPI instance will be polled again (without the need to be rescheduled). Do not re-arm the queue, as NAPI will handle the reschedule, so we do not have to involve hardware to send an additional interrupt for the completions that should be processed. 2. Event processing has been completed: Call napi_complete_done() to mark NAPI processing as completed, which means that the poll method will not be rescheduled. Re-arm the queue, as all completions were handled. In case that poll method handled exactly 'budget' completions, return work-done = budget -1, to distinguish from the case that driver still has completions to handle. Otherwise, return the amount of completions that were handled. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 96 ++++++++++++++++++----- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 7724f9a61479..bf66d996e32e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -87,7 +87,7 @@ struct mlxsw_pci_queue { struct { enum mlxsw_pci_cqe_v v; struct mlxsw_pci_queue *dq; - struct tasklet_struct tasklet; + struct napi_struct napi; } cq; struct { struct tasklet_struct tasklet; @@ -684,16 +684,29 @@ static char *mlxsw_pci_cq_sw_cqe_get(struct mlxsw_pci_queue *q) return elem; } -#define MLXSW_PCI_CQ_MAX_HANDLE 64 +static bool mlxsw_pci_cq_cqe_to_handle(struct mlxsw_pci_queue *q) +{ + struct mlxsw_pci_queue_elem_info *elem_info; + bool owner_bit; + + elem_info = mlxsw_pci_queue_elem_info_consumer_get(q); + owner_bit = mlxsw_pci_cqe_owner_get(q->u.cq.v, elem_info->elem); + return !mlxsw_pci_elem_hw_owned(q, owner_bit); +} -static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) +static int mlxsw_pci_napi_poll_cq_rx(struct napi_struct *napi, int budget) { - struct mlxsw_pci_queue *q = from_tasklet(q, t, u.cq.tasklet); + struct mlxsw_pci_queue *q = container_of(napi, struct mlxsw_pci_queue, + u.cq.napi); struct mlxsw_pci_queue *rdq = q->u.cq.dq; struct mlxsw_pci *mlxsw_pci = q->pci; - int items = 0; + int work_done = 0; char *cqe; + /* If the budget is 0, Rx processing should be skipped. */ + if (unlikely(!budget)) + return 0; + while ((cqe = mlxsw_pci_cq_sw_cqe_get(q))) { u16 wqe_counter = mlxsw_pci_cqe_wqe_counter_get(cqe); u8 sendq = mlxsw_pci_cqe_sr_get(q->u.cq.v, cqe); @@ -712,22 +725,44 @@ static void mlxsw_pci_cq_rx_tasklet(struct tasklet_struct *t) mlxsw_pci_cqe_rdq_handle(mlxsw_pci, rdq, wqe_counter, q->u.cq.v, cqe); - if (++items == MLXSW_PCI_CQ_MAX_HANDLE) + if (++work_done == budget) break; } mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); mlxsw_pci_queue_doorbell_producer_ring(mlxsw_pci, rdq); - mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q); + + if (work_done < budget) + goto processing_completed; + + /* The driver still has outstanding work to do, budget was exhausted. + * Return exactly budget. In that case, the NAPI instance will be polled + * again. + */ + if (mlxsw_pci_cq_cqe_to_handle(q)) + goto out; + + /* The driver processed all the completions and handled exactly + * 'budget'. Return 'budget - 1' to distinguish from the case that + * driver still has completions to handle. + */ + if (work_done == budget) + work_done--; + +processing_completed: + if (napi_complete_done(napi, work_done)) + mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q); +out: + return work_done; } -static void mlxsw_pci_cq_tx_tasklet(struct tasklet_struct *t) +static int mlxsw_pci_napi_poll_cq_tx(struct napi_struct *napi, int budget) { - struct mlxsw_pci_queue *q = from_tasklet(q, t, u.cq.tasklet); + struct mlxsw_pci_queue *q = container_of(napi, struct mlxsw_pci_queue, + u.cq.napi); struct mlxsw_pci_queue *sdq = q->u.cq.dq; struct mlxsw_pci *mlxsw_pci = q->pci; - int credits = q->count >> 1; - int items = 0; + int work_done = 0; char *cqe; while ((cqe = mlxsw_pci_cq_sw_cqe_get(q))) { @@ -752,11 +787,21 @@ static void mlxsw_pci_cq_tx_tasklet(struct tasklet_struct *t) mlxsw_pci_cqe_sdq_handle(mlxsw_pci, sdq, wqe_counter, q->u.cq.v, ncqe); - if (++items == credits) - break; + work_done++; } + /* If the budget is 0 napi_complete_done() should never be called. */ + if (unlikely(!budget)) + goto processing_completed; + + work_done = min(work_done, budget - 1); + if (unlikely(!napi_complete_done(napi, work_done))) + goto out; + +processing_completed: mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q); +out: + return work_done; } static enum mlxsw_pci_cq_type @@ -772,17 +817,29 @@ mlxsw_pci_cq_type(const struct mlxsw_pci *mlxsw_pci, return MLXSW_PCI_CQ_RDQ; } -static void mlxsw_pci_cq_tasklet_setup(struct mlxsw_pci_queue *q, - enum mlxsw_pci_cq_type cq_type) +static void mlxsw_pci_cq_napi_setup(struct mlxsw_pci_queue *q, + enum mlxsw_pci_cq_type cq_type) { + struct mlxsw_pci *mlxsw_pci = q->pci; + switch (cq_type) { case MLXSW_PCI_CQ_SDQ: - tasklet_setup(&q->u.cq.tasklet, mlxsw_pci_cq_tx_tasklet); + netif_napi_add(mlxsw_pci->napi_dev_tx, &q->u.cq.napi, + mlxsw_pci_napi_poll_cq_tx); break; case MLXSW_PCI_CQ_RDQ: - tasklet_setup(&q->u.cq.tasklet, mlxsw_pci_cq_rx_tasklet); + netif_napi_add(mlxsw_pci->napi_dev_rx, &q->u.cq.napi, + mlxsw_pci_napi_poll_cq_rx); break; } + + napi_enable(&q->u.cq.napi); +} + +static void mlxsw_pci_cq_napi_teardown(struct mlxsw_pci_queue *q) +{ + napi_disable(&q->u.cq.napi); + netif_napi_del(&q->u.cq.napi); } static int mlxsw_pci_cq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, @@ -817,7 +874,7 @@ static int mlxsw_pci_cq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, err = mlxsw_cmd_sw2hw_cq(mlxsw_pci->core, mbox, q->num); if (err) return err; - mlxsw_pci_cq_tasklet_setup(q, mlxsw_pci_cq_type(mlxsw_pci, q)); + mlxsw_pci_cq_napi_setup(q, mlxsw_pci_cq_type(mlxsw_pci, q)); mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q); return 0; @@ -826,6 +883,7 @@ static int mlxsw_pci_cq_init(struct mlxsw_pci *mlxsw_pci, char *mbox, static void mlxsw_pci_cq_fini(struct mlxsw_pci *mlxsw_pci, struct mlxsw_pci_queue *q) { + mlxsw_pci_cq_napi_teardown(q); mlxsw_cmd_hw2sw_cq(mlxsw_pci->core, q->num); } @@ -886,7 +944,7 @@ static void mlxsw_pci_eq_tasklet(struct tasklet_struct *t) cq_count = mlxsw_pci->num_cqs; for_each_set_bit(cqn, active_cqns, cq_count) { q = mlxsw_pci_cq_get(mlxsw_pci, cqn); - tasklet_schedule(&q->u.cq.tasklet); + napi_schedule(&q->u.cq.napi); } }