summaryrefslogtreecommitdiffstats
path: root/sys/dev/netmap/ixgbe_netmap.h
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/netmap/ixgbe_netmap.h
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/netmap/ixgbe_netmap.h')
-rw-r--r--sys/dev/netmap/ixgbe_netmap.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/sys/dev/netmap/ixgbe_netmap.h b/sys/dev/netmap/ixgbe_netmap.h
index bdcaf38..5f5a240 100644
--- a/sys/dev/netmap/ixgbe_netmap.h
+++ b/sys/dev/netmap/ixgbe_netmap.h
@@ -210,6 +210,7 @@ ixgbe_netmap_txsync(struct ifnet *ifp, u_int ring_nr, int do_lock)
IXGBE_TX_LOCK(txr);
/* take a copy of ring->cur now, and never read it again */
k = ring->cur;
+ /* do a sanity check on cur - hwcur XXX verify */
l = k - kring->nr_hwcur;
if (l < 0)
l += lim + 1;
@@ -240,9 +241,7 @@ ixgbe_netmap_txsync(struct ifnet *ifp, u_int ring_nr, int do_lock)
*/
j = kring->nr_hwcur;
if (j != k) { /* we have new packets to send */
- l = j - kring->nkr_hwofs;
- if (l < 0) /* wraparound */
- l += lim + 1;
+ l = netmap_tidx_k2n(na, ring_nr, j); /* NIC index */
while (j != k) {
/*
@@ -459,9 +458,7 @@ ixgbe_netmap_rxsync(struct ifnet *ifp, u_int ring_nr, int do_lock)
* rxr->next_to_check is set to 0 on a ring reinit
*/
l = rxr->next_to_check;
- j = rxr->next_to_check + kring->nkr_hwofs;
- if (j > lim)
- j -= lim + 1;
+ j = netmap_ridx_n2k(na, ring_nr, l);
if (netmap_no_pendintr || force_update) {
for (n = 0; ; n++) {
@@ -493,9 +490,7 @@ ixgbe_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 = kring->nr_hwcur - kring->nkr_hwofs;
- if (l < 0)
- l += lim + 1;
+ l = netmap_ridx_k2n(na, ring_nr, j);
while (j != k) {
/* collect per-slot info, with similar validations
* and flag handling as in the txsync code.
OpenPOWER on IntegriCloud