Skip to content

Commit f44f841

Browse files
ikhorndavem330
authored andcommitted
net: ethernet: ti: cpsw: fix sw timestamping for non PTP packets
The cpts can timestmap only ptp packets at this moment, so driver cannot mark every packet as though it's going to be timestamped, only because h/w timestamping for given skb is enabled with SKBTX_HW_TSTAMP. It doesn't allow to use sw timestamping, as result outgoing packet is not timestamped at all if it's not PTP and h/w timestamping is enabled. So, fix it by setting SKBTX_IN_PROGRESS only for PTP packets. Signed-off-by: Ivan Khoronzhuk <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 98fdd85 commit f44f841

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
15981598
{
15991599
struct cpsw_priv *priv = netdev_priv(ndev);
16001600
struct cpsw_common *cpsw = priv->cpsw;
1601+
struct cpts *cpts = cpsw->cpts;
16011602
struct netdev_queue *txq;
16021603
struct cpdma_chan *txch;
16031604
int ret, q_idx;
@@ -1609,7 +1610,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
16091610
}
16101611

16111612
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
1612-
cpts_is_tx_enabled(cpsw->cpts))
1613+
cpts_is_tx_enabled(cpts) && cpts_can_timestamp(cpts, skb))
16131614
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
16141615

16151616
q_idx = skb_get_queue_mapping(skb);

drivers/net/ethernet/ti/cpts.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/of.h>
3131
#include <linux/ptp_clock_kernel.h>
3232
#include <linux/skbuff.h>
33+
#include <linux/ptp_classify.h>
3334
#include <linux/timecounter.h>
3435

3536
struct cpsw_cpts {
@@ -155,6 +156,16 @@ static inline bool cpts_is_tx_enabled(struct cpts *cpts)
155156
return !!cpts->tx_enable;
156157
}
157158

159+
static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb)
160+
{
161+
unsigned int class = ptp_classify_raw(skb);
162+
163+
if (class == PTP_CLASS_NONE)
164+
return false;
165+
166+
return true;
167+
}
168+
158169
#else
159170
struct cpts;
160171

@@ -203,6 +214,11 @@ static inline bool cpts_is_tx_enabled(struct cpts *cpts)
203214
{
204215
return false;
205216
}
217+
218+
static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb)
219+
{
220+
return false;
221+
}
206222
#endif
207223

208224

0 commit comments

Comments
 (0)