Deleted Added
full compact
netmap_kern.h (231594) netmap_kern.h (231796)
1/*
2 * Copyright (C) 2011-2012 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-2012 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 231594 2012-02-13 18:56:34Z luigi $
27 * $FreeBSD: head/sys/dev/netmap/netmap_kern.h 231796 2012-02-15 23:13:29Z 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_

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

245{
246 if (map) {
247 bus_dmamap_unload(tag, map);
248 bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
249 netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
250 }
251}
252
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_

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

245{
246 if (map) {
247 bus_dmamap_unload(tag, map);
248 bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
249 netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
250 }
251}
252
253/*
254 * functions to map NIC to KRING indexes (n2k) and vice versa (k2n)
255 */
256static inline int
257netmap_ridx_n2k(struct netmap_adapter *na, int ring, int nic_idx)
258{
259 int kring_idx = nic_idx + na->rx_rings[ring].nkr_hwofs;
260 if (kring_idx < 0)
261 return kring_idx + na->num_rx_desc;
262 else if (kring_idx < na->num_rx_desc)
263 return kring_idx;
264 else
265 return kring_idx - na->num_rx_desc;
266}
253
267
268static inline int
269netmap_tidx_n2k(struct netmap_adapter *na, int ring, int nic_idx)
270{
271 int kring_idx = nic_idx + na->tx_rings[ring].nkr_hwofs;
272 if (kring_idx < 0)
273 return kring_idx + na->num_tx_desc;
274 else if (kring_idx < na->num_tx_desc)
275 return kring_idx;
276 else
277 return kring_idx - na->num_tx_desc;
278}
279
280
281static inline int
282netmap_ridx_k2n(struct netmap_adapter *na, int ring, int kring_idx)
283{
284 int nic_idx = kring_idx - na->rx_rings[ring].nkr_hwofs;
285 if (nic_idx < 0)
286 return nic_idx + na->num_rx_desc;
287 else if (nic_idx < na->num_rx_desc)
288 return nic_idx;
289 else
290 return nic_idx - na->num_rx_desc;
291}
292
293
294static inline int
295netmap_tidx_k2n(struct netmap_adapter *na, int ring, int kring_idx)
296{
297 int nic_idx = kring_idx - na->tx_rings[ring].nkr_hwofs;
298 if (nic_idx < 0)
299 return nic_idx + na->num_tx_desc;
300 else if (nic_idx < na->num_tx_desc)
301 return nic_idx;
302 else
303 return nic_idx - na->num_tx_desc;
304}
305
254/*
255 * NMB return the virtual address of a buffer (buffer 0 on bad index)
256 * PNMB also fills the physical address
257 */
258static inline void *
259NMB(struct netmap_slot *slot)
260{
261 uint32_t i = slot->buf_idx;

--- 22 unchanged lines hidden ---
306/*
307 * NMB return the virtual address of a buffer (buffer 0 on bad index)
308 * PNMB also fills the physical address
309 */
310static inline void *
311NMB(struct netmap_slot *slot)
312{
313 uint32_t i = slot->buf_idx;

--- 22 unchanged lines hidden ---