netmap.4 (1c37b63fb637010fcb530e213013e22e8882c705) netmap.4 (197f150c0c0f34514aae0aa8b3bfc9683221f422)
1.\" Copyright (c) 2011-2014 Matteo Landi, Luigi Rizzo, Universita` di Pisa
2.\" 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.

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

980.Nm
981ports.
982It can be used for transparent forwarding between
983interfaces, as in
984.Dl bridge -i netmap:ix0 -i netmap:ix1
985or even connect the NIC to the host stack using netmap
986.Dl bridge -i netmap:ix0
987.Ss USING THE NATIVE API
1.\" Copyright (c) 2011-2014 Matteo Landi, Luigi Rizzo, Universita` di Pisa
2.\" 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.

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

980.Nm
981ports.
982It can be used for transparent forwarding between
983interfaces, as in
984.Dl bridge -i netmap:ix0 -i netmap:ix1
985or even connect the NIC to the host stack using netmap
986.Dl bridge -i netmap:ix0
987.Ss USING THE NATIVE API
988The following code implements a traffic generator
988The following code implements a traffic generator:
989.Pp
990.Bd -literal -compact
991#include <net/netmap_user.h>
992\&...
993void sender(void)
994{
995 struct netmap_if *nifp;
996 struct netmap_ring *ring;

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

1015 ... prepare packet in buf ...
1016 ring->slot[i].len = ... packet length ...
1017 ring->head = ring->cur = nm_ring_next(ring, i);
1018 }
1019 }
1020}
1021.Ed
1022.Ss HELPER FUNCTIONS
989.Pp
990.Bd -literal -compact
991#include <net/netmap_user.h>
992\&...
993void sender(void)
994{
995 struct netmap_if *nifp;
996 struct netmap_ring *ring;

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

1015 ... prepare packet in buf ...
1016 ring->slot[i].len = ... packet length ...
1017 ring->head = ring->cur = nm_ring_next(ring, i);
1018 }
1019 }
1020}
1021.Ed
1022.Ss HELPER FUNCTIONS
1023A simple receiver can be implemented using the helper functions
1023A simple receiver can be implemented using the helper functions:
1024.Pp
1024.Bd -literal -compact
1025#define NETMAP_WITH_LIBS
1026#include <net/netmap_user.h>
1027\&...
1028void receiver(void)
1029{
1030 struct nm_desc *d;
1031 struct pollfd fds;

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

1044}
1045.Ed
1046.Ss ZERO-COPY FORWARDING
1047Since physical interfaces share the same memory region,
1048it is possible to do packet forwarding between ports
1049swapping buffers.
1050The buffer from the transmit ring is used
1051to replenish the receive ring:
1025.Bd -literal -compact
1026#define NETMAP_WITH_LIBS
1027#include <net/netmap_user.h>
1028\&...
1029void receiver(void)
1030{
1031 struct nm_desc *d;
1032 struct pollfd fds;

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

1045}
1046.Ed
1047.Ss ZERO-COPY FORWARDING
1048Since physical interfaces share the same memory region,
1049it is possible to do packet forwarding between ports
1050swapping buffers.
1051The buffer from the transmit ring is used
1052to replenish the receive ring:
1053.Pp
1052.Bd -literal -compact
1053 uint32_t tmp;
1054 struct netmap_slot *src, *dst;
1055 ...
1056 src = &src_ring->slot[rxr->cur];
1057 dst = &dst_ring->slot[txr->cur];
1058 tmp = dst->buf_idx;
1059 dst->buf_idx = src->buf_idx;

--- 113 unchanged lines hidden ---
1054.Bd -literal -compact
1055 uint32_t tmp;
1056 struct netmap_slot *src, *dst;
1057 ...
1058 src = &src_ring->slot[rxr->cur];
1059 dst = &dst_ring->slot[txr->cur];
1060 tmp = dst->buf_idx;
1061 dst->buf_idx = src->buf_idx;

--- 113 unchanged lines hidden ---