[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87vdz4sdqy.fsf@basil.nowhere.org>
Date: Thu, 17 Jul 2008 17:59:33 +0200
From: Andi Kleen <andi@...stfloor.org>
To: David Miller <davem@...emloft.net>
Cc: netdev@...r.kernel.org, kaber@...sh.net, johannes@...solutions.net,
linux-wireless@...r.kernel.org
Subject: Re: [PATCH 11/31]: net: Implement simple sw TX hashing.
David Miller <davem@...emloft.net> writes:
> +static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
> +{
> + u32 *addr, *ports, hash, ihl;
> + u8 ip_proto;
> + int alen;
> +
> + switch (skb->protocol) {
> + case __constant_htons(ETH_P_IP):
> + ip_proto = ip_hdr(skb)->protocol;
> + addr = &ip_hdr(skb)->saddr;
> + ihl = ip_hdr(skb)->ihl;
> + alen = 2;
> + break;
> + case __constant_htons(ETH_P_IPV6):
> + ip_proto = ipv6_hdr(skb)->nexthdr;
> + addr = &ipv6_hdr(skb)->saddr.s6_addr32[0];
> + ihl = (40 >> 2);
> + alen = 8;
> + break;
> + default:
> + return 0;
Could you add a linuxmib counter for this default event? Just so that
people can diagnose this more easily.
> +
> + ports = (u32 *) (skb_network_header(skb) + (ihl * 4));
> +
> + hash = 0;
> + while (alen--)
> + hash ^= *addr++;
Are you sure the hash behaves the same between big endian and little
endian? Perhaps it would be safer to always convert endian even if
that complicates the code a bit.
> + hash ^= *ports;
> + break;
> +
> + default:
> + break;
And also a linuxmib counter here.
> + }
> +
> + return hash % dev->real_num_tx_queues;
I haven't rechecked it in detail, but I suspect some more
folding of higher bits would be better again for endian safety.
-Andi
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists