diff options
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 | }; |