From nobody Fri Nov 29 00:55:40 2024 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 92807381AF for ; Wed, 25 Sep 2024 16:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727281263; cv=none; b=n56LjWYrVRe0yvglLrdV3hInfg9KJGBkrK6A4fiTBfe1PbNALrmNg58UoEhI+QMhFBW8ANu4HX9fKYbvOPt68c9uiKygmKGTfwxTBqsPMm4GxONaoZDeBA+rB6F5i+kEPrzlj9DN2Vi+jxsIHKGjdlR5mzPG1viRmkR+INLrqjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727281263; c=relaxed/simple; bh=/C3n/otTQtjjOW+S8EgHIZOwg2eJkivLmPEPYaCFeIE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tkYWEoK5DHLu8OJR36TDRQLWC/916Nb0FTaHIxpkzJ7lr9p6w1cIPGpOzdsCgip/tZYwFCjGWisHu199LcHIMaNcqG+oLJprmWnBC/PgS7/GGFuDvsN6Qwh7cGwR11cBMEiq9/RYB4S0Mes/iBZC1FXdv4thSRuD0p+qEs1KUs4= 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=ncWW2heG; arc=none smtp.client-ip=209.85.161.50 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="ncWW2heG" Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5daa93677e1so18932eaf.3 for ; Wed, 25 Sep 2024 09:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727281260; x=1727886060; 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=VRNRoZ1Q22A0B1+jOcTZDRfMVA7CQPyYZ3o93tUoHMc=; b=ncWW2heGQtY1o48AB3P7jQm4I75mmLI9nXqUUthMErUXTtSAsq8tOP6cbVpjypuEAb mZ4vEj9A3lDk8+mPCSSlMQhq/SNSCU28+Y1if/qoThH3A5Lb9yLpERXwGU5p7KhZ67Ee 52tlMWKQq+vzOn8THwco1OL442S+fLigXK9TM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727281260; x=1727886060; 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=VRNRoZ1Q22A0B1+jOcTZDRfMVA7CQPyYZ3o93tUoHMc=; b=gdubYwRLjLKp7DomBH6VSpMSjeXrxtewLjq89vrvIulBfb6ErERLycoiuQQuUaTOHd NJkk3wb9ofHS98jFbgyGV9ASDbjFU2g6g0e96EP5Vm8360TufrtjOJ2uCMzZaISi30q+ pSxxGMjmLGbdRAtB64938l7P3oLEPo+RngEZSDbVe0GIet1x6U/Rn78eiianQlHgmdx8 HEcGYyNrViI4IDS/1f0cNzGgG31eNEU5SECrhXkOkk2D4Qs/OpEOPhv0hhORa323N1n+ NjBeB8MgQkCxLUuGddFkM0mYPPzx+LktHe7sWvD0ItFX3S43swJe9l4WXqC210o961cZ ozCQ== X-Forwarded-Encrypted: i=1; AJvYcCUsHQvnRvyzLkr6btsfpV3+M3CPMDkrW878r2Zby/duOPWfTae2GyDkMgUCUbVUczSOeDhgK6cm5tOmAlE=@vger.kernel.org X-Gm-Message-State: AOJu0YxmM0fFo7lr6ogILT8O0qPYEo2d0uhbbuWAFDTrg7G90P9R4hI+ uVTqTkb1T91/1XnSquCVQ7ORPH4mMDhSLjZLCSE4LuN+8yzNGNWRSMIkS/m941k= X-Google-Smtp-Source: AGHT+IEaW3u53guo2I9o+m2lHO3SxFF1Nx51GF93b4nhd0J46dpRFk/eaFwYfb90KUwt4+fj0x444A== X-Received: by 2002:a05:6870:f729:b0:27c:475c:ab2c with SMTP id 586e51a60fabf-286e1751b46mr3040395fac.43.1727281260477; Wed, 25 Sep 2024 09:21:00 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6b7c73341sm2948433a12.72.2024.09.25.09.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 09:21:00 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Pavan Chebbi , Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v2 1/2] tg3: Link IRQs to NAPI instances Date: Wed, 25 Sep 2024 16:20:47 +0000 Message-Id: <20240925162048.16208-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240925162048.16208-1-jdamato@fastly.com> References: <20240925162048.16208-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. Compare the output of /proc/interrupts for my tg3 device with the output of netdev-genl after applying this patch: $ cat /proc/interrupts | grep eth0 | cut -f1 --delimiter=3D':' 331 332 333 334 335 $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump napi-get --json=3D'{"ifindex": 2}' [{'id': 149, 'ifindex': 2, 'irq': 335}, {'id': 148, 'ifindex': 2, 'irq': 334}, {'id': 147, 'ifindex': 2, 'irq': 333}, {'id': 146, 'ifindex': 2, 'irq': 332}, {'id': 145, 'ifindex': 2, 'irq': 331}] Signed-off-by: Joe Damato --- drivers/net/ethernet/broadcom/tg3.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/bro= adcom/tg3.c index 378815917741..ddf0bb65c929 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7413,9 +7413,10 @@ static void tg3_napi_init(struct tg3 *tp) { int i; =20 - netif_napi_add(tp->dev, &tp->napi[0].napi, tg3_poll); - for (i =3D 1; i < tp->irq_cnt; i++) - netif_napi_add(tp->dev, &tp->napi[i].napi, tg3_poll_msix); + for (i =3D 0; i < tp->irq_cnt; i++) { + netif_napi_add(tp->dev, &tp->napi[i].napi, i ? tg3_poll_msix : tg3_poll); + netif_napi_set_irq(&tp->napi[i].napi, tp->napi[i].irq_vec); + } } =20 static void tg3_napi_fini(struct tg3 *tp) --=20 2.25.1 From nobody Fri Nov 29 00:55:40 2024 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (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 14A214965C for ; Wed, 25 Sep 2024 16:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727281264; cv=none; b=nLGlg1KJnQfq6N0PqA60gotVLWWe4yq3FdezO+7hXYX5/PYPiSXIThnvuqrjqnLjSwPjFta5ZaoYRvkHYfaB/KNGcOK3bCz7YGPr6j+stDdbT1Idmwzt0OAM/usxNdelzwA2PonAy6lo3DcDerextJ4X7jT3y8NVq32cyBbpZXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727281264; c=relaxed/simple; bh=dKt1w+hORDTSGCSREIgcSOY/polV8gNEtej77pHHn2Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sn3bXcr64q/EIdWxO6ylB628dDneXdhWUjbBISCYd2Z6V6SIh8Mu8PTogSfHEcvMAjk//5gXVpiHvwtLHhX9fgZ7ZfvsJHLldmgQcv8G2sJ0jL6Cts9M63X1ihrF+JeoP2CdaCSgla/cmWZYUlkbh9Ql/5BPOkOgqwiHicfXAQI= 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=f1iH8eqz; arc=none smtp.client-ip=209.85.166.182 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="f1iH8eqz" Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-3a056727fdfso24454095ab.3 for ; Wed, 25 Sep 2024 09:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727281262; x=1727886062; 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=ds+S/MZetPsKWvU7c9jTLdR0Y2FRO8ABAdvsJaaWkZs=; b=f1iH8eqz8uwKPz/wo7iN42SiE9QiMFRwos6IQL3zvPqDWEUKQ+IjrTCCUH/g1WyStQ USdpmwzvOoy6U6jvsOgvxTTofOpLqva6ndpi5YN/C65VPpOr2cUoYkYBTMtyYeQgDP7F zTq7eV1W52mtPHbgFYePJ6Q4oYpSaXDYUW/ag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727281262; x=1727886062; 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=ds+S/MZetPsKWvU7c9jTLdR0Y2FRO8ABAdvsJaaWkZs=; b=ILCbGp2ukSSLlzlmuRFNcKVCrNzsLwkSoSdUdxdnHsSB8uCAxwuVOEQXMuvBoSlIqp dBSSNjjWj5toYRH3IkjviUxjs3rMrDhYtpVimmWmvmEYvlz0FnTnmxvYJlqSA0WGZJx4 xm3epwMRtjw80cumbnuF0HeqIOBsFlxVs15R6/JOtlMR1CUzSLZNd7DCaUxqHTwkv8oc 5lH2cm6Wxj8ZfxByldGzhIx9hn+WFVTNcIdPSNwgS4ucq65IuOVF1ZoSE5KMeVT3iNNE WcL28vfTaVE5Jpanah0SU3cnYloTLYLAfKDCOLLMshQMRaRhEXbH+VwAm1OR5qhOccJc rvaA== X-Forwarded-Encrypted: i=1; AJvYcCUe+f3PszRDgIuy6qkf4+/Kb+XlSi8scM05poVRH1ZGJKOxl1JzgjLeqRaTABmw6C40ukmeJo4+uPOro1E=@vger.kernel.org X-Gm-Message-State: AOJu0YwjVkBfRt8xVMnrSjQg3Jl/ue8/dGheN1L+v2Gd1L6vFLw64tBV e4K0nJP/TtCIJDWmZRKdWiM0ZjtcrWjvpDk23fsdD0uK4s1WNh3/odK/K3hcH4M= X-Google-Smtp-Source: AGHT+IFaxcC34k7ddgcU2fJhDTtJSAWSQ1OP73ZVmq50xBFAa2+XpiHScPN2QaIUpK0YEokOuADvrA== X-Received: by 2002:a05:6e02:188c:b0:3a0:8d2f:2914 with SMTP id e9e14a558f8ab-3a26d7f0e76mr36241535ab.23.1727281261959; Wed, 25 Sep 2024 09:21:01 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6b7c73341sm2948433a12.72.2024.09.25.09.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 09:21:01 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Pavan Chebbi , Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v2 2/2] tg3: Link queues to NAPIs Date: Wed, 25 Sep 2024 16:20:48 +0000 Message-Id: <20240925162048.16208-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240925162048.16208-1-jdamato@fastly.com> References: <20240925162048.16208-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, 'type': 'rx'}, {'id': 1, 'ifindex': 2, 'napi-id': 146, 'type': 'rx'}, {'id': 2, 'ifindex': 2, 'napi-id': 147, 'type': 'rx'}, {'id': 3, 'ifindex': 2, 'napi-id': 148, 'type': 'rx'}, {'id': 0, 'ifindex': 2, 'napi-id': 145, 'type': 'tx'}] Signed-off-by: Joe Damato --- drivers/net/ethernet/broadcom/tg3.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/bro= adcom/tg3.c index ddf0bb65c929..f78d7e8c40b2 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7395,18 +7395,34 @@ static int tg3_poll(struct napi_struct *napi, int b= udget) =20 static void tg3_napi_disable(struct tg3 *tp) { + struct tg3_napi *tnapi; int i; =20 - for (i =3D tp->irq_cnt - 1; i >=3D 0; i--) - napi_disable(&tp->napi[i].napi); + ASSERT_RTNL(); + for (i =3D tp->irq_cnt - 1; i >=3D 0; i--) { + tnapi =3D &tp->napi[i]; + if (tnapi->tx_buffers) + netif_queue_set_napi(tp->dev, i, NETDEV_QUEUE_TYPE_TX, NULL); + else if (tnapi->rx_rcb) + netif_queue_set_napi(tp->dev, i, NETDEV_QUEUE_TYPE_RX, NULL); + napi_disable(&tnapi->napi); + } } =20 static void tg3_napi_enable(struct tg3 *tp) { + struct tg3_napi *tnapi; int i; =20 - for (i =3D 0; i < tp->irq_cnt; i++) - napi_enable(&tp->napi[i].napi); + ASSERT_RTNL(); + for (i =3D 0; i < tp->irq_cnt; i++) { + tnapi =3D &tp->napi[i]; + napi_enable(&tnapi->napi); + if (tnapi->tx_buffers) + netif_queue_set_napi(tp->dev, i, NETDEV_QUEUE_TYPE_TX, &tnapi->napi); + else if (tnapi->rx_rcb) + netif_queue_set_napi(tp->dev, i, NETDEV_QUEUE_TYPE_RX, &tnapi->napi); + } } =20 static void tg3_napi_init(struct tg3 *tp) --=20 2.25.1