Skip to contentSkip to conversation

Check for SKBTX_HW_TSTAMP in macb driver

PATCH In review Paul Thomas 3 participants 12 messages Mar 12, 2019 – Mar 13, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check for SKBTX_HW_TSTAMP in macb driver

Make sure SKBTX_HW_TSTAMP (i.e. SOF_TIMESTAMPING_TX_HARDWARE) has been enabled for this skb This is a concept for discussion, more testing is needed.
It does fix the issue where normal socks that aren't expecting a timestamp will not wake up on select.

---
 drivers/net/ethernet/cadence/macb_main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +7 -5
index ad099fd01b45..b2f184fc1370 100644
@@ -898,11 +898,13 @@ static void macb_tx_interrupt(struct macb_queue *queue)
 
 			/* First, update TX stats if needed */
 			if (skb) {
-				if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
-					/* skb now belongs to timestamp buffer
-					 * and will be removed later
-					 */
-					tx_skb->skb = NULL;
+				if(unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
+					if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
+						/* skb now belongs to timestamp buffer
+						 * and will be removed later
+						 */
+						tx_skb->skb = NULL;
+					}
 				}
 				netdev_vdbg(bp->dev, "skb %u (data %p) TX complete\n",
 					    macb_tx_ring_wrap(bp, tail),
Signature · 1 line
2.17.1
#1 lore raw
Quoted 14 lines · Paul Thomas

Make sure SKBTX_HW_TSTAMP (i.e. SOF_TIMESTAMPING_TX_HARDWARE) has been enabled for this skb This is a concept for discussion, more testing is needed.
It does fix the issue where normal socks that aren't expecting a timestamp will not wake up on select.

---
 drivers/net/ethernet/cadence/macb_main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index ad099fd01b45..b2f184fc1370 100644

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue *queue) · line 904

Quoted 7 lines
drivers/net/ethernet/cadence/macb_main.c +0 -4
@@ -898,11 +898,13 @@ static void macb_tx_interrupt(struct macb_queue *queue)
 
                        /* First, update TX stats if needed */
                        if (skb) {
-                               if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
-                                       /* skb now belongs to timestamp buffer
-                                        * and will be removed later
-                                        */

I think the above does the same thing as if CONFIG_MACB_USE_HWSTAMP is undefined regarding cleanup, so there is no extra cleanup if the gem_ptp_do_txstamp() path isn't taken, but I wasn't sure about the "skb now belongs to the timestamp buffer" if we don't go down that path.

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue *queue) · line 901

