1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Microchip switch tag common header
4 * Copyright (C) 2022 Microchip Technology Inc.
7 #ifndef _NET_DSA_KSZ_COMMON_H_
8 #define _NET_DSA_KSZ_COMMON_H_
12 /* All time stamps from the KSZ consist of 2 bits for seconds and 30 bits for
13 * nanoseconds. This is NOT the same as 32 bits for nanoseconds.
15 #define KSZ_TSTAMP_SEC_MASK GENMASK(31, 30)
16 #define KSZ_TSTAMP_NSEC_MASK GENMASK(29, 0)
18 static inline ktime_t ksz_decode_tstamp(u32 tstamp)
20 u64 ns = FIELD_GET(KSZ_TSTAMP_SEC_MASK, tstamp) * NSEC_PER_SEC +
21 FIELD_GET(KSZ_TSTAMP_NSEC_MASK, tstamp);
23 return ns_to_ktime(ns);
26 struct ksz_deferred_xmit_work {
29 struct kthread_work work;
32 struct ksz_tagger_data {
33 void (*xmit_work_fn)(struct kthread_work *work);
34 void (*hwtstamp_set_state)(struct dsa_switch *ds, bool on);
38 struct sk_buff *clone;
39 unsigned int ptp_type;
40 bool update_correction;
44 #define KSZ_SKB_CB(skb) \
45 ((struct ksz_skb_cb *)((skb)->cb))
47 static inline struct ksz_tagger_data *
48 ksz_tagger_data(struct dsa_switch *ds)
50 return ds->tagger_data;
53 #endif /* _NET_DSA_KSZ_COMMON_H_ */