diff options
author | Alex Elder <elder@linaro.org> | 2021-06-12 17:37:29 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-06-12 23:18:48 +0300 |
commit | 0e6af897fcd9c154c06f239669401c64da52d84e (patch) | |
tree | d3e07cf56c5a407b4b639e0ca71623ea04260fc4 /drivers/net/ethernet/qualcomm | |
parent | 73a378601a25dc6312530c33822fde3e177883d4 (diff) | |
download | linux-0e6af897fcd9c154c06f239669401c64da52d84e.tar.xz |
net: qualcomm: rmnet: remove some local variables
In rmnet_map_ipv4_dl_csum_trailer(), remove the "csum_temp" and
"addend" local variables, and simplify a few lines of code.
Remove the "csum_temp", "csum_value", "ip6_hdr_csum", and "addend"
local variables in rmnet_map_ipv6_dl_csum_trailer(), and simplify a
few lines of code there as well.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qualcomm')
-rw-r--r-- | drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c index d4d23ab446ef..3e6feef0fd25 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c @@ -35,10 +35,9 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, { struct iphdr *ip4h = (struct iphdr *)skb->data; void *txporthdr = skb->data + ip4h->ihl * 4; - __sum16 *csum_field, csum_temp, pseudo_csum; + __sum16 *csum_field, pseudo_csum; __sum16 ip_payload_csum; - u16 csum_value_final; - __be16 addend; + __sum16 csum_value_final; /* Computing the checksum over just the IPv4 header--including its * checksum field--should yield 0. If it doesn't, the IP header @@ -83,14 +82,11 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, pseudo_csum = ~csum_tcpudp_magic(ip4h->saddr, ip4h->daddr, ntohs(ip4h->tot_len) - ip4h->ihl * 4, ip4h->protocol, 0); - addend = (__force __be16)pseudo_csum; - pseudo_csum = csum16_add(ip_payload_csum, addend); + pseudo_csum = csum16_add(ip_payload_csum, (__force __be16)pseudo_csum); - addend = (__force __be16)*csum_field; - csum_temp = ~csum16_sub(pseudo_csum, addend); - csum_value_final = (__force u16)csum_temp; + csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); - if (unlikely(csum_value_final == 0)) { + if (unlikely(!csum_value_final)) { switch (ip4h->protocol) { case IPPROTO_UDP: /* RFC 768 - DL4 1's complement rule for UDP csum 0 */ @@ -105,7 +101,7 @@ rmnet_map_ipv4_dl_csum_trailer(struct sk_buff *skb, } } - if (csum_value_final == (__force u16)*csum_field) { + if (csum_value_final == *csum_field) { priv->stats.csum_ok++; return 0; } else { @@ -122,12 +118,10 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, { struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data; void *txporthdr = skb->data + sizeof(*ip6h); - __sum16 *csum_field, pseudo_csum, csum_temp; - __be16 ip6_hdr_csum, addend; + __sum16 *csum_field, pseudo_csum; __sum16 ip6_payload_csum; __be16 ip_header_csum; - u16 csum_value_final; - __be16 csum_value; + __sum16 csum_value_final; u32 length; /* Checksum offload is only supported for UDP and TCP protocols; @@ -145,23 +139,18 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, * of the IP header from the trailer checksum. We then add the * checksum computed over the pseudo header. */ - csum_value = ~csum_trailer->csum_value; ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); - ip6_hdr_csum = (__force __be16)~ip_header_csum; - ip6_payload_csum = csum16_sub((__force __sum16)csum_value, - ip6_hdr_csum); + ip6_payload_csum = csum16_sub((__force __sum16)~csum_trailer->csum_value, + ~ip_header_csum); length = (ip6h->nexthdr == IPPROTO_UDP) ? ntohs(((struct udphdr *)txporthdr)->len) : ntohs(ip6h->payload_len); pseudo_csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, length, ip6h->nexthdr, 0); - addend = (__force __be16)pseudo_csum; - pseudo_csum = csum16_add(ip6_payload_csum, addend); + pseudo_csum = csum16_add(ip6_payload_csum, (__force __be16)pseudo_csum); - addend = (__force __be16)*csum_field; - csum_temp = ~csum16_sub(pseudo_csum, addend); - csum_value_final = (__force u16)csum_temp; + csum_value_final = ~csum16_sub(pseudo_csum, (__force __be16)*csum_field); if (unlikely(csum_value_final == 0)) { switch (ip6h->nexthdr) { @@ -180,7 +169,7 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, } } - if (csum_value_final == (__force u16)*csum_field) { + if (csum_value_final == *csum_field) { priv->stats.csum_ok++; return 0; } else { |