diff mbox series

[net-next,02/10] bnxt_en: Add is_ts_pkt field to struct bnxt_sw_tx_bd

Message ID 20240626164307.219568-3-michael.chan@broadcom.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: PTP updates for net-next | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 842 this patch: 842
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 849 this patch: 849
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 853 this patch: 853
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 57 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-27--03-00 (tests: 665)

Commit Message

Michael Chan June 26, 2024, 4:42 p.m. UTC
Remove the unused is_gso field and add the is_ts_pkt field to struct
bnxt_sw_tx_bd.  This field will mark the TX BD that has requested
HW TX timestamp.  The field needs to be cleared if the timestamp packet
is later aborted.  This field will be useful when processing the
new TX timestamp completion from the hardware in the next patches.

Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++++++++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

Comments

Jakub Kicinski June 28, 2024, 12:08 a.m. UTC | #1
On Wed, 26 Jun 2024 09:42:59 -0700 Michael Chan wrote:
> @@ -612,9 +613,11 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  normal_tx:
>  	if (length < BNXT_MIN_PKT_SIZE) {
>  		pad = BNXT_MIN_PKT_SIZE - length;
> -		if (skb_pad(skb, pad))
> +		if (skb_pad(skb, pad)) {
>  			/* SKB already freed. */
> +			tx_buf->is_ts_pkt = 0;
>  			goto tx_kick_pending;
> +		}
>  		length = BNXT_MIN_PKT_SIZE;
>  	}

There is a jump to tx_free in between these two, when DMA mapping
head fails. It appears not to clear is_ts_pkt.

Why not add the clearing above the line on the error patch which 
clears the skb pointer?

@@ -771,6 +770,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (txr->kick_pending)
                bnxt_txr_db_kick(bp, txr, txr->tx_prod);
        txr->tx_buf_ring[txr->tx_prod].skb = NULL;
+       txr->tx_buf_ring[txr->tx_prod].is_ts_pkt = 0;
        dev_core_stats_tx_dropped_inc(dev);
        return NETDEV_TX_OK;
 }

> @@ -741,6 +744,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	/* start back at beginning and unmap skb */
>  	prod = txr->tx_prod;
>  	tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)];
> +	tx_buf->is_ts_pkt = 0;
>  	dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping),
>  			 skb_headlen(skb), DMA_TO_DEVICE);
>  	prod = NEXT_TX(prod);
Michael Chan June 28, 2024, 12:39 a.m. UTC | #2
On Thu, Jun 27, 2024 at 5:08 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Wed, 26 Jun 2024 09:42:59 -0700 Michael Chan wrote:
> > @@ -612,9 +613,11 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
> >  normal_tx:
> >       if (length < BNXT_MIN_PKT_SIZE) {
> >               pad = BNXT_MIN_PKT_SIZE - length;
> > -             if (skb_pad(skb, pad))
> > +             if (skb_pad(skb, pad)) {
> >                       /* SKB already freed. */
> > +                     tx_buf->is_ts_pkt = 0;
> >                       goto tx_kick_pending;
> > +             }
> >               length = BNXT_MIN_PKT_SIZE;
> >       }
>
> There is a jump to tx_free in between these two, when DMA mapping
> head fails. It appears not to clear is_ts_pkt.
>

You are absolutely right.

> Why not add the clearing above the line on the error patch which
> clears the skb pointer?

Yes, that looks like the best place to clear it for all error
conditions.  I think I will consolidate all the PTP cleanup around
that location to make the code look cleaner.  Thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 1bd0c5973252..996d9fe80495 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -522,6 +522,7 @@  static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 				if (vlan_tag_flags)
 					ptp->tx_hdr_off += VLAN_HLEN;
 				lflags |= cpu_to_le32(TX_BD_FLAGS_STAMP);
+				tx_buf->is_ts_pkt = 1;
 				skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
 			} else {
 				atomic_inc(&bp->ptp_cfg->tx_avail);
@@ -612,9 +613,11 @@  static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 normal_tx:
 	if (length < BNXT_MIN_PKT_SIZE) {
 		pad = BNXT_MIN_PKT_SIZE - length;
-		if (skb_pad(skb, pad))
+		if (skb_pad(skb, pad)) {
 			/* SKB already freed. */
+			tx_buf->is_ts_pkt = 0;
 			goto tx_kick_pending;
+		}
 		length = BNXT_MIN_PKT_SIZE;
 	}
 
@@ -741,6 +744,7 @@  static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	/* start back at beginning and unmap skb */
 	prod = txr->tx_prod;
 	tx_buf = &txr->tx_buf_ring[RING_TX(bp, prod)];
+	tx_buf->is_ts_pkt = 0;
 	dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping),
 			 skb_headlen(skb), DMA_TO_DEVICE);
 	prod = NEXT_TX(prod);
@@ -781,6 +785,7 @@  static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
 	while (RING_TX(bp, cons) != hw_cons) {
 		struct bnxt_sw_tx_bd *tx_buf;
 		struct sk_buff *skb;
+		bool is_ts_pkt;
 		int j, last;
 
 		tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)];
@@ -800,6 +805,8 @@  static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
 			tx_buf->is_push = 0;
 			goto next_tx_int;
 		}
+		is_ts_pkt = tx_buf->is_ts_pkt;
+		tx_buf->is_ts_pkt = 0;
 
 		dma_unmap_single(&pdev->dev, dma_unmap_addr(tx_buf, mapping),
 				 skb_headlen(skb), DMA_TO_DEVICE);
@@ -814,7 +821,7 @@  static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
 				skb_frag_size(&skb_shinfo(skb)->frags[j]),
 				DMA_TO_DEVICE);
 		}
-		if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
+		if (unlikely(is_ts_pkt)) {
 			if (BNXT_CHIP_P5(bp)) {
 				/* PTP worker takes ownership of the skb */
 				if (!bnxt_get_tx_ts_p5(bp, skb)) {
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index d3ad73d4c00a..00976e8a1e6a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -874,7 +874,7 @@  struct bnxt_sw_tx_bd {
 	DEFINE_DMA_UNMAP_ADDR(mapping);
 	DEFINE_DMA_UNMAP_LEN(len);
 	struct page		*page;
-	u8			is_gso;
+	u8			is_ts_pkt;
 	u8			is_push;
 	u8			action;
 	unsigned short		nr_frags;