Skip to content

Commit 869684a

Browse files
committed
Merge branch 'net-fix-sw-timestamping'
Ivan Khoronzhuk says: ==================== net: fix sw timestamping for non PTP packets This series contains several corrections connected with timestamping for cpsw and netcp drivers based on same cpts module. Based on net/next ==================== Reviewed-by: Grygorii Strashko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents bf24e13 + 0ccf59b commit 869684a

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ static inline int cpsw_tx_packet_submit(struct cpsw_priv *priv,
12361236
{
12371237
struct cpsw_common *cpsw = priv->cpsw;
12381238

1239+
skb_tx_timestamp(skb);
12391240
return cpdma_chan_submit(txch, skb, skb->data, skb->len,
12401241
priv->emac_port + cpsw->data.dual_emac);
12411242
}
@@ -1597,6 +1598,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
15971598
{
15981599
struct cpsw_priv *priv = netdev_priv(ndev);
15991600
struct cpsw_common *cpsw = priv->cpsw;
1601+
struct cpts *cpts = cpsw->cpts;
16001602
struct netdev_queue *txq;
16011603
struct cpdma_chan *txch;
16021604
int ret, q_idx;
@@ -1608,11 +1610,9 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
16081610
}
16091611

16101612
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
1611-
cpts_is_tx_enabled(cpsw->cpts))
1613+
cpts_is_tx_enabled(cpts) && cpts_can_timestamp(cpts, skb))
16121614
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
16131615

1614-
skb_tx_timestamp(skb);
1615-
16161616
q_idx = skb_get_queue_mapping(skb);
16171617
if (q_idx >= cpsw->tx_ch_num)
16181618
q_idx = q_idx % cpsw->tx_ch_num;

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

drivers/net/ethernet/ti/netcp_ethss.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,24 +2503,8 @@ static bool gbe_need_txtstamp(struct gbe_intf *gbe_intf,
25032503
const struct netcp_packet *p_info)
25042504
{
25052505
struct sk_buff *skb = p_info->skb;
2506-
unsigned int class = ptp_classify_raw(skb);
25072506

2508-
if (class == PTP_CLASS_NONE)
2509-
return false;
2510-
2511-
switch (class) {
2512-
case PTP_CLASS_V1_IPV4:
2513-
case PTP_CLASS_V1_IPV6:
2514-
case PTP_CLASS_V2_IPV4:
2515-
case PTP_CLASS_V2_IPV6:
2516-
case PTP_CLASS_V2_L2:
2517-
case (PTP_CLASS_V2_VLAN | PTP_CLASS_L2):
2518-
case (PTP_CLASS_V2_VLAN | PTP_CLASS_IPV4):
2519-
case (PTP_CLASS_V2_VLAN | PTP_CLASS_IPV6):
2520-
return true;
2521-
}
2522-
2523-
return false;
2507+
return cpts_can_timestamp(gbe_intf->gbe_dev->cpts, skb);
25242508
}
25252509

25262510
static int gbe_txtstamp_mark_pkt(struct gbe_intf *gbe_intf,

0 commit comments

Comments
 (0)