if_re_netmap.h (228276) | if_re_netmap.h (229939) |
---|---|
1/* 2 * Copyright (C) 2011 Luigi Rizzo. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26/* | 1/* 2 * Copyright (C) 2011 Luigi Rizzo. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26/* |
27 * $FreeBSD: head/sys/dev/netmap/if_re_netmap.h 228276 2011-12-05 12:06:53Z luigi $ | 27 * $FreeBSD: head/sys/dev/netmap/if_re_netmap.h 229939 2012-01-10 19:57:23Z luigi $ |
28 * $Id: if_re_netmap.h 9802 2011-12-02 18:42:37Z luigi $ 29 * 30 * netmap support for if_re 31 */ 32 33#include <net/netmap.h> 34#include <sys/selinfo.h> 35#include <vm/vm.h> --- 142 unchanged lines hidden (view full) --- 178 if (j != k) { /* we have new packets to send */ 179 n = 0; 180 l = sc->rl_ldata.rl_tx_prodidx; 181 while (j != k) { 182 struct netmap_slot *slot = &ring->slot[j]; 183 struct rl_desc *desc = &sc->rl_ldata.rl_tx_list[l]; 184 int cmd = slot->len | RL_TDESC_CMD_EOF | 185 RL_TDESC_CMD_OWN | RL_TDESC_CMD_SOF ; | 28 * $Id: if_re_netmap.h 9802 2011-12-02 18:42:37Z luigi $ 29 * 30 * netmap support for if_re 31 */ 32 33#include <net/netmap.h> 34#include <sys/selinfo.h> 35#include <vm/vm.h> --- 142 unchanged lines hidden (view full) --- 178 if (j != k) { /* we have new packets to send */ 179 n = 0; 180 l = sc->rl_ldata.rl_tx_prodidx; 181 while (j != k) { 182 struct netmap_slot *slot = &ring->slot[j]; 183 struct rl_desc *desc = &sc->rl_ldata.rl_tx_list[l]; 184 int cmd = slot->len | RL_TDESC_CMD_EOF | 185 RL_TDESC_CMD_OWN | RL_TDESC_CMD_SOF ; |
186 void *addr = NMB(slot); | 186 uint64_t paddr; 187 void *addr = PNMB(slot, &paddr); |
187 int len = slot->len; 188 189 if (addr == netmap_buffer_base || len > NETMAP_BUF_SIZE) { 190 if (do_lock) 191 RL_UNLOCK(sc); 192 // XXX what about prodidx ? 193 return netmap_ring_reinit(kring); 194 } 195 196 if (l == lim) /* mark end of ring */ 197 cmd |= RL_TDESC_CMD_EOR; 198 199 if (slot->flags & NS_BUF_CHANGED) { | 188 int len = slot->len; 189 190 if (addr == netmap_buffer_base || len > NETMAP_BUF_SIZE) { 191 if (do_lock) 192 RL_UNLOCK(sc); 193 // XXX what about prodidx ? 194 return netmap_ring_reinit(kring); 195 } 196 197 if (l == lim) /* mark end of ring */ 198 cmd |= RL_TDESC_CMD_EOR; 199 200 if (slot->flags & NS_BUF_CHANGED) { |
200 uint64_t paddr = vtophys(addr); | |
201 desc->rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 202 desc->rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 203 /* buffer has changed, unload and reload map */ 204 netmap_reload_map(sc->rl_ldata.rl_tx_mtag, | 201 desc->rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 202 desc->rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 203 /* buffer has changed, unload and reload map */ 204 netmap_reload_map(sc->rl_ldata.rl_tx_mtag, |
205 txd[l].tx_dmamap, addr, na->buff_size); | 205 txd[l].tx_dmamap, addr); |
206 slot->flags &= ~NS_BUF_CHANGED; 207 } 208 slot->flags &= ~NS_REPORT; 209 desc->rl_cmdstat = htole32(cmd); 210 bus_dmamap_sync(sc->rl_ldata.rl_tx_mtag, 211 txd[l].tx_dmamap, BUS_DMASYNC_PREWRITE); 212 j = (j == lim) ? 0 : j + 1; 213 l = (l == lim) ? 0 : l + 1; --- 85 unchanged lines hidden (view full) --- 299 n = 0; 300 l = kring->nr_hwcur - kring->nkr_hwofs; 301 if (l < 0) 302 l += lim + 1; 303 while (j != k) { 304 struct netmap_slot *slot = ring->slot + j; 305 struct rl_desc *desc = &sc->rl_ldata.rl_rx_list[l]; 306 int cmd = na->buff_size | RL_RDESC_CMD_OWN; | 206 slot->flags &= ~NS_BUF_CHANGED; 207 } 208 slot->flags &= ~NS_REPORT; 209 desc->rl_cmdstat = htole32(cmd); 210 bus_dmamap_sync(sc->rl_ldata.rl_tx_mtag, 211 txd[l].tx_dmamap, BUS_DMASYNC_PREWRITE); 212 j = (j == lim) ? 0 : j + 1; 213 l = (l == lim) ? 0 : l + 1; --- 85 unchanged lines hidden (view full) --- 299 n = 0; 300 l = kring->nr_hwcur - kring->nkr_hwofs; 301 if (l < 0) 302 l += lim + 1; 303 while (j != k) { 304 struct netmap_slot *slot = ring->slot + j; 305 struct rl_desc *desc = &sc->rl_ldata.rl_rx_list[l]; 306 int cmd = na->buff_size | RL_RDESC_CMD_OWN; |
307 void *addr = NMB(slot); | 307 uint64_t paddr; 308 void *addr = PNMB(slot, &paddr); |
308 309 if (addr == netmap_buffer_base) { /* bad buf */ 310 if (do_lock) 311 RL_UNLOCK(sc); 312 return netmap_ring_reinit(kring); 313 } 314 315 if (l == lim) /* mark end of ring */ 316 cmd |= RL_RDESC_CMD_EOR; 317 318 desc->rl_cmdstat = htole32(cmd); 319 slot->flags &= ~NS_REPORT; 320 if (slot->flags & NS_BUF_CHANGED) { | 309 310 if (addr == netmap_buffer_base) { /* bad buf */ 311 if (do_lock) 312 RL_UNLOCK(sc); 313 return netmap_ring_reinit(kring); 314 } 315 316 if (l == lim) /* mark end of ring */ 317 cmd |= RL_RDESC_CMD_EOR; 318 319 desc->rl_cmdstat = htole32(cmd); 320 slot->flags &= ~NS_REPORT; 321 if (slot->flags & NS_BUF_CHANGED) { |
321 uint64_t paddr = vtophys(addr); | |
322 desc->rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 323 desc->rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 324 netmap_reload_map(sc->rl_ldata.rl_rx_mtag, | 322 desc->rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 323 desc->rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 324 netmap_reload_map(sc->rl_ldata.rl_rx_mtag, |
325 rxd[l].rx_dmamap, addr, na->buff_size); | 325 rxd[l].rx_dmamap, addr); |
326 slot->flags &= ~NS_BUF_CHANGED; 327 } 328 bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, 329 rxd[l].rx_dmamap, BUS_DMASYNC_PREREAD); 330 j = (j == lim) ? 0 : j + 1; 331 l = (l == lim) ? 0 : l + 1; 332 n++; 333 } --- 38 unchanged lines hidden (view full) --- 372 void *addr; 373 uint64_t paddr; 374 struct netmap_kring *kring = &na->tx_rings[0]; 375 int l = i + kring->nkr_hwofs; 376 377 if (l >= n) 378 l -= n; 379 | 326 slot->flags &= ~NS_BUF_CHANGED; 327 } 328 bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, 329 rxd[l].rx_dmamap, BUS_DMASYNC_PREREAD); 330 j = (j == lim) ? 0 : j + 1; 331 l = (l == lim) ? 0 : l + 1; 332 n++; 333 } --- 38 unchanged lines hidden (view full) --- 372 void *addr; 373 uint64_t paddr; 374 struct netmap_kring *kring = &na->tx_rings[0]; 375 int l = i + kring->nkr_hwofs; 376 377 if (l >= n) 378 l -= n; 379 |
380 addr = NMB(slot + l); 381 paddr = vtophys(addr); | 380 addr = PNMB(slot + l, &paddr); |
382 desc[i].rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 383 desc[i].rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 384 netmap_load_map(sc->rl_ldata.rl_tx_mtag, | 381 desc[i].rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 382 desc[i].rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 383 netmap_load_map(sc->rl_ldata.rl_tx_mtag, |
385 txd[i].tx_dmamap, addr, na->buff_size); | 384 txd[i].tx_dmamap, addr); |
386 } 387} 388 389static void 390re_netmap_rx_init(struct rl_softc *sc) 391{ 392 struct netmap_adapter *na = NA(sc->rl_ifp); 393 struct netmap_slot *slot = netmap_reset(na, NR_RX, 0, 0); --- 8 unchanged lines hidden (view full) --- 402 void *addr; 403 uint64_t paddr; 404 struct netmap_kring *kring = &na->rx_rings[0]; 405 int l = i + kring->nkr_hwofs; 406 407 if (l >= n) 408 l -= n; 409 | 385 } 386} 387 388static void 389re_netmap_rx_init(struct rl_softc *sc) 390{ 391 struct netmap_adapter *na = NA(sc->rl_ifp); 392 struct netmap_slot *slot = netmap_reset(na, NR_RX, 0, 0); --- 8 unchanged lines hidden (view full) --- 401 void *addr; 402 uint64_t paddr; 403 struct netmap_kring *kring = &na->rx_rings[0]; 404 int l = i + kring->nkr_hwofs; 405 406 if (l >= n) 407 l -= n; 408 |
410 addr = NMB(slot + l); 411 paddr = vtophys(addr); | 409 addr = PNMB(slot + l, &paddr); 410 411 netmap_reload_map(sc->rl_ldata.rl_rx_mtag, 412 sc->rl_ldata.rl_rx_desc[i].rx_dmamap, addr); 413 bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, 414 sc->rl_ldata.rl_rx_desc[i].rx_dmamap, BUS_DMASYNC_PREREAD); |
412 desc[i].rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 413 desc[i].rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 414 cmdstat = na->buff_size; 415 if (i == n - 1) 416 cmdstat |= RL_RDESC_CMD_EOR; 417 /* 418 * userspace knows that hwavail packets were ready before the 419 * reset, so we need to tell the NIC that last hwavail 420 * descriptors of the ring are still owned by the driver. 421 */ 422 if (i < n - 1 - kring->nr_hwavail) // XXX + 1 ? 423 cmdstat |= RL_RDESC_CMD_OWN; 424 desc[i].rl_cmdstat = htole32(cmdstat); | 415 desc[i].rl_bufaddr_lo = htole32(RL_ADDR_LO(paddr)); 416 desc[i].rl_bufaddr_hi = htole32(RL_ADDR_HI(paddr)); 417 cmdstat = na->buff_size; 418 if (i == n - 1) 419 cmdstat |= RL_RDESC_CMD_EOR; 420 /* 421 * userspace knows that hwavail packets were ready before the 422 * reset, so we need to tell the NIC that last hwavail 423 * descriptors of the ring are still owned by the driver. 424 */ 425 if (i < n - 1 - kring->nr_hwavail) // XXX + 1 ? 426 cmdstat |= RL_RDESC_CMD_OWN; 427 desc[i].rl_cmdstat = htole32(cmdstat); |
425 426 netmap_reload_map(sc->rl_ldata.rl_rx_mtag, 427 sc->rl_ldata.rl_rx_desc[i].rx_dmamap, 428 addr, na->buff_size); | |
429 } 430} | 428 } 429} |