diff options
Diffstat (limited to 'drivers/net/ethernet/tile/tilegx.c')
-rw-r--r-- | drivers/net/ethernet/tile/tilegx.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c index 0e9fb3301b11..17503da9f7a5 100644 --- a/drivers/net/ethernet/tile/tilegx.c +++ b/drivers/net/ethernet/tile/tilegx.c | |||
@@ -187,10 +187,8 @@ struct tile_net_priv { | |||
187 | int echannel; | 187 | int echannel; |
188 | /* mPIPE instance, 0 or 1. */ | 188 | /* mPIPE instance, 0 or 1. */ |
189 | int instance; | 189 | int instance; |
190 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
191 | /* The timestamp config. */ | 190 | /* The timestamp config. */ |
192 | struct hwtstamp_config stamp_cfg; | 191 | struct hwtstamp_config stamp_cfg; |
193 | #endif | ||
194 | }; | 192 | }; |
195 | 193 | ||
196 | static struct mpipe_data { | 194 | static struct mpipe_data { |
@@ -229,14 +227,12 @@ static struct mpipe_data { | |||
229 | int first_bucket; | 227 | int first_bucket; |
230 | int num_buckets; | 228 | int num_buckets; |
231 | 229 | ||
232 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
233 | /* PTP-specific data. */ | 230 | /* PTP-specific data. */ |
234 | struct ptp_clock *ptp_clock; | 231 | struct ptp_clock *ptp_clock; |
235 | struct ptp_clock_info caps; | 232 | struct ptp_clock_info caps; |
236 | 233 | ||
237 | /* Lock for ptp accessors. */ | 234 | /* Lock for ptp accessors. */ |
238 | struct mutex ptp_lock; | 235 | struct mutex ptp_lock; |
239 | #endif | ||
240 | 236 | ||
241 | } mpipe_data[NR_MPIPE_MAX] = { | 237 | } mpipe_data[NR_MPIPE_MAX] = { |
242 | [0 ... (NR_MPIPE_MAX - 1)] { | 238 | [0 ... (NR_MPIPE_MAX - 1)] { |
@@ -451,20 +447,17 @@ static void tile_net_provide_needed_buffers(void) | |||
451 | static void tile_rx_timestamp(struct tile_net_priv *priv, struct sk_buff *skb, | 447 | static void tile_rx_timestamp(struct tile_net_priv *priv, struct sk_buff *skb, |
452 | gxio_mpipe_idesc_t *idesc) | 448 | gxio_mpipe_idesc_t *idesc) |
453 | { | 449 | { |
454 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
455 | if (unlikely(priv->stamp_cfg.rx_filter != HWTSTAMP_FILTER_NONE)) { | 450 | if (unlikely(priv->stamp_cfg.rx_filter != HWTSTAMP_FILTER_NONE)) { |
456 | struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); | 451 | struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); |
457 | memset(shhwtstamps, 0, sizeof(*shhwtstamps)); | 452 | memset(shhwtstamps, 0, sizeof(*shhwtstamps)); |
458 | shhwtstamps->hwtstamp = ktime_set(idesc->time_stamp_sec, | 453 | shhwtstamps->hwtstamp = ktime_set(idesc->time_stamp_sec, |
459 | idesc->time_stamp_ns); | 454 | idesc->time_stamp_ns); |
460 | } | 455 | } |
461 | #endif | ||
462 | } | 456 | } |
463 | 457 | ||
464 | /* Get TX timestamp, and store it in the skb. */ | 458 | /* Get TX timestamp, and store it in the skb. */ |
465 | static void tile_tx_timestamp(struct sk_buff *skb, int instance) | 459 | static void tile_tx_timestamp(struct sk_buff *skb, int instance) |
466 | { | 460 | { |
467 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
468 | struct skb_shared_info *shtx = skb_shinfo(skb); | 461 | struct skb_shared_info *shtx = skb_shinfo(skb); |
469 | if (unlikely((shtx->tx_flags & SKBTX_HW_TSTAMP) != 0)) { | 462 | if (unlikely((shtx->tx_flags & SKBTX_HW_TSTAMP) != 0)) { |
470 | struct mpipe_data *md = &mpipe_data[instance]; | 463 | struct mpipe_data *md = &mpipe_data[instance]; |
@@ -477,14 +470,11 @@ static void tile_tx_timestamp(struct sk_buff *skb, int instance) | |||
477 | shhwtstamps.hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec); | 470 | shhwtstamps.hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec); |
478 | skb_tstamp_tx(skb, &shhwtstamps); | 471 | skb_tstamp_tx(skb, &shhwtstamps); |
479 | } | 472 | } |
480 | #endif | ||
481 | } | 473 | } |
482 | 474 | ||
483 | /* Use ioctl() to enable or disable TX or RX timestamping. */ | 475 | /* Use ioctl() to enable or disable TX or RX timestamping. */ |
484 | static int tile_hwtstamp_ioctl(struct net_device *dev, struct ifreq *rq, | 476 | static int tile_hwtstamp_set(struct net_device *dev, struct ifreq *rq) |
485 | int cmd) | ||
486 | { | 477 | { |
487 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
488 | struct hwtstamp_config config; | 478 | struct hwtstamp_config config; |
489 | struct tile_net_priv *priv = netdev_priv(dev); | 479 | struct tile_net_priv *priv = netdev_priv(dev); |
490 | 480 | ||
@@ -530,9 +520,17 @@ static int tile_hwtstamp_ioctl(struct net_device *dev, struct ifreq *rq, | |||
530 | 520 | ||
531 | priv->stamp_cfg = config; | 521 | priv->stamp_cfg = config; |
532 | return 0; | 522 | return 0; |
533 | #else | 523 | } |
534 | return -EOPNOTSUPP; | 524 | |
535 | #endif | 525 | static int tile_hwtstamp_get(struct net_device *dev, struct ifreq *rq) |
526 | { | ||
527 | struct tile_net_priv *priv = netdev_priv(dev); | ||
528 | |||
529 | if (copy_to_user(rq->ifr_data, &priv->stamp_cfg, | ||
530 | sizeof(priv->stamp_cfg))) | ||
531 | return -EFAULT; | ||
532 | |||
533 | return 0; | ||
536 | } | 534 | } |
537 | 535 | ||
538 | static inline bool filter_packet(struct net_device *dev, void *buf) | 536 | static inline bool filter_packet(struct net_device *dev, void *buf) |
@@ -814,8 +812,6 @@ static enum hrtimer_restart tile_net_handle_egress_timer(struct hrtimer *t) | |||
814 | return HRTIMER_NORESTART; | 812 | return HRTIMER_NORESTART; |
815 | } | 813 | } |
816 | 814 | ||
817 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
818 | |||
819 | /* PTP clock operations. */ | 815 | /* PTP clock operations. */ |
820 | 816 | ||
821 | static int ptp_mpipe_adjfreq(struct ptp_clock_info *ptp, s32 ppb) | 817 | static int ptp_mpipe_adjfreq(struct ptp_clock_info *ptp, s32 ppb) |
@@ -882,12 +878,9 @@ static struct ptp_clock_info ptp_mpipe_caps = { | |||
882 | .enable = ptp_mpipe_enable, | 878 | .enable = ptp_mpipe_enable, |
883 | }; | 879 | }; |
884 | 880 | ||
885 | #endif /* CONFIG_PTP_1588_CLOCK_TILEGX */ | ||
886 | |||
887 | /* Sync mPIPE's timestamp up with Linux system time and register PTP clock. */ | 881 | /* Sync mPIPE's timestamp up with Linux system time and register PTP clock. */ |
888 | static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md) | 882 | static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md) |
889 | { | 883 | { |
890 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
891 | struct timespec ts; | 884 | struct timespec ts; |
892 | 885 | ||
893 | getnstimeofday(&ts); | 886 | getnstimeofday(&ts); |
@@ -899,16 +892,13 @@ static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md) | |||
899 | if (IS_ERR(md->ptp_clock)) | 892 | if (IS_ERR(md->ptp_clock)) |
900 | netdev_err(dev, "ptp_clock_register failed %ld\n", | 893 | netdev_err(dev, "ptp_clock_register failed %ld\n", |
901 | PTR_ERR(md->ptp_clock)); | 894 | PTR_ERR(md->ptp_clock)); |
902 | #endif | ||
903 | } | 895 | } |
904 | 896 | ||
905 | /* Initialize PTP fields in a new device. */ | 897 | /* Initialize PTP fields in a new device. */ |
906 | static void init_ptp_dev(struct tile_net_priv *priv) | 898 | static void init_ptp_dev(struct tile_net_priv *priv) |
907 | { | 899 | { |
908 | #ifdef CONFIG_PTP_1588_CLOCK_TILEGX | ||
909 | priv->stamp_cfg.rx_filter = HWTSTAMP_FILTER_NONE; | 900 | priv->stamp_cfg.rx_filter = HWTSTAMP_FILTER_NONE; |
910 | priv->stamp_cfg.tx_type = HWTSTAMP_TX_OFF; | 901 | priv->stamp_cfg.tx_type = HWTSTAMP_TX_OFF; |
911 | #endif | ||
912 | } | 902 | } |
913 | 903 | ||
914 | /* Helper functions for "tile_net_update()". */ | 904 | /* Helper functions for "tile_net_update()". */ |
@@ -2081,7 +2071,7 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev) | |||
2081 | 2071 | ||
2082 | /* Return subqueue id on this core (one per core). */ | 2072 | /* Return subqueue id on this core (one per core). */ |
2083 | static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb, | 2073 | static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb, |
2084 | void *accel_priv) | 2074 | void *accel_priv, select_queue_fallback_t fallback) |
2085 | { | 2075 | { |
2086 | return smp_processor_id(); | 2076 | return smp_processor_id(); |
2087 | } | 2077 | } |
@@ -2099,7 +2089,9 @@ static void tile_net_tx_timeout(struct net_device *dev) | |||
2099 | static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 2089 | static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
2100 | { | 2090 | { |
2101 | if (cmd == SIOCSHWTSTAMP) | 2091 | if (cmd == SIOCSHWTSTAMP) |
2102 | return tile_hwtstamp_ioctl(dev, rq, cmd); | 2092 | return tile_hwtstamp_set(dev, rq); |
2093 | if (cmd == SIOCGHWTSTAMP) | ||
2094 | return tile_hwtstamp_get(dev, rq); | ||
2103 | 2095 | ||
2104 | return -EOPNOTSUPP; | 2096 | return -EOPNOTSUPP; |
2105 | } | 2097 | } |