Skip to content
Snippets Groups Projects
Commit 036c508b authored by Kurt Kanzenbach's avatar Kurt Kanzenbach Committed by David S. Miller
Browse files

ptp: Add generic ptp message type function


The message type is located at different offsets within the ptp header depending
on the ptp version (v1 or v2). Therefore, drivers which also deal with ptp v1
have some code for it.

Extract this into a helper function for drivers to be used.

Signed-off-by: default avatarKurt Kanzenbach <kurt@linutronix.de>
Reviewed-by: default avatarRichard Cochran <richardcochran@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bdfbb63c
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,31 @@ unsigned int ptp_classify_raw(const struct sk_buff *skb);
*/
struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type);
/**
* ptp_get_msgtype - Extract ptp message type from given header
* @hdr: ptp header
* @type: type of the packet (see ptp_classify_raw())
*
* This function returns the message type for a given ptp header. It takes care
* of the different ptp header versions (v1 or v2).
*
* Return: The message type
*/
static inline u8 ptp_get_msgtype(const struct ptp_header *hdr,
unsigned int type)
{
u8 msgtype;
if (unlikely(type & PTP_CLASS_V1)) {
/* msg type is located at the control field for ptp v1 */
msgtype = hdr->control;
} else {
msgtype = hdr->tsmt & 0x0f;
}
return msgtype;
}
void __init ptp_classifier_init(void);
#else
static inline void ptp_classifier_init(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment