From: Sepherosa Ziehau Date: Wed, 18 Mar 2009 13:11:19 +0000 (+0800) Subject: jme(4): Using code logic to create redirect table. X-Git-Tag: v2.3.1~269 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/66f75939187923ae9afac34235f91facf582c422 jme(4): Using code logic to create redirect table. - Avoid using magic number when creating redirect table, apply code logic instead. - Add comment about how the redirect table is filled. --- diff --git a/sys/dev/netif/jme/if_jme.c b/sys/dev/netif/jme/if_jme.c index 87a852bbaa..af9a9eef56 100644 --- a/sys/dev/netif/jme/if_jme.c +++ b/sys/dev/netif/jme/if_jme.c @@ -78,7 +78,7 @@ #ifdef JME_RSS_DEBUG #define JME_RSS_DPRINTF(sc, lvl, fmt, ...) \ do { \ - if ((sc)->jme_rss_debug > (lvl)) \ + if ((sc)->jme_rss_debug >= (lvl)) \ if_printf(&(sc)->arpcom.ac_if, fmt, __VA_ARGS__); \ } while (0) #else /* !JME_RSS_DEBUG */ @@ -3056,6 +3056,11 @@ jme_enable_rss(struct jme_softc *sc) sc->jme_rx_ring_inuse = sc->jme_rx_ring_cnt; + KASSERT(sc->jme_rx_ring_inuse == JME_NRXRING_2 || + sc->jme_rx_ring_inuse == JME_NRXRING_4, + ("%s: invalid # of RX rings (%d)\n", + sc->arpcom.ac_if.if_xname, sc->jme_rx_ring_inuse)); + rssc = RSSC_HASH_64_ENTRY; rssc |= RSSC_HASH_IPV4 | RSSC_HASH_IPV4_TCP; rssc |= sc->jme_rx_ring_inuse >> 1; @@ -3072,16 +3077,19 @@ jme_enable_rss(struct jme_softc *sc) CSR_WRITE_4(sc, RSSKEY_REG(i), keyreg); } + /* + * Create redirect table in following fashion: + * (hash & ring_cnt_mask) == rdr_table[(hash & rdr_table_mask)] + */ ind = 0; - if (sc->jme_rx_ring_inuse == JME_NRXRING_2) { - ind = 0x01000100; - } else if (sc->jme_rx_ring_inuse == JME_NRXRING_4) { - ind = 0x03020100; - } else { - panic("%s: invalid # of RX rings (%d)\n", - sc->arpcom.ac_if.if_xname, sc->jme_rx_ring_inuse); + for (i = 0; i < RSSTBL_REGSIZE; ++i) { + int q; + + q = i % sc->jme_rx_ring_inuse; + ind |= q << (i * 8); } JME_RSS_DPRINTF(sc, 1, "ind 0x%08x\n", ind); + for (i = 0; i < RSSTBL_NREGS; ++i) CSR_WRITE_4(sc, RSSTBL_REG(i), ind); } diff --git a/sys/dev/netif/jme/if_jmereg.h b/sys/dev/netif/jme/if_jmereg.h index fc3e4e6e5c..c20a6448e7 100644 --- a/sys/dev/netif/jme/if_jmereg.h +++ b/sys/dev/netif/jme/if_jmereg.h @@ -832,7 +832,8 @@ /* RSS indirection table entries. */ #define JME_RSSTBL_BASE 0x0C80 #define RSSTBL_NREGS 32 -#define RSSTBL_REG(x) (JME_RSSTBL_BASE + (4 * (x))) +#define RSSTBL_REGSIZE 4 +#define RSSTBL_REG(x) (JME_RSSTBL_BASE + (RSSTBL_REGSIZE * (x))) /* MSI-X table. */ #define JME_MSIX_BASE_ADDR 0x2000