Deleted Added
full compact
netmap_kern.h (230052) netmap_kern.h (230058)
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/netmap_kern.h 230052 2012-01-13 10:21:15Z luigi $
27 * $FreeBSD: head/sys/dev/netmap/netmap_kern.h 230058 2012-01-13 11:58:06Z luigi $
28 * $Id: netmap_kern.h 9795 2011-12-02 11:39:08Z luigi $
29 *
30 * The header contains the definitions of constants and function
31 * prototypes used only in kernelspace.
32 */
33
34#ifndef _NET_NETMAP_KERN_H_
35#define _NET_NETMAP_KERN_H_
36
37#ifdef MALLOC_DECLARE
38MALLOC_DECLARE(M_NETMAP);
39#endif
40
41#define ND(format, ...)
28 * $Id: netmap_kern.h 9795 2011-12-02 11:39:08Z luigi $
29 *
30 * The header contains the definitions of constants and function
31 * prototypes used only in kernelspace.
32 */
33
34#ifndef _NET_NETMAP_KERN_H_
35#define _NET_NETMAP_KERN_H_
36
37#ifdef MALLOC_DECLARE
38MALLOC_DECLARE(M_NETMAP);
39#endif
40
41#define ND(format, ...)
42#define D(format, ...) \
43 do { \
44 struct timeval __xxts; \
42#define D(format, ...) \
43 do { \
44 struct timeval __xxts; \
45 microtime(&__xxts); \
45 microtime(&__xxts); \
46 printf("%03d.%06d %s [%d] " format "\n",\
47 (int)__xxts.tv_sec % 1000, (int)__xxts.tv_usec, \
48 __FUNCTION__, __LINE__, ##__VA_ARGS__); \
46 printf("%03d.%06d %s [%d] " format "\n", \
47 (int)__xxts.tv_sec % 1000, (int)__xxts.tv_usec, \
48 __FUNCTION__, __LINE__, ##__VA_ARGS__); \
49 } while (0)
50
51struct netmap_adapter;
52
53/*
54 * private, kernel view of a ring.
55 *
56 * XXX 20110627-todo

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

192#ifndef WNA
193#define WNA(_ifp) (_ifp)->if_pspare[0]
194#endif
195#define NA(_ifp) ((struct netmap_adapter *)WNA(_ifp))
196
197
198/* Callback invoked by the dma machinery after a successfull dmamap_load */
199static void netmap_dmamap_cb(__unused void *arg,
49 } while (0)
50
51struct netmap_adapter;
52
53/*
54 * private, kernel view of a ring.
55 *
56 * XXX 20110627-todo

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

192#ifndef WNA
193#define WNA(_ifp) (_ifp)->if_pspare[0]
194#endif
195#define NA(_ifp) ((struct netmap_adapter *)WNA(_ifp))
196
197
198/* Callback invoked by the dma machinery after a successfull dmamap_load */
199static void netmap_dmamap_cb(__unused void *arg,
200 __unused bus_dma_segment_t * segs, __unused int nseg, __unused int error)
200 __unused bus_dma_segment_t * segs, __unused int nseg, __unused int error)
201{
202}
203
204/* bus_dmamap_load wrapper: call aforementioned function if map != NULL.
205 * XXX can we do it without a callback ?
206 */
207static inline void
208netmap_load_map(bus_dma_tag_t tag, bus_dmamap_t map, void *buf)
209{
210 if (map)
211 bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
201{
202}
203
204/* bus_dmamap_load wrapper: call aforementioned function if map != NULL.
205 * XXX can we do it without a callback ?
206 */
207static inline void
208netmap_load_map(bus_dma_tag_t tag, bus_dmamap_t map, void *buf)
209{
210 if (map)
211 bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
212 netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
212 netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
213}
214
215/* update the map when a buffer changes. */
216static inline void
217netmap_reload_map(bus_dma_tag_t tag, bus_dmamap_t map, void *buf)
218{
219 if (map) {
220 bus_dmamap_unload(tag, map);
221 bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
213}
214
215/* update the map when a buffer changes. */
216static inline void
217netmap_reload_map(bus_dma_tag_t tag, bus_dmamap_t map, void *buf)
218{
219 if (map) {
220 bus_dmamap_unload(tag, map);
221 bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
222 netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
222 netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
223 }
224}
225
226
227/*
228 * NMB return the virtual address of a buffer (buffer 0 on bad index)
229 * PNMB also fills the physical address
223 }
224}
225
226
227/*
228 * NMB return the virtual address of a buffer (buffer 0 on bad index)
229 * PNMB also fills the physical address
230 * XXX this is a special version with hardwired 2k bufs
231 */
232static inline void *
233NMB(struct netmap_slot *slot)
234{
235 uint32_t i = slot->buf_idx;
236 return (i >= netmap_total_buffers) ? netmap_buffer_base :
237#if NETMAP_BUF_SIZE == 2048
238 netmap_buffer_base + (i << 11);

--- 20 unchanged lines hidden ---
230 */
231static inline void *
232NMB(struct netmap_slot *slot)
233{
234 uint32_t i = slot->buf_idx;
235 return (i >= netmap_total_buffers) ? netmap_buffer_base :
236#if NETMAP_BUF_SIZE == 2048
237 netmap_buffer_base + (i << 11);

--- 20 unchanged lines hidden ---