From: Ben Hutchings <bhutchings@solarflare.com>
To: Mugunthan V N <mugunthanvnm@ti.com>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH 4/6] ptp: add api to get ptp seq id and event type from skb
Date: Wed, 17 Oct 2012 00:10:30 +0100 [thread overview]
Message-ID: <1350429030.2649.49.camel@bwh-desktop.uk.solarflarecom.com> (raw)
In-Reply-To: <1350427518-7230-5-git-send-email-mugunthanvnm@ti.com>
On Wed, 2012-10-17 at 04:15 +0530, Mugunthan V N wrote:
> Cc: Richard Cochran <richardcochran@gmail.com>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
> include/linux/ptp_classify.h | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/ptp_classify.h b/include/linux/ptp_classify.h
> index 1dc420b..9b3b55b 100644
> --- a/include/linux/ptp_classify.h
> +++ b/include/linux/ptp_classify.h
> @@ -137,4 +137,46 @@ static inline int ptp_filter_init(struct sock_filter *f, int len)
> {OP_RETA, 0, 0, 0 }, /* */ \
> /*L6x*/ {OP_RETK, 0, 0, PTP_CLASS_NONE },
>
> +static inline int ptp_get_skb_event(struct sk_buff *skb, u32 ptp_class,
> + u16 *evt_seqid, u8 *evt_msgtype)
> +{
> + u16 *seqid;
> + unsigned int offset;
> + u8 *msgtype, *data = skb->data;
> +
> + switch (ptp_class) {
> + case PTP_CLASS_V1_IPV4:
> + case PTP_CLASS_V2_IPV4:
> + offset = ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN;
> + break;
> + case PTP_CLASS_V1_IPV6:
> + case PTP_CLASS_V2_IPV6:
> + offset = OFF_PTP6;
> + break;
> + case PTP_CLASS_V2_L2:
> + offset = ETH_HLEN;
> + break;
> + case PTP_CLASS_V2_VLAN:
> + offset = ETH_HLEN + VLAN_HLEN;
> + break;
> + default:
> + return 0;
> + }
> +
> + if (skb->len + ETH_HLEN < offset + OFF_PTP_SEQUENCE_ID + sizeof(*seqid))
> + return 0;
> +
> + if (unlikely(ptp_class & PTP_CLASS_V1))
> + msgtype = data + offset + OFF_PTP_CONTROL;
> + else
> + msgtype = data + offset;
> +
> + seqid = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
This assumes the skb is linear. Use skb_header_pointer() to allow for
fragmented skbs.
Ben.
> + *evt_seqid = ntohs(*seqid);
> + *evt_msgtype = *msgtype & 0xf;
> +
> + return 0;
> +}
> +
> #endif
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2012-10-16 23:10 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-16 22:45 [PATCH 0/6] Add CPTS PTP driver support Mugunthan V N
2012-10-16 22:45 ` [PATCH 1/6] drivers: net: ethernet: cpsw: add support for CPSW register offset changes in different IP version Mugunthan V N
2012-10-18 2:45 ` Richard Cochran
2012-10-22 10:39 ` N, Mugunthan V
2012-10-22 11:23 ` Richard Cochran
2012-10-22 12:19 ` N, Mugunthan V
2012-10-22 12:25 ` Richard Cochran
2012-10-16 22:45 ` [PATCH 2/6] drivers: net: ethernet: davinci_cpdma: add clear api for statistics interrupt Mugunthan V N
2012-10-18 2:48 ` Richard Cochran
2012-10-22 10:42 ` N, Mugunthan V
2012-10-22 11:31 ` Richard Cochran
2012-10-16 22:45 ` [PATCH 3/6] drivers: net: ethernet: cpsw: add multicast address to ALE table Mugunthan V N
2012-10-18 2:49 ` Richard Cochran
2012-10-21 11:26 ` Richard Cochran
2012-10-22 10:46 ` N, Mugunthan V
2012-10-16 22:45 ` [PATCH 4/6] ptp: add api to get ptp seq id and event type from skb Mugunthan V N
2012-10-16 23:10 ` Ben Hutchings [this message]
2012-10-17 13:48 ` N, Mugunthan V
2012-10-18 2:55 ` Richard Cochran
2012-10-22 10:46 ` N, Mugunthan V
2012-10-22 11:36 ` Richard Cochran
2012-10-22 12:32 ` N, Mugunthan V
2012-10-22 12:37 ` Richard Cochran
2012-10-16 22:45 ` [PATCH 5/6] drivers: net: ethernet: cpts: implement cpts hardware clock Mugunthan V N
2012-10-20 13:43 ` Richard Cochran
2012-10-22 10:55 ` N, Mugunthan V
2012-10-22 11:41 ` Richard Cochran
2012-10-22 11:44 ` Richard Cochran
2012-10-22 12:38 ` N, Mugunthan V
2012-10-22 11:46 ` Richard Cochran
2012-10-22 12:42 ` N, Mugunthan V
2012-10-16 22:45 ` [PATCH 6/6] drivers: net: ethernet: cpsw: implement timestamping capabilities in cpsw Mugunthan V N
2012-10-21 18:11 ` Richard Cochran
2012-10-21 18:46 ` [PATCH 0/6] Add CPTS PTP driver support Richard Cochran
2012-10-22 10:51 ` N, Mugunthan V
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350429030.2649.49.camel@bwh-desktop.uk.solarflarecom.com \
--to=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=mugunthanvnm@ti.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.