Deleted Added
full compact
if_igb_netmap.h (231198) if_igb_netmap.h (231594)
1/*
2 * Copyright (C) 2011 Universita` di Pisa. 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 Universita` di Pisa. 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_igb_netmap.h 231198 2012-02-08 11:43:29Z luigi $
27 * $FreeBSD: head/sys/dev/netmap/if_igb_netmap.h 231594 2012-02-13 18:56:34Z luigi $
28 * $Id: if_igb_netmap.h 9802 2011-12-02 18:42:37Z luigi $
29 *
30 * netmap modifications for igb
31 * contribured by Ahmed Kooli
32 */
33
34#include <net/netmap.h>
35#include <sys/selinfo.h>
36#include <vm/vm.h>
37#include <vm/pmap.h> /* vtophys ? */
38#include <dev/netmap/netmap_kern.h>
39
40static int igb_netmap_reg(struct ifnet *, int onoff);
28 * $Id: if_igb_netmap.h 9802 2011-12-02 18:42:37Z luigi $
29 *
30 * netmap modifications for igb
31 * contribured by Ahmed Kooli
32 */
33
34#include <net/netmap.h>
35#include <sys/selinfo.h>
36#include <vm/vm.h>
37#include <vm/pmap.h> /* vtophys ? */
38#include <dev/netmap/netmap_kern.h>
39
40static int igb_netmap_reg(struct ifnet *, int onoff);
41static int igb_netmap_txsync(void *, u_int, int);
42static int igb_netmap_rxsync(void *, u_int, int);
43static void igb_netmap_lock_wrapper(void *, int, u_int);
41static int igb_netmap_txsync(struct ifnet *, u_int, int);
42static int igb_netmap_rxsync(struct ifnet *, u_int, int);
43static void igb_netmap_lock_wrapper(struct ifnet *, int, u_int);
44
45
46static void
47igb_netmap_attach(struct adapter *adapter)
48{
49 struct netmap_adapter na;
50
51 bzero(&na, sizeof(na));

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

61 netmap_attach(&na, adapter->num_queues);
62}
63
64
65/*
66 * wrapper to export locks to the generic code
67 */
68static void
44
45
46static void
47igb_netmap_attach(struct adapter *adapter)
48{
49 struct netmap_adapter na;
50
51 bzero(&na, sizeof(na));

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

61 netmap_attach(&na, adapter->num_queues);
62}
63
64
65/*
66 * wrapper to export locks to the generic code
67 */
68static void
69igb_netmap_lock_wrapper(void *_a, int what, u_int queueid)
69igb_netmap_lock_wrapper(struct ifnet *ifp, int what, u_int queueid)
70{
70{
71 struct adapter *adapter = _a;
71 struct adapter *adapter = ifp->if_softc;
72
73 ASSERT(queueid < adapter->num_queues);
74 switch (what) {
75 case NETMAP_CORE_LOCK:
76 IGB_CORE_LOCK(adapter);
77 break;
78 case NETMAP_CORE_UNLOCK:
79 IGB_CORE_UNLOCK(adapter);

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

135 return (error);
136}
137
138
139/*
140 * Reconcile kernel and user view of the transmit ring.
141 */
142static int
72
73 ASSERT(queueid < adapter->num_queues);
74 switch (what) {
75 case NETMAP_CORE_LOCK:
76 IGB_CORE_LOCK(adapter);
77 break;
78 case NETMAP_CORE_UNLOCK:
79 IGB_CORE_UNLOCK(adapter);

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

135 return (error);
136}
137
138
139/*
140 * Reconcile kernel and user view of the transmit ring.
141 */
142static int
143igb_netmap_txsync(void *a, u_int ring_nr, int do_lock)
143igb_netmap_txsync(struct ifnet *ifp, u_int ring_nr, int do_lock)
144{
144{
145 struct adapter *adapter = a;
145 struct adapter *adapter = ifp->if_softc;
146 struct tx_ring *txr = &adapter->tx_rings[ring_nr];
147 struct netmap_adapter *na = NA(adapter->ifp);
148 struct netmap_kring *kring = &na->tx_rings[ring_nr];
149 struct netmap_ring *ring = kring->ring;
150 int j, k, l, n = 0, lim = kring->nkr_num_slots - 1;
151
152 /* generate an interrupt approximately every half ring */
153 int report_frequency = kring->nkr_num_slots >> 1;

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

253 return 0;
254}
255
256
257/*
258 * Reconcile kernel and user view of the receive ring.
259 */
260static int
146 struct tx_ring *txr = &adapter->tx_rings[ring_nr];
147 struct netmap_adapter *na = NA(adapter->ifp);
148 struct netmap_kring *kring = &na->tx_rings[ring_nr];
149 struct netmap_ring *ring = kring->ring;
150 int j, k, l, n = 0, lim = kring->nkr_num_slots - 1;
151
152 /* generate an interrupt approximately every half ring */
153 int report_frequency = kring->nkr_num_slots >> 1;

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

253 return 0;
254}
255
256
257/*
258 * Reconcile kernel and user view of the receive ring.
259 */
260static int
261igb_netmap_rxsync(void *a, u_int ring_nr, int do_lock)
261igb_netmap_rxsync(struct ifnet *ifp, u_int ring_nr, int do_lock)
262{
262{
263 struct adapter *adapter = a;
263 struct adapter *adapter = ifp->if_softc;
264 struct rx_ring *rxr = &adapter->rx_rings[ring_nr];
265 struct netmap_adapter *na = NA(adapter->ifp);
266 struct netmap_kring *kring = &na->rx_rings[ring_nr];
267 struct netmap_ring *ring = kring->ring;
268 int j, k, l, n, lim = kring->nkr_num_slots - 1;
269
270 k = ring->cur;
271 if (k > lim)

--- 86 unchanged lines hidden ---
264 struct rx_ring *rxr = &adapter->rx_rings[ring_nr];
265 struct netmap_adapter *na = NA(adapter->ifp);
266 struct netmap_kring *kring = &na->rx_rings[ring_nr];
267 struct netmap_ring *ring = kring->ring;
268 int j, k, l, n, lim = kring->nkr_num_slots - 1;
269
270 k = ring->cur;
271 if (k > lim)

--- 86 unchanged lines hidden ---