summaryrefslogtreecommitdiff
path: root/sys/dev/netmap
Commit message (Collapse)AuthorAgeFilesLines
* MFC :r340436Vincenzo Maffione2018-11-151-207/+315
| | | | | | | | | | | | | | | | | | | | | | | | | | | | vtnet: fix netmap support netmap(4) support for vtnet(4) was incomplete and had multiple bugs. This commit fixes those bugs to bring netmap on vtnet in a functional state. Changelist: - handle errors returned by virtqueue_enqueue() properly (they were previously ignored) - make sure netmap XOR rest of the kernel access each virtqueue. - compute the number of netmap slots for TX and RX separately, according to whether indirect descriptors are used or not for a given virtqueue. - make sure sglist are freed according to their type (mbufs or netmap buffers) - add support for mulitiqueue and netmap host (aka sw) rings. - intercept VQ interrupts directly instead of intercepting them in txq_eof and rxq_eof. This simplifies the code and makes it easier to make sure taskqueues are not running for a VQ while it is in netmap mode. - implement vntet_netmap_config() to cope with changes in the number of queues. Sponsored by: Sunny Valley Networks Differential Revision: https://reviews.freebsd.org/D17916 Approved by: re (gjb) Notes: svn path=/stable/12/; revision=340461
* MFC r339639:Vincenzo Maffione2018-10-3010-2327/+2740
| | | | | | | | | | | | | | | | | | | | netmap: align codebase to the current upstream (sha 8374e1a7e6941) Changelist: - Move large parts of VALE code to a new file and header netmap_bdg.[ch]. This is useful to reuse the code within upcoming projects. - Improvements and bug fixes to pipes and monitors. - Introduce nm_os_onattach(), nm_os_onenter() and nm_os_onexit() to handle differences between FreeBSD and Linux. - Introduce some new helper functions to handle more host rings and fake rings (netmap_all_rings(), netmap_real_rings(), ...) - Added new sysctl to enable/disable hw checksum in emulated netmap mode. - nm_inject: add support for NS_MOREFRAG Approved by: re (gjb) Notes: svn path=/stable/12/; revision=339906
* Fix several memory leaks.David Bright2018-08-141-1/+1
| | | | | | | | | | | | | | | | | The libkqueue tests have several places that leak memory by using an idiom like: puts(kevent_to_str(kevp)); Rework to save the pointer returned from kevent_to_str() and then free() it after it has been used. Reported by: asomers (pointer to Coverity), Coverity CID: 1296063, 1296064, 1296065, 1296066, 1296067, 1350287, 1394960 Sponsored by: Dell EMC Notes: svn path=/head/; revision=337812
* netmap and iflib drivers, silence unused var warningsMatt Macy2018-05-191-1/+1
| | | | Notes: svn path=/head/; revision=333870
* netmap: compare e1 with e2, not with itselfMatt Macy2018-05-191-1/+1
| | | | Notes: svn path=/head/; revision=333865
* netmap: pull fix for 32-bit support from upstreamMatt Macy2018-05-1811-285/+308
| | | | | | | Approved by: sbruno Notes: svn path=/head/; revision=333778
* Fix build on 32-bit systems.Brooks Davis2018-04-131-2/+2
| | | | Notes: svn path=/head/; revision=332488
* netmap: align codebase to the current upstream (commit id 3fb001303718146)Vincenzo Maffione2018-04-1214-1364/+2570
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changelist: - Turn tx_rings and rx_rings arrays into arrays of pointers to kring structs. This patch includes fixes for ixv, ixl, ix, re, cxgbe, iflib, vtnet and ptnet drivers to cope with the change. - Generalize the nm_config() callback to accept a struct containing many parameters. - Introduce NKR_FAKERING to support buffers sharing (used for netmap pipes) - Improved API for external VALE modules. - Various bug fixes and improvements to the netmap memory allocator, including support for externally (userspace) allocated memory. - Refactoring of netmap pipes: now linked rings share the same netmap buffers, with a separate set of kring pointers (rhead, rcur, rtail). Buffer swapping does not need to happen anymore. - Large refactoring of the control API towards an extensible solution; the goal is to allow the addition of more commands and extension of existing ones (with new options) without the need of hacks or the risk of running out of configuration space. A new NIOCCTRL ioctl has been added to handle all the requests of the new control API, which cover all the functionalities so far supported. The netmap API bumps from 11 to 12 with this patch. Full backward compatibility is provided for the old control command (NIOCREGIF), by means of a new netmap_legacy module. Many parts of the old netmap.h header has now been moved to netmap_legacy.h (included by netmap.h). Approved by: hrs (mentor) Notes: svn path=/head/; revision=332423
* netmap: align codebase to upstream version v11.4Vincenzo Maffione2018-04-0919-463/+1230
| | | | | | | | | | | | | | | | | | | Changelist: - remove unused nkr_slot_flags - new nm_intr adapter callback to enable/disable interrupts - remove unused sysctls and document the other sysctls - new infrastructure to support NS_MOREFRAG for NIC ports - support for external memory allocator (for now linux-only), including linux-specific changes in common headers - optimizations within netmap pipes datapath - improvements on VALE control API - new nm_parse() helper function in netmap_user.h - various bug fixes and code clean up Approved by: hrs (mentor) Notes: svn path=/head/; revision=332319
* netmap: align if_ptnet guest driver to the upstream code (commit 0e15788)Vincenzo Maffione2018-04-043-174/+204
| | | | | | | | | | | | | The change upgrades the driver to use the split Communication Status Block (CSB) format. In this way the variables written by the guest and read by the host are allocated in a different cacheline than the variables written by the host and read by the guest; this is needed to avoid cache thrashing. Approved by: hrs (mentor) Notes: svn path=/head/; revision=332047
* Revert r327828, r327949, r327953, r328016-r328026, r328041:Pedro F. Giffuni2018-01-211-1/+1
| | | | | | | | | | | | | | | | | | Uses of mallocarray(9). The use of mallocarray(9) has rocketed the required swap to build FreeBSD. This is likely caused by the allocation size attributes which put extra pressure on the compiler. Given that most of these checks are superfluous we have to choose better where to use mallocarray(9). We still have more uses of mallocarray(9) but hopefully this is enough to bring swap usage to a reasonable level. Reported by: wosch PR: 225197 Notes: svn path=/head/; revision=328218
* dev: make some use of mallocarray(9).Pedro F. Giffuni2018-01-131-1/+1
| | | | | | | | | | | | | | Focus on code where we are doing multiplications within malloc(9). None of these is likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values. Notes: svn path=/head/; revision=327949
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2716-16/+48
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* Shorten list of arguments to mbuf external storage freeing function.Gleb Smirnoff2017-10-091-2/+2
| | | | | | | | | | | | | | | | | | | | All of these arguments are stored in m_ext, so there is no reason to pass them in the argument list. Not all functions need the second argument, some don't even need the first one. The second argument lives in next cache line, so not dereferencing it is a performance gain. This was discovered in sendfile(2), which will be covered by next commits. The second goal of this commit is to bring even more flexibility to m_ext mbufs, allowing to create more fields in m_ext, opaque to the generic mbuf code, and potentially set and dereferenced by subsystems. Reviewed by: gallatin, kbowling Differential Revision: https://reviews.freebsd.org/D12615 Notes: svn path=/head/; revision=324446
* Restore the changes done in r313982: Replace zero with NULL for pointers.Luiz Otavio O Souza2017-07-212-2/+2
| | | | | | | | | Spotted by: Harry Schmalzbauer MFC after: 1 week Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=321321
* Do not allow the use of the loopback interface in netmap.Luiz Otavio O Souza2017-07-211-0/+8
| | | | | | | | | | | | | | | The generic support in netmap send the packets using if_transmit() and the loopback do not support packets coming from if_transmit()/if_start(). This avoids the use of the loopback interface and the subsequent crash that happens when the application send packets to the loopback interface. Details in: https://github.com/luigirizzo/netmap/issues/322 Reported by: Vincenzo Maffione <v.maffione@gmail.com> Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=321317
* Update the current version of netmap to bring it in sync with the githubLuiz Otavio O Souza2017-06-1212-830/+1230
| | | | | | | | | | | | | | version. This commit contains mostly refactoring, a few fixes and minor added functionality. Submitted by: Vincenzo Maffione <v.maffione at gmail.com> Requested by: many Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=319881
* sys/dev: Replace zero with NULL for pointers.Pedro F. Giffuni2017-02-202-2/+2
| | | | | | | | | | | Makes things easier to read, plus architectures may set NULL to something different than zero. Found with: devel/coccinelle MFC after: 3 weeks Notes: svn path=/head/; revision=313982
* Unbreak the gcc build of netmap.Mark Johnston2017-02-141-9/+15
| | | | | | | | | This fixes several LINT targets. Reviewed by: Vincenzo Maffione Notes: svn path=/head/; revision=313747
* Fix panic on mb_free_ext() due to NULL destructor.Sean Bruno2017-01-121-3/+3
| | | | | | | | | | This used to happen because of the SET_MBUF_DESTRUCTOR() called on unregif. Submitted by: Vincenzo Maffione <v.maffione@gmail.com> Notes: svn path=/head/; revision=311986
* [netmap] call RLOCK /and/ RUNLOCK.Adrian Chadd2017-01-021-1/+1
| | | | | | | Reported by: olivier Notes: svn path=/head/; revision=311045
* [netmap] fix locking regressionsAdrian Chadd2016-12-301-4/+4
| | | | | | | | | | | | | | | | | * Firmware oriented NICs may need to sleep in their configuration paths. Use RLOCK instead of WLOCK to allow this to again occur. This fixes netmap on cxgbe. * Change the worker lock to a normal mutex rather than a spin lock. Drivers shouldn't be doing netmap work from the fast interrupt handlers, so it's not required to be a spinlock. Submitted by: luigi, Vincenzo Maffione <v.maffione@gmail.com> Reviewed by: jhb Notes: svn path=/head/; revision=310822
* netmap: add cast to fix powerpc64 LINT kernelEd Maste2016-11-301-3/+3
| | | | | | | | | | | | | Attempt to fix powerpc64 LINT kernel broken by r308000. Netmap's use of a uint64_t wchan seems odd, but in the interest of minimizing this change just cast through uintptr_t to silence the compiler warning. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8669 Notes: svn path=/head/; revision=309306
* The buffer address is always overwritten in the extended descriptor format,Sean Bruno2016-10-281-1/+1
| | | | | | | | | | | | | we have to refresh it ... always. This fixes problems reported in NetMap with em(4) devices after conversion to extended descriptor format in svn r293331. Submitted by: luigi@ Reported by: franco@opnsense.org MFC after: 2 days Notes: svn path=/head/; revision=308038
* Various fixes for ptnet/ptnetmap (passthrough of netmap ports). In detail:Luigi Rizzo2016-10-278-285/+214
| | | | | | | | | | | - use PCI_VENDOR and PCI_DEVICE ids from a publicly allocated range (thanks to RedHat) - export memory pool information through PCI registers - improve mechanism for configuring passthrough on different hypervisors Code is from Vincenzo Maffione as a follow up to his GSOC work. Notes: svn path=/head/; revision=308000
* netmap: fix kernel build on GCC-using architecturesEd Maste2016-10-211-1/+1
| | | | | | | | GCC produced a multiple declaration warning from the SYSCTL_DECL(_dev_netmap). Notes: svn path=/head/; revision=307728
* netmap: Unbreak LINT-VIMAGE buildingSepherosa Ziehau2016-10-211-3/+3
| | | | | | | Sponsored by: Microsoft Notes: svn path=/head/; revision=307706
* netmap: Unbreak i386 LINT buildingSepherosa Ziehau2016-10-211-2/+2
| | | | | | | Sponsored by: Microsoft Notes: svn path=/head/; revision=307703
* remove stale and unused code from various filesLuigi Rizzo2016-10-187-104/+60
| | | | | | | | | | | | fix build on 32 bit platforms simplify logic in netmap_virt.h The commands (in net/netmap.h) to configure communication with the hypervisor may be revised soon. At the moment they are unused so this will not be a change of API. Notes: svn path=/head/; revision=307574
* remove trailing whitespace. No code changes.Luigi Rizzo2016-10-184-11/+11
| | | | Notes: svn path=/head/; revision=307572
* Restore svn r306772 that was overwritten by netmap import at svn r307394Sean Bruno2016-10-181-0/+1
| | | | | | | | #include <sys/selinfo.h> should be here as all drivers that support netmap need to use this file regardless. Notes: svn path=/head/; revision=307569
* add two missing files for the netmap importLuigi Rizzo2016-10-162-0/+3739
| | | | Notes: svn path=/head/; revision=307395
* Import the current version of netmap, aligned with the one on github.Luigi Rizzo2016-10-1615-1602/+4404
| | | | | | | | | | | | | | | | | | | 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
* Move netmap selinfo.h in to sensible location.Sean Bruno2016-10-061-0/+1
| | | | | | | | | | | | | netmap_kern.h currently requires all drivers including it to include selinfo.h. Submitted by: mmacy@nextbsd.org Reviewed by: gnn MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D5334 Notes: svn path=/head/; revision=306772
* Fix linker warnings (errors on gcc) that resulted from r304510.Eric Joyner2016-09-011-1/+0
| | | | | | | | | | | The variables that are extern in the netmap header file should be defined in ixl_txrx.c (the file that is included in both ixl(4)/ixlv(4), not in the main driver source files. Reported by: ed@, dim@, ngie@ Notes: svn path=/head/; revision=305168
* Consistently use `device_t`Jean-Sébastien Pédron2016-08-091-2/+2
| | | | | | | | | | | | | | | | | | Several files use the internal name of `struct device` instead of `device_t` which is part of the public API. This patch changes all `struct device *` to `device_t`. The remaining occurrences of `struct device` are those referring to the Linux or OpenBSD version of the structure, or the code is not built on FreeBSD and it's unclear what to do. Submitted by: Matthew Macy <mmacy@nextbsd.org> (previous version) Approved by: emaste, jhibbits, sbruno MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D7447 Notes: svn path=/head/; revision=303890
* Don't repeat the the word 'the'Eitan Adler2016-05-171-1/+1
| | | | | | | | | | (one manual change to fix grammar) Confirmed With: db Approved by: secteam (not really, but this is a comment typo fix) Notes: svn path=/head/; revision=300050
* sys/dev: minor spelling fixes.Pedro F. Giffuni2016-05-033-5/+5
| | | | | | | Most affect comments, very few have user-visible effects. Notes: svn path=/head/; revision=298955
* Plug leak in m_unshare.Navdeep Parhar2016-03-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | m_unshare passes on the source mbuf's flags as-is to m_getcl and this results in a leak if the flags include M_NOFREE. The fix is to clear the bits not listed in M_COPYALL before calling m_getcl. M_RDONLY should probably be filtered out too but that's outside the scope of this fix. Add assertions in the zone_mbuf and zone_pack ctors to catch similar bugs. Update netmap_get_mbuf to not pass M_NOFREE to m_getcl. It's not clear what the original code was trying to do but it's likely incorrect. Updated code is no different functionally but it avoids the newly added assertions. Reviewed by: gnn@ Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D5698 Notes: svn path=/head/; revision=297298
* These files were getting sys/malloc.h and vm/uma.h with header pollutionGleb Smirnoff2016-02-011-0/+1
| | | | | | | via sys/mbuf.h Notes: svn path=/head/; revision=295126
* Switch em(4) to the extended RX descriptor format. This matches theSean Bruno2016-01-071-8/+8
| | | | | | | | | | | | | | | | | | | | | e1000/e1000e split in linux. Split rxbuffer and txbuffer apart to support the new RX descriptor format structures. Move rxbuffer manipulation to em_setup_rxdesc() to unify the new behavior changes. Add a RSSKEYLEN macro for help in generating the RSSKEY data structures in the card. Change em_receive_checksum() to process the new rxdescriptor format status bit. MFC after: 2 weeks Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D3447 Notes: svn path=/head/; revision=293331
* Fix typo (s/harware/hardware/)Kevin Lo2015-12-251-1/+1
| | | | Notes: svn path=/head/; revision=292730
* Don't call enable_all_rings if the adapter has been freed.Adrian Chadd2015-09-071-2/+5
| | | | | | | | | | | This is a subtle use-after-free race that results in some very undesirable hang behaviour. Reviewed by: pkelsey Obtained from: Kip Macy, NextBSD (https://github.com/NextBSD/NextBSD/commit/91a9bd1dbb33dafb41684d054e59d73976de9654) Notes: svn path=/head/; revision=287543
* add a use count so the netmap module cannot be unloaded while in use.Luigi Rizzo2015-07-193-2/+18
| | | | Notes: svn path=/head/; revision=285699
* properly destroy persistent vale portsLuigi Rizzo2015-07-191-12/+6
| | | | Notes: svn path=/head/; revision=285698
* do not free NULL if pipe allocation failsLuigi Rizzo2015-07-191-1/+3
| | | | Notes: svn path=/head/; revision=285697
* release a reference when stopping a monitorLuigi Rizzo2015-07-191-0/+1
| | | | Notes: svn path=/head/; revision=285696
* small documentation updateLuigi Rizzo2015-07-191-3/+4
| | | | Notes: svn path=/head/; revision=285695
* Add netmap support for ixgbe SRIOV VFs (that is, to if_ixv).Patrick Kelsey2015-07-151-13/+14
| | | | | | | | | | Differential Revision: https://reviews.freebsd.org/D2923 Reviewed by: erj, gnn Approved by: jmallett (mentor) Sponsored by: Norse Corp, Inc. Notes: svn path=/head/; revision=285592
* set the refcount for the structure (dropped by mistake in the last commit).Luigi Rizzo2015-07-131-0/+1
| | | | Notes: svn path=/head/; revision=285445