Quoted 2 lines
drivers/net/ethernet/cadence/macb_main.c +1 -1
-                                       tx_skb->skb = NULL;
+                               if(unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {

This looks like how other drivers are doing things

Quoted 12 lines
drivers/net/ethernet/cadence/macb_main.c +6 -1
+                                       if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
+                                               /* skb now belongs to timestamp buffer
+                                                * and will be removed later
+                                                */
+                                               tx_skb->skb = NULL;
+                                       }
                                }
                                netdev_vdbg(bp->dev, "skb %u (data %p) TX complete\n",
                                            macb_tx_ring_wrap(bp, tail),
--

2.17.1

#2 lore raw
Quoted 35 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Paul Thomas
Sent: Tuesday, March 12, 2019 1:05 PM
To: [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Quoted 2 lines · Paul Thomas

Make sure SKBTX_HW_TSTAMP (i.e. SOF_TIMESTAMPING_TX_HARDWARE) has

been enabled for this skb

Quoted 2 lines

This is a concept for discussion, more testing is needed.
It does fix the issue where normal socks that aren't expecting a timestamp will not

wake

Review

Quoted 6 lines

up on select.

---
 drivers/net/ethernet/cadence/macb_main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/cadence/macb_main.c

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue

Quoted 4 lines

index ad099fd01b45..b2f184fc1370 100644

drivers/net/ethernet/cadence/macb_main.c +0 -0
@@ -898,11 +898,13 @@ static void macb_tx_interrupt(struct macb_queue

*queue)

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue *queue) · line 904

Quoted 7 lines
drivers/net/ethernet/cadence/macb_main.c +0 -4
                        /* First, update TX stats if needed */
                        if (skb) {
-                               if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
-                                       /* skb now belongs to timestamp buffer
-                                        * and will be removed later
-                                        */
Quoted 5 lines

I think the above does the same thing as if CONFIG_MACB_USE_HWSTAMP is undefined regarding cleanup, so there is no extra cleanup if the gem_ptp_do_txstamp() path isn't taken, but I wasn't sure about the "skb now belongs to the timestamp buffer" if we don't go down that path.

The path they're taking here seems a bit weird... I suspect the function gem_ptp_do_txstamp is doing something.

Normally the driver should use something like skb_get to obtain a reference to the skb.

However, the main goal of this patch is correct.

Thanks,
Jake

Quoted 15 lines

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue *queue) · line 901

Quoted 2 lines
drivers/net/ethernet/cadence/macb_main.c +1 -1
-                                       tx_skb->skb = NULL;
+                               if(unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {

This looks like how other drivers are doing things

Quoted 12 lines
drivers/net/ethernet/cadence/macb_main.c +6 -1
+                                       if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
+                                               /* skb now belongs to timestamp buffer
+                                                * and will be removed later
+                                                */
+                                               tx_skb->skb = NULL;
+                                       }
                                }
                                netdev_vdbg(bp->dev, "skb %u (data %p) TX complete\n",
                                            macb_tx_ring_wrap(bp, tail),
--

2.17.1

#3 lore raw

Hi Paul, Jake,

Quoted 12 lines · Jacob E
Quoted 12 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Paul Thomas
Sent: Tuesday, March 12, 2019 1:05 PM
To: [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Quoted 1 line · Paul Thomas

<snip>

Quoted 12 lines
Quoted 11 lines

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue *queue) · line 904

Quoted 6 lines
                        /* First, update TX stats if needed */
                        if (skb) {
drivers/net/ethernet/cadence/macb_main.c +0 -4
-                               if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
-                                       /* skb now belongs to timestamp buffer
-                                        * and will be removed later
-                                        */

I think the above does the same thing as if CONFIG_MACB_USE_HWSTAMP is undefined regarding cleanup, so there is no extra cleanup if the gem_ptp_do_txstamp() path isn't taken, but I wasn't sure about the "skb now belongs to the timestamp buffer" if we don't go down that path.

Quoted 3 lines

The path they're taking here seems a bit weird... I suspect the function gem_ptp_do_txstamp is doing something.

Normally the driver should use something like skb_get to obtain a reference to the skb.

Just FYI, this is the historical reason for the skb implementation here:
https://patchwork.kernel.org/patch/9473937/

Regards,
Harini

#4 lore raw
Quoted 39 lines

-----Original Message-----
From: Harini Katakam [mailto:[email protected]]
Sent: Tuesday, March 12, 2019 11:00 PM
To: Keller, Jacob E <[email protected]>
Cc: Paul Thomas <[email protected]>; [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Hi Paul, Jake,

Quoted 11 lines · Jacob E
Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Paul Thomas
Sent: Tuesday, March 12, 2019 1:05 PM
To: [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

On Tue, Mar 12, 2019 at 3:51 PM Paul Thomas <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line

<snip>

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
                        /* First, update TX stats if needed */
                        if (skb) {
drivers/net/ethernet/cadence/macb_main.c +0 -4
-                               if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
-                                       /* skb now belongs to timestamp buffer
-                                        * and will be removed later
-                                        */
Quoted 7 lines
Quoted 5 lines

I think the above does the same thing as if CONFIG_MACB_USE_HWSTAMP is undefined regarding cleanup, so there is no extra cleanup if the gem_ptp_do_txstamp() path isn't taken, but I wasn't sure about the "skb now belongs to the timestamp buffer" if we don't go down that path.

The path they're taking here seems a bit weird... I suspect the function

gem_ptp_do_txstamp is doing something.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Normally the driver should use something like skb_get to obtain a reference to the

skb.

Just FYI, this is the historical reason for the skb implementation here:
https://patchwork.kernel.org/patch/9473937/

Regards,
Harini

I'm not sure I follow that logic, but I obviously haven't dug into what gem_ptp_do_txstamp does, or what calls its making.

Either way, I think this patch is a strict improvement on what was previously happening. It can be someone else's responsibility to change how the skb is handled if they find an issue with it.

Thanks,
Jake

#5 lore raw
In reply to Paul Thomas
Quoted 24 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Paul Thomas
Sent: Tuesday, March 12, 2019 12:51 PM
To: [email protected]
Cc: Paul Thomas <[email protected]>
Subject: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Make sure SKBTX_HW_TSTAMP (i.e. SOF_TIMESTAMPING_TX_HARDWARE) has been enabled for this skb
This is a concept for discussion, more testing is needed.
It does fix the issue where normal socks that aren't expecting a timestamp will not wake
up on select.

---
 drivers/net/ethernet/cadence/macb_main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index ad099fd01b45..b2f184fc1370 100644

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue *queue) · line 902

Quoted 10 lines
drivers/net/ethernet/cadence/macb_main.c +1 -5
@@ -898,11 +898,13 @@ static void macb_tx_interrupt(struct macb_queue *queue)
 
 			/* First, update TX stats if needed */
 			if (skb) {
-				if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
-					/* skb now belongs to timestamp buffer
-					 * and will be removed later
-					 */
-					tx_skb->skb = NULL;
+				if(unlikely(skb_shinfo(skb)->tx_flags &
 SKBTX_HW_TSTAMP)) {

This should be && for logical AND. Technically a bitwise & will likely work, but it's not what you intended.

Thanks,
Jake

Quoted 14 lines
drivers/net/ethernet/cadence/macb_main.c +2 -0
+					if (gem_ptp_do_txstamp(queue, skb, desc)
 == 0) {
+						/* skb now belongs to timestamp

buffer

drivers/net/ethernet/cadence/macb_main.c +4 -0
+						 * and will be removed later
+						 */
+						tx_skb->skb = NULL;
+					}
 				}
 				netdev_vdbg(bp->dev, "skb %u (data %p) TX

complete\n",
macb_tx_ring_wrap(bp, tail),
--
2.17.1

#6 lore raw
Quoted 47 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Keller, Jacob E
Sent: Tuesday, March 12, 2019 2:35 PM
To: Paul Thomas <[email protected]>; [email protected]
Subject: RE: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Quoted 9 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Paul Thomas
Sent: Tuesday, March 12, 2019 12:51 PM
To: [email protected]
Cc: Paul Thomas <[email protected]>
Subject: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Make sure SKBTX_HW_TSTAMP (i.e. SOF_TIMESTAMPING_TX_HARDWARE) has

been

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue

Quoted 15 lines

enabled for this skb
This is a concept for discussion, more testing is needed.
It does fix the issue where normal socks that aren't expecting a timestamp will not wake
up on select.

---
 drivers/net/ethernet/cadence/macb_main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index ad099fd01b45..b2f184fc1370 100644
@@ -898,11 +898,13 @@ static void macb_tx_interrupt(struct macb_queue

*queue)

drivers/net/ethernet/cadence/macb_main.c static void macb_tx_interrupt(struct macb_queue *queue)

Quoted 10 lines
drivers/net/ethernet/cadence/macb_main.c +1 -5
 			/* First, update TX stats if needed */
 			if (skb) {
-				if (gem_ptp_do_txstamp(queue, skb, desc) == 0) {
-					/* skb now belongs to timestamp buffer
-					 * and will be removed later
-					 */
-					tx_skb->skb = NULL;
+				if(unlikely(skb_shinfo(skb)->tx_flags &
 SKBTX_HW_TSTAMP)) {

This should be && for logical AND. Technically a bitwise & will likely work, but it's not what you intended.

Quoted 3 lines

Thanks,
Jake

Sorry, I misread the code.

You have two conditionals inside, and I misread where you were doing the checking of the SKBTX_HW_TSTAMP flag.

I would do the following :

if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

    gem_ptp_do_txstamp(queue, skb, desc)) {

....
}

Rather than have two nested if statements, relying on the short circuiting to exit early.

The patch looks technically correct to me now that I'm reading it properly.

Jake

Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/cadence/macb_main.c +2 -0
+					if (gem_ptp_do_txstamp(queue, skb, desc)
 == 0) {
+						/* skb now belongs to timestamp

buffer

drivers/net/ethernet/cadence/macb_main.c +4 -0
+						 * and will be removed later
+						 */
+						tx_skb->skb = NULL;
+					}
 				}
 				netdev_vdbg(bp->dev, "skb %u (data %p) TX

complete\n",
macb_tx_ring_wrap(bp, tail),
--
2.17.1

#7 lore raw

Hi Jake, thanks for all the help and for looking at this!

Quoted 7 lines

You have two conditionals inside, and I misread where you were doing the checking of the SKBTX_HW_TSTAMP flag.

I would do the following :

if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

    gem_ptp_do_txstamp(queue, skb, desc)) {

I guess I was thinking the call to gem_ptp_do_txstamp() could be avoided in many cases, but either way is fine with me..

Quoted 3 lines

....
}

-Paul

#8 lore raw
Quoted 13 lines

-----Original Message-----
From: Paul Thomas [mailto:[email protected]]
Sent: Tuesday, March 12, 2019 3:05 PM
To: Keller, Jacob E <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Hi Jake, thanks for all the help and for looking at this!

Quoted 2 lines

You have two conditionals inside, and I misread where you were doing the checking

Quoted 8 lines

of the SKBTX_HW_TSTAMP flag.

Quoted 5 lines

I would do the following :

if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

    gem_ptp_do_txstamp(queue, skb, desc)) {

I guess I was thinking the call to gem_ptp_do_txstamp() could be avoided in many cases, but either way is fine with me..

The call will be avoided by virtue of short-curcuit boolean AND. If the first check is false, then the entire section is skipped without evaluating the second condition.

Thanks,
Jake

Quoted 4 lines
Quoted 3 lines

....
}

-Paul

#9 lore raw
Quoted 16 lines · Jacob E
Quoted 16 lines

-----Original Message-----
From: Paul Thomas [mailto:[email protected]]
Sent: Tuesday, March 12, 2019 3:05 PM
To: Keller, Jacob E <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Hi Jake, thanks for all the help and for looking at this!

Quoted 2 lines

You have two conditionals inside, and I misread where you were doing the checking

of the SKBTX_HW_TSTAMP flag.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I would do the following :

if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

    gem_ptp_do_txstamp(queue, skb, desc)) {

I guess I was thinking the call to gem_ptp_do_txstamp() could be avoided in many cases, but either way is fine with me..

The call will be avoided by virtue of short-curcuit boolean AND. If the first check is false, then the entire section is skipped without evaluating the second condition.

Cool! good to know.

-Paul

Quoted 7 lines

Thanks,
Jake

Quoted 4 lines
Quoted 3 lines

....
}

-Paul

#10 lore raw

Hi Paul, Jake,

Quoted 16 lines · Paul Thomas
Quoted 13 lines · Jacob E
Quoted 13 lines

-----Original Message-----
From: Paul Thomas [mailto:[email protected]]
Sent: Tuesday, March 12, 2019 3:05 PM
To: Keller, Jacob E <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Hi Jake, thanks for all the help and for looking at this!

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

You have two conditionals inside, and I misread where you were doing the checking

of the SKBTX_HW_TSTAMP flag.

Quoted 5 lines

I would do the following :

if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

    gem_ptp_do_txstamp(queue, skb, desc)) {

Thanks for looking into this. Shouldn't this be:
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

      (gem_ptp_do_txstamp(queue, skb, desc) == 0)) {

Regards,
Harini

#11 lore raw
Quoted 34 lines

-----Original Message-----
From: Harini Katakam [mailto:[email protected]]
Sent: Tuesday, March 12, 2019 10:40 PM
To: Paul Thomas <[email protected]>
Cc: Keller, Jacob E <[email protected]>; [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Hi Paul, Jake,

Quoted 13 lines · Paul Thomas
Quoted 10 lines · Jacob E
Quoted 10 lines

-----Original Message-----
From: Paul Thomas [mailto:[email protected]]
Sent: Tuesday, March 12, 2019 3:05 PM
To: Keller, Jacob E <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Check for SKBTX_HW_TSTAMP in macb driver

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jake, thanks for all the help and for looking at this!

Quoted 2 lines

You have two conditionals inside, and I misread where you were doing the

checking

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

of the SKBTX_HW_TSTAMP flag.

Quoted 5 lines

I would do the following :

if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

    gem_ptp_do_txstamp(queue, skb, desc)) {
Quoted 6 lines

Thanks for looking into this. Shouldn't this be:
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HWTSTAMP) &&

      (gem_ptp_do_txstamp(queue, skb, desc) == 0)) {

Regards,
Harini

Yes, you're correct, because gem_ptp_do_txstamp doesn't use the "non-zero = error code" pattern.

Thanks,
Jake