From patchwork Thu Oct 3 23:38:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13821657 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 2EBAB1CF5C0 for ; Thu, 3 Oct 2024 23:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727998747; cv=none; b=piu24yc9VYJ7z8h9NWhkaWLU+9lEFmanXSTQUHbn72VEvQoELWHVOJIGxUxN4gTbBw5sGenOCxkFEGYHb7Nm0oqVVNxq6Z7SmVfaC9REfYY9jd93/6x4yNRFpatr3PQ2CAHzbDJRHp32skMcgsdwEeFL4JQyR3gKJEF3o0Cet5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727998747; c=relaxed/simple; bh=aOPeijS4l9gs82itlGqmWgc4L9/VH7+qNqQbZnpSjfs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=duzOtxn2jv2hcq4Jzt/PqAI5VyDKsY6qV0Sslp8aVKraK9WZCY6KlPsGDAQBAjL0x4IJ+rfEf8Kb36z1QtXQhSA+8Rus4L6gBhsDAZKXolH4lzVWR7Ee42JSqn6go6HaZZJiUUxK60pJ9IpFTp84fTXl2ZNlt1hsYCu1OFQhpBQ= 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=Ph+EI6vV; arc=none smtp.client-ip=209.85.214.180 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="Ph+EI6vV" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20ba8d92af9so11701045ad.3 for ; Thu, 03 Oct 2024 16:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727998745; x=1728603545; 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=WhYp0DiSsQbpO6IwfgRG0/juZs6Inw4x8enD4rVfZ6Y=; b=Ph+EI6vVHnN5Qki1onLS7NYJbUNz87WGE85rlcb12TjnB3CkTI94OYooLrYoY/Jhdr LvI2kNIbEzkkC5pMHqDyI4G9E4dOa+4piOHro2TCj4FACHP1Bm+KCk7NX3X9T2dlBC56 QOs+U47ZkdxfLc/hQbjaQAaH8U7MdDHosRzYY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727998745; x=1728603545; 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=WhYp0DiSsQbpO6IwfgRG0/juZs6Inw4x8enD4rVfZ6Y=; b=eKVDw0JXQ8ye4QftCQrxIbfZRAOTEZNkENRKpdwAlrtjcD8jUkNCze8Dw6fXwc4nF5 EuFKzfHm4PHJ/6rNRCxq5V8Z+u/uX4QkRHZ25YDkl4Aku48hhjw6OuCCJf+ym689nm96 xYYYXhaZF/Wz+Xy9c+FKT3v6ecfG2hih3WpORbq9Za336CskTxXan+eQoV1PIsy/GZIb Z3XfWx8jfIPqzBuOUnmAjiGCTYNjQ/06dUuTX893io7u4fWbU+VI0YZDdHfNdXcKe9uN fXRs4n5FecwJlZSiZHWiScSFiU7pYZnRLVD2RvNsZdEvMZroR2RDBuX2ZDHzS/OYqqM9 9Tlg== X-Gm-Message-State: AOJu0Ywy8xS7J2WOGz0avZgmvbzDs1uLqhBDJFcBdf2Q7IgEV/lZx0Tj UWejvKUVkGACzJ5BpXaeuWji7LUT632CZ0YDd/+VzWbrS50QSMGfsRe/wM6DjyOv1H0oR8Yqq/E vDux96N8syp9wjiatpzPlI+9aun6xUzvwT2GBUsHBss77NXbsxLv4wnuZ8vh3Tx6ebJwDaFZtVK GA60mgnfXAB31AJh7HtY5goxgFU9YJQhf69ao= X-Google-Smtp-Source: AGHT+IGTpJ2+WaujujgDrlAgiMjkPmANHMw7/ysggq4USb76kJULVyruSiv/pbcSPf0FW7LJGb0RPw== X-Received: by 2002:a17:903:2a85:b0:206:ae39:9f4 with SMTP id d9443c01a7336-20bfdfc6ff8mr15955935ad.20.1727998745106; Thu, 03 Oct 2024 16:39:05 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20beef8ec6bsm13960705ad.158.2024.10.03.16.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 16:39:04 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 1/2] igc: Link IRQs to NAPI instances Date: Thu, 3 Oct 2024 23:38:49 +0000 Message-Id: <20241003233850.199495-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241003233850.199495-1-jdamato@fastly.com> References: <20241003233850.199495-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 X-Patchwork-State: RFC Link IRQs to NAPI instances via netdev-genl API so that users can query this information with netlink. Compare the output of /proc/interrupts (noting that IRQ 144 is the "other" IRQ which does not appear to have a NAPI instance): $ cat /proc/interrupts | grep enp86s0 | cut --delimiter=":" -f1 144 145 146 147 148 The output from netlink shows the mapping of NAPI IDs to IRQs (again noting that 144 is absent as it is the "other" IRQ): $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump napi-get --json='{"ifindex": 2}' [{'id': 8196, 'ifindex': 2, 'irq': 148}, {'id': 8195, 'ifindex': 2, 'irq': 147}, {'id': 8194, 'ifindex': 2, 'irq': 146}, {'id': 8193, 'ifindex': 2, 'irq': 145}] Signed-off-by: Joe Damato --- drivers/net/ethernet/intel/igc/igc.h | 1 + drivers/net/ethernet/intel/igc/igc_main.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index eac0f966e0e4..e757ba53f165 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -593,6 +593,7 @@ struct igc_q_vector { struct rcu_head rcu; /* to avoid race with update stats on free */ char name[IFNAMSIZ + 9]; + int irq; /* for dynamic allocation of rings associated with this q_vector */ struct igc_ring ring[] ____cacheline_internodealigned_in_smp; diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 6e70bca15db1..7964bbedb16c 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -5576,6 +5576,9 @@ static int igc_request_msix(struct igc_adapter *adapter) q_vector); if (err) goto err_free; + + netif_napi_set_irq(&q_vector->napi, + adapter->msix_entries[vector].vector); } igc_configure_msix(adapter); From patchwork Thu Oct 3 23:38:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13821658 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.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 A4A9A1D07A7 for ; Thu, 3 Oct 2024 23:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727998749; cv=none; b=m2PTiuZIiXqbWqho6GHhYC3sui0RbQXut80/fDCqLRV30DJkQ5N1YXs7t3fxEyfiR2TkpO/si2FZoTchw7j/kZ3QbZo1XbqXhFHFwJB5dQzBRiDT75YZX062Wm66JgHokE0NhbOh9GUvEhzzY5Lh4nqAsXGWjW+7EBWZUdo87XU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727998749; c=relaxed/simple; bh=4bT09cAu2qhfAav0tDdUjSpZJuBDzgUwRyW6i3IdhQE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bOs5efvy1ernCLOcWIcpRLDD5eEf9eLEJlkrGo9d3tQu8Q3UN/8QQUUpK94Y+sJAPbZc//nRjJwWFxBb4pwRDO4JQtppBNEA7yrfCy6CqP3vnbagQr600Hg9l8Ja0iFpZxmuKmW1hcddnqOIrdTVdLOaPWixkWn8Ddx8qaunA1Q= 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=nReqn2Cs; arc=none smtp.client-ip=209.85.214.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="nReqn2Cs" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20ba9f3824fso12298795ad.0 for ; Thu, 03 Oct 2024 16:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727998747; x=1728603547; 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=ZpDtgFKpiW6n7Ug+1YSP06l0kr3SHis2120480WaYUs=; b=nReqn2CsKP/Vspc+0IxehZ+Apr6pBWNxLuYV0ssoLUV1p0k5WlouxTmg9Y5vpoHez4 DuRDtm4BnsLPGz77NRlTXgkTr7C/pQBqBBwoYLYK8vXwg3BAOtAhE25oFQaIx7DaOmY3 UETnB6DW4LTlKV28Wu680jy/rnLmPnZA2H8mQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727998747; x=1728603547; 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=ZpDtgFKpiW6n7Ug+1YSP06l0kr3SHis2120480WaYUs=; b=MMqokCzLYxP7e5w/Qs4iXmna68Q247xSJ2CqlNS/w22JVxFJLfWje3Uw3jMV3BLIrh HQILJA+rgl7grCBrgzc9pCyrsb310uTEqruub89sng1HvMI0pMF8sK9e+dMHYYOjMYor ACrJWEHjtsrj1og2dFpluEnTStgzpFmqEh1u5xQl8Vlmr1Cjsbj7ZdzUZLDd8NdJzXV4 G46jbdQrPpsZBlw7QISQfX/ZR/57ExJNAM55pT/DqzXecs6LMH+BzmxDQRR5flL+07H+ RbFXQBhEWqH+edAzc4uWew5ihTKiS6On8xkciGpj65UDZh6gD3+GJOHNQfZe/G4Hh3Ta wC0A== X-Gm-Message-State: AOJu0YzEO0CaxPeuSECJl4q2ktf+PLLO3GTGUDHngVHNjw5ChoEBFpv6 aV/IHuTYGVetC5S+nMf6MRyJhY+/D9q+2JFtBHnRrrSVL2oDwjzlXv8K0f3Ycl0/IusumYAtkha 2XhVXsRIvPLfjcG7VElLJ08E5YB4kN4dUbHMvpWU+Jw5+ks/83jL3xVd/hC/FHIV6Nd+lQM8bxo GvxJ3E4JUp1XH+6z+YW1B9cndmmj9blPE2UkE= X-Google-Smtp-Source: AGHT+IEscOgAVx/0YG9i/MINtF9xq0NivswWkuBxhiN50OJBwJky40grr6JNhThn+Z2xOj8C0ihYvQ== X-Received: by 2002:a17:902:e742:b0:20b:b7b2:b6f4 with SMTP id d9443c01a7336-20bfea5417fmr10500325ad.47.1727998746571; Thu, 03 Oct 2024 16:39:06 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20beef8ec6bsm13960705ad.158.2024.10.03.16.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 16:39:06 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 2/2] igc: Link queues to NAPI instances Date: Thu, 3 Oct 2024 23:38:50 +0000 Message-Id: <20241003233850.199495-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241003233850.199495-1-jdamato@fastly.com> References: <20241003233850.199495-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 X-Patchwork-State: RFC Link queues to NAPI instances via netdev-genl API so that users can query this information with netlink: $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump queue-get --json='{"ifindex": 2}' [{'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'rx'}, {'id': 1, 'ifindex': 2, 'napi-id': 8194, 'type': 'rx'}, {'id': 2, 'ifindex': 2, 'napi-id': 8195, 'type': 'rx'}, {'id': 3, 'ifindex': 2, 'napi-id': 8196, 'type': 'rx'}, {'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'tx'}, {'id': 1, 'ifindex': 2, 'napi-id': 8194, 'type': 'tx'}, {'id': 2, 'ifindex': 2, 'napi-id': 8195, 'type': 'tx'}, {'id': 3, 'ifindex': 2, 'napi-id': 8196, 'type': 'tx'}] Since igc uses only combined queues, you'll note that the same NAPI ID is present for both rx and tx queues at the same index, for example index 0: {'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'rx'}, {'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'tx'}, Signed-off-by: Joe Damato --- drivers/net/ethernet/intel/igc/igc_main.c | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 7964bbedb16c..b3bd5bf29fa7 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4955,6 +4955,7 @@ static int igc_sw_init(struct igc_adapter *adapter) void igc_up(struct igc_adapter *adapter) { struct igc_hw *hw = &adapter->hw; + struct napi_struct *napi; int i = 0; /* hardware has been reset, we need to reload some things */ @@ -4962,8 +4963,17 @@ void igc_up(struct igc_adapter *adapter) clear_bit(__IGC_DOWN, &adapter->state); - for (i = 0; i < adapter->num_q_vectors; i++) - napi_enable(&adapter->q_vector[i]->napi); + for (i = 0; i < adapter->num_q_vectors; i++) { + napi = &adapter->q_vector[i]->napi; + napi_enable(napi); + /* igc only supports combined queues, so link each NAPI to both + * TX and RX + */ + netif_queue_set_napi(adapter->netdev, i, NETDEV_QUEUE_TYPE_RX, + napi); + netif_queue_set_napi(adapter->netdev, i, NETDEV_QUEUE_TYPE_TX, + napi); + } if (adapter->msix_entries) igc_configure_msix(adapter); @@ -5192,6 +5202,10 @@ void igc_down(struct igc_adapter *adapter) for (i = 0; i < adapter->num_q_vectors; i++) { if (adapter->q_vector[i]) { napi_synchronize(&adapter->q_vector[i]->napi); + netif_queue_set_napi(netdev, i, NETDEV_QUEUE_TYPE_RX, + NULL); + netif_queue_set_napi(netdev, i, NETDEV_QUEUE_TYPE_TX, + NULL); napi_disable(&adapter->q_vector[i]->napi); } } @@ -6021,6 +6035,7 @@ static int __igc_open(struct net_device *netdev, bool resuming) struct igc_adapter *adapter = netdev_priv(netdev); struct pci_dev *pdev = adapter->pdev; struct igc_hw *hw = &adapter->hw; + struct napi_struct *napi; int err = 0; int i = 0; @@ -6056,8 +6071,15 @@ static int __igc_open(struct net_device *netdev, bool resuming) clear_bit(__IGC_DOWN, &adapter->state); - for (i = 0; i < adapter->num_q_vectors; i++) - napi_enable(&adapter->q_vector[i]->napi); + for (i = 0; i < adapter->num_q_vectors; i++) { + napi = &adapter->q_vector[i]->napi; + napi_enable(napi); + /* igc only supports combined queues, so link each NAPI to both + * TX and RX + */ + netif_queue_set_napi(netdev, i, NETDEV_QUEUE_TYPE_RX, napi); + netif_queue_set_napi(netdev, i, NETDEV_QUEUE_TYPE_TX, napi); + } /* Clear any pending interrupts. */ rd32(IGC_ICR);