Commit f72de02e authored by Kurt Kanzenbach's avatar Kurt Kanzenbach Committed by David S. Miller

ptp: Add generic PTP is_sync() function

PHY drivers such as micrel or dp83640 need to analyze whether a given
skb is a PTP sync message for one step functionality.

In order to avoid code duplication introduce a generic function and
move it to ptp classify.
Signed-off-by: Kurt Kanzenbach's avatarKurt Kanzenbach <kurt@linutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 669b258a
...@@ -126,6 +126,17 @@ static inline u8 ptp_get_msgtype(const struct ptp_header *hdr, ...@@ -126,6 +126,17 @@ static inline u8 ptp_get_msgtype(const struct ptp_header *hdr,
return msgtype; return msgtype;
} }
/**
* ptp_msg_is_sync - Evaluates whether the given skb is a PTP Sync message
* @skb: packet buffer
* @type: type of the packet (see ptp_classify_raw())
*
* This function evaluates whether the given skb is a PTP Sync message.
*
* Return: true if sync message, false otherwise
*/
bool ptp_msg_is_sync(struct sk_buff *skb, unsigned int type);
void __init ptp_classifier_init(void); void __init ptp_classifier_init(void);
#else #else
static inline void ptp_classifier_init(void) static inline void ptp_classifier_init(void)
...@@ -148,5 +159,9 @@ static inline u8 ptp_get_msgtype(const struct ptp_header *hdr, ...@@ -148,5 +159,9 @@ static inline u8 ptp_get_msgtype(const struct ptp_header *hdr,
*/ */
return PTP_MSGTYPE_SYNC; return PTP_MSGTYPE_SYNC;
} }
static inline bool ptp_msg_is_sync(struct sk_buff *skb, unsigned int type)
{
return false;
}
#endif #endif
#endif /* _PTP_CLASSIFY_H_ */ #endif /* _PTP_CLASSIFY_H_ */
...@@ -137,6 +137,18 @@ struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type) ...@@ -137,6 +137,18 @@ struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type)
} }
EXPORT_SYMBOL_GPL(ptp_parse_header); EXPORT_SYMBOL_GPL(ptp_parse_header);
bool ptp_msg_is_sync(struct sk_buff *skb, unsigned int type)
{
struct ptp_header *hdr;
hdr = ptp_parse_header(skb, type);
if (!hdr)
return false;
return ptp_get_msgtype(hdr, type) == PTP_MSGTYPE_SYNC;
}
EXPORT_SYMBOL_GPL(ptp_msg_is_sync);
void __init ptp_classifier_init(void) void __init ptp_classifier_init(void)
{ {
static struct sock_filter ptp_filter[] __initdata = { static struct sock_filter ptp_filter[] __initdata = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment