From patchwork Mon Sep 30 19:56:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13816967 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFA3E1A00ED for ; Mon, 30 Sep 2024 19:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727726193; cv=none; b=k3GTtvzRJ6GSZy2y2Rtx7CbK+rv+vqIcdSgGnNiqnXvoygaFW2x8ROsH2CZpRFFJISNTY9V8LLWDkQsZLFxackNlnaSpCG4fzpdxfJq69jCCNO3kR5qRLxtt3RYevb0ymjTpJekbSV/6br2Lv6Ftxjp7bfrwbfblciPU+pOH024= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727726193; c=relaxed/simple; bh=VOP2E4EdNOlzmnohLf0Aivfl38U8ErSPEO+iGtQjFcw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IakdUk0l7yhGr69Ryew7pyE8ovBFDdqlFMGhAnCjOWrp9OvxP6uKdmjLiZyFNEqGPXU7S3ZYiPfJsTN+Rja6I4QAIh/HcAI0a28WEjrtS3mx4UgIXaeXGTmick8jJntFStN5LxRhTzvnvl3d8O1jqp+t82XwLL4G69pMx0az97A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=jzswEsnL; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="jzswEsnL" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7d916b6a73aso3041491a12.1 for ; Mon, 30 Sep 2024 12:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727726189; x=1728330989; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9YrIxNM9HjJUUgFmx4X8hgJEmT6bLFjQYQ/uTKQH+yI=; b=jzswEsnLnwUWLqB+qmvSJBj1v1okWoCrdfkj7HbvDIoxQ3afSf5TdK3sUhORgkkWBs ILqMDGRdsKA1bZ/iR48bvUUQKF22D64ZTBgtA/EEssc0EgjBeN9RtR4UudU1HhZL/yT6 A1nh8C8uuiqnd9C8bT1BIVDdnZlSz8qd+jEhA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727726189; x=1728330989; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9YrIxNM9HjJUUgFmx4X8hgJEmT6bLFjQYQ/uTKQH+yI=; b=ePDAoFifKgq6hOsxAVxdTb+hApji1bJCFpek8sxKVbhTtjgAM4jJ1bv+nJHUOJyNLZ m82rzvNU9OeYqqTBRd6mCt07vAnSJ5ldYKGW6xI5DvFGdbVImrBp7kkUptSC5BDv56+O H6Vi3YmSxuWreLYye9RoROH4NqV5KPh1ipneMyryOSeQ88gpUTq8d/ynDrIxFlkl7sl1 dhnM2bxdyJjqgfZMuU5hTjAyvFx7XMnNhRejTDDYgOKMKtzPhBbz0Xo0oSU2fYFh0ApG jkWoFBgOqkMMNx+tA1PLRwE1Egzr3VF5rESam/ZQrXAE37y4v23SV3fD+IuU10VJQgoQ 5DOQ== X-Gm-Message-State: AOJu0YxkUec3KIOupVUrR1tO34SynKbgoo/BazihbL/3qOoGwDq39/mC ll87P+JxqSuaF8oAVbEYCcfkN+O8lozBgwSW0MXAGtnMkOEd2r+Nlrww9rakwmOC8fU+lmFYOJ5 garGUG+CVjG/UAzgSlwMFMG+rzPnsUdIkCHCpV7yKRZQQbpWQGUqjzUqg4WNYTQx8Z0LFT7Ql96 TBeVXd4hZFLlquaXZB7078rOqw3klOh9wR/8U= X-Google-Smtp-Source: AGHT+IHgE5GnxDFi+aeV5uEKrnZGDLW/FvYDcTAFwrkxEpkkA9AIh3erQXuaGCJcfY7pKP88QGl+Jg== X-Received: by 2002:a05:6a21:1693:b0:1d5:1354:5256 with SMTP id adf61e73a8af0-1d5135453a2mr7660563637.39.1727726189164; Mon, 30 Sep 2024 12:56:29 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b2649a2cesm6604450b3a.43.2024.09.30.12.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 12:56:28 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kamal Heib , linux-kernel@vger.kernel.org (open list) Subject: [net-next 1/2] ena: Link IRQs to NAPI instances Date: Mon, 30 Sep 2024 19:56:12 +0000 Message-Id: <20240930195617.37369-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240930195617.37369-1-jdamato@fastly.com> References: <20240930195617.37369-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Link IRQs to NAPI instances with netif_napi_set_irq. This information can be queried with the netdev-genl API. Note that the ENA device appears to allocate an IRQ for management purposes which does not have a NAPI associated with it; this commit takes this into consideration to accurately construct a map between IRQs and NAPI instances. Compare the output of /proc/interrupts for my ena device with the output of netdev-genl after applying this patch: $ cat /proc/interrupts | grep enp55s0 | cut -f1 --delimiter=':' 94 95 96 97 98 99 100 101 $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump napi-get --json='{"ifindex": 2}' [{'id': 8208, 'ifindex': 2, 'irq': 101}, {'id': 8207, 'ifindex': 2, 'irq': 100}, {'id': 8206, 'ifindex': 2, 'irq': 99}, {'id': 8205, 'ifindex': 2, 'irq': 98}, {'id': 8204, 'ifindex': 2, 'irq': 97}, {'id': 8203, 'ifindex': 2, 'irq': 96}, {'id': 8202, 'ifindex': 2, 'irq': 95}, {'id': 8201, 'ifindex': 2, 'irq': 94}] Signed-off-by: Joe Damato --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index c5b50cfa935a..e88de5e426ef 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -1679,7 +1679,7 @@ static int ena_request_io_irq(struct ena_adapter *adapter) u32 io_queue_count = adapter->num_io_queues + adapter->xdp_num_queues; unsigned long flags = 0; struct ena_irq *irq; - int rc = 0, i, k; + int rc = 0, i, k, irq_idx; if (!test_bit(ENA_FLAG_MSIX_ENABLED, &adapter->flags)) { netif_err(adapter, ifup, adapter->netdev, @@ -1705,6 +1705,16 @@ static int ena_request_io_irq(struct ena_adapter *adapter) irq_set_affinity_hint(irq->vector, &irq->affinity_hint_mask); } + /* Now that IO IRQs have been successfully allocated map them to the + * corresponding IO NAPI instance. Note that the mgmnt IRQ does not + * have a NAPI, so care must be taken to correctly map IRQs to NAPIs. + */ + for (i = 0; i < io_queue_count; i++) { + irq_idx = ENA_IO_IRQ_IDX(i); + irq = &adapter->irq_tbl[irq_idx]; + netif_napi_set_irq(&adapter->ena_napi[i].napi, irq->vector); + } + return rc; err: From patchwork Mon Sep 30 19:56:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13816968 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB8C91A01DB for ; Mon, 30 Sep 2024 19:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727726195; cv=none; b=nM5POtMetuD8o9PmgzCM+34HobBqUG+nZhkBlsCyUqM/U/1ZOtOjPZ7GXcoKUxtZllM+Loi9h2ZegG9dCAWoXBjfIP+3JVFFnXtLVU5fIG6MH2WA4oWv5tffgn1WWsbGJNjPEL0i2XsgLrgb3q6TVE1QT9XxO93dOMGnNhVev18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727726195; c=relaxed/simple; bh=UA0m3VMYAwf7VZLj3wNgsyeHamH7xUAmp8+jviHGxUA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hlev4WBxJVxwnQlcjSBzcDWioZf6g8qWbYMKSmq92d3ZXv+Uzc1Wl6xnE3XpkPiBEUbEFYYz9OWR4FyTvUZ8cxVUumd3A7AjGgji1ts6t4T/eJo//wtgFsp6HMK6TEGA+mQ/Y4zVxN4MQQubeoRg2VkFMCRCI4sPwQEkldRmt4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=yRg+imbU; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="yRg+imbU" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-718d606726cso3394923b3a.3 for ; Mon, 30 Sep 2024 12:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727726192; x=1728330992; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lxtv2lrF1kOetNp7xi3WglFSuTqjxy0uNajfsDkNvuU=; b=yRg+imbUi7bGSZneMP0cJqGUe6lYG0H3ejIn3qalyl/5b67WeQk5LWEoPRDfZUkQPC QYauuwVtpF2KelD25JqqmdOM11bzJb++6w4K9vyzkaBY/SnUhywbcDugSD+/El95FBV3 RVqciJ63OMQltvkALlxuMvFjGdppsvS69h6iw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727726192; x=1728330992; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lxtv2lrF1kOetNp7xi3WglFSuTqjxy0uNajfsDkNvuU=; b=aSWu1FdApWhxzwxoBip/bJppi5jHwjFgNTzEYfYVVKMH8YX4uVSwwMBTAGaxO82NkK EWEkPAq/CCHBcGUmR4SFUhasI3LTcDjZKNdEOSUiHSc+6p6+U9aFKiVuP4HnjscCTJqx h61wzSVCYWwneAe96eDmSkviqNxd28Ch1ye2pB1jNsDkmmr0SqcGYPfoN3Zh3lEgB8H7 IVxpkPf8ObCe3OECK1hQAsLcd0pAlmjsGBb1aL1wjjihzmMFVjDebYPZ7+6Y4dpR7RSp 6o+POAN7pjluPZxCO3+NbgFpgFmI6ey3lGV16LdkTBgFvrF1jU7Ar2FzVcDP/u1XVL1y aPeg== X-Gm-Message-State: AOJu0YwsAomMXhOiRNquinwS3Bd1Jzo5fB0dX+HLCljb317QuBqSYX3+ PUdVFfc6xmwkUIDm3UtCIMh/9dZTAI1htmiSXaa0pq4xlxucp5+pdoq3Al16N5NnPx2L7lxkbrK bFEuOwkpQD69NNGpq5qsYYcCC9zz4IqSiZ3tp+vM3h566EfKY2tOsRWM8j6Eeiegw+1PIKfaKiC B7IJnjBCYOE8z91kNrp4iDgoFwcTQ0rB5P/fU= X-Google-Smtp-Source: AGHT+IHYMQgS9wxg2iL/t0osMPTamKqFGShjRfad8poeTcxLS0lYKsFnK8dQ6emauZeBXHfOlaTwiQ== X-Received: by 2002:a05:6a00:cc4:b0:706:58ef:613 with SMTP id d2e1a72fcca58-71b2607ae1bmr16336872b3a.27.1727726192145; Mon, 30 Sep 2024 12:56:32 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b2649a2cesm6604450b3a.43.2024.09.30.12.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 12:56:31 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kamal Heib , linux-kernel@vger.kernel.org (open list) Subject: [net-next 2/2] ena: Link queues to NAPIs Date: Mon, 30 Sep 2024 19:56:13 +0000 Message-Id: <20240930195617.37369-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240930195617.37369-1-jdamato@fastly.com> References: <20240930195617.37369-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Link queues to NAPIs using the netdev-genl API so this information is queryable. $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump queue-get --json='{"ifindex": 2}' [{'id': 0, 'ifindex': 2, 'napi-id': 8201, 'type': 'rx'}, {'id': 1, 'ifindex': 2, 'napi-id': 8202, 'type': 'rx'}, {'id': 2, 'ifindex': 2, 'napi-id': 8203, 'type': 'rx'}, {'id': 3, 'ifindex': 2, 'napi-id': 8204, 'type': 'rx'}, {'id': 4, 'ifindex': 2, 'napi-id': 8205, 'type': 'rx'}, {'id': 5, 'ifindex': 2, 'napi-id': 8206, 'type': 'rx'}, {'id': 6, 'ifindex': 2, 'napi-id': 8207, 'type': 'rx'}, {'id': 7, 'ifindex': 2, 'napi-id': 8208, 'type': 'rx'}, {'id': 0, 'ifindex': 2, 'napi-id': 8201, 'type': 'tx'}, {'id': 1, 'ifindex': 2, 'napi-id': 8202, 'type': 'tx'}, {'id': 2, 'ifindex': 2, 'napi-id': 8203, 'type': 'tx'}, {'id': 3, 'ifindex': 2, 'napi-id': 8204, 'type': 'tx'}, {'id': 4, 'ifindex': 2, 'napi-id': 8205, 'type': 'tx'}, {'id': 5, 'ifindex': 2, 'napi-id': 8206, 'type': 'tx'}, {'id': 6, 'ifindex': 2, 'napi-id': 8207, 'type': 'tx'}, {'id': 7, 'ifindex': 2, 'napi-id': 8208, 'type': 'tx'}] Signed-off-by: Joe Damato --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index e88de5e426ef..1c59aedaa5d5 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -1821,20 +1821,38 @@ static void ena_napi_disable_in_range(struct ena_adapter *adapter, int first_index, int count) { + struct napi_struct *napi; int i; - for (i = first_index; i < first_index + count; i++) - napi_disable(&adapter->ena_napi[i].napi); + for (i = first_index; i < first_index + count; i++) { + napi = &adapter->ena_napi[i].napi; + if (!ENA_IS_XDP_INDEX(adapter, i)) { + netif_queue_set_napi(adapter->netdev, i, + NETDEV_QUEUE_TYPE_TX, NULL); + netif_queue_set_napi(adapter->netdev, i, + NETDEV_QUEUE_TYPE_RX, NULL); + } + napi_disable(napi); + } } static void ena_napi_enable_in_range(struct ena_adapter *adapter, int first_index, int count) { + struct napi_struct *napi; int i; - for (i = first_index; i < first_index + count; i++) - napi_enable(&adapter->ena_napi[i].napi); + for (i = first_index; i < first_index + count; i++) { + napi = &adapter->ena_napi[i].napi; + napi_enable(napi); + if (!ENA_IS_XDP_INDEX(adapter, i)) { + netif_queue_set_napi(adapter->netdev, i, + NETDEV_QUEUE_TYPE_RX, napi); + netif_queue_set_napi(adapter->netdev, i, + NETDEV_QUEUE_TYPE_TX, napi); + } + } } /* Configure the Rx forwarding */