netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shradha Shah <sshah@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-net-drivers@solarflare.com>
Subject: [PATCH net-next 02/13] sfc: Cache skb->data in local variable in efx_ptp_rx()
Date: Wed, 12 Feb 2014 18:58:34 +0000	[thread overview]
Message-ID: <52FBC45A.9060809@solarflare.com> (raw)
In-Reply-To: <52FBC3C2.7030103@solarflare.com>

From: Ben Hutchings <bhutchings@solarflare.com>

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Shradha Shah <sshah@solarflare.com>
---
 drivers/net/ethernet/sfc/ptp.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index 52be63d..7d0de50 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -1366,6 +1366,7 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
 	struct efx_ptp_match *match = (struct efx_ptp_match *)skb->cb;
 	u8 *match_data_012, *match_data_345;
 	unsigned int version;
+	u8 *data;
 
 	match->expiry = jiffies + msecs_to_jiffies(PKT_EVENT_LIFETIME_MS);
 
@@ -1374,7 +1375,8 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
 		if (!pskb_may_pull(skb, PTP_V1_MIN_LENGTH)) {
 			return false;
 		}
-		version = ntohs(*(__be16 *)&skb->data[PTP_V1_VERSION_OFFSET]);
+		data = skb->data;
+		version = ntohs(*(__be16 *)&data[PTP_V1_VERSION_OFFSET]);
 		if (version != PTP_VERSION_V1) {
 			return false;
 		}
@@ -1382,13 +1384,14 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
 		/* PTP V1 uses all six bytes of the UUID to match the packet
 		 * to the timestamp
 		 */
-		match_data_012 = skb->data + PTP_V1_UUID_OFFSET;
-		match_data_345 = skb->data + PTP_V1_UUID_OFFSET + 3;
+		match_data_012 = data + PTP_V1_UUID_OFFSET;
+		match_data_345 = data + PTP_V1_UUID_OFFSET + 3;
 	} else {
 		if (!pskb_may_pull(skb, PTP_V2_MIN_LENGTH)) {
 			return false;
 		}
-		version = skb->data[PTP_V2_VERSION_OFFSET];
+		data = skb->data;
+		version = data[PTP_V2_VERSION_OFFSET];
 		if ((version & PTP_VERSION_V2_MASK) != PTP_VERSION_V2) {
 			return false;
 		}
@@ -1400,17 +1403,17 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
 		 * enhanced mode fixes this issue and uses bytes 0-2
 		 * and byte 5-7 of the UUID.
 		 */
-		match_data_345 = skb->data + PTP_V2_UUID_OFFSET + 5;
+		match_data_345 = data + PTP_V2_UUID_OFFSET + 5;
 		if (ptp->mode == MC_CMD_PTP_MODE_V2) {
-			match_data_012 = skb->data + PTP_V2_UUID_OFFSET + 2;
+			match_data_012 = data + PTP_V2_UUID_OFFSET + 2;
 		} else {
-			match_data_012 = skb->data + PTP_V2_UUID_OFFSET + 0;
+			match_data_012 = data + PTP_V2_UUID_OFFSET + 0;
 			BUG_ON(ptp->mode != MC_CMD_PTP_MODE_V2_ENHANCED);
 		}
 	}
 
 	/* Does this packet require timestamping? */
-	if (ntohs(*(__be16 *)&skb->data[PTP_DPORT_OFFSET]) == PTP_EVENT_PORT) {
+	if (ntohs(*(__be16 *)&data[PTP_DPORT_OFFSET]) == PTP_EVENT_PORT) {
 		match->state = PTP_PACKET_STATE_UNMATCHED;
 
 		/* We expect the sequence number to be in the same position in
@@ -1426,8 +1429,8 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
 				   (match_data_345[0] << 24));
 		match->words[1] = (match_data_345[1]         |
 				   (match_data_345[2] << 8)  |
-				   (skb->data[PTP_V1_SEQUENCE_OFFSET +
-					      PTP_V1_SEQUENCE_LENGTH - 1] <<
+				   (data[PTP_V1_SEQUENCE_OFFSET +
+					 PTP_V1_SEQUENCE_LENGTH - 1] <<
 				    16));
 	} else {
 		match->state = PTP_PACKET_STATE_MATCH_UNWANTED;

  parent reply	other threads:[~2014-02-12 18:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12 18:56 [PATCH net-next 00/13] Cleanup patches for the SFC driver Shradha Shah
2014-02-12 18:58 ` [PATCH net-next 01/13] sfc: Removed adhoc scheme to rate limit PTP event queue overflow message Shradha Shah
2014-02-12 18:58 ` Shradha Shah [this message]
2014-02-12 18:58 ` [PATCH net-next 03/13] sfc: Rewrite adjustment of PPS event in a clearer way Shradha Shah
2014-02-12 18:58 ` [PATCH net-next 04/13] sfc: Replace TSOH_OFFSET with the equivalent NET_IP_ALIGN Shradha Shah
2014-02-12 18:59 ` [PATCH net-next 06/13] sfc: Remove unused definitions of EF10 user-mode DMA descriptors Shradha Shah
2014-02-12 18:59 ` [PATCH net-next 07/13] sfc: Correct comment about number of TX queues used on EF10 Shradha Shah
2014-02-12 18:59 ` [PATCH net-next 08/13] sfc: Preserve rx_frm_trunc counters when resizing DMA rings Shradha Shah
2014-02-12 18:59 ` [PATCH net-next 05/13] sfc: Rename 'use_options' variable in tso_start() to clearer 'use_opt_desc' Shradha Shah
2014-02-12 18:59 ` [PATCH net-next 09/13] sfc: Use canonical pointer type for MAC address in efx_set_mac_address() Shradha Shah
2014-02-12 19:00 ` [PATCH net-next 10/13] sfc: Update product naming Shradha Shah
2014-02-12 19:00 ` [PATCH net-next 11/13] sfc: Cosmetic changes to self-test from the out-of-tree driver Shradha Shah
2014-02-12 19:00 ` [PATCH net-next 12/13] sfc: Fail self-test with -EBUSY, not -EIO, if the device is busy Shradha Shah
2014-02-12 19:00 ` [PATCH net-next 13/13] sfc: Add/remove blank lines to taste Shradha Shah
2014-02-12 23:42 ` [PATCH net-next 00/13] Cleanup patches for the SFC driver David Miller
  -- strict thread matches above, loose matches on Subject: below --
2014-02-03 23:21 [PATCH net-next 00/13] Cleanup patches Shradha Shah
2014-02-03 23:33 ` [PATCH net-next 02/13] sfc: Cache skb->data in local variable in efx_ptp_rx() Shradha Shah

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=52FBC45A.9060809@solarflare.com \
    --to=sshah@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).