From nobody Thu Nov 28 10:39:22 2024 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 7AFB1322E for ; Wed, 2 Oct 2024 00:34:12 +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=1727829253; cv=none; b=nlNnHaX3wY+ORuG8pTU2auiiDw9bJJRgC3KpFt5wvRS46LeSJTLRH4c7YnJRpoiqK012JQB31YETPuYlqCakOwNVS5asANyVJzKJmV+vJHwhJM4PoXcmkygLG+A2iq5PtUBs4kwJKOgEJ3O+bftphYZJ3qk3BZp1f3h4sBm/nyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727829253; c=relaxed/simple; bh=KL3UNVOO+s3nv/aYZ11pPp7hRX34/k3082Gj4LNGNS4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=soPWcdC7cUtKYTGsS2LGb1rjS3qDUglIx+UzvHX3XTiIMuCP1e8Kp6kojK7riV8OK40qJQb0jMmKUIEqtp3tNK5D+5jJETfR/4h1tnVffRZnFoCepUh31fYhicOMhOy5xLZCd6dm2DBmgIG8oNia9GaCUbl1ZE0eD/GaJiCUKhU= 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.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="fijOsP/p" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20b9b35c7c7so16965605ad.1 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=SyRc6uUaDQOrPRclSufeenPt01p2OaFU//RSpBNvuAdnRvswf4Lk5qqXW/z53IHm0E LLLAv5WdbA/5jop/OgtQUUnU+QsZ93i0VHF0GJlwQVfa+WzvokQ39WjUCVlUcdF8xhrH YtxYAbEDdek7P69keuNd9feWGXR8+Qd3a+vgh6B3AuqOrurFyTZlMCh9wTEPnCfHIYct Cwd9fbi+boTewBaNQu6zf+bIJG5NpZA3Qk3JXU5iKBlyx8tQwOJnVN/rS8c4z6qbPwSH W8WRkzAmF6EtBx7custyeBqfyvJ1KjuvImRUmkHsY4nxJ/iIpN+kOje4IzVDXQA4tGAf uSkA== X-Forwarded-Encrypted: i=1; AJvYcCVrQA62raYdXAwxt7PVNQ7uHtgocRtiQ3bvUhwO0NSG9dnqRSVxN5+JkQyLpFq4NfuQuz3JH/Xryx9sofo=@vger.kernel.org X-Gm-Message-State: AOJu0YyCjkLm3db8csnhDygOkALRJHRHUgp/od4EKND/ev2nJmRSTY9O 5TXzFFBQus4xgmO10Nh1mydtUkY4ephX9iOHqdGJbCBRpzG2wzmouPxbrKyEKZg= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D':' 94 95 96 97 98 99 100 101 $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump napi-get --json=3D'{"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/eth= ernet/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 =3D adapter->num_io_queues + adapter->xdp_num_queues; + int rc =3D 0, i, k, irq_idx; unsigned long flags =3D 0; struct ena_irq *irq; - int rc =3D 0, i, k; =20 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 *ad= apter) irq_set_affinity_hint(irq->vector, &irq->affinity_hint_mask); } =20 + /* 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 =3D 0; i < io_queue_count; i++) { + irq_idx =3D ENA_IO_IRQ_IDX(i); + irq =3D &adapter->irq_tbl[irq_idx]; + netif_napi_set_irq(&adapter->ena_napi[i].napi, irq->vector); + } + return rc; =20 err: --=20 2.25.1 From nobody Thu Nov 28 10:39:22 2024 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 1B2AF8F66 for ; Wed, 2 Oct 2024 00:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727829257; cv=none; b=ALZxPHpMPhVVxom6AebApBM5TRfDJ7Abhnz5hBO5T2VBvYszIi08zuisYZCANwMIW3/ZUAJLDSWZHcqlBDr7Qnju5EEX6iMypK4CUoccZ+J39kL2xy16AbqR/cXczjIL6ZT+AIYpxISBCUeLoS0tmvDjk23UjsncO4cm5euBeDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727829257; c=relaxed/simple; bh=yStr/6PJPenHSI7D8HokTLRUj51fig9mf3TfmVYcCLY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p0eGUcnNB/g4HWedlxXudC8xr9+jnKf6MsErw4ctHp23RSypf7G2mKkds8AybyTEsW6/L3AcgLQ2y8Swdgf7Gs2SXV1lJElI48JRXYhGX6ssZL8NiGHChlS3Zb96HQhX3XMxMxvLqzG+LwkPSI5UIdy/37UQsN97uHotRDNCx9g= 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.176 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-f176.google.com with SMTP id d9443c01a7336-20b86298710so26195545ad.1 for ; Tue, 01 Oct 2024 17:34:15 -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=SyckwrF26AwylEHljNy/8YQaHHIdHV+/X9fTqz9jvwfXmVRhw9fiz4aFwBl25D5PiI NzSF1g6/fCXT+8/GGKqz0AZY8wGnXSv6fP7WwXZmARe4gkfU+2RbFxdF70erql/+d/fH KcfBGWVkyhD9C9h6u2iZ6smc3qyqTpIy2Ydf85KfWqAOwReZjYsWrJmK8Q7XeLIcWgb7 bOzd5ULNEJ0jukn/ItSl0BG0TR/NJxyeLrOdasP38W7g1YJ/Aw6AczUhtzaoExKXjk0I UdS0hzPG/aqMfb05I8InciYnpct0yxMaDLNmj9/Q3/GfqlhyK+QqtG+6au7aP+giq4OY 09qA== X-Forwarded-Encrypted: i=1; AJvYcCUhEHStBdnvO2l/g9Mnr4eOebE+Z0B3M8zQqhRMJSR2RWQrkgxfPtehWHcxMuMo9h7ypY+mSUrsu94F/cE=@vger.kernel.org X-Gm-Message-State: AOJu0YwdJZB8qMkW4yw8zE5FaiCBK6ZTyTEDVfAM0iBVk7J/Kcjl+ALQ Opr6gsarhpSb1MCusxWWl41uYOxX+JsEfJiMiR4thGw8xw7J0K1zUa1IfD1kF9s= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D'{"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/eth= ernet/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_ad= apter *adapter, int first_index, int count) { + struct napi_struct *napi; int i; =20 - for (i =3D first_index; i < first_index + count; i++) - napi_disable(&adapter->ena_napi[i].napi); + for (i =3D first_index; i < first_index + count; i++) { + napi =3D &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); + } } =20 static void ena_napi_enable_in_range(struct ena_adapter *adapter, int first_index, int count) { + struct napi_struct *napi; int i; =20 - for (i =3D first_index; i < first_index + count; i++) - napi_enable(&adapter->ena_napi[i].napi); + for (i =3D first_index; i < first_index + count; i++) { + napi =3D &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); + } + } } =20 /* Configure the Rx forwarding */ --=20 2.25.1