From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 7A58719CC1D for ; Wed, 2 Oct 2024 23:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727911310; cv=none; b=lzRiVGpq+8aqwe3HpkNZJ4N4n940eRX3feCGL+odE4yEv5QxrN3ZDQ6R28GEG9zFaUtj6NmhUhmWxjO1tUUxUHZrguUcV9kgxf6S67R81RvhRzhu90DCA1H0U6djJyCTHjUn4yDRv5wUWjsFWf+mBNCYyZ8aiIAX74vvOojZ2mI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727911310; c=relaxed/simple; bh=UgcY+wNQp8XxmT35NKeAGyErRXgcmWWykfdLdZIOUes=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QHFRsn+byI6by+nhf9B5164bfS1J+NghMz3REg/IlZdBjp+VSYQ+Mv/lzooVYALBP/kmHzrOf/HkeEGmz0q/cs2cwtlUj9Q5KZYPfbe02hrszc2ZQoGnkOOq5oHVGTLjNZ8/Rk0ui+VGwL/ECpXMnBwYZyY+8TK1/JWMCJBXW0g= 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=mV+HT5wo; arc=none smtp.client-ip=209.85.215.174 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="mV+HT5wo" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-656d8b346d2so174828a12.2 for ; Wed, 02 Oct 2024 16:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727911307; x=1728516107; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:from:to:cc:subject:date:message-id:reply-to; bh=pMSZt2f+Fs+nBRBUgyo6uxKDO9ysy2u/oaoeF/+PoFY=; b=mV+HT5womGcH6AjEE2w8R8chDOv8lYQ9K5y4B9+zgFJAeyUcUG12KlXVK68myVHcqG +kK5A4PLflhJrSywNx6RngoahMiZR6uQR6vAU+1A36ay+GJHPskVFzNbpFKBoW4Omcni aq4IFbHanctOKM313hnXckfngv6UGIqHOA3rM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727911307; x=1728516107; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pMSZt2f+Fs+nBRBUgyo6uxKDO9ysy2u/oaoeF/+PoFY=; b=SPYiwywjrZlvFHJUzTyXEYcrhywwQvcg1TphZCFAUtEBzMuUB3iFqpvBAcApmrJPou cbSL+j8/BF3AnCfM1hH0lJqwlF7IDI8HNBZOYsqxdVdEbAgp3ZVmrbson9J51jp7aIgM 3wv9jw1cVJjD0MyzkzpL9oqodtiQMNyx2x3e/+QXjmmiUhb2w+Dptf8TanuBEZzI8hyK dEBUaRFd+AUgGmRxUmb09IbqAAmX/bKmbKQvoo9EcGl5HXKfya5/N2TXDCwXPn8hXwjk TtQecA1v2XFDvcFy2fnzErSxHBe3+CvJZssJygYK4skFnJ82qKaHwG2mC6qSaK/bc5Fb 66Hw== X-Forwarded-Encrypted: i=1; AJvYcCUPvPjudKOn/ZTwQgPeqdZOJXbbaIa9XDwDzu6cj8CVBejRP5DsceSvr73m+0I3ue96UgLJ/Hi9LUyHpd4=@vger.kernel.org X-Gm-Message-State: AOJu0YyvI/GG1DYd+NGbECTxGzqoCadL7hyf9dcDi+EkvL6v+jM0T0o+ NfdTDNIt4dwmZEcd3uuLzvjKAQ2EWTw2fzOXbMtAYUadkJnJc6r0Uh8bsX7lwDI= X-Google-Smtp-Source: AGHT+IGxCRiO+MThPsnHFV/JWL+UWtXglUtoKM2ktl5U+eU1OimyCYDNPHhyUOSGNIvy2Gdw2GjQFg== X-Received: by 2002:a05:6a21:1796:b0:1d0:56b1:1c59 with SMTP id adf61e73a8af0-1d5e2d4a211mr6284060637.32.1727911306792; Wed, 02 Oct 2024 16:21:46 -0700 (PDT) Received: from LQ3V64L9R2 (c-24-6-151-244.hsd1.ca.comcast.net. [24.6.151.244]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71dd9df0ae6sm17684b3a.174.2024.10.02.16.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 16:21:46 -0700 (PDT) Date: Wed, 2 Oct 2024 16:21:43 -0700 From: Joe Damato To: Pavan Chebbi Cc: netdev@vger.kernel.org, Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , open list Subject: Re: [RFC net-next v2 2/2] tg3: Link queues to NAPIs Message-ID: Mail-Followup-To: Joe Damato , Pavan Chebbi , netdev@vger.kernel.org, Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , open list References: <20240925162048.16208-1-jdamato@fastly.com> <20240925162048.16208-3-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Sep 27, 2024 at 09:33:51AM +0530, Pavan Chebbi wrote: > On Fri, Sep 27, 2024 at 4:47 AM Joe Damato wrote: > > > > On Wed, Sep 25, 2024 at 04:20:48PM +0000, Joe Damato wrote: > > > 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, '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/broadcom/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 budget) > > > > > > static void tg3_napi_disable(struct tg3 *tp) > > > { > > > + struct tg3_napi *tnapi; > > > int i; > > > > > > - for (i = tp->irq_cnt - 1; i >= 0; i--) > > > - napi_disable(&tp->napi[i].napi); > > > + ASSERT_RTNL(); > > > + for (i = tp->irq_cnt - 1; i >= 0; i--) { > > > + tnapi = &tp->napi[i]; > > > + if (tnapi->tx_buffers) > > > + netif_queue_set_napi(tp->dev, i, NETDEV_QUEUE_TYPE_TX, NULL); > > > > It looks like the ASSERT_RTNL is unnecessary; netif_queue_set_napi > > will call it internally, so I'll remove it before sending this to > > the list (barring any other feedback). > > Thanks LGTM. You can use Reviewed-by: Pavan Chebbi I noticed there's a misnumbering issue in the code. Note the output from the first patch: [{'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}] Note the output in the commit message above: [{'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'}] Note that id 0 type: 'rx' has no napi-id associated with it, and in the second block, NAPI ID 149 is nowhere to be found. This is happening because the code in the driver does this: 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, i, NETDEV_QUEUE_TYPE_TX, &tnapi->napi); The code I added assumed that i is the txq or rxq index, but it's not - it's the index into the array of struct tg3_napi. Corrected, the code looks like something like this: int txq_idx = 0, rxq_idx = 0; [...] 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++; [...] I tested that and the output looks correct to me. However, what to do about tg3_napi_disable ? Probably something like this (txq only for brevity): int txq_idx = tp->txq_cnt - 1; [...] for (i = tp->irq_cnt - 1; i >= 0; i--) { [...] if (tnapi->tx_buffers) { netif_queue_set_napi(tp->dev, txq_idx, NETDEV_QUEUE_TYPE_TX, NULL); txq_idx--; } [...] Does that seem correct to you? I wanted to ask before sending another revision, since I am not a tg3 expert. I will of course remove your Reviewed-by from this patch (but leave it on patch 1 which is unmodified) when I resend it.