summaryrefslogtreecommitdiffstats
path: root/sys/dev/e1000/if_em.c
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2012-02-15 23:13:29 +0000
committerluigi <luigi@FreeBSD.org>2012-02-15 23:13:29 +0000
commit626117dcad75e9526ae6bc4c7b0e7d93aea9a8c1 (patch)
treeff5d6ba38e3c75e6316b850d0cfb7877385f0bdc /sys/dev/e1000/if_em.c
parentc73b374c7d18d2132436080cbdf957c5bf7aba58 (diff)
downloadFreeBSD-src-626117dcad75e9526ae6bc4c7b0e7d93aea9a8c1.zip
FreeBSD-src-626117dcad75e9526ae6bc4c7b0e7d93aea9a8c1.tar.gz
(This commit only touches code within the DEV_NETMAP blocks)
Introduce some functions to map NIC ring indexes into netmap ring indexes and vice versa. This way we can implement the bound checks only in one place (and hopefully in a correct way). On passing, make the code and comments more uniform across the various drivers.
Diffstat (limited to 'sys/dev/e1000/if_em.c')
-rw-r--r--sys/dev/e1000/if_em.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 95d8b9a..9495c79 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -3296,12 +3296,10 @@ em_setup_transmit_ring(struct tx_ring *txr)
}
#ifdef DEV_NETMAP
if (slot) {
- int si = i + na->tx_rings[txr->me].nkr_hwofs;
+ int si = netmap_tidx_n2k(na, txr->me, i);
uint64_t paddr;
void *addr;
- if (si >= na->num_tx_desc)
- si -= na->num_tx_desc;
addr = PNMB(slot + si, &paddr);
txr->tx_base[i].buffer_addr = htole64(paddr);
/* reload the map for netmap mode */
@@ -4053,13 +4051,10 @@ em_setup_receive_ring(struct rx_ring *rxr)
rxbuf = &rxr->rx_buffers[j];
#ifdef DEV_NETMAP
if (slot) {
- /* slot si is mapped to the j-th NIC-ring entry */
- int si = j + na->rx_rings[0].nkr_hwofs;
+ int si = netmap_ridx_n2k(na, rxr->me, j);
uint64_t paddr;
void *addr;
- if (si > na->num_rx_desc)
- si -= na->num_rx_desc;
addr = PNMB(slot + si, &paddr);
netmap_load_map(rxr->rxtag, rxbuf->map, addr);
/* Update descriptor */
OpenPOWER on IntegriCloud