aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2013-12-19 14:21:14 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-27 12:44:55 -0500
commit69317a5351022e1b207131e7cccc78f261ace9ac (patch)
treec6741a0209ddee000b4afacd8302df92625711fd
parentfcf93a0a2f9d317c0bffc430ddf8950041d13265 (diff)
tile_net: Always enable PTP clock support on TILE-Gx
All other net drivers with PTP support enable it unconditionally. Make tile_net consistent with this. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Acked-by: Chris Metcalf <cmetcalf@tilera.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/tile/Kconfig12
-rw-r--r--drivers/net/ethernet/tile/tilegx.c24
2 files changed, 1 insertions, 35 deletions
diff --git a/drivers/net/ethernet/tile/Kconfig b/drivers/net/ethernet/tile/Kconfig
index 4083ba8839e1..f59a6c265331 100644
--- a/drivers/net/ethernet/tile/Kconfig
+++ b/drivers/net/ethernet/tile/Kconfig
@@ -9,20 +9,10 @@ config TILE_NET
9 select CRC32 9 select CRC32
10 select TILE_GXIO_MPIPE if TILEGX 10 select TILE_GXIO_MPIPE if TILEGX
11 select HIGH_RES_TIMERS if TILEGX 11 select HIGH_RES_TIMERS if TILEGX
12 select PTP_1588_CLOCK if TILEGX
12 ---help--- 13 ---help---
13 This is a standard Linux network device driver for the 14 This is a standard Linux network device driver for the
14 on-chip Tilera Gigabit Ethernet and XAUI interfaces. 15 on-chip Tilera Gigabit Ethernet and XAUI interfaces.
15 16
16 To compile this driver as a module, choose M here: the module 17 To compile this driver as a module, choose M here: the module
17 will be called tile_net. 18 will be called tile_net.
18
19config PTP_1588_CLOCK_TILEGX
20 tristate "Tilera TILE-Gx mPIPE as PTP clock"
21 select PTP_1588_CLOCK
22 depends on TILE_NET
23 depends on TILEGX
24 ---help---
25 This driver adds support for using the mPIPE as a PTP
26 clock. This clock is only useful if your PTP programs are
27 getting hardware time stamps on the PTP Ethernet packets
28 using the SO_TIMESTAMPING API.
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 858f9a786b8c..570495be77f3 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
196static struct mpipe_data { 194static 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)
451static void tile_rx_timestamp(struct tile_net_priv *priv, struct sk_buff *skb, 447static 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. */
465static void tile_tx_timestamp(struct sk_buff *skb, int instance) 459static 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,13 +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. */
484static int tile_hwtstamp_set(struct net_device *dev, struct ifreq *rq) 476static int tile_hwtstamp_set(struct net_device *dev, struct ifreq *rq)
485{ 477{
486#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
487 struct hwtstamp_config config; 478 struct hwtstamp_config config;
488 struct tile_net_priv *priv = netdev_priv(dev); 479 struct tile_net_priv *priv = netdev_priv(dev);
489 480
@@ -529,14 +520,10 @@ static int tile_hwtstamp_set(struct net_device *dev, struct ifreq *rq)
529 520
530 priv->stamp_cfg = config; 521 priv->stamp_cfg = config;
531 return 0; 522 return 0;
532#else
533 return -EOPNOTSUPP;
534#endif
535} 523}
536 524
537static int tile_hwtstamp_get(struct net_device *dev, struct ifreq *rq) 525static int tile_hwtstamp_get(struct net_device *dev, struct ifreq *rq)
538{ 526{
539#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
540 struct tile_net_priv *priv = netdev_priv(dev); 527 struct tile_net_priv *priv = netdev_priv(dev);
541 528
542 if (copy_to_user(rq->ifr_data, &priv->stamp_cfg, 529 if (copy_to_user(rq->ifr_data, &priv->stamp_cfg,
@@ -544,9 +531,6 @@ static int tile_hwtstamp_get(struct net_device *dev, struct ifreq *rq)
544 return -EFAULT; 531 return -EFAULT;
545 532
546 return 0; 533 return 0;
547#else
548 return -EOPNOTSUPP;
549#endif
550} 534}
551 535
552static inline bool filter_packet(struct net_device *dev, void *buf) 536static inline bool filter_packet(struct net_device *dev, void *buf)
@@ -828,8 +812,6 @@ static enum hrtimer_restart tile_net_handle_egress_timer(struct hrtimer *t)
828 return HRTIMER_NORESTART; 812 return HRTIMER_NORESTART;
829} 813}
830 814
831#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
832
833/* PTP clock operations. */ 815/* PTP clock operations. */
834 816
835static int ptp_mpipe_adjfreq(struct ptp_clock_info *ptp, s32 ppb) 817static int ptp_mpipe_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
@@ -896,12 +878,9 @@ static struct ptp_clock_info ptp_mpipe_caps = {
896 .enable = ptp_mpipe_enable, 878 .enable = ptp_mpipe_enable,
897}; 879};
898 880
899#endif /* CONFIG_PTP_1588_CLOCK_TILEGX */
900
901/* 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. */
902static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md) 882static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md)
903{ 883{
904#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
905 struct timespec ts; 884 struct timespec ts;
906 885
907 getnstimeofday(&ts); 886 getnstimeofday(&ts);
@@ -913,16 +892,13 @@ static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md)
913 if (IS_ERR(md->ptp_clock)) 892 if (IS_ERR(md->ptp_clock))
914 netdev_err(dev, "ptp_clock_register failed %ld\n", 893 netdev_err(dev, "ptp_clock_register failed %ld\n",
915 PTR_ERR(md->ptp_clock)); 894 PTR_ERR(md->ptp_clock));
916#endif
917} 895}
918 896
919/* Initialize PTP fields in a new device. */ 897/* Initialize PTP fields in a new device. */
920static void init_ptp_dev(struct tile_net_priv *priv) 898static void init_ptp_dev(struct tile_net_priv *priv)
921{ 899{
922#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
923 priv->stamp_cfg.rx_filter = HWTSTAMP_FILTER_NONE; 900 priv->stamp_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
924 priv->stamp_cfg.tx_type = HWTSTAMP_TX_OFF; 901 priv->stamp_cfg.tx_type = HWTSTAMP_TX_OFF;
925#endif
926} 902}
927 903
928/* Helper functions for "tile_net_update()". */ 904/* Helper functions for "tile_net_update()". */