aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/e1000/if_lem.c
diff options
context:
space:
mode:
authorLuigi Rizzo <luigi@FreeBSD.org>2012-02-15 23:13:29 +0000
committerLuigi Rizzo <luigi@FreeBSD.org>2012-02-15 23:13:29 +0000
commit5644ccec612ab2b8c38f1752bb75919f86970a27 (patch)
treeff5d6ba38e3c75e6316b850d0cfb7877385f0bdc /sys/dev/e1000/if_lem.c
parenta7d022e777918b571b508b3391108a7d874b921c (diff)
(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.
Notes
Notes: svn path=/head/; revision=231796
Diffstat (limited to 'sys/dev/e1000/if_lem.c')
-rw-r--r--sys/dev/e1000/if_lem.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/sys/dev/e1000/if_lem.c b/sys/dev/e1000/if_lem.c
index 0774cb99f5cb..be4626054a53 100644
--- a/sys/dev/e1000/if_lem.c
+++ b/sys/dev/e1000/if_lem.c
@@ -2668,13 +2668,11 @@ lem_setup_transmit_structures(struct adapter *adapter)
tx_buffer->m_head = NULL;
#ifdef DEV_NETMAP
if (slot) {
- /* slot si is mapped to the i-th NIC-ring entry */
- int si = i + na->tx_rings[0].nkr_hwofs;
+ /* the i-th NIC entry goes to slot si */
+ int si = netmap_tidx_n2k(na, 0, i);
uint64_t paddr;
void *addr;
- if (si > na->num_tx_desc)
- si -= na->num_tx_desc;
addr = PNMB(slot + si, &paddr);
adapter->tx_desc_base[si].buffer_addr = htole64(paddr);
/* reload the map for netmap mode */
@@ -3244,13 +3242,11 @@ lem_setup_receive_structures(struct adapter *adapter)
for (i = 0; i < adapter->num_rx_desc; i++) {
#ifdef DEV_NETMAP
if (slot) {
- /* slot si is mapped to the i-th NIC-ring entry */
- int si = i + na->rx_rings[0].nkr_hwofs;
+ /* the i-th NIC entry goes to slot si */
+ int si = netmap_ridx_n2k(na, 0, i);
uint64_t paddr;
void *addr;
- if (si > na->num_rx_desc)
- si -= na->num_rx_desc;
addr = PNMB(slot + si, &paddr);
netmap_load_map(adapter->rxtag, rx_buffer->map, addr);
/* Update descriptor */