diff options
author | luigi <luigi@FreeBSD.org> | 2012-02-15 23:13:29 +0000 |
---|---|---|
committer | luigi <luigi@FreeBSD.org> | 2012-02-15 23:13:29 +0000 |
commit | 626117dcad75e9526ae6bc4c7b0e7d93aea9a8c1 (patch) | |
tree | ff5d6ba38e3c75e6316b850d0cfb7877385f0bdc /sys/dev/netmap/if_igb_netmap.h | |
parent | c73b374c7d18d2132436080cbdf957c5bf7aba58 (diff) | |
download | FreeBSD-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/netmap/if_igb_netmap.h')
-rw-r--r-- | sys/dev/netmap/if_igb_netmap.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/sys/dev/netmap/if_igb_netmap.h b/sys/dev/netmap/if_igb_netmap.h index 86dd331..7bea4b1 100644 --- a/sys/dev/netmap/if_igb_netmap.h +++ b/sys/dev/netmap/if_igb_netmap.h @@ -169,9 +169,7 @@ igb_netmap_txsync(struct ifnet *ifp, u_int ring_nr, int do_lock) u32 olinfo_status = (adapter->hw.mac.type == e1000_82575) ? (txr->me << 4) : 0; - l = j - kring->nkr_hwofs; - if (l < 0) - l += lim + 1; + l = netmap_tidx_k2n(na, ring_nr, j); while (j != k) { struct netmap_slot *slot = &ring->slot[j]; union e1000_adv_tx_desc *curr = @@ -287,9 +285,7 @@ igb_netmap_rxsync(struct ifnet *ifp, u_int ring_nr, int do_lock) * j == (l + kring->nkr_hwofs) % ring_size */ l = rxr->next_to_check; - j = l + kring->nkr_hwofs; - if (j > lim) - j -= lim + 1; + j = netmap_ridx_n2k(na, ring_nr, l); for (n = 0; ; n++) { union e1000_adv_rx_desc *curr = &rxr->rx_base[l]; uint32_t staterr = le32toh(curr->wb.upper.status_error); @@ -311,9 +307,7 @@ igb_netmap_rxsync(struct ifnet *ifp, u_int ring_nr, int do_lock) j = kring->nr_hwcur; if (j != k) { /* userspace has read some packets. */ n = 0; - l = j - kring->nkr_hwofs; - if (l < 0) - l += lim + 1; + l = netmap_ridx_k2n(na, ring_nr, j); while (j != k) { struct netmap_slot *slot = ring->slot + j; union e1000_adv_rx_desc *curr = &rxr->rx_base[l]; |