Patchwork [RFC,3/3] igb: example of how to update igb to make use of in-kernel Toeplitz hashing

login
register
mail settings
Submitter Alexander Duyck
Date Dec. 18, 2010, 1 a.m.
Message ID <20101218010048.28602.49776.stgit@gitlad.jf.intel.com>
Download mbox | patch
Permalink /patch/76051/
State Rejected
Delegated to: David Miller
Headers show

Comments

Alexander Duyck - Dec. 18, 2010, 1 a.m.
This change allows igb to make use of the in-kernel Toeplitz hashing so
that RX and TX hash queues can be matched up.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---

 drivers/net/igb/igb_main.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Dec. 18, 2010, 5:09 a.m.
From: Alexander Duyck <alexander.h.duyck@intel.com>
Date: Fri, 17 Dec 2010 17:00:48 -0800

> @@ -1691,6 +1692,7 @@ static const struct net_device_ops igb_netdev_ops = {
>  	.ndo_open		= igb_open,
>  	.ndo_stop		= igb_close,
>  	.ndo_start_xmit		= igb_xmit_frame_adv,
> +	.ndo_select_queue	= toeplitz_select_queue,
>  	.ndo_get_stats64	= igb_get_stats64,
>  	.ndo_set_rx_mode	= igb_set_rx_mode,
>  	.ndo_set_multicast_list	= igb_set_rx_mode,

Adding a NETIF_F_TX_TOEPLITZ flag that skb_tx_hash() keys off of would
be a lot simpler.

We want less overriding of ->ndo_select_queue(), not more, and this case
is definitely gratuitous.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Duyck - Dec. 18, 2010, 6:53 a.m.
On Fri, Dec 17, 2010 at 9:09 PM, David Miller <davem@davemloft.net> wrote:
> From: Alexander Duyck <alexander.h.duyck@intel.com>
> Date: Fri, 17 Dec 2010 17:00:48 -0800
>
>> @@ -1691,6 +1692,7 @@ static const struct net_device_ops igb_netdev_ops = {
>>       .ndo_open               = igb_open,
>>       .ndo_stop               = igb_close,
>>       .ndo_start_xmit         = igb_xmit_frame_adv,
>> +     .ndo_select_queue       = toeplitz_select_queue,
>>       .ndo_get_stats64        = igb_get_stats64,
>>       .ndo_set_rx_mode        = igb_set_rx_mode,
>>       .ndo_set_multicast_list = igb_set_rx_mode,
>
> Adding a NETIF_F_TX_TOEPLITZ flag that skb_tx_hash() keys off of would
> be a lot simpler

Thats probably true.  I hadn't put much thought into it at the time.

> We want less overriding of ->ndo_select_queue(), not more, and this case
> is definitely gratuitous.

I kind of figured that was the approach was flawed.  As I said in the
cover page, this is a somewhat hastily thrown together set of patches
to demonstrate a proof of concept.  To me this appeared to be the
quickest way to come up with the means to alter the queue selection.
The main piece I am interested in is any input on the first patch that
added the Toeplitz hash functionality.  Specifically would a 16 bit
key/hash work for queue selection or would there be cases where we
need a 32 bit key/hash result?

Thanks,

Alex
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Dec. 18, 2010, 6:59 a.m.
From: Alexander Duyck <alexander.duyck@gmail.com>
Date: Fri, 17 Dec 2010 22:53:24 -0800

> Specifically would a 16 bit key/hash work for queue selection or
> would there be cases where we need a 32 bit key/hash result?

Currently for TX 16-bit ought to be enough.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 72a2fad..9e6a437 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -45,6 +45,7 @@ 
 #include <linux/interrupt.h>
 #include <linux/if_ether.h>
 #include <linux/aer.h>
+#include <linux/toeplitz.h>
 #ifdef CONFIG_IGB_DCA
 #include <linux/dca.h>
 #endif
@@ -1691,6 +1692,7 @@  static const struct net_device_ops igb_netdev_ops = {
 	.ndo_open		= igb_open,
 	.ndo_stop		= igb_close,
 	.ndo_start_xmit		= igb_xmit_frame_adv,
+	.ndo_select_queue	= toeplitz_select_queue,
 	.ndo_get_stats64	= igb_get_stats64,
 	.ndo_set_rx_mode	= igb_set_rx_mode,
 	.ndo_set_multicast_list	= igb_set_rx_mode,
@@ -2660,19 +2662,14 @@  static void igb_setup_mrqc(struct igb_adapter *adapter)
 		u32 dword;
 		u8  bytes[4];
 	} reta;
-	static const u8 rsshash[40] = {
-		0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, 0x41, 0x67,
-		0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, 0xd0, 0xca, 0x2b, 0xcb,
-		0xae, 0x7b, 0x30, 0xb4,	0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30,
-		0xf2, 0x0c, 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa };
 
 	/* Fill out hash function seeds */
 	for (j = 0; j < 10; j++) {
-		u32 rsskey = rsshash[(j * 4)];
-		rsskey |= rsshash[(j * 4) + 1] << 8;
-		rsskey |= rsshash[(j * 4) + 2] << 16;
-		rsskey |= rsshash[(j * 4) + 3] << 24;
-		array_wr32(E1000_RSSRK(0), j, rsskey);
+		u32 toeplitz_key = (u32)toeplitz_get_key_byte((4 * j));
+		toeplitz_key |= (u32)toeplitz_get_key_byte((4 * j) + 1) << 8;
+		toeplitz_key |= (u32)toeplitz_get_key_byte((4 * j) + 2) << 16;
+		toeplitz_key |= (u32)toeplitz_get_key_byte((4 * j) + 3) << 24;
+		array_wr32(E1000_RSSRK(0), j, toeplitz_key);
 	}
 
 	num_rx_queues = adapter->rss_queues;
@@ -2700,8 +2697,9 @@  static void igb_setup_mrqc(struct igb_adapter *adapter)
 			shift = 6;
 	}
 
-	for (j = 0; j < (32 * 4); j++) {
-		reta.bytes[j & 3] = (j % num_rx_queues) << shift;
+	for (j = 0; j < 128; j++) {
+		u32 entry = ((j * num_rx_queues) & 0xFF80) >> 7;
+		reta.bytes[j & 3] = entry << shift;
 		if (shift2)
 			reta.bytes[j & 3] |= num_rx_queues << shift2;
 		if ((j & 3) == 3)