ixgbe_netmap.h (228844) | ixgbe_netmap.h (229939) |
---|---|
1/* 2 * Copyright (C) 2011 Matteo Landi, 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 Matteo Landi, 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/ixgbe_netmap.h 228844 2011-12-23 16:02:14Z luigi $ | 27 * $FreeBSD: head/sys/dev/netmap/ixgbe_netmap.h 229939 2012-01-10 19:57:23Z luigi $ |
28 * $Id: ixgbe_netmap.h 9802 2011-12-02 18:42:37Z luigi $ 29 * 30 * netmap modifications for ixgbe 31 * 32 * This file is meant to be a reference on how to implement 33 * netmap support for a network driver. 34 * This file contains code but only static or inline functions 35 * that are used by a single driver. To avoid replication of --- 212 unchanged lines hidden (view full) --- 248 l += lim + 1; 249 250 while (j != k) { 251 /* 252 * Collect per-slot info. 253 * Note that txbuf and curr are indexed by l. 254 * 255 * In this driver we collect the buffer address | 28 * $Id: ixgbe_netmap.h 9802 2011-12-02 18:42:37Z luigi $ 29 * 30 * netmap modifications for ixgbe 31 * 32 * This file is meant to be a reference on how to implement 33 * netmap support for a network driver. 34 * This file contains code but only static or inline functions 35 * that are used by a single driver. To avoid replication of --- 212 unchanged lines hidden (view full) --- 248 l += lim + 1; 249 250 while (j != k) { 251 /* 252 * Collect per-slot info. 253 * Note that txbuf and curr are indexed by l. 254 * 255 * In this driver we collect the buffer address |
256 * (using the NMB() macro) because we always | 256 * (using the PNMB() macro) because we always |
257 * need to rewrite it into the NIC ring. 258 * Many other drivers preserve the address, so 259 * we only need to access it if NS_BUF_CHANGED 260 * is set. 261 */ 262 struct netmap_slot *slot = &ring->slot[j]; 263 struct ixgbe_tx_buf *txbuf = &txr->tx_buffers[l]; 264 union ixgbe_adv_tx_desc *curr = &txr->tx_base[l]; | 257 * need to rewrite it into the NIC ring. 258 * Many other drivers preserve the address, so 259 * we only need to access it if NS_BUF_CHANGED 260 * is set. 261 */ 262 struct netmap_slot *slot = &ring->slot[j]; 263 struct ixgbe_tx_buf *txbuf = &txr->tx_buffers[l]; 264 union ixgbe_adv_tx_desc *curr = &txr->tx_base[l]; |
265 void *addr = NMB(slot); | 265 uint64_t paddr; 266 void *addr = PNMB(slot, &paddr); |
266 // XXX type for flags and len ? 267 int flags = ((slot->flags & NS_REPORT) || 268 j == 0 || j == report_frequency) ? 269 IXGBE_TXD_CMD_RS : 0; 270 int len = slot->len; 271 272 /* 273 * Quick check for valid addr and len. --- 11 unchanged lines hidden (view full) --- 285 286 slot->flags &= ~NS_REPORT; 287 /* 288 * Fill the slot in the NIC ring. 289 * In this driver we need to rewrite the buffer 290 * address in the NIC ring. Other drivers do not 291 * need this. 292 */ | 267 // XXX type for flags and len ? 268 int flags = ((slot->flags & NS_REPORT) || 269 j == 0 || j == report_frequency) ? 270 IXGBE_TXD_CMD_RS : 0; 271 int len = slot->len; 272 273 /* 274 * Quick check for valid addr and len. --- 11 unchanged lines hidden (view full) --- 286 287 slot->flags &= ~NS_REPORT; 288 /* 289 * Fill the slot in the NIC ring. 290 * In this driver we need to rewrite the buffer 291 * address in the NIC ring. Other drivers do not 292 * need this. 293 */ |
293 curr->read.buffer_addr = htole64(vtophys(addr)); | 294 curr->read.buffer_addr = htole64(paddr); |
294 curr->read.olinfo_status = 0; 295 curr->read.cmd_type_len = 296 htole32(txr->txd_cmd | len | 297 (IXGBE_ADVTXD_DTYP_DATA | 298 IXGBE_ADVTXD_DCMD_IFCS | 299 IXGBE_TXD_CMD_EOP | flags) ); 300 /* If the buffer has changed, unload and reload map 301 * (and possibly the physical address in the NIC 302 * slot, but we did it already). 303 */ 304 if (slot->flags & NS_BUF_CHANGED) { 305 /* buffer has changed, unload and reload map */ | 295 curr->read.olinfo_status = 0; 296 curr->read.cmd_type_len = 297 htole32(txr->txd_cmd | len | 298 (IXGBE_ADVTXD_DTYP_DATA | 299 IXGBE_ADVTXD_DCMD_IFCS | 300 IXGBE_TXD_CMD_EOP | flags) ); 301 /* If the buffer has changed, unload and reload map 302 * (and possibly the physical address in the NIC 303 * slot, but we did it already). 304 */ 305 if (slot->flags & NS_BUF_CHANGED) { 306 /* buffer has changed, unload and reload map */ |
306 netmap_reload_map(txr->txtag, txbuf->map, 307 addr, na->buff_size); | 307 netmap_reload_map(txr->txtag, txbuf->map, addr); |
308 slot->flags &= ~NS_BUF_CHANGED; 309 } 310 311 /* make sure changes to the buffer are synced */ 312 bus_dmamap_sync(txr->txtag, txbuf->map, 313 BUS_DMASYNC_PREWRITE); 314 j = (j == lim) ? 0 : j + 1; 315 l = (l == lim) ? 0 : l + 1; --- 158 unchanged lines hidden (view full) --- 474 * NOTE curr and rxbuf are indexed by l. 475 * Also, this driver needs to update the physical 476 * address in the NIC ring, but other drivers 477 * may not have this requirement. 478 */ 479 struct netmap_slot *slot = &ring->slot[j]; 480 union ixgbe_adv_rx_desc *curr = &rxr->rx_base[l]; 481 struct ixgbe_rx_buf *rxbuf = &rxr->rx_buffers[l]; | 308 slot->flags &= ~NS_BUF_CHANGED; 309 } 310 311 /* make sure changes to the buffer are synced */ 312 bus_dmamap_sync(txr->txtag, txbuf->map, 313 BUS_DMASYNC_PREWRITE); 314 j = (j == lim) ? 0 : j + 1; 315 l = (l == lim) ? 0 : l + 1; --- 158 unchanged lines hidden (view full) --- 474 * NOTE curr and rxbuf are indexed by l. 475 * Also, this driver needs to update the physical 476 * address in the NIC ring, but other drivers 477 * may not have this requirement. 478 */ 479 struct netmap_slot *slot = &ring->slot[j]; 480 union ixgbe_adv_rx_desc *curr = &rxr->rx_base[l]; 481 struct ixgbe_rx_buf *rxbuf = &rxr->rx_buffers[l]; |
482 void *addr = NMB(slot); | 482 uint64_t paddr; 483 void *addr = PNMB(slot, &paddr); |
483 484 if (addr == netmap_buffer_base) /* bad buf */ 485 goto ring_reset; 486 487 curr->wb.upper.status_error = 0; | 484 485 if (addr == netmap_buffer_base) /* bad buf */ 486 goto ring_reset; 487 488 curr->wb.upper.status_error = 0; |
488 curr->read.pkt_addr = htole64(vtophys(addr)); | 489 curr->read.pkt_addr = htole64(paddr); |
489 if (slot->flags & NS_BUF_CHANGED) { | 490 if (slot->flags & NS_BUF_CHANGED) { |
490 netmap_reload_map(rxr->ptag, rxbuf->pmap, 491 addr, na->buff_size); | 491 netmap_reload_map(rxr->ptag, rxbuf->pmap, addr); |
492 slot->flags &= ~NS_BUF_CHANGED; 493 } 494 495 bus_dmamap_sync(rxr->ptag, rxbuf->pmap, 496 BUS_DMASYNC_PREREAD); 497 498 j = (j == lim) ? 0 : j + 1; 499 l = (l == lim) ? 0 : l + 1; --- 24 unchanged lines hidden --- | 492 slot->flags &= ~NS_BUF_CHANGED; 493 } 494 495 bus_dmamap_sync(rxr->ptag, rxbuf->pmap, 496 BUS_DMASYNC_PREREAD); 497 498 j = (j == lim) ? 0 : j + 1; 499 l = (l == lim) ? 0 : l + 1; --- 24 unchanged lines hidden --- |