aboutsummaryrefslogtreecommitdiff
path: root/tools/tools/netmap/pkt-gen.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* netmap: pkt-gen: sync with upstreamVincenzo Maffione2023-04-261-2/+84
| | | | | | | | | | | | Keep in sync with the recent upstream changes: Fix compilation on 32-bit architectures Update IP length, UDP length/checksum when size changes Man page fixes Submitted by: jlduran@gmail.com MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D39760
* netmap: pkt-gen: init all slots of every tx ringVincenzo Maffione2023-03-061-5/+14
| | | | | | | | | | | | | | | | | | | | | | sender_body() uses OPT_COPY to copy the frame into the destination slot for the first 100,000 packets. Then it removes OPT_COPY to improve performance. The function always starts with the first tx ring. If multiple tx rings are in use, it is possible that the initial 100k packets will only use the first ring. After OPT_COPY is removed, there may come a time when the first ring is full and sender_body() will move to the next ring which was never initialized. As a result it will send all zero packets. (This was discovered when the receiving NIC reported rx errors.) Before any transmissions, step through every tx ring and set NS_BUF_CHANGED on every slot. That will force send_packets() to initialize the slot when first used. Since it only copies when necessary, it performs better than always setting OPT_COPY. With this change, there is no reason for the "drop copy" code. Submitted by: Brian Poole <brian90013@gmail.com> MFC after: 7 days
* netmap: Fix compiler warnings in toolsMark Johnston2023-02-271-5/+7
| | | | | | | | | | | | - Remove write-only variables, or hide them in cases where their use is conditional or commented out. - Check for errors from cmd_apply() in nmreplay. - Use ANSI C definitions. Reviewed by: vmaffione MFC after: 2 weeks Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38752
* netmap: pkt-gen: fix ifname before cmp in source_hwaddrVincenzo Maffione2022-12-241-0/+4
| | | | | | | | | | | | | | | In source_hwaddr(), the configured ifname is compared against all interfaces. However, in main(), the string 'netmap:' is prepended to the interface string if no explicit type is given. Therefore the ifname will not match any system interface and the source MAC address is always empty. Check for the leading 'netmap:' string and skip past it to match against system interfaces. Note that 'tap:' and 'pcap:' devices strip the type string from the ifname in main() so no further work is needed. MFC after: 7 days Submitted by: Brian Poole <brian90013@gmail.com>
* tools: Remove a double wordsGordon Bergling2022-09-101-1/+1
| | | | | | | - s/to to/to/ - s/to to/to do/ in an error message MFC after: 3 days
* pkt-gen: flip IPv4 address in ping-pong modeVincenzo Maffione2022-08-241-0/+17
| | | | MFC after: 7 days
* netmap: pkt-gen: fix compilation issueVincenzo Maffione2021-06-151-1/+1
| | | | | | | | | | Remove stray characters preventing the source code from being compiled. Fixes: 20d684ecc9d7 ("pkt-gen: Allow limiting received packets"). Submitted by: ar_semihalf.com Reviewed by: vmaffione Differential Revision: <https://reviews.freebsd.org/D###>
* pkt-gen: Allow limiting received packetsAllan Jude2021-05-221-3/+4
| | | | | | | | | | Makes pkg-gen quit after having received N packets, the same way it already supports doing for sent packets. Reviewed by: vmaffione Sponsored by: Klara Inc. MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D30266
* netmap: several typo fixesVincenzo Maffione2021-04-021-1/+1
| | | | No functional changes intended.
* netmap: pkt-gen: allow -Z and -z to be used togetherVincenzo Maffione2021-03-301-59/+66
| | | | | | | These options are used for generating random source/destination IP/ports within transmitted packets. MFC after: 1 week
* netmap: pkt-gen: fix offset hex formattingVincenzo Maffione2021-01-121-3/+3
| | | | | | PR: 252594 Reported by: brpoole@vt.edu MFC after: 3 days
* netmap: pkt-gen: switch to libnetmapVincenzo Maffione2020-11-221-95/+120
| | | | | | | | Use the newer libnetmap (included in base) rather than the older nm_open()/nm_close() defined in netmap_user.h Notes: svn path=/head/; revision=367932
* netmap: tools: fix several compiler warningsVincenzo Maffione2020-10-031-13/+12
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=366393
* netmap: pkt-gen: minor corrections to documentationVincenzo Maffione2020-10-031-8/+8
| | | | | | | | Submitted by: Brian Poole <brian90013@gmail.com> MFC after: 3 days Notes: svn path=/head/; revision=366387
* netmap: minor misc improvementsVincenzo Maffione2019-10-201-1/+2
| | | | | | | | | | | - use ring->head rather than ring->cur in lb(8) - use strlcat() rather than strncat() - fix bandwidth computation in pkt-gen(8) MFC after: 1 week Notes: svn path=/head/; revision=353775
* netmap: pkt-gen: fix bug in send_packets()Vincenzo Maffione2019-03-011-33/+33
| | | | | | | | | | | | | | | | | The send_packets() function was using ring->cur as index to scan the transmit ring. This function may also set ring->cur ahead of ring->head, in case no more slots are available. However, the function also uses nm_ring_space() which looks at ring->head to check how many slots are available. If ring->head and ring->cur are different, this results in pkt-gen advancing ring->cur beyond ring->tail. This patch fixes send_packets() (and similar source locations) to use ring->head as a index, rather than using ring->cur. MFC after: 1 week Notes: svn path=/head/; revision=344696
* tools: netmap: pkt-gen: check packet length against interface MTUVincenzo Maffione2018-12-081-19/+63
| | | | | | | | | | | | | Validate the value of the -l argument (packet length) against the MTU of the netmap port. In case the netmap port does not refer to a physical interface (e.g. VALE port or pipe), then the netmap buffer size is used as MTU. This change also sets a better default value for the -M option, so that pkt-gen uses the largest possible fragments in case of multi-slot packets. Differential Revision: https://reviews.freebsd.org/D18436 Notes: svn path=/head/; revision=341726
* netmap: pkt-gen: several updates from upstreamVincenzo Maffione2018-11-101-533/+1114
| | | | | | | | | | | | | | | | | | Various improvements to the netmap pkt-gen program: - indentation fixes - support for IPV6 - fixes to checksum computation - support for NS_MOREFRAG - rate limiting in ping mode Reviewed by: bcr, 0mp Approved by: gnn (mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D17698 Notes: svn path=/head/; revision=340325
* netmap pkt-gen tool: Fix memset(3) argument orderConrad Meyer2017-12-131-1/+1
| | | | | | | | Submitted by: Michael McConville <mmcco AT mykolab.com> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=326832
* Import the current version of netmap, aligned with the one on github.Luigi Rizzo2016-10-161-260/+854
| | | | | | | | | | | | | | | | | | | This commit, long overdue, contains contributions in the last 2 years from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including: + fixes on monitor ports + the 'ptnet' virtual device driver, and ptnetmap backend, for high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit) + improved emulated netmap mode + more robust error handling + removal of stale code + various fixes to code and documentation (some mixup between RX and TX parameters, and private and public variables) We also include an additional tool, nmreplay, which is functionally equivalent to tcpreplay but operating on netmap ports. Notes: svn path=/head/; revision=307394
* Update pkt-gen to optionally use randomised source/destinationAdrian Chadd2015-04-191-25/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | IPv4 addresses/ports. When doing traffic testing of actual code that /does/ things to the packet (rather than say, 'bridge.c'), it's typically a good idea to use a variety of cache-busting and flow-tracking-busting packet spreads. The pkt-gen method of testing an IP range was to walk it linearly - which is fine, but not useful enough. This can be used to completely randomize the source/destination addresses (eg to test out flow-tracking-busting) and to keep the destination fixed whilst randomising the source (eg to test out what a DDoS may look like.) Tested: * Intel ixgbe 10G (82599) netmap Differential Revision: https://reviews.freebsd.org/D2309 MFC after: 2 weeks Sponsored by: Norse Corp, Inc. Notes: svn path=/head/; revision=281746
* Silence a warning.George V. Neville-Neil2015-02-121-1/+1
| | | | Notes: svn path=/head/; revision=278641
* Add a new option, -P, to pkt-gen which reads a single packet from a storedGeorge V. Neville-Neil2014-10-111-6/+39
| | | | | | | | | | pcap file and transmits it instead of the default UDP packet. Reviewed by: luigi MFC after: 2 weeks Notes: svn path=/head/; revision=272962
* Update to the current version of netmap.Luigi Rizzo2014-08-161-31/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mostly bugfixes or features developed in the past 6 months, so this is a 10.1 candidate. Basically no user API changes (some bugfixes in sys/net/netmap_user.h). In detail: 1. netmap support for virtio-net, including in netmap mode. Under bhyve and with a netmap backend [2] we reach over 1Mpps with standard APIs (e.g. libpcap), and 5-8 Mpps in netmap mode. 2. (kernel) add support for multiple memory allocators, so we can better partition physical and virtual interfaces giving access to separate users. The most visible effect is one additional argument to the various kernel functions to compute buffer addresses. All netmap-supported drivers are affected, but changes are mechanical and trivial 3. (kernel) simplify the prototype for *txsync() and *rxsync() driver methods. All netmap drivers affected, changes mostly mechanical. 4. add support for netmap-monitor ports. Think of it as a mirroring port on a physical switch: a netmap monitor port replicates traffic present on the main port. Restrictions apply. Drive carefully. 5. if_lem.c: support for various paravirtualization features, experimental and disabled by default. Most of these are described in our ANCS'13 paper [1]. Paravirtualized support in netmap mode is new, and beats the numbers in the paper by a large factor (under qemu-kvm, we measured gues-host throughput up to 10-12 Mpps). A lot of refactoring and additional documentation in the files in sys/dev/netmap, but apart from #2 and #3 above, almost nothing of this stuff is visible to other kernel parts. Example programs in tools/tools/netmap have been updated with bugfixes and to support more of the existing features. This is meant to go into 10.1 so we plan an MFC before the Aug.22 deadline. A lot of this code has been contributed by my colleagues at UNIPI, including Giuseppe Lettieri, Vincenzo Maffione, Stefano Garzarella. MFC after: 3 days. Notes: svn path=/head/; revision=270063
* This new version of netmap brings you the following:Luigi Rizzo2014-02-151-227/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - netmap pipes, providing bidirectional blocking I/O while moving 100+ Mpps between processes using shared memory channels (no mistake: over one hundred million. But mind you, i said *moving* not *processing*); - kqueue support (BHyVe needs it); - improved user library. Just the interface name lets you select a NIC, host port, VALE switch port, netmap pipe, and individual queues. The upcoming netmap-enabled libpcap will use this feature. - optional extra buffers associated to netmap ports, for applications that need to buffer data yet don't want to make copies. - segmentation offloading for the VALE switch, useful between VMs. and a number of bug fixes and performance improvements. My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial amount of work on these features so we owe them a big thanks. There are some external repositories that can be of interest: https://code.google.com/p/netmap our public repository for netmap/VALE code, including linux versions and other stuff that does not belong here, such as python bindings. https://code.google.com/p/netmap-libpcap a clone of the libpcap repository with netmap support. With this any libpcap client has access to most netmap feature with no recompilation. E.g. tcpdump can filter packets at 10-15 Mpps. https://code.google.com/p/netmap-ipfw a userspace version of ipfw+dummynet which uses netmap to send/receive packets. Speed is up in the 7-10 Mpps range per core for simple rulesets. Both netmap-libpcap and netmap-ipfw will be merged upstream at some point, but while this happens it is useful to have access to them. And yes, this code will be merged soon. It is infinitely better than the version currently in 10 and 9. MFC after: 3 days Notes: svn path=/head/; revision=261909
* netmap_user.h:Luigi Rizzo2014-01-161-55/+92
| | | | | | | | | | | | | | | | | | | | | add separate rx/tx ring indexes add ring specifier in nm_open device name netmap.c, netmap_vale.c more consistent errno numbers netmap_generic.c correctly handle failure in registering interfaces. tools/tools/netmap/ massive cleanup of the example programs (a lot of common code is now in netmap_user.h.) nm_util.[ch] are going away soon. pcap.c will also go when i commit the native netmap support for libpcap. Notes: svn path=/head/; revision=260700
* It is 2014 and we have a new version of netmap.Luigi Rizzo2014-01-061-123/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most relevant features: - netmap emulation on any NIC, even those without native netmap support. On the ixgbe we have measured about 4Mpps/core/queue in this mode, which is still a lot more than with sockets/bpf. - seamless interconnection of VALE switch, NICs and host stack. If you disable accelerations on your NIC (say em0) ifconfig em0 -txcsum -txcsum you can use the VALE switch to connect the NIC and the host stack: vale-ctl -h valeXX:em0 allowing sharing the NIC with other netmap clients. - THE USER API HAS SLIGHTLY CHANGED (head/cur/tail pointers instead of pointers/count as before). This was unavoidable to support, in the future, multiple threads operating on the same rings. Netmap clients require very small source code changes to compile again. On the plus side, the new API should be easier to understand and the internals are a lot simpler. The manual page has been updated extensively to reflect the current features and give some examples. This is the result of work of several people including Giuseppe Lettieri, Vincenzo Maffione, Michio Honda and myself, and has been financially supported by EU projects CHANGE and OPENLAB, from NetApp University Research Fund, NEC, and of course the Universita` di Pisa. Notes: svn path=/head/; revision=260368
* Minor spelling correction.Hiren Panchasara2013-11-101-3/+3
| | | | Notes: svn path=/head/; revision=257906
* update to the latest netmap snapshot.Luigi Rizzo2013-11-011-114/+280
| | | | | | | | | | | | | | | | | | | | | | | This includes the following: - use separate memory regions for VALE ports - locking fixes - some simplifications in the NIC-specific routines - performance improvements for the VALE switch - some new features in the pkt-gen test program - documentation updates There are small API changes that require programs to be recompiled (NETMAP_API has been bumped so you will detect old binaries at runtime). In particular: - struct netmap_slot now is 16 bytes to support an extra pointer, which may save one data copy when using VALE ports or VMs; - the struct netmap_if has two extra fields; MFC after: 3 days Notes: svn path=/head/; revision=257529
* new features (mostly for testing netmap capabilities)Luigi Rizzo2013-06-051-38/+63
| | | | | | | | | | | | | | | | + pkt-gen -f rx now remains active even when traffic stops Previous behaviour (exit after 1 second of silence) can be restored with the -W option + the -X option does a hexdump of the content of a packet (both tx and rx). This can be useful to check what goes in and out. + the -I option instructs the sender to use indirect buffers (not really useful other than to test the kernel module in the VALE switch) Notes: svn path=/head/; revision=251426
* add support for rate-limiting in the sender (-R ...)Luigi Rizzo2013-05-301-17/+139
| | | | | | | Obtained from: Giuseppe Lettieri Notes: svn path=/head/; revision=251132
* update the netmap example programs merging some common code in nm_util.cLuigi Rizzo2013-02-171-458/+824
| | | | | | | | pkt-gen now implements several functions (unlimited transmit, receive, ping-pong) and can operate on a 'tap' device. Notes: svn path=/head/; revision=246896
* Failure to open netmap device is unrecoverable.Ed Maste2012-09-041-1/+1
| | | | | | | | There's no reason to "fail later" since there's nothing this tool can do in netmap mode without /dev/netmap open. Notes: svn path=/head/; revision=240103
* Be more descriptive about poll error / timeout when transmitting.Ed Maste2012-08-081-3/+8
| | | | Notes: svn path=/head/; revision=239145
* Round displayed pps (instead of truncating)Ed Maste2012-08-081-1/+1
| | | | Notes: svn path=/head/; revision=239139
* Allow continuous packet transmission (via -t 0)Ed Maste2012-07-061-6/+13
| | | | | | | | Also add a missing check for the cancel flag while waiting for the first packet in receive mode. Notes: svn path=/head/; revision=238175
* Also report tx bandwidth with Ethernet overheadEd Maste2012-07-061-14/+28
| | | | Notes: svn path=/head/; revision=238170
* Allow threads to finish up when terminated by userEd Maste2012-07-061-13/+11
| | | | | | | | | Set a flag and allow worker threads to finish upon ^C, instead of immediately cancelling them, so that final packet count and rate stats can be displayed. Notes: svn path=/head/; revision=238165
* Update comment to reflect function's actual operationEd Maste2012-07-031-1/+1
| | | | Notes: svn path=/head/; revision=238081
* - add code to run pkt-gen on top of libpcap so we can see theLuigi Rizzo2012-05-031-25/+108
| | | | | | | | | | difference from a native API - add some testing options, such as conditional prefetching and packet copy. Notes: svn path=/head/; revision=234956
* A bunch of netmap fixes:Luigi Rizzo2012-02-271-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USERSPACE: 1. add support for devices with different number of rx and tx queues; 2. add better support for zero-copy operation, adding an extra field to the netmap ring to indicate how many buffers we have already processed but not yet released (with help from Eddie Kohler); 3. The two changes above unfortunately require an API change, so while at it add a version field and some spares to the ioctl() argument to help detect mismatches. 4. update the manual page for the two changes above; 5. update sample applications in tools/tools/netmap KERNEL: 1. simplify the internal structures moving the global wait queues to the 'struct netmap_adapter'; 2. simplify the functions that map kring<->nic ring indexes 3. normalize device-specific code, helps mainteinance; 4. start exploring the impact of micro-optimizations (prefetch etc.) in the ixgbe driver. Use 'legacy' descriptors on the tx ring and prefetch slots gives about 20% speedup at 900 MHz. Another 7-10% would come from removing the explict calls to bus_dmamap* in the core (they are effectively NOPs in this case, but it takes expensive load of the per-buffer dma maps to figure out that they are all NULL. Rx performance not investigated. I am postponing the MFC so i can import a few more improvements before merging. Notes: svn path=/head/; revision=232238
* - change the buffer size from a constant to aLuigi Rizzo2012-02-081-1/+1
| | | | | | | | | | | | | | | | TUNABLE variable (hw.netmap.buf_size) so we can experiment with values different from 2048 which may give better cache performance. - rearrange the memory allocation code so it will be easier to replace it with a different implementation. The current code relies on a single large contiguous chunk of memory obtained through contigmalloc. The new implementation (not committed yet) uses multiple smaller chunks which are easier to fit in a fragmented address space. Notes: svn path=/head/; revision=231198
* Spelling fixes for tools/Ulrich Spörlein2011-12-301-5/+5
| | | | | | | Add some $FreeBSD$ tags so svn will allow the commit. Notes: svn path=/head/; revision=228975
* 1. Fix the handling of link reset while in netmap more.Luigi Rizzo2011-12-051-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A link reset now is completely transparent for the netmap client: even if the NIC resets its own ring (e.g. restarting from 0), the client will not see any change in the current rx/tx positions, because the driver will keep track of the offset between the two. 2. make the device-specific code more uniform across different drivers There were some inconsistencies in the implementation of the netmap support routines, now drivers have been aligned to a common code structure. 3. import netmap support for ixgbe . This is implemented as a very small patch for ixgbe.c (233 lines, 11 chunks, mostly comments: in total the patch has only 54 lines of new code) , as most of the code is in an external file sys/dev/netmap/ixgbe_netmap.h , following some initial comments from Jack Vogel about making changes less intrusive. (Note, i have emailed Jack multiple times asking if he had comments on this structure of the code; i got no reply so i assume he is fine with it). Support for other drivers (em, lem, re, igb) will come later. "ixgbe" is now the reference driver for netmap support. Both the external file (sys/dev/netmap/ixgbe_netmap.h) and the device-specific patches (in sys/dev/ixgbe/ixgbe.c) are heavily commented and should serve as a reference for other device drivers. Tested on i386 and amd64 with the pkt-gen program in tools/tools/netmap, the sender does 14.88 Mpps at 1050 Mhz and 14.2 Mpps at 900 MHz on an i7-860 with 4 cores and 82599 card. Haven't tried yet more aggressive optimizations such as adding 'prefetch' instructions in the time-critical parts of the code. Notes: svn path=/head/; revision=228276
* Bring in support for netmap, a framework for very efficient packetLuigi Rizzo2011-11-171-0/+1021
I/O from userspace, capable of line rate at 10G, see http://info.iet.unipi.it/~luigi/netmap/ At this time I am bringing in only the generic code (sys/dev/netmap/ plus two headers under sys/net/), and some sample applications in tools/tools/netmap. There is also a manpage in share/man/man4 [1] In order to make use of the framework you need to build a kernel with "device netmap", and patch individual drivers with the code that you can find in sys/dev/netmap/head.diff The file will go away as the relevant pieces are committed to the various device drivers, which should happen in a few days after talking to the driver maintainers. Netmap support is available at the moment for Intel 10G and 1G cards (ixgbe, em/lem/igb), and for the Realtek 1G card ("re"). I have partial patches for "bge" and am starting to work on "cxgbe". Hopefully changes are trivial enough so interested third parties can submit their patches. Interested people can contact me for advice on how to add netmap support to specific devices. CREDITS: Netmap has been developed by Luigi Rizzo and other collaborators at the Universita` di Pisa, and supported by EU project CHANGE (http://www.change-project.eu/) The code is distributed under a BSD Copyright. [1] In my opinion is a bad idea to have all manpage in one directory. We should place kernel documentation in the same dir that contains the code, which would make it much simpler to keep doc and code in sync, reduce the clutter in share/man/ and incidentally is the policy used for all of userspace code. Makefiles and doc tools can be trivially adjusted to find the manpages in the relevant subdirs. Notes: svn path=/head/; revision=227614