Commit ce320f44 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

sfc: Cache skb->data in local variable in efx_ptp_rx()

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarShradha Shah <sshah@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f9fd7ec7
...@@ -1366,6 +1366,7 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) ...@@ -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; struct efx_ptp_match *match = (struct efx_ptp_match *)skb->cb;
u8 *match_data_012, *match_data_345; u8 *match_data_012, *match_data_345;
unsigned int version; unsigned int version;
u8 *data;
match->expiry = jiffies + msecs_to_jiffies(PKT_EVENT_LIFETIME_MS); 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) ...@@ -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)) { if (!pskb_may_pull(skb, PTP_V1_MIN_LENGTH)) {
return false; 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) { if (version != PTP_VERSION_V1) {
return false; return false;
} }
...@@ -1382,13 +1384,14 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) ...@@ -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 /* PTP V1 uses all six bytes of the UUID to match the packet
* to the timestamp * to the timestamp
*/ */
match_data_012 = skb->data + PTP_V1_UUID_OFFSET; match_data_012 = data + PTP_V1_UUID_OFFSET;
match_data_345 = skb->data + PTP_V1_UUID_OFFSET + 3; match_data_345 = data + PTP_V1_UUID_OFFSET + 3;
} else { } else {
if (!pskb_may_pull(skb, PTP_V2_MIN_LENGTH)) { if (!pskb_may_pull(skb, PTP_V2_MIN_LENGTH)) {
return false; 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) { if ((version & PTP_VERSION_V2_MASK) != PTP_VERSION_V2) {
return false; return false;
} }
...@@ -1400,17 +1403,17 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb) ...@@ -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 * enhanced mode fixes this issue and uses bytes 0-2
* and byte 5-7 of the UUID. * 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) { 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 { } 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); BUG_ON(ptp->mode != MC_CMD_PTP_MODE_V2_ENHANCED);
} }
} }
/* Does this packet require timestamping? */ /* 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; match->state = PTP_PACKET_STATE_UNMATCHED;
/* We expect the sequence number to be in the same position in /* 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) ...@@ -1426,8 +1429,8 @@ static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
(match_data_345[0] << 24)); (match_data_345[0] << 24));
match->words[1] = (match_data_345[1] | match->words[1] = (match_data_345[1] |
(match_data_345[2] << 8) | (match_data_345[2] << 8) |
(skb->data[PTP_V1_SEQUENCE_OFFSET + (data[PTP_V1_SEQUENCE_OFFSET +
PTP_V1_SEQUENCE_LENGTH - 1] << PTP_V1_SEQUENCE_LENGTH - 1] <<
16)); 16));
} else { } else {
match->state = PTP_PACKET_STATE_MATCH_UNWANTED; match->state = PTP_PACKET_STATE_MATCH_UNWANTED;
......
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