Deleted Added
full compact
if_em_netmap.h (231778) if_em_netmap.h (231796)
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/if_em_netmap.h 231778 2012-02-15 18:59:26Z luigi $
27 * $FreeBSD: head/sys/dev/netmap/if_em_netmap.h 231796 2012-02-15 23:13:29Z luigi $
28 * $Id: if_em_netmap.h 9802 2011-12-02 18:42:37Z luigi $
29 *
28 * $Id: if_em_netmap.h 9802 2011-12-02 18:42:37Z luigi $
29 *
30 * netmap support for if_em.
30 * netmap support for if_em.c
31 *
32 * For structure and details on the individual functions please see
33 * ixgbe_netmap.h
34 */
35
36#include <net/netmap.h>
37#include <sys/selinfo.h>
38#include <vm/vm.h>

--- 22 unchanged lines hidden (view full) ---

61 na.nm_txsync = em_netmap_txsync;
62 na.nm_rxsync = em_netmap_rxsync;
63 na.nm_lock = em_netmap_lock_wrapper;
64 na.nm_register = em_netmap_reg;
65 netmap_attach(&na, adapter->num_queues);
66}
67
68
31 *
32 * For structure and details on the individual functions please see
33 * ixgbe_netmap.h
34 */
35
36#include <net/netmap.h>
37#include <sys/selinfo.h>
38#include <vm/vm.h>

--- 22 unchanged lines hidden (view full) ---

