From patchwork Sat Oct 5 14:57:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13823306 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (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 50626156256 for ; Sat, 5 Oct 2024 14:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728140249; cv=none; b=shB42FgsxK9qBPOBWbd8GW4CzfJvnB/3q5RvKJLUK32kVP9qbVYzEdHCZomjt79H5bjzjmWasW+FlVZEnJu8a72bQ5Vd8yGsayPFcarAy9/xhS8NbhkgsYIYy+I3Cp+A/teNE+uUwfPUYllp71sob4RqvgMkveR4Jwhl4HIhCgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728140249; c=relaxed/simple; bh=ysbX5l1vLBzimCzPDgAViVv+ZxYYBsLYzrBE1+8ybHo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mHTKFwS3rzUkEYUourYnen3WVumWCLbJSkJ/UDVzQEc4xcXRWv2qzq5/zDwZzxyrh16VKHI7utWE3OxVkq5kZkq3STGv+ep3VbqwMtvh+CMgScflY3M9BnoP+uBXktIavV0xb7SEUja/2l7eufbcawPQUv0Xg/zcCtsKp27y7vU= 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=DpSz7gUq; arc=none smtp.client-ip=209.85.215.177 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="DpSz7gUq" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7e9ff6fb4c6so377110a12.3 for ; Sat, 05 Oct 2024 07:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728140247; x=1728745047; 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=zIZerHGyKKkDkl5U8HwNES4+6GKUJadKoubjuPnUQug=; b=DpSz7gUqNylgUxdP9uUfImzXxW9zxYUYTacoYO55ZtSOxfaPOczx2m2YveO7yqMd6C d26Rpx0VOQxPLlcE/N/T9TVROgiYalO7CcTDs/+Jip3yX4lqnoCLHIaQws8/+mhoIgQX eveTdKYSH1z6zuCQB6HQu/OcKN5tqJuZc5a7w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728140247; x=1728745047; 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=zIZerHGyKKkDkl5U8HwNES4+6GKUJadKoubjuPnUQug=; b=nXe0fTwJ7tmzNNCB4An1jHr92H/8kfpPdh6ssWXMj0VE4ZAbnm/Lrnh+aKIpYG/coA 3fmFAANz31YJpsDxeawDzh4EV5WLq4DTnP0U+rDW7snk7MWajXdqA9QNh0LnEyWe7wQs AAthUYVAt7+JWTgWnHY6rU6jcvA/qfsKLR8FeWnnRo4qUZ4jowyHA9xKExqvlXvSfHWh PwBXiWqYzPCZBjUrolljtSle940Qf7mB/yCsL9cP8+W3xRBrLEH6+yMzSQQzYKboHPQX YRIqmssZESGUqnXFgYsL/t1770LfPv5IYEjItX0UXF5rMd9LRl7SsP2UkhbjvAxYAD8N Pnfw== X-Gm-Message-State: AOJu0Yw1i+FznDK6eYUZQ4l21174MLBtDP1gS6I1NsjQXK2Dp9eo3l4r dqAqgjzxVg2EmMpMH210tcLMxu0CmEXaog7tC5nyUFevIcq23oImQ5iw/KDxZzXOcvLBGodUPLr xhpj86OcCX3RCABntbTu5gMtPOvvBsETHf0JhcDdIcx5rBeS2JpYuK/CO4bfwfz6FkuMjmf5cMr FCl0RUTzSId7J1p8xwbFBJn5R/TCWmvJ2xK2M= X-Google-Smtp-Source: AGHT+IEiERjQcTgt7RF6P0SsPQ0UjCg+IJotQMwFZzgz0muvxhy1nyS1UI6dlzjI4j/sBinrRL+JlA== X-Received: by 2002:a05:6a21:3983:b0:1d6:236f:bd6b with SMTP id adf61e73a8af0-1d6df72467cmr11886207637.0.1728140247287; Sat, 05 Oct 2024 07:57:27 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0d7d3b5sm1569273b3a.215.2024.10.05.07.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 07:57:26 -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: [net-next v3 1/2] tg3: Link IRQs to NAPI instances Date: Sat, 5 Oct 2024 14:57:16 +0000 Message-Id: <20241005145717.302575-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241005145717.302575-1-jdamato@fastly.com> References: <20241005145717.302575-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. 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=':' 343 344 345 346 347 $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump napi-get --json='{"ifindex": 2}' [{'id': 8197, 'ifindex': 2, 'irq': 347}, {'id': 8196, 'ifindex': 2, 'irq': 346}, {'id': 8195, 'ifindex': 2, 'irq': 345}, {'id': 8194, 'ifindex': 2, 'irq': 344}, {'id': 8193, 'ifindex': 2, 'irq': 343}] Signed-off-by: Joe Damato Reviewed-by: Pavan Chebbi --- rfcv3: - wrapped the netif_napi_add call to 80 characters drivers/net/ethernet/broadcom/tg3.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 378815917741..6564072b47ba 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7413,9 +7413,11 @@ static void tg3_napi_init(struct tg3 *tp) { int i; - netif_napi_add(tp->dev, &tp->napi[0].napi, tg3_poll); - for (i = 1; i < tp->irq_cnt; i++) - netif_napi_add(tp->dev, &tp->napi[i].napi, tg3_poll_msix); + for (i = 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); + } } static void tg3_napi_fini(struct tg3 *tp) From patchwork Sat Oct 5 14:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13823307 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 CD68B156F21 for ; Sat, 5 Oct 2024 14:57:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728140251; cv=none; b=AfZ8/ICmTscWk69Ogqcuvg9+wlGF1+/aTGbhfdSHuZkz2XS4sGyAWzvxzVTkA9esIYMi2QYGrV4gjUpu7Xe9hc+jfder3ZUaQ3qXBrGPaDfgXRUaOuaHM/9yJvKTkuasOBNdDyM8QUGjhPOWN9U/WGXjxWIqicM+yRFC+p8cZSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728140251; c=relaxed/simple; bh=thcYphpNAdIzT0H0M8T+Xo0AMmC8z3xkUwKuUa32lqc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tYkvPcA3qH6Rq1sfnM7StqW3AH3ddW2MN38h0rGPmOIdSBqj6X5eNOr5C5jLIMzqRStk6OoE/qmfHQiBDOTpB25zHxbfSx/ve7oqWx/xbRvC9MsKG7LQwfgCQLbrv5sVLdgHp+FEVrHXKCMIxtnvixp+58GcKsEvn8ae6v5EQWQ= 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=f+Oi/nLi; arc=none smtp.client-ip=209.85.210.177 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="f+Oi/nLi" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-7179069d029so2358043b3a.2 for ; Sat, 05 Oct 2024 07:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728140249; x=1728745049; 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=Vj//5XoNe5l6Dm+CRfm/cmDjjfvCDewa/ozF5GNrUio=; b=f+Oi/nLiUj0pjrRp0rbgEG9HDFZtIWkaO7WfwbePIJcNb3LscOur+iQdghLjxFgP5O YDgxm8R5VBCJ04Ym5uywEshk4NWyc72ZuRwDmrb/2PzPIYMc8KMWjNRPcxoTiumzHi2s CJX4T+Mrx90JoEaRLbweL0nUhEPNk0zGJTXvY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728140249; x=1728745049; 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=Vj//5XoNe5l6Dm+CRfm/cmDjjfvCDewa/ozF5GNrUio=; b=QnPWwr3/c7coIPXn8GrRuAAkawOB/CE4OVUeP9p44D+UCzLMIEbponcu7GeeEjYMyF D6dlEyWWpbTxj1M4PoyU7MvtiK56iVcMg6sAI6oalq85gTpOBKTvvnWRgTSySviQ4+gl w+9M87vGub4PxF8ncR4v9mJmAxRQYI4gsLDhwkT4PxzpYauYtj5nb0YEP5UIgtlPDtIR SDqLI2XcwkYj7LU5IOO665e4cjE5hGTHSmIPPEhu1NfVpcillwhAUcXnwasOoJFpj7FT ln89tOLIjd+uoRxOoB6BVJVf3EQkFyvk+o/J8TCLuZfl/DdVTpHPNA6zSuOpuQv0hWd1 Wnvw== X-Gm-Message-State: AOJu0YzbWDqLWGHkCetWdnWNHRoCi9W4KZUl8LFrUn7H81EnBs/PVa09 CAZ8jvqC4Jhv8DjLqIDFKxmPRlF4qmTX4weUgfEHHxukYDup29YwNKkEXQOIT5kZUJ8RSn7Jbet 0Er0zwaKdXmlVF24V037YG8A6Ulqb5NEYGalMT8K+VVFCyFeSRQQc2uKOH/LnfYZmexend+erdO Wy6U8LXgy2XXzgkTZxgNbIi8unWjFTVOqENUk= X-Google-Smtp-Source: AGHT+IFM8cTLINP21Oa0a7lFaVHhoyEZPhHMUUa1IT3Mgtmuz66wQMuiHFBnA4EPR0BKC2/BFUEojw== X-Received: by 2002:a05:6a21:a24c:b0:1d3:1765:c09c with SMTP id adf61e73a8af0-1d6dfa486e7mr10003756637.29.1728140248804; Sat, 05 Oct 2024 07:57:28 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0d7d3b5sm1569273b3a.215.2024.10.05.07.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 07:57:28 -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: [net-next v3 2/2] tg3: Link queues to NAPIs Date: Sat, 5 Oct 2024 14:57:17 +0000 Message-Id: <20241005145717.302575-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241005145717.302575-1-jdamato@fastly.com> References: <20241005145717.302575-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': 8194, 'type': 'rx'}, {'id': 1, 'ifindex': 2, 'napi-id': 8195, 'type': 'rx'}, {'id': 2, 'ifindex': 2, 'napi-id': 8196, 'type': 'rx'}, {'id': 3, 'ifindex': 2, 'napi-id': 8197, 'type': 'rx'}, {'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'tx'}] Signed-off-by: Joe Damato --- drivers/net/ethernet/broadcom/tg3.c | 37 +++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 6564072b47ba..12172783b9b6 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -7395,18 +7395,47 @@ static int tg3_poll(struct napi_struct *napi, int budget) static void tg3_napi_disable(struct tg3 *tp) { + int txq_idx = tp->txq_cnt - 1; + int rxq_idx = tp->rxq_cnt - 1; + struct tg3_napi *tnapi; int i; - for (i = tp->irq_cnt - 1; i >= 0; i--) - napi_disable(&tp->napi[i].napi); + for (i = tp->irq_cnt - 1; i >= 0; i--) { + tnapi = &tp->napi[i]; + if (tnapi->tx_buffers) { + netif_queue_set_napi(tp->dev, txq_idx, + NETDEV_QUEUE_TYPE_TX, NULL); + txq_idx--; + } else if (tnapi->rx_rcb) { + netif_queue_set_napi(tp->dev, rxq_idx, + NETDEV_QUEUE_TYPE_RX, NULL); + rxq_idx--; + } + napi_disable(&tnapi->napi); + } } static void tg3_napi_enable(struct tg3 *tp) { + int txq_idx = 0, rxq_idx = 0; + struct tg3_napi *tnapi; int i; - for (i = 0; i < tp->irq_cnt; i++) - napi_enable(&tp->napi[i].napi); + for (i = 0; i < tp->irq_cnt; i++) { + tnapi = &tp->napi[i]; + napi_enable(&tnapi->napi); + if (tnapi->tx_buffers) { + netif_queue_set_napi(tp->dev, txq_idx, + NETDEV_QUEUE_TYPE_TX, + &tnapi->napi); + txq_idx++; + } else if (tnapi->rx_rcb) { + netif_queue_set_napi(tp->dev, rxq_idx, + NETDEV_QUEUE_TYPE_RX, + &tnapi->napi); + rxq_idx++; + } + } } static void tg3_napi_init(struct tg3 *tp)