From patchwork Wed Oct 2 00:13:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13819064 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 E29454431 for ; Wed, 2 Oct 2024 00:34:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727829254; cv=none; b=UUoanF5bBiHyoXYCzpeGfeh6nR24EpLh/uisCmqxjKCkvZ8CNuc5Q3ZQ7wgMiIkk5JzVfgW4ttfu5/dhtn80qxDx/IUldKr0nqO8xzySmb45Ho+V39OcnrTtp1oRwVtkRCWECBNyKmd+0VTQCxkXx2MgSczDNmS2GDjBsC2a6hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727829254; c=relaxed/simple; bh=KL3UNVOO+s3nv/aYZ11pPp7hRX34/k3082Gj4LNGNS4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C6Hm/87aolEM20luo6vGXaiLoV+R6oeQXd6zDet4WJI3E34e0osCHg5GUiKYKcxzvDEtw7D+Z9Ftpax0SJPqstmiXlsRutre7PBhjkIeIZklqIJz6SSABUpPRMYf75YRFr3XQR0ukBIIt+TJkomkaqZ37BP2PDyDOhfKVgE6o8E= 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=fijOsP/p; arc=none smtp.client-ip=209.85.214.172 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="fijOsP/p" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b833f9b35so25471545ad.2 for ; Tue, 01 Oct 2024 17:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727829252; x=1728434052; 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=hp3VZUxo/lD901bYrs19RJOxa2w8kC8h+z4RpfrjR9c=; b=fijOsP/pJNuTnB2ALKwouqLQp28uXao7jLNMXgkFvue8BK1+9WmRUNPzAyBNw5Qrzk 2wXLJ9hG6FqQUkv+TsZF8T52/+xThcEzNkNRD8Q52mgFJdYduGtv9GF5RNb132LcKMsK Vc3J1TkceSIMnVlenaWV6eg84d//JkZs4aHI0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727829252; x=1728434052; 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=hp3VZUxo/lD901bYrs19RJOxa2w8kC8h+z4RpfrjR9c=; b=jJvqj5Gyhfkdrk8zlr4ynP2dtWEf2grWevyh0T2Of4PWAYRltzaIdyT95+ZcBGLzJ1 3/qUbK1MeriDdUzQbtJjwtPfrH8XSR8yhtcm3kwqr4ANSwJU1hkVgkQspTrzKwnhfeZU u7JyQWKNvnCtpIlkjMfD0905h6UaYpZIr0K56nYeXpfyeVQZS7y2+ZZXq9OEnApS01ml XZozMWl8XusHV/a7QJHJt1Vvjuok8UTJ/u7f/WUeOEVxLgHWaYV4k6X+NnKmiwcValw3 CKqI4927acSXH4m69KV15y53+A8EzxJz2T4DIeVWxrK/DgXGNJY2r+tqcmKsnzaHVTq8 lVuA== X-Gm-Message-State: AOJu0YwtEh3wbfZpfacbsLl8Nq229A/wEUIjP4C+t95eFlhslsV6LjTg zq3oPwsunAWCxLOBAvhTAVRBIXWrRzsptwukvizuF0+O6QTMltumCyJIphElg171ne5oXspXJqb tNL5TfkSEmDfCDXqK9aljsrKDt5lbQKlVVIF91/3cz/hXzUKpnuN/Q/ABFDjgkqiaTI6xwliZUW crW54XIZ1VDP+Ct/zgs41bvLHobfP2ioho4kU= X-Google-Smtp-Source: AGHT+IEIekgibqyro99agvc+hy8DZog7aA6fRr+4APIpGVoW11t7pGNTqxGiUlThpzOf0vmpJQ/9Tw== X-Received: by 2002:a17:903:60f:b0:20b:af36:ea5 with SMTP id d9443c01a7336-20bc59c3584mr16249735ad.18.1727829251677; Tue, 01 Oct 2024 17:34:11 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37e5ecc1sm75521295ad.268.2024.10.01.17.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 17:34:11 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: darinzon@amazon.com, Joe Damato , Shay Agroskin , Arthur Kiyanovski , 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 v2 1/2] ena: Link IRQs to NAPI instances Date: Wed, 2 Oct 2024 00:13:27 +0000 Message-Id: <20241002001331.65444-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241002001331.65444-1-jdamato@fastly.com> References: <20241002001331.65444-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 Reviewed-by: David Arinzon --- v2: - Preserve reverse christmas tree order in ena_request_io_irq - No functional changes 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..74ce9fa45cf8 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -1677,9 +1677,9 @@ static int ena_request_mgmnt_irq(struct ena_adapter *adapter) static int ena_request_io_irq(struct ena_adapter *adapter) { u32 io_queue_count = adapter->num_io_queues + adapter->xdp_num_queues; + int rc = 0, i, k, irq_idx; unsigned long flags = 0; struct ena_irq *irq; - int rc = 0, i, k; 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 Wed Oct 2 00:13:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13819065 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 EF7ACB661 for ; Wed, 2 Oct 2024 00:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727829258; cv=none; b=ZOR11vh4ZL/HXcxNeJyzCzsCvkOFsn9zwNb1Ipx90ghYVXl5LNRQa137X0RyCECavRxNOy1Rh27YTMbVoHSIw1uu1fF5Epd3+BJnUVsv72mNr337INglRoSizXtAZ9gxcKY7lCqL65+QytPh3WmP+V8jylKi2YIN5FWxJpqYLi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727829258; c=relaxed/simple; bh=yStr/6PJPenHSI7D8HokTLRUj51fig9mf3TfmVYcCLY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aTbFYwcYEzYngYJHkU+g20cQ0Q6qNwl5RuWwpJQJ3QVaV5t1ytc6n8UqdRhELNfM/AGX1fAdDxLHLcWZb66Ev1qeV9iiuRYzjhgvnnOnkyToVqzT+lM2IJ7aOr5kquZiYQSujQuabAVL3epURdKJn5HzAv9P57CIHnJ7lLTr4E8= 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=sLldTGhJ; arc=none smtp.client-ip=209.85.214.173 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="sLldTGhJ" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-207115e3056so54266005ad.2 for ; Tue, 01 Oct 2024 17:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727829255; x=1728434055; 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=nSZqwRLg8/VfUGa/yJh0BLiOqFcBWWUlHrlyk3W8pCU=; b=sLldTGhJzHsCqhdRcsHu5fpCh2Mo9E9kyNkcK4ycJKIxXVz+A8vZpNthUtQuBRfEPW vWcms+ZXSNcdxphJwdPc4OkVJDZHZzCjmKmElgbpChjmalyIym8JrZkHaQirTExyUPFl /lERu5OR6o2bHL9FEo3XZ4mWJO+VG97uRNkhM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727829255; x=1728434055; 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=nSZqwRLg8/VfUGa/yJh0BLiOqFcBWWUlHrlyk3W8pCU=; b=UlbAqOL5SeuLZgK8Fd23pcf2o/BBgbrsUYPoFqslBGaWXvcjyAuSndPAkFBMxwSYRt HI4aV87kSJFp6ZaG7Wr2daTVXTwraQ9FmOC4kmhAy0wqwj1csCU40OgFWmMN01mVeBZY palnxLgc1S2lmR6LT2dEq6ROrvjQNRROby/thRDCKBOikSkUpwBji+ydQTt9ZwHd5WZE +75qvvszoe8l5V1VLUmMa6grQT7eoWsPLHnDFI6nS/LqE8kRQCL9be5oErQFKYqq2c7r iLxcQBfyXTSumEthLFuKojuCqJg2orpXfeYdkbMXQxERJAfi5YRvnzoLa/IovXEJc3YR zMXA== X-Gm-Message-State: AOJu0YzYy8g4MlycJpPRcZTFRVoEGsqffFCVfK3LaqRI4DeDPZJsFnG+ 04VlVStEwueTWJG2B3umjdzkjB6KueH5S/ekWqAcrKb50xUBjGydWHruckVLwUWXyiKjFhsbRDj liG1nMU3uQlMCq/W7asHbhKDaYmx5i3gxU16n3hSheR3Gs4R8BYU0+WQDpljPai0ceJRfgtGu6G PNupOTJ69KrBAzIBZa0xKxXCHltkG7/4F59U4= X-Google-Smtp-Source: AGHT+IEqTtOYAZ0xs5mg5rdotEr2lEo3d5tqrafo4yS/vRO6Ol5mizZCFWULpLfJsb7blCc8Mpf/bA== X-Received: by 2002:a17:902:e80c:b0:20b:51c2:d789 with SMTP id d9443c01a7336-20bc59e6496mr20807085ad.16.1727829255450; Tue, 01 Oct 2024 17:34:15 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37e5ecc1sm75521295ad.268.2024.10.01.17.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 17:34:14 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: darinzon@amazon.com, Joe Damato , Shay Agroskin , Arthur Kiyanovski , 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 v2 2/2] ena: Link queues to NAPIs Date: Wed, 2 Oct 2024 00:13:28 +0000 Message-Id: <20241002001331.65444-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241002001331.65444-1-jdamato@fastly.com> References: <20241002001331.65444-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 Reviewed-by: David Arinzon --- v2: - Comments added to ena_napi_disable_in_range and ena_napi_enable_in_range - No functional changes drivers/net/ethernet/amazon/ena/ena_netdev.c | 28 +++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 74ce9fa45cf8..96df20854eb9 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -1821,20 +1821,40 @@ 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)) { + /* This API is supported for non-XDP queues only */ + 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)) { + /* This API is supported for non-XDP queues only */ + 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 */