net: dsa: microchip: ptp: add packet reception timestamping
Rx Timestamping is done through 4 additional bytes in tail tag. Whenever the ptp packet is received, the 4 byte hardware time stamped value is added before 1 byte tail tag. Also, bit 7 in tail tag indicates it as PTP frame. This 4 byte value is extracted from the tail tag and reconstructed to absolute time and assigned to skb hwtstamp. If the packet received in PDelay_Resp, then partial ingress timestamp is subtracted from the correction field. Since user space tools expects to be done in hardware. Signed-off-by: Christian Eggers <ceggers@arri.de> Co-developed-by: Arun Ramadoss <arun.ramadoss@microchip.com> Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
2955762b37
commit
90188fff65
@@ -9,10 +9,31 @@
|
||||
|
||||
#include <net/dsa.h>
|
||||
|
||||
/* All time stamps from the KSZ consist of 2 bits for seconds and 30 bits for
|
||||
* nanoseconds. This is NOT the same as 32 bits for nanoseconds.
|
||||
*/
|
||||
#define KSZ_TSTAMP_SEC_MASK GENMASK(31, 30)
|
||||
#define KSZ_TSTAMP_NSEC_MASK GENMASK(29, 0)
|
||||
|
||||
static inline ktime_t ksz_decode_tstamp(u32 tstamp)
|
||||
{
|
||||
u64 ns = FIELD_GET(KSZ_TSTAMP_SEC_MASK, tstamp) * NSEC_PER_SEC +
|
||||
FIELD_GET(KSZ_TSTAMP_NSEC_MASK, tstamp);
|
||||
|
||||
return ns_to_ktime(ns);
|
||||
}
|
||||
|
||||
struct ksz_tagger_data {
|
||||
void (*hwtstamp_set_state)(struct dsa_switch *ds, bool on);
|
||||
};
|
||||
|
||||
struct ksz_skb_cb {
|
||||
u32 tstamp;
|
||||
};
|
||||
|
||||
#define KSZ_SKB_CB(skb) \
|
||||
((struct ksz_skb_cb *)((skb)->cb))
|
||||
|
||||
static inline struct ksz_tagger_data *
|
||||
ksz_tagger_data(struct dsa_switch *ds)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user