From patchwork Wed Jun 26 16:43:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13713187 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 D028318F2EB for ; Wed, 26 Jun 2024 16:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420219; cv=none; b=sRJM28WPt+VM7G2TDrA3Py0P2NGxIsNrDYdo2HKwYf45mEu5tckhaVuuAQfwcBa8n0nwTHYauyLx5qy8b5OcCBYUWtZDYT3TYZhuRqfNHFQyBu5C4uYarRO9nnD3GDhAPwaDqRGOtUPiTFR6yuv6O88ncSmStvD4UPpBH7us/aI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719420219; c=relaxed/simple; bh=zd1+5YHnmYGebQdRIrenpzsuChk9p/WJMl/pqwP9Fzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TMAksoac64FGWM1eHRarRO003Dai68yXaE2E5mB0paYyOTTP8qRFCqZ8uI5oCC3Zd/v6ZhLhyxWNUVl6Kmy3rSbXEZmqScOGBzRvqTllxvwlmIq6Mtuhkq/Z7Jh2p4ACt+PoJ0t5WYaeH4B7wWjYsS4emJfOMnX0KZSkmy5lX4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=hLhoR57o; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="hLhoR57o" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-700cf7e2779so758726a34.1 for ; Wed, 26 Jun 2024 09:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1719420217; x=1720025017; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=0c74ncTltVL8E8rT3+LoyxLtEXCltjgcRGPmIFQTpBg=; b=hLhoR57o+KDzEf9jt1inh2WgBhkeChUyqH9HHdwvABD2W9bT+HzWvTAWBSOyLVHW/O p0W4e5ETNu7SXd3Ed9wf9Abg4cHsb8l2MAUUo7rON5VT3rp7CBSyOc+T4mjOKslPPZ/C O2mh9eo4wb31G8oxwVPttwc53x8w73BqpO4ZU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719420217; x=1720025017; h=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=0c74ncTltVL8E8rT3+LoyxLtEXCltjgcRGPmIFQTpBg=; b=Sm5vA8LPRFxKjZFqSa+yFwhzeS/o+Czl3pIYHffy+J2HbZ/9TEWdmCm2BKEhC7f5OH nMd33fpK4qe4Tmc9jiLfR9Eg6XIko2JuXaUDVJcaZVgSs77QnagTf0luTOC+tEZRwQQA JVlHLe4CtzYOT+bGI7dVIC7kMiKtE32lRu+yK53pS5BSAeFx1ssMKFPzNDQldQf6ji6G 3cg+S5ENRcFw6fgMQ+OBxNhlOYaRau4ury9ikikviyBXYIseT2FkaLrzRnHZIPJxwCOv owdlv13tw+BPleOtan+bpL5KMG9vh7gqiXNaiZxRy1u3Byhdra69SCWoyQJ24XHU/McW iaQA== X-Gm-Message-State: AOJu0YzpIGE1SMwuBOKl01SZ0mTc/AIH85WrFRG7LsQgiWriZNoZQrh+ 8quoA/42K4nkkgi5AcNxQjajerI3HdGBK02ip4FswpyvMgxL+IrpuMO4rfmt3w== X-Google-Smtp-Source: AGHT+IE5TVZHAQCPCVlXjGPHZSgq0stip2mSMmEgvj+OuefV+e8YZzbkgZUcqRrI3jLjoP2p4NFaXw== X-Received: by 2002:a9d:76d1:0:b0:6f9:75c9:854c with SMTP id 46e09a7af769-700b1271e04mr10941412a34.27.1719420216635; Wed, 26 Jun 2024 09:43:36 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d53c42aafsm53570485a.58.2024.06.26.09.43.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 09:43:36 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, richardcochran@gmail.com Subject: [PATCH net-next 03/10] bnxt_en: Allow some TX packets to be unprocessed in NAPI Date: Wed, 26 Jun 2024 09:43:00 -0700 Message-ID: <20240626164307.219568-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240626164307.219568-1-michael.chan@broadcom.com> References: <20240626164307.219568-1-michael.chan@broadcom.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 The driver's current logic will always free all the TX SKBs up to txr->tx_hw_cons within NAPI. In the next patches, we'll be adding logic to handle TX timestamp completion and we may need to hold some remaining TX SKBs if we don't have the timestamp completions yet. Modify __bnxt_poll_work_done() to clear each event bit separately to allow bnapi->tx_int() to decide whether to clear BNXT_TX_CMP_EVENT or not. bnapi->tx_int() will not clear BNXT_TX_CMP_EVENT if some TX SKBs are held waiting for TX timestamps. Note that legacy chips will never hold any SKBs this way. The SKB is always deferred to the PTP worker slow path to retrieve the timestamp from firmware. On the new P7 chips, the timestamp is returned by the hardware directly and we can retrieve it directly from NAPI. Reviewed-by: Pavan Chebbi Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 996d9fe80495..784787a09dba 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -772,7 +772,8 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; } -static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, +/* Returns true if some remaining TX packets not processed. */ +static bool __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, int budget) { struct netdev_queue *txq = netdev_get_tx_queue(bp->dev, txr->txq_index); @@ -795,7 +796,7 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, if (unlikely(!skb)) { bnxt_sched_reset_txr(bp, txr, cons); - return; + return false; } tx_pkts++; @@ -844,18 +845,22 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, __netif_txq_completed_wake(txq, tx_pkts, tx_bytes, bnxt_tx_avail(bp, txr), bp->tx_wake_thresh, READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING); + + return false; } static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) { struct bnxt_tx_ring_info *txr; + bool more = false; int i; bnxt_for_each_napi_tx(i, bnapi, txr) { if (txr->tx_hw_cons != RING_TX(bp, txr->tx_cons)) - __bnxt_tx_int(bp, txr, budget); + more |= __bnxt_tx_int(bp, txr, budget); } - bnapi->events &= ~BNXT_TX_CMP_EVENT; + if (!more) + bnapi->events &= ~BNXT_TX_CMP_EVENT; } static struct page *__bnxt_alloc_rx_page(struct bnxt *bp, dma_addr_t *mapping, @@ -2952,8 +2957,10 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, } } - if (event & BNXT_REDIRECT_EVENT) + if (event & BNXT_REDIRECT_EVENT) { xdp_do_flush(); + event &= ~BNXT_REDIRECT_EVENT; + } if (event & BNXT_TX_EVENT) { struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0]; @@ -2963,6 +2970,7 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, wmb(); bnxt_db_write_relaxed(bp, &txr->tx_db, prod); + event &= ~BNXT_TX_EVENT; } cpr->cp_raw_cons = raw_cons; @@ -2980,13 +2988,14 @@ static void __bnxt_poll_work_done(struct bnxt *bp, struct bnxt_napi *bnapi, struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod); + bnapi->events &= ~BNXT_RX_EVENT; } if (bnapi->events & BNXT_AGG_EVENT) { struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod); + bnapi->events &= ~BNXT_AGG_EVENT; } - bnapi->events &= BNXT_TX_CMP_EVENT; } static int bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,