61 na.nm_txsync = em_netmap_txsync;
62 na.nm_rxsync = em_netmap_rxsync;
63 na.nm_lock = em_netmap_lock_wrapper;
64 na.nm_register = em_netmap_reg;
65 netmap_attach(&na, adapter->num_queues);
66}
67
68
69/*
70 * wrapper to export locks to the generic code
71 */
72static void
73em_netmap_lock_wrapper(struct ifnet *ifp, int what, u_int queueid)
74{
75 struct adapter *adapter = ifp->if_softc;
76
77 ASSERT(queueid < adapter->num_queues);
78 switch (what) {
79 case NETMAP_CORE_LOCK:

--- 129 unchanged lines hidden (view full) ---

209
210 /* check for new packets to send.
211 * j indexes the netmap ring, l indexes the nic ring, and
212 * j = kring->nr_hwcur, l = E1000_TDT (not tracked),
213 * j == (l + kring->nkr_hwofs) % ring_size
214 */
215 j = kring->nr_hwcur;
216 if (j != k) { /* we have packets to send */
69static void
70em_netmap_lock_wrapper(struct ifnet *ifp, int what, u_int queueid)
71{
72 struct adapter *adapter = ifp->if_softc;
73
74 ASSERT(queueid < adapter->num_queues);
75 switch (what) {
76 case NETMAP_CORE_LOCK:

--- 129 unchanged lines hidden (view full) ---

206
207 /* check for new packets to send.
208 * j indexes the netmap ring, l indexes the nic ring, and
209 * j = kring->nr_hwcur, l = E1000_TDT (not tracked),
210 * j == (l + kring->nkr_hwofs) % ring_size
211 */
212 j = kring->nr_hwcur;
213 if (j != k) { /* we have packets to send */
217 l = j - kring->nkr_hwofs;
218 if (l < 0)
219 l += lim + 1;
214 l = netmap_tidx_k2n(na, ring_nr, j);
220 while (j != k) {
221 struct netmap_slot *slot = &ring->slot[j];
222 struct e1000_tx_desc *curr = &txr->tx_base[l];
223 struct em_buffer *txbuf = &txr->tx_buffers[l];
224 int flags = ((slot->flags & NS_REPORT) ||
225 j == 0 || j == report_frequency) ?
226 E1000_TXD_CMD_RS : 0;
227 uint64_t paddr;

--- 89 unchanged lines hidden (view full) ---

317 /* import newly received packets into the netmap ring.
318 * j is an index in the netmap ring, l in the NIC ring, and
319 * j = (kring->nr_hwcur + kring->nr_hwavail) % ring_size
320 * l = rxr->next_to_check;
321 * and
322 * j == (l + kring->nkr_hwofs) % ring_size
323 */
324 l = rxr->next_to_check;
215 while (j != k) {
216 struct netmap_slot *slot = &ring->slot[j];
217 struct e1000_tx_desc *curr = &txr->tx_base[l];
218 struct em_buffer *txbuf = &txr->tx_buffers[l];
219 int flags = ((slot->flags & NS_REPORT) ||
220 j == 0 || j == report_frequency) ?
221 E1000_TXD_CMD_RS : 0;
222 uint64_t paddr;

--- 89 unchanged lines hidden (view full) ---

312 /* import newly received packets into the netmap ring.
313 * j is an index in the netmap ring, l in the NIC ring, and
314 * j = (kring->nr_hwcur + kring->nr_hwavail) % ring_size
315 * l = rxr->next_to_check;
316 * and
317 * j == (l + kring->nkr_hwofs) % ring_size
318 */
319 l = rxr->next_to_check;
325 j = l + kring->nkr_hwofs;
326 /* XXX here nkr_hwofs can be negative so must check for j < 0 */
327 if (j < 0)
328 j += lim + 1;
329 else if (j > lim)
330 j -= lim + 1;
320 j = netmap_ridx_n2k(na, ring_nr, l);
331 for (n = 0; ; n++) {
332 struct e1000_rx_desc *curr = &rxr->rx_base[l];
333
334 if ((curr->status & E1000_RXD_STAT_DD) == 0)
335 break;
336 ring->slot[j].len = le16toh(curr->length);
337 bus_dmamap_sync(rxr->rxtag, rxr->rx_buffers[l].map,
338 BUS_DMASYNC_POSTREAD);
339 j = (j == lim) ? 0 : j + 1;
340 /* make sure next_to_refresh follows next_to_check */
341 rxr->next_to_refresh = l; // XXX
342 l = (l == lim) ? 0 : l + 1;
343 }
344 if (n) {
345 rxr->next_to_check = l;
346 kring->nr_hwavail += n;
347 }
348
349 /* skip past packets that userspace has already processed */
321 for (n = 0; ; n++) {
322 struct e1000_rx_desc *curr = &rxr->rx_base[l];
323
324 if ((curr->status & E1000_RXD_STAT_DD) == 0)
325 break;
326 ring->slot[j].len = le16toh(curr->length);
327 bus_dmamap_sync(rxr->rxtag, rxr->rx_buffers[l].map,
328 BUS_DMASYNC_POSTREAD);
329 j = (j == lim) ? 0 : j + 1;
330 /* make sure next_to_refresh follows next_to_check */
331 rxr->next_to_refresh = l; // XXX
332 l = (l == lim) ? 0 : l + 1;
333 }
334 if (n) {
335 rxr->next_to_check = l;
336 kring->nr_hwavail += n;
337 }
338
339 /* skip past packets that userspace has already processed */
350 j = kring->nr_hwcur;
340 j = kring->nr_hwcur; /* netmap ring index */
351 if (j != k) { /* userspace has read some packets. */
352 n = 0;
341 if (j != k) { /* userspace has read some packets. */
342 n = 0;
353 l = j - kring->nkr_hwofs; /* NIC ring index */
354 /* here nkr_hwofs can be negative so check for l > lim */
355 if (l < 0)
356 l += lim + 1;
357 else if (l > lim)
358 l -= lim + 1;
343 l = netmap_ridx_k2n(na, ring_nr, j); /* NIC ring index */
359 while (j != k) {
360 struct netmap_slot *slot = &ring->slot[j];
361 struct e1000_rx_desc *curr = &rxr->rx_base[l];
362 struct em_buffer *rxbuf = &rxr->rx_buffers[l];
363 uint64_t paddr;
364 void *addr = PNMB(slot, &paddr);
365
366 if (addr == netmap_buffer_base) { /* bad buf */

--- 38 unchanged lines hidden ---
344 while (j != k) {
345 struct netmap_slot *slot = &ring->slot[j];
346 struct e1000_rx_desc *curr = &rxr->rx_base[l];
347 struct em_buffer *rxbuf = &rxr->rx_buffers[l];
348 uint64_t paddr;
349 void *addr = PNMB(slot, &paddr);
350
351 if (addr == netmap_buffer_base) { /* bad buf */

--- 38 unchanged lines hidden ---