aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ptp
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-12 21:07:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-12 21:07:07 -0500
commit6be35c700f742e911ecedd07fcc43d4439922334 (patch)
treeca9f37214d204465fcc2d79c82efd291e357c53c /drivers/ptp
parente37aa63e87bd581f9be5555ed0ba83f5295c92fc (diff)
parent520dfe3a3645257bf83660f672c47f8558f3d4c4 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David Miller: 1) Allow to dump, monitor, and change the bridge multicast database using netlink. From Cong Wang. 2) RFC 5961 TCP blind data injection attack mitigation, from Eric Dumazet. 3) Networking user namespace support from Eric W. Biederman. 4) tuntap/virtio-net multiqueue support by Jason Wang. 5) Support for checksum offload of encapsulated packets (basically, tunneled traffic can still be checksummed by HW). From Joseph Gasparakis. 6) Allow BPF filter access to VLAN tags, from Eric Dumazet and Daniel Borkmann. 7) Bridge port parameters over netlink and BPDU blocking support from Stephen Hemminger. 8) Improve data access patterns during inet socket demux by rearranging socket layout, from Eric Dumazet. 9) TIPC protocol updates and cleanups from Ying Xue, Paul Gortmaker, and Jon Maloy. 10) Update TCP socket hash sizing to be more in line with current day realities. The existing heurstics were choosen a decade ago. From Eric Dumazet. 11) Fix races, queue bloat, and excessive wakeups in ATM and associated drivers, from Krzysztof Mazur and David Woodhouse. 12) Support DOVE (Distributed Overlay Virtual Ethernet) extensions in VXLAN driver, from David Stevens. 13) Add "oops_only" mode to netconsole, from Amerigo Wang. 14) Support set and query of VEB/VEPA bridge mode via PF_BRIDGE, also allow DCB netlink to work on namespaces other than the initial namespace. From John Fastabend. 15) Support PTP in the Tigon3 driver, from Matt Carlson. 16) tun/vhost zero copy fixes and improvements, plus turn it on by default, from Michael S. Tsirkin. 17) Support per-association statistics in SCTP, from Michele Baldessari. And many, many, driver updates, cleanups, and improvements. Too numerous to mention individually. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1722 commits) net/mlx4_en: Add support for destination MAC in steering rules net/mlx4_en: Use generic etherdevice.h functions. net: ethtool: Add destination MAC address to flow steering API bridge: add support of adding and deleting mdb entries bridge: notify mdb changes via netlink ndisc: Unexport ndisc_{build,send}_skb(). uapi: add missing netconf.h to export list pkt_sched: avoid requeues if possible solos-pci: fix double-free of TX skb in DMA mode bnx2: Fix accidental reversions. bna: Driver Version Updated to 3.1.2.1 bna: Firmware update bna: Add RX State bna: Rx Page Based Allocation bna: TX Intr Coalescing Fix bna: Tx and Rx Optimizations bna: Code Cleanup and Enhancements ath9k: check pdata variable before dereferencing it ath5k: RX timestamp is reported at end of frame ath9k_htc: RX timestamp is reported at end of frame ...
Diffstat (limited to 'drivers/ptp')
-rw-r--r--drivers/ptp/Kconfig19
-rw-r--r--drivers/ptp/ptp_chardev.c61
2 files changed, 64 insertions, 16 deletions
diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index ffdf712f9a67..1ea6f1dbbedd 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -4,13 +4,9 @@
4 4
5menu "PTP clock support" 5menu "PTP clock support"
6 6
7comment "Enable Device Drivers -> PPS to see the PTP clock options."
8 depends on PPS=n
9
10config PTP_1588_CLOCK 7config PTP_1588_CLOCK
11 tristate "PTP clock support" 8 tristate "PTP clock support"
12 depends on EXPERIMENTAL 9 select PPS
13 depends on PPS
14 help 10 help
15 The IEEE 1588 standard defines a method to precisely 11 The IEEE 1588 standard defines a method to precisely
16 synchronize distributed clocks over Ethernet networks. The 12 synchronize distributed clocks over Ethernet networks. The
@@ -29,8 +25,9 @@ config PTP_1588_CLOCK
29 25
30config PTP_1588_CLOCK_GIANFAR 26config PTP_1588_CLOCK_GIANFAR
31 tristate "Freescale eTSEC as PTP clock" 27 tristate "Freescale eTSEC as PTP clock"
32 depends on PTP_1588_CLOCK
33 depends on GIANFAR 28 depends on GIANFAR
29 select PTP_1588_CLOCK
30 default y
34 help 31 help
35 This driver adds support for using the eTSEC as a PTP 32 This driver adds support for using the eTSEC as a PTP
36 clock. This clock is only useful if your PTP programs are 33 clock. This clock is only useful if your PTP programs are
@@ -42,8 +39,9 @@ config PTP_1588_CLOCK_GIANFAR
42 39
43config PTP_1588_CLOCK_IXP46X 40config PTP_1588_CLOCK_IXP46X
44 tristate "Intel IXP46x as PTP clock" 41 tristate "Intel IXP46x as PTP clock"
45 depends on PTP_1588_CLOCK
46 depends on IXP4XX_ETH 42 depends on IXP4XX_ETH
43 select PTP_1588_CLOCK
44 default y
47 help 45 help
48 This driver adds support for using the IXP46X as a PTP 46 This driver adds support for using the IXP46X as a PTP
49 clock. This clock is only useful if your PTP programs are 47 clock. This clock is only useful if your PTP programs are
@@ -54,13 +52,13 @@ config PTP_1588_CLOCK_IXP46X
54 will be called ptp_ixp46x. 52 will be called ptp_ixp46x.
55 53
56comment "Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks." 54comment "Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks."
57 depends on PTP_1588_CLOCK && (PHYLIB=n || NETWORK_PHY_TIMESTAMPING=n) 55 depends on PHYLIB=n || NETWORK_PHY_TIMESTAMPING=n
58 56
59config DP83640_PHY 57config DP83640_PHY
60 tristate "Driver for the National Semiconductor DP83640 PHYTER" 58 tristate "Driver for the National Semiconductor DP83640 PHYTER"
61 depends on PTP_1588_CLOCK
62 depends on NETWORK_PHY_TIMESTAMPING 59 depends on NETWORK_PHY_TIMESTAMPING
63 depends on PHYLIB 60 depends on PHYLIB
61 select PTP_1588_CLOCK
64 ---help--- 62 ---help---
65 Supports the DP83640 PHYTER with IEEE 1588 features. 63 Supports the DP83640 PHYTER with IEEE 1588 features.
66 64
@@ -74,8 +72,7 @@ config DP83640_PHY
74 72
75config PTP_1588_CLOCK_PCH 73config PTP_1588_CLOCK_PCH
76 tristate "Intel PCH EG20T as PTP clock" 74 tristate "Intel PCH EG20T as PTP clock"
77 depends on PTP_1588_CLOCK 75 select PTP_1588_CLOCK
78 depends on PCH_GBE
79 help 76 help
80 This driver adds support for using the PCH EG20T as a PTP 77 This driver adds support for using the PCH EG20T as a PTP
81 clock. The hardware supports time stamping of PTP packets 78 clock. The hardware supports time stamping of PTP packets
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index e7f301da2902..34a0c607318e 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -21,6 +21,7 @@
21#include <linux/posix-clock.h> 21#include <linux/posix-clock.h>
22#include <linux/poll.h> 22#include <linux/poll.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h>
24 25
25#include "ptp_private.h" 26#include "ptp_private.h"
26 27
@@ -33,9 +34,13 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
33{ 34{
34 struct ptp_clock_caps caps; 35 struct ptp_clock_caps caps;
35 struct ptp_clock_request req; 36 struct ptp_clock_request req;
37 struct ptp_sys_offset *sysoff = NULL;
36 struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); 38 struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
37 struct ptp_clock_info *ops = ptp->info; 39 struct ptp_clock_info *ops = ptp->info;
40 struct ptp_clock_time *pct;
41 struct timespec ts;
38 int enable, err = 0; 42 int enable, err = 0;
43 unsigned int i;
39 44
40 switch (cmd) { 45 switch (cmd) {
41 46
@@ -88,10 +93,45 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
88 err = ops->enable(ops, &req, enable); 93 err = ops->enable(ops, &req, enable);
89 break; 94 break;
90 95
96 case PTP_SYS_OFFSET:
97 sysoff = kmalloc(sizeof(*sysoff), GFP_KERNEL);
98 if (!sysoff) {
99 err = -ENOMEM;
100 break;
101 }
102 if (copy_from_user(sysoff, (void __user *)arg,
103 sizeof(*sysoff))) {
104 err = -EFAULT;
105 break;
106 }
107 if (sysoff->n_samples > PTP_MAX_SAMPLES) {
108 err = -EINVAL;
109 break;
110 }
111 pct = &sysoff->ts[0];
112 for (i = 0; i < sysoff->n_samples; i++) {
113 getnstimeofday(&ts);
114 pct->sec = ts.tv_sec;
115 pct->nsec = ts.tv_nsec;
116 pct++;
117 ptp->info->gettime(ptp->info, &ts);
118 pct->sec = ts.tv_sec;
119 pct->nsec = ts.tv_nsec;
120 pct++;
121 }
122 getnstimeofday(&ts);
123 pct->sec = ts.tv_sec;
124 pct->nsec = ts.tv_nsec;
125 if (copy_to_user((void __user *)arg, sysoff, sizeof(*sysoff)))
126 err = -EFAULT;
127 break;
128
91 default: 129 default:
92 err = -ENOTTY; 130 err = -ENOTTY;
93 break; 131 break;
94 } 132 }
133
134 kfree(sysoff);
95 return err; 135 return err;
96} 136}
97 137
@@ -104,20 +144,23 @@ unsigned int ptp_poll(struct posix_clock *pc, struct file *fp, poll_table *wait)
104 return queue_cnt(&ptp->tsevq) ? POLLIN : 0; 144 return queue_cnt(&ptp->tsevq) ? POLLIN : 0;
105} 145}
106 146
147#define EXTTS_BUFSIZE (PTP_BUF_TIMESTAMPS * sizeof(struct ptp_extts_event))
148
107ssize_t ptp_read(struct posix_clock *pc, 149ssize_t ptp_read(struct posix_clock *pc,
108 uint rdflags, char __user *buf, size_t cnt) 150 uint rdflags, char __user *buf, size_t cnt)
109{ 151{
110 struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); 152 struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
111 struct timestamp_event_queue *queue = &ptp->tsevq; 153 struct timestamp_event_queue *queue = &ptp->tsevq;
112 struct ptp_extts_event event[PTP_BUF_TIMESTAMPS]; 154 struct ptp_extts_event *event;
113 unsigned long flags; 155 unsigned long flags;
114 size_t qcnt, i; 156 size_t qcnt, i;
157 int result;
115 158
116 if (cnt % sizeof(struct ptp_extts_event) != 0) 159 if (cnt % sizeof(struct ptp_extts_event) != 0)
117 return -EINVAL; 160 return -EINVAL;
118 161
119 if (cnt > sizeof(event)) 162 if (cnt > EXTTS_BUFSIZE)
120 cnt = sizeof(event); 163 cnt = EXTTS_BUFSIZE;
121 164
122 cnt = cnt / sizeof(struct ptp_extts_event); 165 cnt = cnt / sizeof(struct ptp_extts_event);
123 166
@@ -135,6 +178,12 @@ ssize_t ptp_read(struct posix_clock *pc,
135 return -ENODEV; 178 return -ENODEV;
136 } 179 }
137 180
181 event = kmalloc(EXTTS_BUFSIZE, GFP_KERNEL);
182 if (!event) {
183 mutex_unlock(&ptp->tsevq_mux);
184 return -ENOMEM;
185 }
186
138 spin_lock_irqsave(&queue->lock, flags); 187 spin_lock_irqsave(&queue->lock, flags);
139 188
140 qcnt = queue_cnt(queue); 189 qcnt = queue_cnt(queue);
@@ -153,8 +202,10 @@ ssize_t ptp_read(struct posix_clock *pc,
153 202
154 mutex_unlock(&ptp->tsevq_mux); 203 mutex_unlock(&ptp->tsevq_mux);
155 204
205 result = cnt;
156 if (copy_to_user(buf, event, cnt)) 206 if (copy_to_user(buf, event, cnt))
157 return -EFAULT; 207 result = -EFAULT;
158 208
159 return cnt; 209 kfree(event);
210 return result;
160} 211}