diff options
| author | David S. Miller <davem@davemloft.net> | 2017-06-29 12:28:57 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2017-06-29 12:28:57 -0400 |
| commit | 869684a70d69e69352eb08fdd22dfd3315637dcd (patch) | |
| tree | 5ccd9f74a277a528e71f36118b20baeb570df368 | |
| parent | bf24e136a32eb513195b6e0148e5a70131a95494 (diff) | |
| parent | 0ccf59ba07377201f3d4347b7c6443f60bd9af93 (diff) | |
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 <grygorii.strashko@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/ti/cpsw.c | 6 | ||||
| -rw-r--r-- | drivers/net/ethernet/ti/cpts.h | 16 | ||||
| -rw-r--r-- | drivers/net/ethernet/ti/netcp_ethss.c | 18 |
3 files changed, 20 insertions, 20 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index b7a0f5eeab62..1850e348f555 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
| @@ -1236,6 +1236,7 @@ static inline int cpsw_tx_packet_submit(struct cpsw_priv *priv, | |||
| 1236 | { | 1236 | { |
| 1237 | struct cpsw_common *cpsw = priv->cpsw; | 1237 | struct cpsw_common *cpsw = priv->cpsw; |
| 1238 | 1238 | ||
| 1239 | skb_tx_timestamp(skb); | ||
| 1239 | return cpdma_chan_submit(txch, skb, skb->data, skb->len, | 1240 | return cpdma_chan_submit(txch, skb, skb->data, skb->len, |
| 1240 | priv->emac_port + cpsw->data.dual_emac); | 1241 | priv->emac_port + cpsw->data.dual_emac); |
| 1241 | } | 1242 | } |
| @@ -1597,6 +1598,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb, | |||
| 1597 | { | 1598 | { |
| 1598 | struct cpsw_priv *priv = netdev_priv(ndev); | 1599 | struct cpsw_priv *priv = netdev_priv(ndev); |
| 1599 | struct cpsw_common *cpsw = priv->cpsw; | 1600 | struct cpsw_common *cpsw = priv->cpsw; |
| 1601 | struct cpts *cpts = cpsw->cpts; | ||
| 1600 | struct netdev_queue *txq; | 1602 | struct netdev_queue *txq; |
| 1601 | struct cpdma_chan *txch; | 1603 | struct cpdma_chan *txch; |
| 1602 | int ret, q_idx; | 1604 | int ret, q_idx; |
| @@ -1608,11 +1610,9 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb, | |||
| 1608 | } | 1610 | } |
| 1609 | 1611 | ||
| 1610 | if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && | 1612 | 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)) |
| 1612 | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; | 1614 | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; |
| 1613 | 1615 | ||
| 1614 | skb_tx_timestamp(skb); | ||
| 1615 | |||
| 1616 | q_idx = skb_get_queue_mapping(skb); | 1616 | q_idx = skb_get_queue_mapping(skb); |
| 1617 | if (q_idx >= cpsw->tx_ch_num) | 1617 | if (q_idx >= cpsw->tx_ch_num) |
| 1618 | q_idx = q_idx % cpsw->tx_ch_num; | 1618 | q_idx = q_idx % cpsw->tx_ch_num; |
diff --git a/drivers/net/ethernet/ti/cpts.h b/drivers/net/ethernet/ti/cpts.h index c96eca2b1b46..01ea82ba9cdc 100644 --- a/drivers/net/ethernet/ti/cpts.h +++ b/drivers/net/ethernet/ti/cpts.h | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/of.h> | 30 | #include <linux/of.h> |
| 31 | #include <linux/ptp_clock_kernel.h> | 31 | #include <linux/ptp_clock_kernel.h> |
| 32 | #include <linux/skbuff.h> | 32 | #include <linux/skbuff.h> |
| 33 | #include <linux/ptp_classify.h> | ||
| 33 | #include <linux/timecounter.h> | 34 | #include <linux/timecounter.h> |
| 34 | 35 | ||
| 35 | struct cpsw_cpts { | 36 | struct cpsw_cpts { |
| @@ -155,6 +156,16 @@ static inline bool cpts_is_tx_enabled(struct cpts *cpts) | |||
| 155 | return !!cpts->tx_enable; | 156 | return !!cpts->tx_enable; |
| 156 | } | 157 | } |
| 157 | 158 | ||
| 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 | |||
| 158 | #else | 169 | #else |
| 159 | struct cpts; | 170 | struct cpts; |
| 160 | 171 | ||
| @@ -203,6 +214,11 @@ static inline bool cpts_is_tx_enabled(struct cpts *cpts) | |||
| 203 | { | 214 | { |
| 204 | return false; | 215 | return false; |
| 205 | } | 216 | } |
| 217 | |||
| 218 | static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb) | ||
| 219 | { | ||
| 220 | return false; | ||
| 221 | } | ||
| 206 | #endif | 222 | #endif |
| 207 | 223 | ||
| 208 | 224 | ||
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c index 0847a8f48cfe..28cb38af1a34 100644 --- a/drivers/net/ethernet/ti/netcp_ethss.c +++ b/drivers/net/ethernet/ti/netcp_ethss.c | |||
| @@ -2503,24 +2503,8 @@ static bool gbe_need_txtstamp(struct gbe_intf *gbe_intf, | |||
| 2503 | const struct netcp_packet *p_info) | 2503 | const struct netcp_packet *p_info) |
| 2504 | { | 2504 | { |
| 2505 | struct sk_buff *skb = p_info->skb; | 2505 | struct sk_buff *skb = p_info->skb; |
| 2506 | unsigned int class = ptp_classify_raw(skb); | ||
| 2507 | 2506 | ||
| 2508 | if (class == PTP_CLASS_NONE) | 2507 | return cpts_can_timestamp(gbe_intf->gbe_dev->cpts, skb); |
| 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; | ||
| 2524 | } | 2508 | } |
| 2525 | 2509 | ||
| 2526 | static int gbe_txtstamp_mark_pkt(struct gbe_intf *gbe_intf, | 2510 | static int gbe_txtstamp_mark_pkt(struct gbe_intf *gbe_intf, |
