diff options
author | Rayagond Kokatanur <rayagond@vayavyalabs.com> | 2013-03-26 00:43:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-26 12:53:37 -0400 |
commit | 891434b18ec0a21cfa4788695165b74e8d4c0474 (patch) | |
tree | 1b052da23d5f4b86efdf0cf45330bf64958e9b62 /drivers/net/ethernet/stmicro/stmmac/norm_desc.c | |
parent | cf32deec16e4e8d47305bdc638fd108c88e06081 (diff) |
stmmac: add IEEE PTPv1 and PTPv2 support.
This patch enhances the stmmac driver to support IEEE 1588-2002
PTP (Precision Time Protocol) version 1 and IEEE 1588-2008 PPT
version 2.
Precision Time Protocol(PTP),which enables precise synchronization
of clocks in measurement and control systems implemented with
technologies such as network communication,local computing,
& distributed objects.
Both PTPv1 and PTPv2 is selected at run-time using the HW capability
register.
The PTPv1 TimeStamp support can be used on chips that have the normal
descriptor structures and PTPv2 TimeStamp support can be used on chips
that have the Extended descriptors(DES4-5-6-7). All such sanity checks
are done and verified by using HW capability register.
V2: in this version the ethtool support has been included in this patch;
Koptions have been completely removed (previously added to select
PTP and PTPv2). PTPv1 and PTPv2 is now added in a single patch instead of
two patches.
get_timestamp() and get_systemtime() L/H have been combined into single APIs.
Signed-off-by: Rayagond Kokatanur <rayagond@vayavyalabs.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/norm_desc.c')
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c index 47d509435ebb..7cbcea348c3d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c | |||
@@ -219,6 +219,39 @@ static int ndesc_get_rx_frame_len(struct dma_desc *p, int rx_coe_type) | |||
219 | return p->des01.rx.frame_length; | 219 | return p->des01.rx.frame_length; |
220 | } | 220 | } |
221 | 221 | ||
222 | static void ndesc_enable_tx_timestamp(struct dma_desc *p) | ||
223 | { | ||
224 | p->des01.tx.time_stamp_enable = 1; | ||
225 | } | ||
226 | |||
227 | static int ndesc_get_tx_timestamp_status(struct dma_desc *p) | ||
228 | { | ||
229 | return p->des01.tx.time_stamp_status; | ||
230 | } | ||
231 | |||
232 | static u64 ndesc_get_timestamp(void *desc, u32 ats) | ||
233 | { | ||
234 | struct dma_desc *p = (struct dma_desc *)desc; | ||
235 | u64 ns; | ||
236 | |||
237 | ns = p->des2; | ||
238 | /* convert high/sec time stamp value to nanosecond */ | ||
239 | ns += p->des3 * 1000000000ULL; | ||
240 | |||
241 | return ns; | ||
242 | } | ||
243 | |||
244 | static int ndesc_get_rx_timestamp_status(void *desc, u32 ats) | ||
245 | { | ||
246 | struct dma_desc *p = (struct dma_desc *)desc; | ||
247 | |||
248 | if ((p->des2 == 0xffffffff) && (p->des3 == 0xffffffff)) | ||
249 | /* timestamp is corrupted, hence don't store it */ | ||
250 | return 0; | ||
251 | else | ||
252 | return 1; | ||
253 | } | ||
254 | |||
222 | const struct stmmac_desc_ops ndesc_ops = { | 255 | const struct stmmac_desc_ops ndesc_ops = { |
223 | .tx_status = ndesc_get_tx_status, | 256 | .tx_status = ndesc_get_tx_status, |
224 | .rx_status = ndesc_get_rx_status, | 257 | .rx_status = ndesc_get_rx_status, |
@@ -235,4 +268,8 @@ const struct stmmac_desc_ops ndesc_ops = { | |||
235 | .set_tx_owner = ndesc_set_tx_owner, | 268 | .set_tx_owner = ndesc_set_tx_owner, |
236 | .set_rx_owner = ndesc_set_rx_owner, | 269 | .set_rx_owner = ndesc_set_rx_owner, |
237 | .get_rx_frame_len = ndesc_get_rx_frame_len, | 270 | .get_rx_frame_len = ndesc_get_rx_frame_len, |
271 | .enable_tx_timestamp = ndesc_enable_tx_timestamp, | ||
272 | .get_tx_timestamp_status = ndesc_get_tx_timestamp_status, | ||
273 | .get_timestamp = ndesc_get_timestamp, | ||
274 | .get_rx_timestamp_status = ndesc_get_rx_timestamp_status, | ||
238 | }; | 275 | }; |