diff options
author | luigi <luigi@FreeBSD.org> | 2013-05-09 16:57:02 +0000 |
---|---|---|
committer | luigi <luigi@FreeBSD.org> | 2013-05-09 16:57:02 +0000 |
commit | 872b0246a59d9de3065dc0c05a1ec085aa5c90fa (patch) | |
tree | e1d79ef1e3ecde19f267da791c74513cf5f13d58 | |
parent | bbb5917525854d5051697db3fb20c8a062fc3e2a (diff) | |
download | FreeBSD-src-872b0246a59d9de3065dc0c05a1ec085aa5c90fa.zip FreeBSD-src-872b0246a59d9de3065dc0c05a1ec085aa5c90fa.tar.gz |
simplify the code to initialize the RDT while in netmap mode.
-rw-r--r-- | sys/dev/e1000/if_em.c | 15 | ||||
-rw-r--r-- | sys/dev/e1000/if_lem.c | 14 |
2 files changed, 9 insertions, 20 deletions
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index eedc0fa..b210d4e 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -4333,6 +4333,8 @@ em_initialize_receive_unit(struct adapter *adapter) for (int i = 0; i < adapter->num_queues; i++, rxr++) { /* Setup the Base and Length of the Rx Descriptor Ring */ + u32 rdt = adapter->num_rx_desc - 1; /* default */ + bus_addr = rxr->rxdma.dma_paddr; E1000_WRITE_REG(hw, E1000_RDLEN(i), adapter->num_rx_desc * sizeof(struct e1000_rx_desc)); @@ -4344,18 +4346,11 @@ em_initialize_receive_unit(struct adapter *adapter) /* * an init() while a netmap client is active must * preserve the rx buffers passed to userspace. - * In this driver it means we adjust RDT to - * something different from na->num_rx_desc - 1. */ - if (ifp->if_capenable & IFCAP_NETMAP) { - struct netmap_adapter *na = NA(adapter->ifp); - struct netmap_kring *kring = &na->rx_rings[i]; - int t = na->num_rx_desc - 1 - kring->nr_hwavail; - - E1000_WRITE_REG(hw, E1000_RDT(i), t); - } else + if (ifp->if_capenable & IFCAP_NETMAP) + rdt -= NA(adapter->ifp)->rx_rings[i].nr_hwavail; #endif /* DEV_NETMAP */ - E1000_WRITE_REG(hw, E1000_RDT(i), adapter->num_rx_desc - 1); + E1000_WRITE_REG(hw, E1000_RDT(i), rdt); } /* Set PTHRESH for improved jumbo performance */ diff --git a/sys/dev/e1000/if_lem.c b/sys/dev/e1000/if_lem.c index ae7893a..0ecf651 100644 --- a/sys/dev/e1000/if_lem.c +++ b/sys/dev/e1000/if_lem.c @@ -3361,19 +3361,13 @@ lem_initialize_receive_unit(struct adapter *adapter) * Tail Descriptor Pointers */ E1000_WRITE_REG(&adapter->hw, E1000_RDH(0), 0); + rctl = adapter->num_rx_desc - 1; /* default RDT value */ #ifdef DEV_NETMAP /* preserve buffers already made available to clients */ - if (ifp->if_capenable & IFCAP_NETMAP) { - struct netmap_adapter *na = NA(adapter->ifp); - struct netmap_kring *kring = &na->rx_rings[0]; - int t = na->num_rx_desc - 1 - kring->nr_hwavail; - - if (t >= na->num_rx_desc) - t -= na->num_rx_desc; - E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), t); - } else + if (ifp->if_capenable & IFCAP_NETMAP) + rctl -= NA(adapter->ifp)->rx_rings[0].nr_hwavail; #endif /* DEV_NETMAP */ - E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), adapter->num_rx_desc - 1); + E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), rctl); return; } |