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

ethernet: ti: am65-cpts: Use generic helper function

In order to reduce code duplication between ptp drivers, generic helper
functions were introduced. Use them.
Signed-off-by: Kurt Kanzenbach's avatarKurt Kanzenbach <kurt@linutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7b2b28c6
...@@ -748,42 +748,23 @@ EXPORT_SYMBOL_GPL(am65_cpts_rx_enable); ...@@ -748,42 +748,23 @@ EXPORT_SYMBOL_GPL(am65_cpts_rx_enable);
static int am65_skb_get_mtype_seqid(struct sk_buff *skb, u32 *mtype_seqid) static int am65_skb_get_mtype_seqid(struct sk_buff *skb, u32 *mtype_seqid)
{ {
unsigned int ptp_class = ptp_classify_raw(skb); unsigned int ptp_class = ptp_classify_raw(skb);
u8 *msgtype, *data = skb->data; struct ptp_header *hdr;
unsigned int offset = 0; u8 msgtype;
__be16 *seqid; u16 seqid;
if (ptp_class == PTP_CLASS_NONE) if (ptp_class == PTP_CLASS_NONE)
return 0; return 0;
if (ptp_class & PTP_CLASS_VLAN) hdr = ptp_parse_header(skb, ptp_class);
offset += VLAN_HLEN; if (!hdr)
switch (ptp_class & PTP_CLASS_PMASK) {
case PTP_CLASS_IPV4:
offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
break;
case PTP_CLASS_IPV6:
offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
break;
case PTP_CLASS_L2:
offset += ETH_HLEN;
break;
default:
return 0;
}
if (skb->len + ETH_HLEN < offset + OFF_PTP_SEQUENCE_ID + sizeof(*seqid))
return 0; return 0;
if (unlikely(ptp_class & PTP_CLASS_V1)) msgtype = ptp_get_msgtype(hdr, ptp_class);
msgtype = data + offset + OFF_PTP_CONTROL; seqid = ntohs(hdr->sequence_id);
else
msgtype = data + offset;
seqid = (__be16 *)(data + offset + OFF_PTP_SEQUENCE_ID); *mtype_seqid = (msgtype << AM65_CPTS_EVENT_1_MESSAGE_TYPE_SHIFT) &
*mtype_seqid = (*msgtype << AM65_CPTS_EVENT_1_MESSAGE_TYPE_SHIFT) &
AM65_CPTS_EVENT_1_MESSAGE_TYPE_MASK; AM65_CPTS_EVENT_1_MESSAGE_TYPE_MASK;
*mtype_seqid |= (ntohs(*seqid) & AM65_CPTS_EVENT_1_SEQUENCE_ID_MASK); *mtype_seqid |= (seqid & AM65_CPTS_EVENT_1_SEQUENCE_ID_MASK);
return 1; return 1;
} }
......
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