├── .gitignore ├── GNUmakefile ├── LICENSE ├── LINUX ├── Kbuild.in ├── README ├── archlinux │ ├── PKGBUILD │ ├── README │ └── netmap.install ├── bsd_glue.h ├── configure ├── default-config.mak.in_ ├── dkms │ ├── Makefile │ ├── README.md │ ├── dkms.conf │ ├── netmap-dkms-mkdeb │ │ ├── Makefile │ │ └── debian │ │ │ ├── README.Debian │ │ │ ├── changelog │ │ │ ├── compat │ │ │ ├── control │ │ │ ├── copyright │ │ │ ├── dirs │ │ │ ├── postinst │ │ │ ├── prerm │ │ │ └── rules │ └── netmap-dkms-mkdsc ├── drv-subdir.mak ├── drvname2config ├── ext-drivers │ └── .gitignore ├── final-patches │ ├── intel--e1000e--3.3.5 │ ├── intel--i40e--1.5.25 │ ├── intel--igb--5.3.5.4 │ ├── intel--ixgbe--4.5.4 │ ├── intel--ixgbevf--3.3.2 │ ├── vanilla--e1000--20620--31200 │ ├── vanilla--e1000--31200--99999 │ ├── vanilla--e1000e--20620--30100 │ ├── vanilla--e1000e--30100--30400 │ ├── vanilla--e1000e--30400--30900 │ ├── vanilla--e1000e--30900--99999 │ ├── vanilla--forcedeth.c--20626--99999 │ ├── vanilla--i40e--30c00--40100 │ ├── vanilla--i40e--40100--40300 │ ├── vanilla--i40e--40300--40400 │ ├── vanilla--i40e--40400--40700 │ ├── vanilla--i40e--40700--99999 │ ├── vanilla--igb--20621--20623 │ ├── vanilla--igb--20623--30200 │ ├── vanilla--igb--30200--30800 │ ├── vanilla--igb--30800--30f00 │ ├── vanilla--igb--30f00--40100 │ ├── vanilla--igb--40100--99999 │ ├── vanilla--ixgbe--20620--20622 │ ├── vanilla--ixgbe--20622--20623 │ ├── vanilla--ixgbe--20623--20625 │ ├── vanilla--ixgbe--20625--20626 │ ├── vanilla--ixgbe--20626--30100 │ ├── vanilla--ixgbe--30100--30200 │ ├── vanilla--ixgbe--30200--30400 │ ├── vanilla--ixgbe--30400--30500 │ ├── vanilla--ixgbe--30500--30700 │ ├── vanilla--ixgbe--30700--30a00 │ ├── vanilla--ixgbe--30a00--30d00 │ ├── vanilla--ixgbe--30d00--30f00 │ ├── vanilla--ixgbe--30f00--31300 │ ├── vanilla--ixgbe--31300--40900 │ ├── vanilla--ixgbe--40900--99999 │ ├── vanilla--r8169.c--20620--20625 │ ├── vanilla--r8169.c--20625--20626 │ ├── vanilla--r8169.c--20626--30400 │ ├── vanilla--veth.c--20620--30900 │ ├── vanilla--veth.c--30900--30f00 │ ├── vanilla--veth.c--30f00--99999 │ ├── vanilla--virtio_net.c--20622--20625 │ ├── vanilla--virtio_net.c--20625--20626 │ ├── vanilla--virtio_net.c--20626--30300 │ ├── vanilla--virtio_net.c--30300--30500 │ ├── vanilla--virtio_net.c--30500--30800 │ ├── vanilla--virtio_net.c--30800--30b00 │ ├── vanilla--virtio_net.c--30b00--31100 │ ├── vanilla--virtio_net.c--31100--31300 │ ├── vanilla--virtio_net.c--31300--40100 │ └── vanilla--virtio_net.c--40100--99999 ├── forcedeth_netmap.h ├── i40e_netmap_linux.h ├── if_e1000_netmap.h ├── if_e1000e_netmap.h ├── if_igb_netmap.h ├── if_re_netmap_linux.h ├── ixgbe_netmap_linux.h ├── netmap.mak.in ├── netmap_linux.c ├── netmap_ptnet.c ├── netmap_set_adapter.sh ├── openwrt │ └── netmap │ │ └── Makefile ├── read-vars.mak ├── scripts │ ├── help │ ├── linux-pktgen.sh │ ├── np │ └── vers ├── veth_netmap.h └── virtio_netmap.h ├── Makefile ├── PORTING ├── README ├── README.images ├── WINDOWS ├── Loader │ ├── loader.vcxproj │ ├── loader.vcxproj.Filters │ └── main.c ├── Makefile ├── README.txt ├── includes │ └── net │ │ ├── ethernet.h │ │ └── if_dl.h ├── my-project-cfg.props ├── my-project.props ├── netmap-pkg.vcxproj ├── netmap-pkg.vcxproj.filters ├── netmap-pkg.vcxproj.user ├── netmap.inf ├── netmap.sln ├── netmap.vcxproj ├── netmap.vcxproj.filters ├── netmap.vcxproj.user ├── netmap_windows.c ├── netmap_windows.rc ├── nm-ndis │ ├── device.c │ ├── filter.c │ ├── filter.h │ ├── filter.rc │ ├── filter.sln │ ├── filteruser.h │ ├── flt_dbg.c │ ├── flt_dbg.h │ ├── license.rtf │ ├── nm-ndis-pkg.vcxproj │ ├── nm-ndis-pkg.vcxproj.filters │ ├── nm-ndis-pkg.vcxproj.user │ ├── nm-ndis.inf │ ├── nm-ndis.vcxproj │ ├── nm-ndis.vcxproj.filters │ ├── nm-ndis.vcxproj.user │ ├── precomp.h │ └── precompsrc.c ├── win_glue.c └── win_glue.h ├── apps ├── README ├── bridge │ ├── GNUmakefile │ └── bridge.c ├── include │ └── ctrs.h ├── lb │ ├── .gitignore │ ├── GNUmakefile │ ├── lb.8 │ ├── lb.c │ ├── pkt_hash.c │ └── pkt_hash.h ├── nmreplay │ ├── .gitignore │ ├── GNUmakefile │ ├── README │ ├── nmreplay.8 │ └── nmreplay.c ├── pkt-gen │ ├── GNUmakefile │ └── pkt-gen.c ├── tlem │ ├── .gitignore │ ├── GNUmakefile │ ├── README │ ├── tlem.8 │ └── tlem.c └── vale-ctl │ ├── GNUmakefile │ ├── vale-ctl.8 │ └── vale-ctl.c ├── configure ├── extra └── python │ ├── Makefile │ ├── README │ ├── netmap.c │ ├── netmap_classes.h │ ├── netmap_desc.c │ ├── netmap_interface.c │ ├── netmap_manager.c │ ├── netmap_memory.c │ ├── netmap_ring.c │ ├── netmap_slot.c │ ├── onepacket.py │ ├── pktman.py │ ├── setup.py │ ├── test.py │ └── tx.py ├── private └── .gitattributes ├── share └── man │ └── man4 │ └── netmap.4 ├── sys ├── dev │ └── netmap │ │ ├── if_em_netmap.h │ │ ├── if_igb_netmap.h │ │ ├── if_ixl_netmap.h │ │ ├── if_lem_netmap.h │ │ ├── if_ptnet.c │ │ ├── if_re_netmap.h │ │ ├── if_vtnet_netmap.h │ │ ├── ixgbe_netmap.h │ │ ├── netmap.c │ │ ├── netmap_freebsd.c │ │ ├── netmap_generic.c │ │ ├── netmap_kern.h │ │ ├── netmap_mbq.c │ │ ├── netmap_mbq.h │ │ ├── netmap_mem2.c │ │ ├── netmap_mem2.h │ │ ├── netmap_monitor.c │ │ ├── netmap_offloadings.c │ │ ├── netmap_pipe.c │ │ ├── netmap_pt.c │ │ └── netmap_vale.c ├── modules │ └── netmap │ │ ├── .gitignore │ │ └── Makefile └── net │ ├── netmap.h │ ├── netmap_user.h │ └── netmap_virt.h └── utils ├── GNUmakefile ├── Makefile ├── README ├── click-test.cfg ├── ctrs.h ├── producer.c ├── switch-modules └── ovs-datapath │ └── 0001-datapath-Add-support-for-netmap-VALE.patch ├── test_nm.c ├── test_select.c ├── testcsum.c ├── testlock.c ├── testmmap.c └── testmod ├── Makefile └── kern_test.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | .*.cmd 4 | *.ko 5 | *.mod.c 6 | *.orig 7 | .*.swp 8 | tags 9 | modules.order 10 | Module.symvers 11 | .tmp_versions 12 | cache/ 13 | cnic_if.h 14 | e1000/ 15 | e1000e*/ 16 | forcedeth.c 17 | xen-netfront.c 18 | r8169.c 19 | get-drivers 20 | igb*/ 21 | ixgbe*/ 22 | log/ 23 | scripts/conf 24 | virtio_net.c 25 | config.log 26 | Kbuild 27 | netmap.mak 28 | config.status 29 | drivers.mak 30 | patches 31 | get-* 32 | netmap-tmpdir 33 | netmap_linux_config.h 34 | netmap-tmp.c 35 | i40e*/ 36 | veth.c 37 | failed-patches 38 | apps/lb/lb 39 | apps/nmreplay/nmreplay 40 | apps/tlem/tlem 41 | apps/bridge/bridge 42 | apps/bridge/bridge-b 43 | apps/pkt-gen/pkt-gen 44 | apps/pkt-gen/pkt-gen-b 45 | utils/test_select 46 | utils/testcsum 47 | utils/testlock 48 | utils/testmmap 49 | utils/vale-ctl 50 | utils/test_nm 51 | utils/cygwin1.dll 52 | examples/pkt-gen.exe 53 | examples/pkt-gen.exe.stackdump 54 | examples/pkt-gen-b.exe 55 | examples/pkt-gen-b.exe.stackdump 56 | build*/ 57 | LINUX/tmp-patches 58 | LINUX/veth.c 59 | *.gcno 60 | *.core 61 | *.suo 62 | *.sdf 63 | *.opensdf 64 | *~ 65 | cscope.out 66 | *.7 67 | default-config.mak 68 | drv-subdir.mak 69 | read-vars.mak 70 | !LINUX/default-config.mak 71 | !LINUX/drv-subdir.mak 72 | !LINUX/read-vars.mak 73 | LINUX/scripts/conf 74 | config.mak 75 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | all: netmap.mak 2 | 3 | -include netmap.mak 4 | 5 | COMPAT_ARGS=$(if $(KSRC),--kernel-dir=$(KSRC),)\ 6 | $(if $(SRC),--kernel-sources=$(SRC),)\ 7 | $(if $(NODRIVERS),--no-drivers) 8 | 9 | netmap.mak: 10 | @echo 'The new way to build netmap is to run the provided configure script first,' 11 | @echo 'followed by make.' 12 | @echo 'We run configure for you now, with compatible arguments, and restart make.' 13 | @echo 'Please run configure again if this is not what you want.' 14 | ./configure $(COMPAT_ARGS) 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011-2017 University of 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. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 | -------------------------------------------------------------------------------- /LINUX/Kbuild.in: -------------------------------------------------------------------------------- 1 | MODNAME:=@MODNAME@ 2 | SUBSYS:=@SUBSYS@ 3 | SRCDIR:=@SRCDIR@ 4 | 5 | # list of objects for this module 6 | # 7 | # objects whose source file is in ../sys/dev/netmap 8 | # the source is not here so we need to specify a dependency 9 | $(foreach s,$(SUBSYS),$(eval CONFIG_NETMAP_$(shell echo $s|tr a-z- A-Z_)=y)) 10 | 11 | remoteobjs-y := netmap_mem2.o netmap_mbq.o 12 | 13 | remoteobjs-$(CONFIG_NETMAP_VALE) += netmap_vale.o netmap_offloadings.o 14 | remoteobjs-$(CONFIG_NETMAP_PIPE) += netmap_pipe.o 15 | remoteobjs-$(CONFIG_NETMAP_MONITOR) += netmap_monitor.o 16 | remoteobjs-$(CONFIG_NETMAP_GENERIC) += netmap_generic.o 17 | remoteobjs-ptnetmap-$(CONFIG_NETMAP_PTNETMAP_GUEST) = netmap_pt.o 18 | remoteobjs-ptnetmap-$(CONFIG_NETMAP_PTNETMAP_HOST) = netmap_pt.o 19 | remoteobjs-y += $(remoteobjs-ptnetmap-y) 20 | 21 | define remote_template 22 | $$(obj)/$(1): %.o: $$(SRCDIR)/../sys/dev/netmap/$(2) FORCE 23 | $$(call if_changed_rule,cc_o_c) 24 | endef 25 | $(foreach o,$(remoteobjs-y),$(eval $(call remote_template,$(o),$(o:.o=.c)))) 26 | # we compile netmap.c into netmap_common.o to allow 27 | # for MODNAME=netmap 28 | $(eval $(call remote_template,netmap_common.o,netmap.c)) 29 | 30 | $(obj)/netmap_linux.o: %.o: $(SRCDIR)/netmap_linux.c FORCE 31 | $(call if_changed_rule,cc_o_c) 32 | 33 | # all objects 34 | $(MODNAME)-objs := $(remoteobjs-y) netmap_common.o netmap_linux.o 35 | 36 | ifdef CONFIG_NETMAP_PTNETMAP_GUEST 37 | $(obj)/netmap_ptnet.o: %.o: $(SRCDIR)/netmap_ptnet.c FORCE 38 | $(call if_changed_rule,cc_o_c) 39 | 40 | $(MODNAME)-objs += netmap_ptnet.o 41 | endif 42 | 43 | obj-$(CONFIG_NETMAP) = $(MODNAME).o 44 | 45 | ifdef NETMAP_DRIVER_SUFFIX 46 | $(foreach v,$(filter %.o,$(O_DRIVERS)),$(eval $(v:.o=$(NETMAP_DRIVER_SUFFIX)-objs) := $v)) 47 | $(foreach v,$(filter %.o,$(O_DRIVERS)),$(info $(v:.o=$(NETMAP_DRIVER_SUFFIX)-objs) := $v)) 48 | obj-m += $(O_DRIVERS:%.o=%$(NETMAP_DRIVER_SUFFIX).o) 49 | else 50 | obj-m += $(O_DRIVERS) 51 | endif 52 | -------------------------------------------------------------------------------- /LINUX/archlinux/README: -------------------------------------------------------------------------------- 1 | These files (PKGBUILD, netmap.install) mirror the content of the 2 | AUR repository available at 3 | https://aur.archlinux.org/packages/netmap/ 4 | -------------------------------------------------------------------------------- /LINUX/archlinux/netmap.install: -------------------------------------------------------------------------------- 1 | post_common() { 2 | depmod -a 3 | KVER2=$(uname -r | sed 's/\.[0-9]\+-[0-9]\+//') 4 | echo ">>> Netmap patched NIC drivers have been installed into" 5 | echo ">>> /lib/modules/extramodules-${KVER2}/netmap-drivers, with" 6 | echo ">>> a '_netmap.ko' suffix, so that they don't replace the" 7 | echo ">>> official ones provided by the linux package." 8 | echo ">>> You should therefore manually unload the official ones and" 9 | echo ">>> load the patched ones." 10 | echo ">>> Alternatively, you can use /etc/modules-load.d/ and" 11 | echo ">>> /etc/modprobe.d/ to automatically load patched drivers and" 12 | echo ">>> blacklist the official ones." 13 | } 14 | 15 | ## arg 1: the new package version 16 | post_install() { 17 | post_common 18 | } 19 | 20 | ## arg 1: the new package version 21 | ## arg 2: the old package version 22 | post_upgrade() { 23 | post_common 24 | } 25 | 26 | ## arg 1: the old package version 27 | post_remove() { 28 | post_common 29 | } 30 | 31 | -------------------------------------------------------------------------------- /LINUX/default-config.mak.in_: -------------------------------------------------------------------------------- 1 | define intel_driver 2 | $(1)@fetch := wget -nc https://sourceforge.net/projects/e1000/files/$(1)%20stable/$(2)/$(1)-$(2).tar.gz -P @SRCDIR@/ext-drivers/ 3 | $(1)@src := tar xf @SRCDIR@/ext-drivers/$(1)-$(2).tar.gz && mv $(1)-$(2)/src $(1) 4 | $(1)@patch := patches/intel--$(1)--$(2) 5 | $(1)@build := make -C $(1) CFLAGS_EXTRA="$(EXTRA_CFLAGS)" NETMAP_DRIVER_SUFFIX=@DRVSUFFIX@ KSRC=@KSRC@ 6 | $(1)@install := make -C $(1) install CFLAGS_EXTRA="$(EXTRA_CFLAGS)" NETMAP_DRIVER_SUFFIX=@DRVSUFFIX@ KSRC=@KSRC@ 7 | $(1)@clean := if [ -d $(1) ]; then make -C $(1) clean CFLAGS_EXTRA="$(EXTRA_CFLAGS)" NETMAP_DRIVER_SUFFIX=@DRVSUFFIX@ KSRC=@KSRC@; fi 8 | $(1)@distclean := rm -rf $(1)-$(2) 9 | endef 10 | 11 | $(eval $(call intel_driver,ixgbe,4.5.4)) 12 | $(eval $(call intel_driver,ixgbevf,3.3.2)) 13 | $(eval $(call intel_driver,e1000e,3.3.5)) 14 | $(eval $(call intel_driver,igb,5.3.5.4)) 15 | $(eval $(call intel_driver,i40e,1.5.25)) 16 | -------------------------------------------------------------------------------- /LINUX/dkms/Makefile: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | -include dkms.conf 4 | 5 | PWD = $(shell pwd) 6 | KVER = $(shell uname -r) 7 | KVER_SHORT = $(shell uname -r | sed -r 's/([0-9]+\.[0-9]+).*?/\1/') 8 | LINUX_SOURCE = linux-source-$(KVER_SHORT) 9 | LINUX_SOURCE_ARCHIVE = "/usr/src/$(LINUX_SOURCE).tar.xz" 10 | LINUX_SOURCE_HEADERS = "/usr/src/linux-headers-$(KVER)" 11 | DKMS_SOURCE_DIR = "/usr/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)" 12 | 13 | build: $(LINUX_SOURCE) 14 | cd LINUX && ./configure --kernel-sources="$(PWD)/$(LINUX_SOURCE)" 15 | cd LINUX && $(MAKE) 16 | 17 | $(LINUX_SOURCE): 18 | tar xf $(LINUX_SOURCE_ARCHIVE) 19 | cd $(LINUX_SOURCE) && $(MAKE) oldconfig && $(MAKE) prepare && $(MAKE) scripts 20 | cp $(LINUX_SOURCE_HEADERS)/Module.symvers $(LINUX_SOURCE)/ 21 | 22 | clean: 23 | rm -rf $(LINUX_SOURCE) 24 | if [ -L LINUX/netmap.mak ]; then cd .. && $(MAKE) distclean; fi 25 | 26 | install-dkms: 27 | mkdir -p $(DKMS_SOURCE_DIR) 28 | cp -a ../../* $(DKMS_SOURCE_DIR) 29 | cp -a ./* $(DKMS_SOURCE_DIR) 30 | dkms add -m $(PACKAGE_NAME)/$(PACKAGE_VERSION) 31 | 32 | .PHONY: build clean install-dkms 33 | -------------------------------------------------------------------------------- /LINUX/dkms/README.md: -------------------------------------------------------------------------------- 1 | DKMS GUIDE 2 | ========== 3 | 4 | Some prerequisites: 5 | # apt-get install dkms linux-source linux-headers-$(uname -r) devscripts 6 | 7 | 8 | First way is a plain dkms installation: 9 | ``` 10 | make install-dkms 11 | dkms install netmap/ 12 | ``` 13 | 14 | Or make .deb package with sources: 15 | ``` 16 | make install-dkms 17 | dkms mkdeb netmap/0.0.1 --source-only 18 | ``` 19 | -------------------------------------------------------------------------------- /LINUX/dkms/dkms.conf: -------------------------------------------------------------------------------- 1 | # netmap dkms 2 | PACKAGE_NAME=netmap 3 | PACKAGE_VERSION=0.0.1 4 | REMAKE_INITRD=yes 5 | AUTOINSTALL=yes 6 | 7 | # netmap driver 8 | MAKE[0]=\'make\' 9 | BUILT_MODULE_NAME[0]=netmap 10 | BUILT_MODULE_LOCATION[0]=LINUX/ 11 | DEST_MODULE_LOCATION[0]=/kernel/net/netmap/ 12 | 13 | # forcedeth driver 14 | BUILT_MODULE_NAME[1]=forcedeth 15 | BUILT_MODULE_LOCATION[1]=LINUX/ 16 | DEST_MODULE_LOCATION[1]=/kernel/drivers/net/ethernet/nvidia/ 17 | 18 | # veth driver 19 | BUILT_MODULE_NAME[2]=veth 20 | BUILT_MODULE_LOCATION[2]=LINUX/ 21 | DEST_MODULE_LOCATION[2]=/kernel/drivers/net/ 22 | 23 | # virtio_net driver 24 | BUILT_MODULE_NAME[3]=virtio_net 25 | BUILT_MODULE_LOCATION[3]=LINUX/ 26 | DEST_MODULE_LOCATION[3]=/kernel/drivers/net/ 27 | 28 | # e1000 driver 29 | BUILT_MODULE_NAME[4]=e1000 30 | BUILT_MODULE_LOCATION[4]=LINUX/e1000/ 31 | DEST_MODULE_LOCATION[4]=/kernel/drivers/net/ethernet/intel/e1000/ 32 | 33 | # e1000e driver 34 | BUILT_MODULE_NAME[5]=e1000e 35 | BUILT_MODULE_LOCATION[5]=LINUX/e1000e/ 36 | DEST_MODULE_LOCATION[5]=/kernel/drivers/net/ethernet/intel/e1000e/ 37 | 38 | # igb driver 39 | BUILT_MODULE_NAME[6]=igb 40 | BUILT_MODULE_LOCATION[6]=LINUX/igb/ 41 | DEST_MODULE_LOCATION[6]=/kernel/drivers/net/ethernet/intel/igb/ 42 | 43 | # ixgbe driver 44 | BUILT_MODULE_NAME[7]=ixgbe 45 | BUILT_MODULE_LOCATION[7]=LINUX/ixgbe/ 46 | DEST_MODULE_LOCATION[7]=/kernel/drivers/net/ethernet/intel/ixgbe/ 47 | 48 | # i40e driver 49 | BUILT_MODULE_NAME[8]=i40e 50 | BUILT_MODULE_LOCATION[8]=LINUX/i40e/ 51 | DEST_MODULE_LOCATION[8]=/kernel/drivers/net/ethernet/intel/i40e/ 52 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/Makefile: -------------------------------------------------------------------------------- 1 | #/usr/bin/make 2 | SRC = $(DESTDIR)/usr/src 3 | SHARE = $(DESTDIR)/usr/share/$(NAME)-dkms 4 | 5 | all: 6 | 7 | clean: 8 | 9 | install: 10 | 11 | #source tree 12 | ifeq ("$(wildcard $(NAME)-$(VERSION))", "$(NAME)-$(VERSION)") 13 | install -d "$(SRC)" 14 | cp -a $(NAME)-$(VERSION) $(SRC) 15 | find "$(SRC)/$(NAME)-$(VERSION)" -type f | xargs chmod a+r 16 | endif 17 | 18 | #tarball, possibly with binaries 19 | ifeq ("$(wildcard $(NAME)-$(VERSION).dkms.tar.gz)", "$(NAME)-$(VERSION).dkms.tar.gz") 20 | install -d "$(SHARE)" 21 | install -m 644 $(NAME)-$(VERSION).dkms.tar.gz "$(SHARE)" 22 | endif 23 | 24 | #postinst, only if we are supporting legacy mode 25 | ifeq ("$(wildcard common.postinst)", "common.postinst") 26 | install -d "$(SHARE)" 27 | install -m 755 $(PREFIX)/usr/lib/dkms/common.postinst $(SHARE)/postinst 28 | endif 29 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/README.Debian: -------------------------------------------------------------------------------- 1 | MODULE_NAME DKMS module for Debian 2 | 3 | This package was automatically generated by the DKMS system, 4 | for distribution on Debian based operating systems. 5 | 6 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/changelog: -------------------------------------------------------------------------------- 1 | DEBIAN_PACKAGE-dkms (MODULE_VERSION) stable; urgency=low 2 | 3 | * Automatically packaged by DKMS. 4 | 5 | -- Dynamic Kernel Modules Support Team DATE_STAMP 6 | 7 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/control: -------------------------------------------------------------------------------- 1 | Source: DEBIAN_PACKAGE-dkms 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Dynamic Kernel Modules Support Team 5 | Build-Depends: debhelper (>= 7), dkms 6 | Standards-Version: 3.8.1 7 | 8 | Package: DEBIAN_PACKAGE-dkms 9 | Architecture: all 10 | Depends: dkms (>= 1.95), ${misc:Depends}, 11 | linux-source, libc6-dev, 12 | linux-headers-686-pae | linux-headers-amd64 | linux-headers-generic | linux-headers 13 | Description: DEBIAN_PACKAGE driver in DKMS format. 14 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/copyright: -------------------------------------------------------------------------------- 1 | Copyright 1992-2015 The FreeBSD Project. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 8 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 9 | 10 | The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/dirs: -------------------------------------------------------------------------------- 1 | usr/src 2 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2002-2005 Flavio Stanchina 3 | # Copyright (C) 2005-2006 Aric Cyr 4 | # Copyright (C) 2007 Mario Limonciello 5 | # Copyright (C) 2009 Alberto Milone 6 | 7 | set -e 8 | 9 | NAME=MODULE_NAME 10 | PACKAGE_NAME=$NAME-dkms 11 | DEB_NAME=$(echo $PACKAGE_NAME | sed 's,_,-,') 12 | CVERSION=`dpkg-query -W -f='${Version}' $DEB_NAME | awk -F "-" '{print $1}' | cut -d\: -f2` 13 | ARCH=`dpkg --print-architecture` 14 | 15 | dkms_configure () { 16 | for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do 17 | if [ -f "$POSTINST" ]; then 18 | "$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2" 19 | return $? 20 | fi 21 | echo "WARNING: $POSTINST does not exist." >&2 22 | done 23 | echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2 24 | echo "built with legacy DKMS support." >&2 25 | echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2 26 | echo "support or upgrade DKMS to a more current version." >&2 27 | return 1 28 | } 29 | 30 | case "$1" in 31 | configure) 32 | dkms_configure 33 | ;; 34 | 35 | abort-upgrade|abort-remove|abort-deconfigure) 36 | ;; 37 | 38 | *) 39 | echo "postinst called with unknown argument \`$1'" >&2 40 | exit 1 41 | ;; 42 | esac 43 | 44 | # dh_installdeb will replace this with shell code automatically 45 | # generated by other debhelper scripts. 46 | 47 | #DEBHELPER# 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | NAME=MODULE_NAME 4 | VERSION=MODULE_VERSION 5 | 6 | set -e 7 | 8 | case "$1" in 9 | remove|upgrade|deconfigure) 10 | if [ "`dkms status -m $NAME`" ]; then 11 | dkms remove -m $NAME -v $VERSION --all 12 | fi 13 | ;; 14 | 15 | failed-upgrade) 16 | ;; 17 | 18 | *) 19 | echo "prerm called with unknown argument \`$1'" >&2 20 | exit 1 21 | ;; 22 | esac 23 | 24 | #DEBHELPER# 25 | 26 | exit 0 27 | 28 | 29 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdeb/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | # Uncomment this to turn on verbose mode. 5 | #export DH_VERBOSE=1 6 | 7 | DEB_NAME=DEBIAN_PACKAGE 8 | NAME=MODULE_NAME 9 | VERSION=MODULE_VERSION 10 | 11 | configure: configure-stamp 12 | configure-stamp: 13 | dh_testdir 14 | touch configure-stamp 15 | 16 | 17 | build: build-stamp 18 | 19 | build-stamp: configure-stamp 20 | dh_testdir 21 | $(MAKE) 22 | touch $@ 23 | 24 | clean: 25 | dh_testdir 26 | dh_testroot 27 | rm -f build-stamp configure-stamp 28 | -$(MAKE) clean 29 | dh_clean 30 | 31 | install: build 32 | dh_testdir 33 | dh_testroot 34 | dh_prep 35 | $(MAKE) DESTDIR=$(CURDIR)/debian/$(DEB_NAME)-dkms NAME=$(NAME) VERSION=$(VERSION) install 36 | 37 | binary-arch: build install 38 | 39 | binary-indep: build install 40 | dh_testdir 41 | dh_testroot 42 | dh_link 43 | dh_strip 44 | dh_compress 45 | dh_fixperms 46 | dh_installdeb 47 | dh_shlibdeps 48 | dh_gencontrol 49 | dh_md5sums 50 | dh_builddeb 51 | 52 | binary: binary-indep binary-arch 53 | .PHONY: build clean binary-indep binary-arch binary install configure 54 | -------------------------------------------------------------------------------- /LINUX/dkms/netmap-dkms-mkdsc: -------------------------------------------------------------------------------- 1 | netmap-dkms-mkdeb -------------------------------------------------------------------------------- /LINUX/drv-subdir.mak: -------------------------------------------------------------------------------- 1 | ifdef NETMAP_DRIVER_SUFFIX 2 | save-obj-m := $(obj-m) 3 | 4 | include $(src)/orig.mak 5 | 6 | driver-name := $(patsubst %.o,%,$(filter-out $(save-obj-m),$(obj-m))) 7 | 8 | $(info driver-name = $(driver-name)) 9 | 10 | obj-m = $(save-obj-m) $(driver-name)$(NETMAP_DRIVER_SUFFIX).o 11 | 12 | $(driver-name)$(NETMAP_DRIVER_SUFFIX)-objs := $($(driver-name)-objs) 13 | $(info $(driver-name)$(NETMAP_DRIVER_SUFFIX)-objs = $($(driver-name)-objs)) 14 | $(driver-name)$(NETMAP_DRIVER_SUFFIX)-y := $($(driver-name)-y) 15 | $(info $(driver-name)$(NETMAP_DRIVER_SUFFIX)-y = $($(driver-name)-y)) 16 | else 17 | include $(src)/orig.mak 18 | endif 19 | -------------------------------------------------------------------------------- /LINUX/drvname2config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beamer-LB/netmap/bc1c694ea188a47e3b5e0b870359d55fd691ca42/LINUX/drvname2config -------------------------------------------------------------------------------- /LINUX/ext-drivers/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /LINUX/final-patches/intel--e1000e--3.3.5: -------------------------------------------------------------------------------- 1 | diff --git a/e1000e/Makefile b/e1000e/Makefile 2 | index 35ccb2d..db5d8fa 100644 3 | --- a/e1000e/Makefile 4 | +++ b/e1000e/Makefile 5 | @@ -36,7 +36,7 @@ ifeq (,$(BUILD_KERNEL)) 6 | BUILD_KERNEL=$(shell uname -r) 7 | endif 8 | 9 | -DRIVER_NAME = e1000e 10 | +DRIVER_NAME = e1000e$(NETMAP_DRIVER_SUFFIX) 11 | 12 | ########################################################################### 13 | # Environment tests 14 | @@ -128,7 +128,7 @@ ifeq ($(ARCH),alpha) 15 | EXTRA_CFLAGS += -ffixed-8 -mno-fp-regs 16 | endif 17 | ifeq ($(ARCH),x86_64) 18 | - EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone 19 | + EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone -fno-pie 20 | endif 21 | ifeq ($(ARCH),ppc) 22 | EXTRA_CFLAGS += -msoft-float 23 | @@ -327,6 +327,9 @@ DEPVER := $(shell /sbin/depmod -V 2>/dev/null | \ 24 | $(MANFILE).gz: ../$(MANFILE) 25 | gzip -c $< > $@ 26 | 27 | +../$(MANFILE): 28 | + touch $@ 29 | + 30 | install: default $(MANFILE).gz 31 | # remove all old versions of the driver 32 | find $(INSTALL_MOD_PATH)/lib/modules/$(KVER) -name $(TARGET) -exec rm -f {} \; || true 33 | diff --git a/e1000e/netdev.c b/e1000e/netdev.c 34 | index 702d367..e31161d 100644 35 | --- a/e1000e/netdev.c 36 | +++ b/e1000e/netdev.c 37 | @@ -504,6 +504,10 @@ static int e1000_desc_unused(struct e1000_ring *ring) 38 | return ring->count + ring->next_to_clean - ring->next_to_use - 1; 39 | } 40 | 41 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 42 | +#include 43 | +#endif 44 | + 45 | #ifdef HAVE_HW_TIME_STAMP 46 | /** 47 | * e1000e_systim_to_hwtstamp - convert system time value to hw time stamp 48 | @@ -1027,6 +1031,17 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring) 49 | bool cleaned = false; 50 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; 51 | 52 | +#ifdef DEV_NETMAP 53 | +#ifdef CONFIG_E1000E_NAPI 54 | +#define NETMAP_DUMMY work_done 55 | +#else 56 | + int dummy; 57 | +#define NETMAP_DUMMY &dummy 58 | +#endif 59 | + if (netmap_rx_irq(netdev, 0, NETMAP_DUMMY)) 60 | + return true; 61 | +#endif /* DEV_NETMAP */ 62 | + 63 | i = rx_ring->next_to_clean; 64 | rx_desc = E1000_RX_DESC_EXT(*rx_ring, i); 65 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 66 | @@ -1338,6 +1353,11 @@ static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring) 67 | unsigned int total_tx_bytes = 0, total_tx_packets = 0; 68 | unsigned int bytes_compl = 0, pkts_compl = 0; 69 | 70 | +#ifdef DEV_NETMAP 71 | + if (netmap_tx_irq(netdev, 0)) 72 | + return true; /* cleaned ok */ 73 | +#endif /* DEV_NETMAP */ 74 | + 75 | i = tx_ring->next_to_clean; 76 | eop = tx_ring->buffer_info[i].next_to_watch; 77 | eop_desc = E1000_TX_DESC(*tx_ring, eop); 78 | @@ -4247,6 +4267,10 @@ static void e1000_configure(struct e1000_adapter *adapter) 79 | #endif 80 | e1000_setup_rctl(adapter); 81 | e1000_configure_rx(adapter); 82 | +#ifdef DEV_NETMAP 83 | + if (e1000e_netmap_init_buffers(adapter)) 84 | + return; 85 | +#endif /* DEV_NETMAP */ 86 | adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL); 87 | } 88 | 89 | @@ -8338,6 +8362,10 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 90 | if (err) 91 | goto err_register; 92 | 93 | +#ifdef DEV_NETMAP 94 | + e1000_netmap_attach(adapter); 95 | +#endif /* DEV_NETMAP */ 96 | + 97 | /* carrier off reporting is important to ethtool even BEFORE open */ 98 | netif_carrier_off(netdev); 99 | 100 | @@ -8442,6 +8470,10 @@ static void e1000_remove(struct pci_dev *pdev) 101 | kfree(adapter->tx_ring); 102 | kfree(adapter->rx_ring); 103 | 104 | +#ifdef DEV_NETMAP 105 | + netmap_detach(netdev); 106 | +#endif /* DEV_NETMAP */ 107 | + 108 | iounmap(adapter->hw.hw_addr); 109 | if ((adapter->hw.flash_address) && 110 | (adapter->hw.mac.type < e1000_pch_spt)) 111 | -------------------------------------------------------------------------------- /LINUX/final-patches/intel--igb--5.3.5.4: -------------------------------------------------------------------------------- 1 | diff --git a/igb/Makefile b/igb/Makefile 2 | index 8e962f7..d7266d4 100644 3 | --- a/igb/Makefile 4 | +++ b/igb/Makefile 5 | @@ -38,7 +38,7 @@ ifeq (,$(BUILD_KERNEL)) 6 | BUILD_KERNEL=$(shell uname -r) 7 | endif 8 | 9 | -DRIVER_NAME=igb 10 | +DRIVER_NAME=igb$(NETMAP_DRIVER_SUFFIX) 11 | 12 | 13 | ########################################################################### 14 | @@ -130,7 +130,7 @@ ifeq ($(ARCH),alpha) 15 | EXTRA_CFLAGS += -ffixed-8 -mno-fp-regs 16 | endif 17 | ifeq ($(ARCH),x86_64) 18 | - EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone 19 | + EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone -fno-pie 20 | endif 21 | ifeq ($(ARCH),ppc) 22 | EXTRA_CFLAGS += -msoft-float 23 | @@ -140,6 +140,8 @@ ifeq ($(ARCH),ppc64) 24 | LDFLAGS += -melf64ppc 25 | endif 26 | 27 | +EXTRA_CFLAGS += -DDISABLE_PACKET_SPLIT 28 | + 29 | # extra flags for module builds 30 | EXTRA_CFLAGS += -DDRIVER_$(shell echo $(DRIVER_NAME) | tr '[a-z]' '[A-Z]') 31 | EXTRA_CFLAGS += -DDRIVER_NAME=$(DRIVER_NAME) 32 | @@ -355,6 +357,9 @@ DEPVER := $(shell /sbin/depmod -V 2>/dev/null | \ 33 | $(MANFILE).gz: ../$(MANFILE) 34 | gzip -c $< > $@ 35 | 36 | +../$(MANFILE): 37 | + touch $@ 38 | + 39 | install: default $(MANFILE).gz 40 | install -D -m 644 $(TARGET) $(INSTALL_MOD_PATH)$(INSTDIR)/$(TARGET) 41 | ifeq (,$(INSTALL_MOD_PATH)) 42 | diff --git a/igb/igb_main.c b/igb/igb_main.c 43 | index 2dff0f4..d848e34 100644 44 | --- a/igb/igb_main.c 45 | +++ b/igb/igb_main.c 46 | @@ -318,6 +318,10 @@ static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE; 47 | module_param(debug, int, 0); 48 | MODULE_PARM_DESC(debug, "Debug level (0=none, ..., 16=all)"); 49 | 50 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 51 | +#include 52 | +#endif 53 | + 54 | /** 55 | * igb_init_module - Driver Registration Routine 56 | * 57 | @@ -3041,6 +3045,10 @@ static int igb_probe(struct pci_dev *pdev, 58 | /* carrier off reporting is important to ethtool even BEFORE open */ 59 | netif_carrier_off(netdev); 60 | 61 | +#ifdef DEV_NETMAP 62 | + igb_netmap_attach(adapter); 63 | +#endif /* DEV_NETMAP */ 64 | + 65 | #ifdef IGB_DCA 66 | if (dca_add_requester(&pdev->dev) == E1000_SUCCESS) { 67 | adapter->flags |= IGB_FLAG_DCA_ENABLED; 68 | @@ -3244,6 +3252,10 @@ static void igb_remove(struct pci_dev *pdev) 69 | */ 70 | igb_release_hw_control(adapter); 71 | 72 | +#ifdef DEV_NETMAP 73 | + netmap_detach(netdev); 74 | +#endif /* DEV_NETMAP */ 75 | + 76 | unregister_netdev(netdev); 77 | 78 | igb_clear_interrupt_scheme(adapter); 79 | @@ -3652,6 +3664,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, 80 | 81 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; 82 | E1000_WRITE_REG(hw, E1000_TXDCTL(reg_idx), txdctl); 83 | +#ifdef DEV_NETMAP 84 | + igb_netmap_configure_tx_ring(adapter, reg_idx); 85 | +#endif /* DEV_NETMAP */ 86 | } 87 | 88 | /** 89 | @@ -7190,6 +7205,11 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) 90 | if (test_bit(__IGB_DOWN, &adapter->state)) 91 | return true; 92 | 93 | +#ifdef DEV_NETMAP 94 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 95 | + return true; /* cleaned ok */ 96 | +#endif /* DEV_NETMAP */ 97 | + 98 | tx_buffer = &tx_ring->tx_buffer_info[i]; 99 | tx_desc = IGB_TX_DESC(tx_ring, i); 100 | i -= tx_ring->count; 101 | @@ -8204,6 +8224,11 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget) 102 | unsigned int total_bytes = 0, total_packets = 0; 103 | u16 cleaned_count = igb_desc_unused(rx_ring); 104 | 105 | +#ifdef DEV_NETMAP 106 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) 107 | + return true; 108 | +#endif /* DEV_NETMAP */ 109 | + 110 | do { 111 | struct igb_rx_buffer *rx_buffer; 112 | union e1000_adv_rx_desc *rx_desc; 113 | @@ -8522,6 +8547,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 114 | struct igb_rx_buffer *bi; 115 | u16 i = rx_ring->next_to_use; 116 | 117 | +#ifdef DEV_NETMAP 118 | + if (igb_netmap_configure_rx_ring(rx_ring)) 119 | + return; 120 | +#endif /* DEV_NETMAP */ 121 | + 122 | /* nothing to do */ 123 | if (!cleaned_count) 124 | return; 125 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--e1000--20620--31200: -------------------------------------------------------------------------------- 1 | diff --git a/e1000/e1000_main.c b/e1000/e1000_main.c 2 | index bcd192c..013f528 100644 3 | --- a/e1000/e1000_main.c 4 | +++ b/e1000/e1000_main.c 5 | @@ -190,6 +190,10 @@ static struct pci_error_handlers e1000_err_handler = { 6 | .resume = e1000_io_resume, 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | static struct pci_driver e1000_driver = { 14 | .name = e1000_driver_name, 15 | .id_table = e1000_pci_tbl, 16 | @@ -375,6 +379,10 @@ static void e1000_configure(struct e1000_adapter *adapter) 17 | e1000_configure_tx(adapter); 18 | e1000_setup_rctl(adapter); 19 | e1000_configure_rx(adapter); 20 | +#ifdef DEV_NETMAP 21 | + if (e1000_netmap_init_buffers(adapter)) 22 | + return; 23 | +#endif /* DEV_NETMAP */ 24 | /* call E1000_DESC_UNUSED which always leaves 25 | * at least 1 descriptor unused to make sure 26 | * next_to_use != next_to_clean */ 27 | @@ -1035,6 +1043,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev, 28 | adapter->wol = adapter->eeprom_wol; 29 | device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); 30 | 31 | +#ifdef DEV_NETMAP 32 | + e1000_netmap_attach(adapter); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | /* print bus type/speed/width info */ 36 | DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ", 37 | ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : ""), 38 | @@ -1113,6 +1125,10 @@ static void __devexit e1000_remove(struct pci_dev *pdev) 39 | 40 | kfree(adapter->tx_ring); 41 | kfree(adapter->rx_ring); 42 | + 43 | +#ifdef DEV_NETMAP 44 | + netmap_detach(netdev); 45 | +#endif /* DEV_NETMAP */ 46 | 47 | iounmap(hw->hw_addr); 48 | if (hw->flash_address) 49 | @@ -3429,6 +3445,10 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, 50 | unsigned int count = 0; 51 | unsigned int total_tx_bytes=0, total_tx_packets=0; 52 | 53 | +#ifdef DEV_NETMAP 54 | + if (netmap_tx_irq(netdev, 0) != NM_IRQ_PASS) 55 | + return 1; /* cleaned ok */ 56 | +#endif /* DEV_NETMAP */ 57 | i = tx_ring->next_to_clean; 58 | eop = tx_ring->buffer_info[i].next_to_watch; 59 | eop_desc = E1000_TX_DESC(*tx_ring, eop); 60 | @@ -3795,6 +3815,15 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, 61 | bool cleaned = false; 62 | unsigned int total_rx_bytes=0, total_rx_packets=0; 63 | 64 | +#ifdef DEV_NETMAP 65 | + int nm_irq = netmap_rx_irq(netdev, 0, work_done); 66 | + if (nm_irq != NM_IRQ_PASS) { 67 | + if (nm_irq == NM_IRQ_RESCHED) { 68 | + *work_done = work_to_do; 69 | + } 70 | + return 1; 71 | + } 72 | +#endif /* DEV_NETMAP */ 73 | i = rx_ring->next_to_clean; 74 | rx_desc = E1000_RX_DESC(*rx_ring, i); 75 | buffer_info = &rx_ring->buffer_info[i]; 76 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--e1000--31200--99999: -------------------------------------------------------------------------------- 1 | diff --git a/e1000/e1000_main.c b/e1000/e1000_main.c 2 | index 24f3986..c28425f 100644 3 | --- a/e1000/e1000_main.c 4 | +++ b/e1000/e1000_main.c 5 | @@ -200,6 +200,10 @@ static const struct pci_error_handlers e1000_err_handler = { 6 | .resume = e1000_io_resume, 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | static struct pci_driver e1000_driver = { 14 | .name = e1000_driver_name, 15 | .id_table = e1000_pci_tbl, 16 | @@ -395,6 +399,10 @@ static void e1000_configure(struct e1000_adapter *adapter) 17 | e1000_configure_tx(adapter); 18 | e1000_setup_rctl(adapter); 19 | e1000_configure_rx(adapter); 20 | +#ifdef DEV_NETMAP 21 | + if (e1000_netmap_init_buffers(adapter)) 22 | + return; 23 | +#endif /* DEV_NETMAP */ 24 | /* call E1000_DESC_UNUSED which always leaves 25 | * at least 1 descriptor unused to make sure 26 | * next_to_use != next_to_clean 27 | @@ -1213,6 +1221,10 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 28 | 29 | e1000_vlan_filter_on_off(adapter, false); 30 | 31 | +#ifdef DEV_NETMAP 32 | + e1000_netmap_attach(adapter); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | /* print bus type/speed/width info */ 36 | e_info(probe, "(PCI%s:%dMHz:%d-bit) %pM\n", 37 | ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : ""), 38 | @@ -1277,6 +1289,10 @@ static void e1000_remove(struct pci_dev *pdev) 39 | 40 | kfree(adapter->tx_ring); 41 | kfree(adapter->rx_ring); 42 | + 43 | +#ifdef DEV_NETMAP 44 | + netmap_detach(netdev); 45 | +#endif /* DEV_NETMAP */ 46 | 47 | if (hw->mac_type == e1000_ce4100) 48 | iounmap(hw->ce4100_gbe_mdio_base_virt); 49 | @@ -3841,6 +3857,10 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, 50 | unsigned int total_tx_bytes=0, total_tx_packets=0; 51 | unsigned int bytes_compl = 0, pkts_compl = 0; 52 | 53 | +#ifdef DEV_NETMAP 54 | + if (netmap_tx_irq(netdev, 0) != NM_IRQ_PASS) 55 | + return 1; /* cleaned ok */ 56 | +#endif /* DEV_NETMAP */ 57 | i = tx_ring->next_to_clean; 58 | eop = tx_ring->buffer_info[i].next_to_watch; 59 | eop_desc = E1000_TX_DESC(*tx_ring, eop); 60 | @@ -4355,6 +4375,15 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, 61 | bool cleaned = false; 62 | unsigned int total_rx_bytes=0, total_rx_packets=0; 63 | 64 | +#ifdef DEV_NETMAP 65 | + int nm_irq = netmap_rx_irq(netdev, 0, work_done); 66 | + if (nm_irq != NM_IRQ_PASS) { 67 | + if (nm_irq == NM_IRQ_RESCHED) { 68 | + *work_done = work_to_do; 69 | + } 70 | + return 1; 71 | + } 72 | +#endif /* DEV_NETMAP */ 73 | i = rx_ring->next_to_clean; 74 | rx_desc = E1000_RX_DESC(*rx_ring, i); 75 | buffer_info = &rx_ring->buffer_info[i]; 76 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--e1000e--20620--30100: -------------------------------------------------------------------------------- 1 | diff --git a/e1000e/netdev.c b/e1000e/netdev.c 2 | index fad8f9e..cd4abfd 100644 3 | --- a/e1000e/netdev.c 4 | +++ b/e1000e/netdev.c 5 | @@ -87,6 +87,10 @@ static int e1000_desc_unused(struct e1000_ring *ring) 6 | return ring->count + ring->next_to_clean - ring->next_to_use - 1; 7 | } 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /** 14 | * e1000_receive_skb - helper function to handle Rx indications 15 | * @adapter: board private structure 16 | @@ -446,6 +450,10 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, 17 | bool cleaned = 0; 18 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_rx_irq(netdev, 0, work_done)) 22 | + return 1; /* seems to be ignored */ 23 | +#endif /* DEV_NETMAP */ 24 | i = rx_ring->next_to_clean; 25 | rx_desc = E1000_RX_DESC(*rx_ring, i); 26 | buffer_info = &rx_ring->buffer_info[i]; 27 | @@ -624,6 +632,10 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) 28 | unsigned int count = 0; 29 | unsigned int total_tx_bytes = 0, total_tx_packets = 0; 30 | 31 | +#ifdef DEV_NETMAP 32 | + if (netmap_tx_irq(netdev, 0)) 33 | + return 1; /* cleaned ok */ 34 | +#endif /* DEV_NETMAP */ 35 | i = tx_ring->next_to_clean; 36 | eop = tx_ring->buffer_info[i].next_to_watch; 37 | eop_desc = E1000_TX_DESC(*tx_ring, eop); 38 | @@ -2632,6 +2644,10 @@ static void e1000_configure(struct e1000_adapter *adapter) 39 | e1000_configure_tx(adapter); 40 | e1000_setup_rctl(adapter); 41 | e1000_configure_rx(adapter); 42 | +#ifdef DEV_NETMAP 43 | + if (e1000e_netmap_init_buffers(adapter)) 44 | + return; 45 | +#endif /* DEV_NETMAP */ 46 | adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring)); 47 | } 48 | 49 | @@ -5227,6 +5243,9 @@ static int __devinit e1000_probe(struct pci_dev *pdev, 50 | if (err) 51 | goto err_register; 52 | 53 | +#ifdef DEV_NETMAP 54 | + e1000_netmap_attach(adapter); 55 | +#endif /* DEV_NETMAP */ 56 | /* carrier off reporting is important to ethtool even BEFORE open */ 57 | netif_carrier_off(netdev); 58 | 59 | @@ -5300,6 +5319,10 @@ static void __devexit e1000_remove(struct pci_dev *pdev) 60 | kfree(adapter->tx_ring); 61 | kfree(adapter->rx_ring); 62 | 63 | +#ifdef DEV_NETMAP 64 | + netmap_detach(netdev); 65 | +#endif /* DEV_NETMAP */ 66 | + 67 | iounmap(adapter->hw.hw_addr); 68 | if (adapter->hw.flash_address) 69 | iounmap(adapter->hw.flash_address); 70 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--e1000e--30100--30400: -------------------------------------------------------------------------------- 1 | diff --git a/e1000e/netdev.c b/e1000e/netdev.c 2 | index 2198e61..588f1ec 100644 3 | --- a/e1000e/netdev.c 4 | +++ b/e1000e/netdev.c 5 | @@ -452,6 +452,10 @@ static int e1000_desc_unused(struct e1000_ring *ring) 6 | return ring->count + ring->next_to_clean - ring->next_to_use - 1; 7 | } 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /** 14 | * e1000_receive_skb - helper function to handle Rx indications 15 | * @adapter: board private structure 16 | @@ -849,6 +853,10 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, 17 | bool cleaned = 0; 18 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_rx_irq(netdev, 0, work_done)) 22 | + return 1; /* seems to be ignored */ 23 | +#endif /* DEV_NETMAP */ 24 | i = rx_ring->next_to_clean; 25 | rx_desc = E1000_RX_DESC(*rx_ring, i); 26 | buffer_info = &rx_ring->buffer_info[i]; 27 | @@ -1066,6 +1074,10 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) 28 | unsigned int count = 0; 29 | unsigned int total_tx_bytes = 0, total_tx_packets = 0; 30 | 31 | +#ifdef DEV_NETMAP 32 | + if (netmap_tx_irq(netdev, 0)) 33 | + return 1; /* cleaned ok */ 34 | +#endif /* DEV_NETMAP */ 35 | i = tx_ring->next_to_clean; 36 | eop = tx_ring->buffer_info[i].next_to_watch; 37 | eop_desc = E1000_TX_DESC(*tx_ring, eop); 38 | @@ -3177,6 +3189,10 @@ static void e1000_configure(struct e1000_adapter *adapter) 39 | e1000_configure_tx(adapter); 40 | e1000_setup_rctl(adapter); 41 | e1000_configure_rx(adapter); 42 | +#ifdef DEV_NETMAP 43 | + if (e1000e_netmap_init_buffers(adapter)) 44 | + return; 45 | +#endif /* DEV_NETMAP */ 46 | adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring), 47 | GFP_KERNEL); 48 | } 49 | @@ -6147,6 +6163,9 @@ static int __devinit e1000_probe(struct pci_dev *pdev, 50 | if (err) 51 | goto err_register; 52 | 53 | +#ifdef DEV_NETMAP 54 | + e1000_netmap_attach(adapter); 55 | +#endif /* DEV_NETMAP */ 56 | /* carrier off reporting is important to ethtool even BEFORE open */ 57 | netif_carrier_off(netdev); 58 | 59 | @@ -6234,6 +6253,10 @@ static void __devexit e1000_remove(struct pci_dev *pdev) 60 | kfree(adapter->tx_ring); 61 | kfree(adapter->rx_ring); 62 | 63 | +#ifdef DEV_NETMAP 64 | + netmap_detach(netdev); 65 | +#endif /* DEV_NETMAP */ 66 | + 67 | iounmap(adapter->hw.hw_addr); 68 | if (adapter->hw.flash_address) 69 | iounmap(adapter->hw.flash_address); 70 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--e1000e--30400--30900: -------------------------------------------------------------------------------- 1 | diff --git a/e1000e/netdev.c b/e1000e/netdev.c 2 | index 9520a6a..bf94805 100644 3 | --- a/e1000e/netdev.c 4 | +++ b/e1000e/netdev.c 5 | @@ -467,6 +467,10 @@ static int e1000_desc_unused(struct e1000_ring *ring) 6 | return ring->count + ring->next_to_clean - ring->next_to_use - 1; 7 | } 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /** 14 | * e1000_receive_skb - helper function to handle Rx indications 15 | * @adapter: board private structure 16 | @@ -875,6 +879,10 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done, 17 | bool cleaned = false; 18 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_rx_irq(netdev, 0, work_done)) 22 | + return 1; /* seems to be ignored */ 23 | +#endif /* DEV_NETMAP */ 24 | i = rx_ring->next_to_clean; 25 | rx_desc = E1000_RX_DESC_EXT(*rx_ring, i); 26 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 27 | @@ -1129,6 +1137,10 @@ static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring) 28 | unsigned int total_tx_bytes = 0, total_tx_packets = 0; 29 | unsigned int bytes_compl = 0, pkts_compl = 0; 30 | 31 | +#ifdef DEV_NETMAP 32 | + if (netmap_tx_irq(netdev, 0)) 33 | + return 1; /* cleaned ok */ 34 | +#endif /* DEV_NETMAP */ 35 | i = tx_ring->next_to_clean; 36 | eop = tx_ring->buffer_info[i].next_to_watch; 37 | eop_desc = E1000_TX_DESC(*tx_ring, eop); 38 | @@ -3358,6 +3370,10 @@ static void e1000_configure(struct e1000_adapter *adapter) 39 | e1000e_setup_rss_hash(adapter); 40 | e1000_setup_rctl(adapter); 41 | e1000_configure_rx(adapter); 42 | +#ifdef DEV_NETMAP 43 | + if (e1000e_netmap_init_buffers(adapter)) 44 | + return; 45 | +#endif /* DEV_NETMAP */ 46 | adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL); 47 | } 48 | 49 | @@ -6417,6 +6433,9 @@ static int __devinit e1000_probe(struct pci_dev *pdev, 50 | if (err) 51 | goto err_register; 52 | 53 | +#ifdef DEV_NETMAP 54 | + e1000_netmap_attach(adapter); 55 | +#endif /* DEV_NETMAP */ 56 | /* carrier off reporting is important to ethtool even BEFORE open */ 57 | netif_carrier_off(netdev); 58 | 59 | @@ -6504,6 +6523,10 @@ static void __devexit e1000_remove(struct pci_dev *pdev) 60 | kfree(adapter->tx_ring); 61 | kfree(adapter->rx_ring); 62 | 63 | +#ifdef DEV_NETMAP 64 | + netmap_detach(netdev); 65 | +#endif /* DEV_NETMAP */ 66 | + 67 | iounmap(adapter->hw.hw_addr); 68 | if (adapter->hw.flash_address) 69 | iounmap(adapter->hw.flash_address); 70 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--e1000e--30900--99999: -------------------------------------------------------------------------------- 1 | diff --git a/e1000e/netdev.c b/e1000e/netdev.c 2 | index 7e615e2..32ce408 100644 3 | --- a/e1000e/netdev.c 4 | +++ b/e1000e/netdev.c 5 | @@ -473,6 +473,10 @@ static int e1000_desc_unused(struct e1000_ring *ring) 6 | return ring->count + ring->next_to_clean - ring->next_to_use - 1; 7 | } 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /** 14 | * e1000e_systim_to_hwtstamp - convert system time value to hw time stamp 15 | * @adapter: board private structure 16 | @@ -914,6 +918,10 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done, 17 | bool cleaned = false; 18 | unsigned int total_rx_bytes = 0, total_rx_packets = 0; 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_rx_irq(netdev, 0, work_done)) 22 | + return 1; /* seems to be ignored */ 23 | +#endif /* DEV_NETMAP */ 24 | i = rx_ring->next_to_clean; 25 | rx_desc = E1000_RX_DESC_EXT(*rx_ring, i); 26 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 27 | @@ -1203,6 +1211,10 @@ static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring) 28 | unsigned int total_tx_bytes = 0, total_tx_packets = 0; 29 | unsigned int bytes_compl = 0, pkts_compl = 0; 30 | 31 | +#ifdef DEV_NETMAP 32 | + if (netmap_tx_irq(netdev, 0)) 33 | + return 1; /* cleaned ok */ 34 | +#endif /* DEV_NETMAP */ 35 | i = tx_ring->next_to_clean; 36 | eop = tx_ring->buffer_info[i].next_to_watch; 37 | eop_desc = E1000_TX_DESC(*tx_ring, eop); 38 | @@ -3685,6 +3697,10 @@ static void e1000_configure(struct e1000_adapter *adapter) 39 | e1000e_setup_rss_hash(adapter); 40 | e1000_setup_rctl(adapter); 41 | e1000_configure_rx(adapter); 42 | +#ifdef DEV_NETMAP 43 | + if (e1000e_netmap_init_buffers(adapter)) 44 | + return; 45 | +#endif /* DEV_NETMAP */ 46 | adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL); 47 | } 48 | 49 | @@ -6768,6 +6784,9 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 50 | if (err) 51 | goto err_register; 52 | 53 | +#ifdef DEV_NETMAP 54 | + e1000_netmap_attach(adapter); 55 | +#endif /* DEV_NETMAP */ 56 | /* carrier off reporting is important to ethtool even BEFORE open */ 57 | netif_carrier_off(netdev); 58 | 59 | @@ -6866,6 +6885,10 @@ static void e1000_remove(struct pci_dev *pdev) 60 | kfree(adapter->tx_ring); 61 | kfree(adapter->rx_ring); 62 | 63 | +#ifdef DEV_NETMAP 64 | + netmap_detach(netdev); 65 | +#endif /* DEV_NETMAP */ 66 | + 67 | iounmap(adapter->hw.hw_addr); 68 | if (adapter->hw.flash_address) 69 | iounmap(adapter->hw.flash_address); 70 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--forcedeth.c--20626--99999: -------------------------------------------------------------------------------- 1 | diff --git a/forcedeth.c b/forcedeth.c 2 | index 9c0b1ba..b081d6b 100644 3 | --- a/forcedeth.c 4 | +++ b/forcedeth.c 5 | @@ -1865,12 +1865,25 @@ static void nv_init_tx(struct net_device *dev) 6 | } 7 | } 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* we need a few forward declarations */ 11 | +static void nv_drain_rxtx(struct net_device *dev); 12 | +static int nv_init_ring(struct net_device *dev); 13 | +#include 14 | +#endif 15 | + 16 | static int nv_init_ring(struct net_device *dev) 17 | { 18 | struct fe_priv *np = netdev_priv(dev); 19 | 20 | nv_init_tx(dev); 21 | nv_init_rx(dev); 22 | +#ifdef DEV_NETMAP 23 | + forcedeth_netmap_tx_init(np); 24 | + if (forcedeth_netmap_rx_init(np)) 25 | + return 0; /* success */ 26 | +#endif /* DEV_NETMAP */ 27 | + 28 | 29 | if (!nv_optimized(np)) 30 | return nv_alloc_rx(dev); 31 | @@ -3386,6 +3399,11 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data) 32 | int i; 33 | unsigned long flags; 34 | 35 | +#ifdef DEV_NETMAP 36 | + if (netmap_tx_irq(dev, 0)) 37 | + return IRQ_HANDLED; 38 | +#endif /* DEV_NETMAP */ 39 | + 40 | for (i = 0;; i++) { 41 | events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQ_TX_ALL; 42 | writel(NVREG_IRQ_TX_ALL, base + NvRegMSIXIrqStatus); 43 | @@ -3497,6 +3515,11 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data) 44 | int i; 45 | unsigned long flags; 46 | 47 | +#ifdef DEV_NETMAP 48 | + if (netmap_rx_irq(dev, 0, &i)) 49 | + return IRQ_HANDLED; 50 | +#endif /* DEV_NETMAP */ 51 | + 52 | for (i = 0;; i++) { 53 | events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQ_RX_ALL; 54 | writel(NVREG_IRQ_RX_ALL, base + NvRegMSIXIrqStatus); 55 | @@ -5645,6 +5668,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i 56 | goto out_error; 57 | } 58 | 59 | +#ifdef DEV_NETMAP 60 | + forcedeth_netmap_attach(np); 61 | +#endif /* DEV_NETMAP */ 62 | + 63 | netif_carrier_off(dev); 64 | 65 | dev_info(&pci_dev->dev, "ifname %s, PHY OUI 0x%x @ %d, addr %pM\n", 66 | @@ -5728,6 +5755,10 @@ static void __devexit nv_remove(struct pci_dev *pci_dev) 67 | 68 | unregister_netdev(dev); 69 | 70 | +#ifdef DEV_NETMAP 71 | + netmap_detach(dev); 72 | +#endif /* DEV_NETMAP */ 73 | + 74 | nv_restore_mac_addr(pci_dev); 75 | 76 | /* restore any phy related changes */ 77 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--i40e--30c00--40100: -------------------------------------------------------------------------------- 1 | diff --git a/i40e/i40e_main.c b/i40e/i40e_main.c 2 | index 221aa47..4e61898 100644 3 | --- a/i40e/i40e_main.c 4 | +++ b/i40e/i40e_main.c 5 | @@ -86,6 +86,11 @@ MODULE_DESCRIPTION("Intel(R) Ethernet Connection XL710 Network Driver"); 6 | MODULE_LICENSE("GPL"); 7 | MODULE_VERSION(DRV_VERSION); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#define NETMAP_I40E_MAIN 11 | +#include 12 | +#endif 13 | + 14 | /** 15 | * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code 16 | * @hw: pointer to the HW structure 17 | @@ -2124,6 +2129,10 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring) 18 | /* cache tail off for easier writes later */ 19 | ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q); 20 | 21 | +#ifdef DEV_NETMAP 22 | + i40e_netmap_configure_tx_ring(ring); 23 | +#endif /* DEV_NETMAP */ 24 | + 25 | return 0; 26 | } 27 | 28 | @@ -2207,6 +2216,11 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring) 29 | ring->tail = hw->hw_addr + I40E_QRX_TAIL(pf_q); 30 | writel(0, ring->tail); 31 | 32 | +#ifdef DEV_NETMAP 33 | + if (i40e_netmap_configure_rx_ring(ring)) 34 | + return 0; 35 | +#endif /* DEV_NETMAP */ 36 | + 37 | i40e_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring)); 38 | 39 | return 0; 40 | @@ -5876,6 +5890,11 @@ int i40e_vsi_release(struct i40e_vsi *vsi) 41 | return -ENODEV; 42 | } 43 | 44 | +#ifdef DEV_NETMAP 45 | + if (vsi->netdev_registered) 46 | + netmap_detach(vsi->netdev); 47 | +#endif 48 | + 49 | uplink_seid = vsi->uplink_seid; 50 | if (vsi->type != I40E_VSI_SRIOV) { 51 | if (vsi->netdev_registered) { 52 | @@ -6124,6 +6143,11 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, 53 | break; 54 | } 55 | 56 | +#ifdef DEV_NETMAP 57 | + if (vsi->netdev_registered) 58 | + i40e_netmap_attach(vsi); 59 | +#endif 60 | + 61 | return vsi; 62 | 63 | err_rings: 64 | diff --git a/i40e/i40e_txrx.c b/i40e/i40e_txrx.c 65 | index 49d2cfa..83f3c56 100644 66 | --- a/i40e/i40e_txrx.c 67 | +++ b/i40e/i40e_txrx.c 68 | @@ -27,6 +27,10 @@ 69 | 70 | #include "i40e.h" 71 | 72 | +#if defined(CONFIG_NETMAP) || defined (CONFIG_NETMAP_MODULE) 73 | +#include 74 | +#endif /* DEV_NETMAP */ 75 | + 76 | static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, 77 | u32 td_tag) 78 | { 79 | @@ -329,6 +333,11 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget) 80 | unsigned int total_packets = 0; 81 | unsigned int total_bytes = 0; 82 | 83 | +#ifdef DEV_NETMAP 84 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 85 | + return true; 86 | +#endif /* DEV_NETMAP */ 87 | + 88 | tx_buf = &tx_ring->tx_bi[i]; 89 | tx_desc = I40E_TX_DESC(tx_ring, i); 90 | 91 | @@ -897,6 +906,15 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget) 92 | u32 rx_error, rx_status; 93 | u64 qword; 94 | 95 | +#ifdef DEV_NETMAP 96 | + { 97 | + int dummy, nm_irq; 98 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy); 99 | + if (nm_irq != NM_IRQ_PASS) 100 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 101 | + } 102 | +#endif /* DEV_NETMAP */ 103 | + 104 | rx_desc = I40E_RX_DESC(rx_ring, i); 105 | qword = le64_to_cpu(rx_desc->wb.qword1.status_error_len); 106 | rx_status = (qword & I40E_RXD_QW1_STATUS_MASK) 107 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--i40e--40100--40300: -------------------------------------------------------------------------------- 1 | diff --git a/i40e/i40e_main.c b/i40e/i40e_main.c 2 | index 5b5bea1..c8a32923 100644 3 | --- a/i40e/i40e_main.c 4 | +++ b/i40e/i40e_main.c 5 | @@ -91,6 +91,11 @@ MODULE_DESCRIPTION("Intel(R) Ethernet Connection XL710 Network Driver"); 6 | MODULE_LICENSE("GPL"); 7 | MODULE_VERSION(DRV_VERSION); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#define NETMAP_I40E_MAIN 11 | +#include 12 | +#endif 13 | + 14 | /** 15 | * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code 16 | * @hw: pointer to the HW structure 17 | @@ -2527,6 +2532,10 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring) 18 | /* cache tail off for easier writes later */ 19 | ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q); 20 | 21 | +#ifdef DEV_NETMAP 22 | + i40e_netmap_configure_tx_ring(ring); 23 | +#endif /* DEV_NETMAP */ 24 | + 25 | return 0; 26 | } 27 | 28 | @@ -2614,6 +2623,11 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring) 29 | ring->tail = hw->hw_addr + I40E_QRX_TAIL(pf_q); 30 | writel(0, ring->tail); 31 | 32 | +#ifdef DEV_NETMAP 33 | + if (i40e_netmap_configure_rx_ring(ring)) 34 | + return 0; 35 | +#endif /* DEV_NETMAP */ 36 | + 37 | if (ring_is_ps_enabled(ring)) { 38 | i40e_alloc_rx_headers(ring); 39 | i40e_alloc_rx_buffers_ps(ring, I40E_DESC_UNUSED(ring)); 40 | @@ -8515,6 +8529,11 @@ int i40e_vsi_release(struct i40e_vsi *vsi) 41 | return -ENODEV; 42 | } 43 | 44 | +#ifdef DEV_NETMAP 45 | + if (vsi->netdev_registered) 46 | + netmap_detach(vsi->netdev); 47 | +#endif 48 | + 49 | uplink_seid = vsi->uplink_seid; 50 | if (vsi->type != I40E_VSI_SRIOV) { 51 | if (vsi->netdev_registered) { 52 | @@ -8850,6 +8869,11 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, 53 | break; 54 | } 55 | 56 | +#ifdef DEV_NETMAP 57 | + if (vsi->netdev_registered) 58 | + i40e_netmap_attach(vsi); 59 | +#endif 60 | + 61 | return vsi; 62 | 63 | err_rings: 64 | diff --git a/i40e/i40e_txrx.c b/i40e/i40e_txrx.c 65 | index 9d95042d..80f8a88 100644 66 | --- a/i40e/i40e_txrx.c 67 | +++ b/i40e/i40e_txrx.c 68 | @@ -29,6 +29,10 @@ 69 | #include "i40e.h" 70 | #include "i40e_prototype.h" 71 | 72 | +#if defined(CONFIG_NETMAP) || defined (CONFIG_NETMAP_MODULE) 73 | +#include 74 | +#endif /* DEV_NETMAP */ 75 | + 76 | static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, 77 | u32 td_tag) 78 | { 79 | @@ -698,6 +702,11 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget) 80 | unsigned int total_packets = 0; 81 | unsigned int total_bytes = 0; 82 | 83 | +#ifdef DEV_NETMAP 84 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 85 | + return true; 86 | +#endif /* DEV_NETMAP */ 87 | + 88 | tx_buf = &tx_ring->tx_bi[i]; 89 | tx_desc = I40E_TX_DESC(tx_ring, i); 90 | i -= tx_ring->count; 91 | @@ -1874,6 +1883,15 @@ int i40e_napi_poll(struct napi_struct *napi, int budget) 92 | budget_per_ring = max(budget/q_vector->num_ringpairs, 1); 93 | 94 | i40e_for_each_ring(ring, q_vector->rx) { 95 | +#ifdef DEV_NETMAP 96 | + int dummy, nm_irq; 97 | + nm_irq = netmap_rx_irq(vsi->netdev, ring->queue_index, &dummy); 98 | + if (nm_irq != NM_IRQ_PASS) { 99 | + clean_complete &= (nm_irq == NM_IRQ_COMPLETED); 100 | + continue; 101 | + } 102 | +#endif /* DEV_NETMAP */ 103 | + 104 | if (ring_is_ps_enabled(ring)) 105 | cleaned = i40e_clean_rx_irq_ps(ring, budget_per_ring); 106 | else 107 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--i40e--40300--40400: -------------------------------------------------------------------------------- 1 | diff --git a/i40e/i40e_main.c b/i40e/i40e_main.c 2 | index 3dd26cd..05b8960 100644 3 | --- a/i40e/i40e_main.c 4 | +++ b/i40e/i40e_main.c 5 | @@ -94,6 +94,11 @@ MODULE_DESCRIPTION("Intel(R) Ethernet Connection XL710 Network Driver"); 6 | MODULE_LICENSE("GPL"); 7 | MODULE_VERSION(DRV_VERSION); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#define NETMAP_I40E_MAIN 11 | +#include 12 | +#endif 13 | + 14 | /** 15 | * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code 16 | * @hw: pointer to the HW structure 17 | @@ -2614,6 +2619,10 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring) 18 | /* cache tail off for easier writes later */ 19 | ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q); 20 | 21 | +#ifdef DEV_NETMAP 22 | + i40e_netmap_configure_tx_ring(ring); 23 | +#endif /* DEV_NETMAP */ 24 | + 25 | return 0; 26 | } 27 | 28 | @@ -2702,6 +2711,11 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring) 29 | ring->tail = hw->hw_addr + I40E_QRX_TAIL(pf_q); 30 | writel(0, ring->tail); 31 | 32 | +#ifdef DEV_NETMAP 33 | + if (i40e_netmap_configure_rx_ring(ring)) 34 | + return 0; 35 | +#endif /* DEV_NETMAP */ 36 | + 37 | if (ring_is_ps_enabled(ring)) { 38 | i40e_alloc_rx_headers(ring); 39 | i40e_alloc_rx_buffers_ps(ring, I40E_DESC_UNUSED(ring)); 40 | @@ -8757,6 +8771,11 @@ int i40e_vsi_release(struct i40e_vsi *vsi) 41 | return -ENODEV; 42 | } 43 | 44 | +#ifdef DEV_NETMAP 45 | + if (vsi->netdev_registered) 46 | + netmap_detach(vsi->netdev); 47 | +#endif 48 | + 49 | uplink_seid = vsi->uplink_seid; 50 | if (vsi->type != I40E_VSI_SRIOV) { 51 | if (vsi->netdev_registered) { 52 | @@ -9101,6 +9120,12 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, 53 | (vsi->type == I40E_VSI_VMDQ2)) { 54 | ret = i40e_vsi_config_rss(vsi); 55 | } 56 | + 57 | +#ifdef DEV_NETMAP 58 | + if (vsi->netdev_registered) 59 | + i40e_netmap_attach(vsi); 60 | +#endif 61 | + 62 | return vsi; 63 | 64 | err_rings: 65 | diff --git a/i40e/i40e_txrx.c b/i40e/i40e_txrx.c 66 | index 738aca6..77e14b3 100644 67 | --- a/i40e/i40e_txrx.c 68 | +++ b/i40e/i40e_txrx.c 69 | @@ -29,6 +29,10 @@ 70 | #include "i40e.h" 71 | #include "i40e_prototype.h" 72 | 73 | +#if defined(CONFIG_NETMAP) || defined (CONFIG_NETMAP_MODULE) 74 | +#include 75 | +#endif /* DEV_NETMAP */ 76 | + 77 | static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, 78 | u32 td_tag) 79 | { 80 | @@ -697,6 +701,11 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget) 81 | unsigned int total_packets = 0; 82 | unsigned int total_bytes = 0; 83 | 84 | +#ifdef DEV_NETMAP 85 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 86 | + return true; 87 | +#endif /* DEV_NETMAP */ 88 | + 89 | tx_buf = &tx_ring->tx_bi[i]; 90 | tx_desc = I40E_TX_DESC(tx_ring, i); 91 | i -= tx_ring->count; 92 | @@ -1929,6 +1938,15 @@ int i40e_napi_poll(struct napi_struct *napi, int budget) 93 | budget_per_ring = max(budget/q_vector->num_ringpairs, 1); 94 | 95 | i40e_for_each_ring(ring, q_vector->rx) { 96 | +#ifdef DEV_NETMAP 97 | + int dummy, nm_irq; 98 | + nm_irq = netmap_rx_irq(vsi->netdev, ring->queue_index, &dummy); 99 | + if (nm_irq != NM_IRQ_PASS) { 100 | + clean_complete &= (nm_irq == NM_IRQ_COMPLETED); 101 | + continue; 102 | + } 103 | +#endif /* DEV_NETMAP */ 104 | + 105 | if (ring_is_ps_enabled(ring)) 106 | cleaned = i40e_clean_rx_irq_ps(ring, budget_per_ring); 107 | else 108 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--i40e--40400--40700: -------------------------------------------------------------------------------- 1 | diff --git a/i40e/i40e_main.c b/i40e/i40e_main.c 2 | index 4a9873ec..2803d11 100644 3 | --- a/i40e/i40e_main.c 4 | +++ b/i40e/i40e_main.c 5 | @@ -97,6 +97,11 @@ MODULE_DESCRIPTION("Intel(R) Ethernet Connection XL710 Network Driver"); 6 | MODULE_LICENSE("GPL"); 7 | MODULE_VERSION(DRV_VERSION); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#define NETMAP_I40E_MAIN 11 | +#include 12 | +#endif 13 | + 14 | /** 15 | * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code 16 | * @hw: pointer to the HW structure 17 | @@ -2805,6 +2810,10 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring) 18 | /* cache tail off for easier writes later */ 19 | ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q); 20 | 21 | +#ifdef DEV_NETMAP 22 | + i40e_netmap_configure_tx_ring(ring); 23 | +#endif /* DEV_NETMAP */ 24 | + 25 | return 0; 26 | } 27 | 28 | @@ -2893,6 +2902,11 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring) 29 | ring->tail = hw->hw_addr + I40E_QRX_TAIL(pf_q); 30 | writel(0, ring->tail); 31 | 32 | +#ifdef DEV_NETMAP 33 | + if (i40e_netmap_configure_rx_ring(ring)) 34 | + return 0; 35 | +#endif /* DEV_NETMAP */ 36 | + 37 | if (ring_is_ps_enabled(ring)) { 38 | i40e_alloc_rx_headers(ring); 39 | i40e_alloc_rx_buffers_ps(ring, I40E_DESC_UNUSED(ring)); 40 | @@ -9031,6 +9045,11 @@ int i40e_vsi_release(struct i40e_vsi *vsi) 41 | return -ENODEV; 42 | } 43 | 44 | +#ifdef DEV_NETMAP 45 | + if (vsi->netdev_registered) 46 | + netmap_detach(vsi->netdev); 47 | +#endif 48 | + 49 | uplink_seid = vsi->uplink_seid; 50 | if (vsi->type != I40E_VSI_SRIOV) { 51 | if (vsi->netdev_registered) { 52 | @@ -9377,6 +9396,12 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, 53 | (vsi->type == I40E_VSI_VMDQ2)) { 54 | ret = i40e_vsi_config_rss(vsi); 55 | } 56 | + 57 | +#ifdef DEV_NETMAP 58 | + if (vsi->netdev_registered) 59 | + i40e_netmap_attach(vsi); 60 | +#endif 61 | + 62 | return vsi; 63 | 64 | err_rings: 65 | diff --git a/i40e/i40e_txrx.c b/i40e/i40e_txrx.c 66 | index 635b3ac..baed465 100644 67 | --- a/i40e/i40e_txrx.c 68 | +++ b/i40e/i40e_txrx.c 69 | @@ -29,6 +29,10 @@ 70 | #include "i40e.h" 71 | #include "i40e_prototype.h" 72 | 73 | +#if defined(CONFIG_NETMAP) || defined (CONFIG_NETMAP_MODULE) 74 | +#include 75 | +#endif /* DEV_NETMAP */ 76 | + 77 | static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, 78 | u32 td_tag) 79 | { 80 | @@ -640,6 +644,11 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget) 81 | unsigned int total_packets = 0; 82 | unsigned int total_bytes = 0; 83 | 84 | +#ifdef DEV_NETMAP 85 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 86 | + return true; 87 | +#endif /* DEV_NETMAP */ 88 | + 89 | tx_buf = &tx_ring->tx_bi[i]; 90 | tx_desc = I40E_TX_DESC(tx_ring, i); 91 | i -= tx_ring->count; 92 | @@ -1912,6 +1921,14 @@ int i40e_napi_poll(struct napi_struct *napi, int budget) 93 | 94 | i40e_for_each_ring(ring, q_vector->rx) { 95 | int cleaned; 96 | +#ifdef DEV_NETMAP 97 | + int dummy, nm_irq; 98 | + nm_irq = netmap_rx_irq(vsi->netdev, ring->queue_index, &dummy); 99 | + if (nm_irq != NM_IRQ_PASS) { 100 | + clean_complete &= (nm_irq == NM_IRQ_COMPLETED); 101 | + continue; 102 | + } 103 | +#endif /* DEV_NETMAP */ 104 | 105 | if (ring_is_ps_enabled(ring)) 106 | cleaned = i40e_clean_rx_irq_ps(ring, budget_per_ring); 107 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--i40e--40700--99999: -------------------------------------------------------------------------------- 1 | diff --git a/i40e/i40e_main.c b/i40e/i40e_main.c 2 | index 501f15d..df24012 100644 3 | --- a/i40e/i40e_main.c 4 | +++ b/i40e/i40e_main.c 5 | @@ -110,6 +110,10 @@ MODULE_LICENSE("GPL"); 6 | MODULE_VERSION(DRV_VERSION); 7 | 8 | static struct workqueue_struct *i40e_wq; 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#define NETMAP_I40E_MAIN 11 | +#include 12 | +#endif 13 | 14 | /** 15 | * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code 16 | @@ -2827,6 +2831,10 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring) 17 | /* cache tail off for easier writes later */ 18 | ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q); 19 | 20 | +#ifdef DEV_NETMAP 21 | + i40e_netmap_configure_tx_ring(ring); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | return 0; 25 | } 26 | 27 | @@ -2902,6 +2910,11 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring) 28 | ring->tail = hw->hw_addr + I40E_QRX_TAIL(pf_q); 29 | writel(0, ring->tail); 30 | 31 | +#ifdef DEV_NETMAP 32 | + if (i40e_netmap_configure_rx_ring(ring)) 33 | + return 0; 34 | +#endif /* DEV_NETMAP */ 35 | + 36 | i40e_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring)); 37 | 38 | return 0; 39 | @@ -9511,6 +9524,11 @@ int i40e_vsi_release(struct i40e_vsi *vsi) 40 | return -ENODEV; 41 | } 42 | 43 | +#ifdef DEV_NETMAP 44 | + if (vsi->netdev_registered) 45 | + netmap_detach(vsi->netdev); 46 | +#endif 47 | + 48 | uplink_seid = vsi->uplink_seid; 49 | if (vsi->type != I40E_VSI_SRIOV) { 50 | if (vsi->netdev_registered) { 51 | @@ -9911,6 +9929,12 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, 52 | (vsi->type == I40E_VSI_VMDQ2)) { 53 | ret = i40e_vsi_config_rss(vsi); 54 | } 55 | + 56 | +#ifdef DEV_NETMAP 57 | + if (vsi->netdev_registered) 58 | + i40e_netmap_attach(vsi); 59 | +#endif 60 | + 61 | return vsi; 62 | 63 | err_rings: 64 | diff --git a/i40e/i40e_txrx.c b/i40e/i40e_txrx.c 65 | index a8868e1..9186a17 100644 66 | --- a/i40e/i40e_txrx.c 67 | +++ b/i40e/i40e_txrx.c 68 | @@ -29,6 +29,10 @@ 69 | #include "i40e.h" 70 | #include "i40e_prototype.h" 71 | 72 | +#if defined(CONFIG_NETMAP) || defined (CONFIG_NETMAP_MODULE) 73 | +#include 74 | +#endif /* DEV_NETMAP */ 75 | + 76 | static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size, 77 | u32 td_tag) 78 | { 79 | @@ -652,6 +656,11 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi, 80 | unsigned int total_bytes = 0, total_packets = 0; 81 | unsigned int budget = vsi->work_limit; 82 | 83 | +#ifdef DEV_NETMAP 84 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 85 | + return true; 86 | +#endif /* DEV_NETMAP */ 87 | + 88 | tx_buf = &tx_ring->tx_bi[i]; 89 | tx_desc = I40E_TX_DESC(tx_ring, i); 90 | i -= tx_ring->count; 91 | @@ -1753,6 +1762,13 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget) 92 | u16 cleaned_count = I40E_DESC_UNUSED(rx_ring); 93 | bool failure = false; 94 | 95 | +#ifdef DEV_NETMAP 96 | + int dummy; 97 | + if (rx_ring->netdev && 98 | + netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy) != NM_IRQ_PASS) 99 | + return 1; 100 | +#endif /* DEV_NETMAP */ 101 | + 102 | while (likely(total_rx_packets < budget)) { 103 | union i40e_rx_desc *rx_desc; 104 | struct sk_buff *skb; 105 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--20621--20623: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index c881347..a2af379 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -226,6 +226,10 @@ char *igb_get_hw_dev_name(struct e1000_hw *hw) 6 | return adapter->netdev->name; 7 | } 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /** 14 | * igb_get_time_str - format current NIC and system time as string 15 | */ 16 | @@ -1614,6 +1618,10 @@ static int __devinit igb_probe(struct pci_dev *pdev, 17 | /* carrier off reporting is important to ethtool even BEFORE open */ 18 | netif_carrier_off(netdev); 19 | 20 | +#ifdef DEV_NETMAP 21 | + igb_netmap_attach(adapter); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | #ifdef CONFIG_IGB_DCA 25 | if (dca_add_requester(&pdev->dev) == 0) { 26 | adapter->flags |= IGB_FLAG_DCA_ENABLED; 27 | @@ -1699,6 +1707,10 @@ static void __devexit igb_remove(struct pci_dev *pdev) 28 | wr32(E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_MODE_DISABLE); 29 | } 30 | #endif 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(netdev); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | 36 | /* Release control of h/w to f/w. If f/w is AMT enabled, this 37 | * would have already happened in close and is redundant. */ 38 | @@ -2196,6 +2208,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, 39 | 40 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; 41 | wr32(E1000_TXDCTL(reg_idx), txdctl); 42 | +#ifdef DEV_NETMAP 43 | + igb_netmap_configure_tx_ring(adapter, reg_idx); 44 | +#endif /* DEV_NETMAP */ 45 | } 46 | 47 | /** 48 | @@ -4905,6 +4920,11 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) 49 | unsigned int i, eop, count = 0; 50 | bool cleaned = false; 51 | 52 | +#ifdef DEV_NETMAP 53 | + if (netmap_tx_irq(netdev, tx_ring->queue_index)) 54 | + return 1; /* cleaned ok */ 55 | +#endif /* DEV_NETMAP */ 56 | + 57 | i = tx_ring->next_to_clean; 58 | eop = tx_ring->buffer_info[i].next_to_watch; 59 | eop_desc = E1000_TX_DESC_ADV(*tx_ring, eop); 60 | @@ -5109,6 +5129,11 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *q_vector, 61 | u16 length; 62 | u16 vlan_tag; 63 | 64 | +#ifdef DEV_NETMAP 65 | + if (netmap_rx_irq(netdev, rx_ring->queue_index, work_done)) 66 | + return 1; 67 | +#endif /* DEV_NETMAP */ 68 | + 69 | i = rx_ring->next_to_clean; 70 | buffer_info = &rx_ring->buffer_info[i]; 71 | rx_desc = E1000_RX_DESC_ADV(*rx_ring, i); 72 | @@ -5236,6 +5261,10 @@ void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring, int cleaned_count) 73 | unsigned int i; 74 | int bufsz; 75 | 76 | +#ifdef DEV_NETMAP 77 | + if (igb_netmap_configure_rx_ring(rx_ring)) 78 | + return; 79 | +#endif /* DEV_NETMAP */ 80 | i = rx_ring->next_to_use; 81 | buffer_info = &rx_ring->buffer_info[i]; 82 | 83 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--20623--30200: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index cea37e0..81fd28b 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -201,6 +201,10 @@ MODULE_DESCRIPTION("Intel(R) Gigabit Ethernet Network Driver"); 6 | MODULE_LICENSE("GPL"); 7 | MODULE_VERSION(DRV_VERSION); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct igb_reg_info { 14 | u32 ofs; 15 | char *name; 16 | @@ -1963,6 +1967,10 @@ static int __devinit igb_probe(struct pci_dev *pdev, 17 | /* carrier off reporting is important to ethtool even BEFORE open */ 18 | netif_carrier_off(netdev); 19 | 20 | +#ifdef DEV_NETMAP 21 | + igb_netmap_attach(adapter); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | #ifdef CONFIG_IGB_DCA 25 | if (dca_add_requester(&pdev->dev) == 0) { 26 | adapter->flags |= IGB_FLAG_DCA_ENABLED; 27 | @@ -2072,6 +2080,10 @@ static void __devexit igb_remove(struct pci_dev *pdev) 28 | dev_info(&pdev->dev, "IOV Disabled\n"); 29 | } 30 | #endif 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(netdev); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | 36 | iounmap(hw->hw_addr); 37 | if (hw->flash_address) 38 | @@ -2545,6 +2557,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, 39 | 40 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; 41 | wr32(E1000_TXDCTL(reg_idx), txdctl); 42 | +#ifdef DEV_NETMAP 43 | + igb_netmap_configure_tx_ring(adapter, reg_idx); 44 | +#endif /* DEV_NETMAP */ 45 | } 46 | 47 | /** 48 | @@ -5338,6 +5353,11 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) 49 | unsigned int i, eop, count = 0; 50 | bool cleaned = false; 51 | 52 | +#ifdef DEV_NETMAP 53 | + if (netmap_tx_irq(netdev, tx_ring->queue_index)) 54 | + return 1; /* cleaned ok */ 55 | +#endif /* DEV_NETMAP */ 56 | + 57 | i = tx_ring->next_to_clean; 58 | eop = tx_ring->buffer_info[i].next_to_watch; 59 | eop_desc = E1000_TX_DESC_ADV(*tx_ring, eop); 60 | @@ -5540,6 +5560,11 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *q_vector, 61 | u16 length; 62 | u16 vlan_tag; 63 | 64 | +#ifdef DEV_NETMAP 65 | + if (netmap_rx_irq(netdev, rx_ring->queue_index, work_done)) 66 | + return 1; 67 | +#endif /* DEV_NETMAP */ 68 | + 69 | i = rx_ring->next_to_clean; 70 | buffer_info = &rx_ring->buffer_info[i]; 71 | rx_desc = E1000_RX_DESC_ADV(*rx_ring, i); 72 | @@ -5668,6 +5693,10 @@ void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring, int cleaned_count) 73 | unsigned int i; 74 | int bufsz; 75 | 76 | +#ifdef DEV_NETMAP 77 | + if (igb_netmap_configure_rx_ring(rx_ring)) 78 | + return; 79 | +#endif /* DEV_NETMAP */ 80 | i = rx_ring->next_to_use; 81 | buffer_info = &rx_ring->buffer_info[i]; 82 | 83 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--30200--30800: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index ced5444..43c2419 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -225,6 +225,10 @@ MODULE_DESCRIPTION("Intel(R) Gigabit Ethernet Network Driver"); 6 | MODULE_LICENSE("GPL"); 7 | MODULE_VERSION(DRV_VERSION); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct igb_reg_info { 14 | u32 ofs; 15 | char *name; 16 | @@ -2073,6 +2077,10 @@ static int __devinit igb_probe(struct pci_dev *pdev, 17 | /* carrier off reporting is important to ethtool even BEFORE open */ 18 | netif_carrier_off(netdev); 19 | 20 | +#ifdef DEV_NETMAP 21 | + igb_netmap_attach(adapter); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | #ifdef CONFIG_IGB_DCA 25 | if (dca_add_requester(&pdev->dev) == 0) { 26 | adapter->flags |= IGB_FLAG_DCA_ENABLED; 27 | @@ -2199,6 +2207,10 @@ static void __devexit igb_remove(struct pci_dev *pdev) 28 | dev_info(&pdev->dev, "IOV Disabled\n"); 29 | } 30 | #endif 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(netdev); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | 36 | iounmap(hw->hw_addr); 37 | if (hw->flash_address) 38 | @@ -2711,6 +2723,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, 39 | 40 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; 41 | wr32(E1000_TXDCTL(reg_idx), txdctl); 42 | +#ifdef DEV_NETMAP 43 | + igb_netmap_configure_tx_ring(adapter, reg_idx); 44 | +#endif /* DEV_NETMAP */ 45 | } 46 | 47 | /** 48 | @@ -3088,6 +3103,19 @@ void igb_configure_rx_ring(struct igb_adapter *adapter, 49 | /* Only set Drop Enable if we are supporting multiple queues */ 50 | if (adapter->vfs_allocated_count || adapter->num_rx_queues > 1) 51 | srrctl |= E1000_SRRCTL_DROP_EN; 52 | +#ifdef DEV_NETMAP 53 | + { 54 | + /* The driver uses split buffers, which are not 55 | + * supported in native netmap mode */ 56 | + struct ifnet *ifp = adapter->netdev; 57 | + struct netmap_adapter *na = NA(ifp); 58 | + if (nm_native_on(na)) { 59 | + srrctl &= ~(7 << 25); /* clear descriptor type */ 60 | + srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF; 61 | + /* XXX we should set tail here */ 62 | + } 63 | + } 64 | +#endif 65 | 66 | wr32(E1000_SRRCTL(reg_idx), srrctl); 67 | 68 | @@ -5705,6 +5733,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) 69 | 70 | if (test_bit(__IGB_DOWN, &adapter->state)) 71 | return true; 72 | +#ifdef DEV_NETMAP 73 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 74 | + return 1; /* cleaned ok */ 75 | +#endif /* DEV_NETMAP */ 76 | 77 | tx_buffer = &tx_ring->tx_buffer_info[i]; 78 | tx_desc = IGB_TX_DESC(tx_ring, i); 79 | @@ -5980,6 +6012,12 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget) 80 | u16 cleaned_count = igb_desc_unused(rx_ring); 81 | u16 i = rx_ring->next_to_clean; 82 | 83 | +#ifdef DEV_NETMAP 84 | + int dummy = 1; // select rx irq handling 85 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy)) 86 | + return 1; 87 | +#endif /* DEV_NETMAP */ 88 | + 89 | rx_desc = IGB_RX_DESC(rx_ring, i); 90 | 91 | while (igb_test_staterr(rx_desc, E1000_RXD_STAT_DD)) { 92 | @@ -6170,6 +6208,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 93 | struct igb_rx_buffer *bi; 94 | u16 i = rx_ring->next_to_use; 95 | 96 | +#ifdef DEV_NETMAP 97 | + if (igb_netmap_configure_rx_ring(rx_ring)) 98 | + return; 99 | +#endif /* DEV_NETMAP */ 100 | + 101 | rx_desc = IGB_RX_DESC(rx_ring, i); 102 | bi = &rx_ring->rx_buffer_info[i]; 103 | i -= rx_ring->count; 104 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--30800--30f00: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index 31cfe2e..2776ed4 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -247,6 +247,10 @@ static int debug = -1; 6 | module_param(debug, int, 0); 7 | MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct igb_reg_info { 14 | u32 ofs; 15 | char *name; 16 | @@ -2127,6 +2131,10 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 17 | /* carrier off reporting is important to ethtool even BEFORE open */ 18 | netif_carrier_off(netdev); 19 | 20 | +#ifdef DEV_NETMAP 21 | + igb_netmap_attach(adapter); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | #ifdef CONFIG_IGB_DCA 25 | if (dca_add_requester(&pdev->dev) == 0) { 26 | adapter->flags |= IGB_FLAG_DCA_ENABLED; 27 | @@ -2233,6 +2241,10 @@ static void igb_remove(struct pci_dev *pdev) 28 | wr32(E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_MODE_DISABLE); 29 | } 30 | #endif 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(netdev); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | 36 | /* Release control of h/w to f/w. If f/w is AMT enabled, this 37 | * would have already happened in close and is redundant. */ 38 | @@ -2746,6 +2758,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, 39 | 40 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; 41 | wr32(E1000_TXDCTL(reg_idx), txdctl); 42 | +#ifdef DEV_NETMAP 43 | + igb_netmap_configure_tx_ring(adapter, reg_idx); 44 | +#endif /* DEV_NETMAP */ 45 | } 46 | 47 | /** 48 | @@ -5690,6 +5705,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) 49 | 50 | if (test_bit(__IGB_DOWN, &adapter->state)) 51 | return true; 52 | +#ifdef DEV_NETMAP 53 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 54 | + return 1; /* cleaned ok */ 55 | +#endif /* DEV_NETMAP */ 56 | 57 | tx_buffer = &tx_ring->tx_buffer_info[i]; 58 | tx_desc = IGB_TX_DESC(tx_ring, i); 59 | @@ -6349,6 +6368,10 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) 60 | unsigned int total_bytes = 0, total_packets = 0; 61 | u16 cleaned_count = igb_desc_unused(rx_ring); 62 | 63 | +#ifdef DEV_NETMAP 64 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) 65 | + return true; 66 | +#endif /* DEV_NETMAP */ 67 | do { 68 | union e1000_adv_rx_desc *rx_desc; 69 | 70 | @@ -6461,6 +6484,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 71 | struct igb_rx_buffer *bi; 72 | u16 i = rx_ring->next_to_use; 73 | 74 | +#ifdef DEV_NETMAP 75 | + if (igb_netmap_configure_rx_ring(rx_ring)) 76 | + return; 77 | +#endif /* DEV_NETMAP */ 78 | + 79 | /* nothing to do */ 80 | if (!cleaned_count) 81 | return; 82 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--30f00--40100: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index 16430a8..c2c4622 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -257,6 +257,10 @@ static int debug = -1; 6 | module_param(debug, int, 0); 7 | MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct igb_reg_info { 14 | u32 ofs; 15 | char *name; 16 | @@ -1798,7 +1802,6 @@ void igb_down(struct igb_adapter *adapter) 17 | napi_disable(&(adapter->q_vector[i]->napi)); 18 | } 19 | 20 | - 21 | del_timer_sync(&adapter->watchdog_timer); 22 | del_timer_sync(&adapter->phy_info_timer); 23 | 24 | @@ -2540,6 +2543,10 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 25 | /* carrier off reporting is important to ethtool even BEFORE open */ 26 | netif_carrier_off(netdev); 27 | 28 | +#ifdef DEV_NETMAP 29 | + igb_netmap_attach(adapter); 30 | +#endif /* DEV_NETMAP */ 31 | + 32 | #ifdef CONFIG_IGB_DCA 33 | if (dca_add_requester(&pdev->dev) == 0) { 34 | adapter->flags |= IGB_FLAG_DCA_ENABLED; 35 | @@ -2805,6 +2812,10 @@ static void igb_remove(struct pci_dev *pdev) 36 | wr32(E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_MODE_DISABLE); 37 | } 38 | #endif 39 | +#ifdef DEV_NETMAP 40 | + netmap_detach(netdev); 41 | +#endif /* DEV_NETMAP */ 42 | + 43 | 44 | /* Release control of h/w to f/w. If f/w is AMT enabled, this 45 | * would have already happened in close and is redundant. 46 | @@ -3276,6 +3287,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, 47 | 48 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; 49 | wr32(E1000_TXDCTL(reg_idx), txdctl); 50 | +#ifdef DEV_NETMAP 51 | + igb_netmap_configure_tx_ring(adapter, reg_idx); 52 | +#endif /* DEV_NETMAP */ 53 | } 54 | 55 | /** 56 | @@ -6321,6 +6335,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) 57 | 58 | if (test_bit(__IGB_DOWN, &adapter->state)) 59 | return true; 60 | +#ifdef DEV_NETMAP 61 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 62 | + return 1; /* cleaned ok */ 63 | +#endif /* DEV_NETMAP */ 64 | 65 | tx_buffer = &tx_ring->tx_buffer_info[i]; 66 | tx_desc = IGB_TX_DESC(tx_ring, i); 67 | @@ -6984,6 +7002,10 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) 68 | unsigned int total_bytes = 0, total_packets = 0; 69 | u16 cleaned_count = igb_desc_unused(rx_ring); 70 | 71 | +#ifdef DEV_NETMAP 72 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) 73 | + return true; 74 | +#endif /* DEV_NETMAP */ 75 | while (likely(total_packets < budget)) { 76 | union e1000_adv_rx_desc *rx_desc; 77 | 78 | @@ -7101,6 +7123,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 79 | struct igb_rx_buffer *bi; 80 | u16 i = rx_ring->next_to_use; 81 | 82 | +#ifdef DEV_NETMAP 83 | + if (igb_netmap_configure_rx_ring(rx_ring)) 84 | + return; 85 | +#endif /* DEV_NETMAP */ 86 | + 87 | /* nothing to do */ 88 | if (!cleaned_count) 89 | return; 90 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--40100--99999: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index a0a9b1f..85be1eb 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -251,6 +251,10 @@ static int debug = -1; 6 | module_param(debug, int, 0); 7 | MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct igb_reg_info { 14 | u32 ofs; 15 | char *name; 16 | @@ -2547,6 +2551,10 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 17 | /* carrier off reporting is important to ethtool even BEFORE open */ 18 | netif_carrier_off(netdev); 19 | 20 | +#ifdef DEV_NETMAP 21 | + igb_netmap_attach(adapter); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | #ifdef CONFIG_IGB_DCA 25 | if (dca_add_requester(&pdev->dev) == 0) { 26 | adapter->flags |= IGB_FLAG_DCA_ENABLED; 27 | @@ -2812,6 +2820,10 @@ static void igb_remove(struct pci_dev *pdev) 28 | wr32(E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_MODE_DISABLE); 29 | } 30 | #endif 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(netdev); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | 36 | /* Release control of h/w to f/w. If f/w is AMT enabled, this 37 | * would have already happened in close and is redundant. 38 | @@ -3284,6 +3296,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, 39 | 40 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; 41 | wr32(E1000_TXDCTL(reg_idx), txdctl); 42 | +#ifdef DEV_NETMAP 43 | + igb_netmap_configure_tx_ring(adapter, reg_idx); 44 | +#endif /* DEV_NETMAP */ 45 | } 46 | 47 | /** 48 | @@ -6400,6 +6415,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) 49 | 50 | if (test_bit(__IGB_DOWN, &adapter->state)) 51 | return true; 52 | +#ifdef DEV_NETMAP 53 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 54 | + return 1; /* cleaned ok */ 55 | +#endif /* DEV_NETMAP */ 56 | 57 | tx_buffer = &tx_ring->tx_buffer_info[i]; 58 | tx_desc = IGB_TX_DESC(tx_ring, i); 59 | @@ -6951,6 +6970,10 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) 60 | unsigned int total_bytes = 0, total_packets = 0; 61 | u16 cleaned_count = igb_desc_unused(rx_ring); 62 | 63 | +#ifdef DEV_NETMAP 64 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) 65 | + return true; 66 | +#endif /* DEV_NETMAP */ 67 | while (likely(total_packets < budget)) { 68 | union e1000_adv_rx_desc *rx_desc; 69 | 70 | @@ -7068,6 +7091,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 71 | struct igb_rx_buffer *bi; 72 | u16 i = rx_ring->next_to_use; 73 | 74 | +#ifdef DEV_NETMAP 75 | + if (igb_netmap_configure_rx_ring(rx_ring)) 76 | + return; 77 | +#endif /* DEV_NETMAP */ 78 | + 79 | /* nothing to do */ 80 | if (!cleaned_count) 81 | return; 82 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--20623--20625: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index 74d9b6d..d2a6b08 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -214,6 +214,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -741,6 +757,16 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | unsigned int i, eop, count = 0; 30 | unsigned int total_bytes = 0, total_packets = 0; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | i = tx_ring->next_to_clean; 43 | eop = tx_ring->tx_buffer_info[i].next_to_watch; 44 | eop_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop); 45 | @@ -1187,6 +1213,17 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 46 | int ddp_bytes = 0; 47 | #endif /* IXGBE_FCOE */ 48 | 49 | +#ifdef DEV_NETMAP 50 | + int nm_irq; 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + nm_irq = netmap_rx_irq(adapter->netdev, rx_ring->queue_index, work_done); 55 | + if (nm_irq != NM_IRQ_PASS) { 56 | + *work_done = (nm_irq == NM_IRQ_RESCHED) ? work_to_do : 1; 57 | + return true; 58 | + } 59 | +#endif /* DEV_NETMAP */ 60 | i = rx_ring->next_to_clean; 61 | rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i); 62 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 63 | @@ -3159,6 +3196,12 @@ static void ixgbe_configure(struct ixgbe_adapter *adapter) 64 | 65 | ixgbe_configure_tx(adapter); 66 | ixgbe_configure_rx(adapter); 67 | +#ifdef DEV_NETMAP 68 | + for (i = 0; i < adapter->num_rx_queues; i++) 69 | + ixgbe_netmap_configure_rx_ring(adapter, 70 | + adapter->rx_ring[i]->reg_idx); 71 | + return; 72 | +#endif /* DEV_NETMAP */ 73 | for (i = 0; i < adapter->num_rx_queues; i++) 74 | ixgbe_alloc_rx_buffers(adapter, adapter->rx_ring[i], 75 | (adapter->rx_ring[i]->count - 1)); 76 | @@ -3390,6 +3433,10 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter) 77 | DPRINTK(DRV, ERR, "Could not enable " 78 | "Tx Queue %d\n", j); 79 | } 80 | +#ifdef DEV_NETMAP // XXX i and j are the same ? 81 | + ixgbe_netmap_configure_tx_ring(adapter, j); 82 | +#endif /* DEV_NETMAP */ 83 | + 84 | } 85 | 86 | for (i = 0; i < num_rx_rings; i++) { 87 | @@ -6833,6 +6880,11 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 88 | 89 | dev_info(&pdev->dev, "Intel(R) 10 Gigabit Network Connection\n"); 90 | cards_found++; 91 | + 92 | +#ifdef DEV_NETMAP 93 | + ixgbe_netmap_attach(adapter); 94 | +#endif /* DEV_NETMAP */ 95 | + 96 | return 0; 97 | 98 | err_register: 99 | @@ -6873,6 +6925,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 100 | struct net_device *netdev = pci_get_drvdata(pdev); 101 | struct ixgbe_adapter *adapter = netdev_priv(netdev); 102 | 103 | +#ifdef DEV_NETMAP 104 | + netmap_detach(netdev); 105 | +#endif /* DEV_NETMAP */ 106 | + 107 | set_bit(__IXGBE_DOWN, &adapter->state); 108 | /* clear the module not found bit to make sure the worker won't 109 | * reschedule 110 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--20625--20626: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index eee0b29..a94380e 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -214,6 +214,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -740,6 +756,16 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | unsigned int i, eop, count = 0; 30 | unsigned int total_bytes = 0, total_packets = 0; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | i = tx_ring->next_to_clean; 43 | eop = tx_ring->tx_buffer_info[i].next_to_watch; 44 | eop_desc = IXGBE_TX_DESC_ADV(tx_ring, eop); 45 | @@ -1185,6 +1211,17 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 46 | int ddp_bytes = 0; 47 | #endif /* IXGBE_FCOE */ 48 | 49 | +#ifdef DEV_NETMAP 50 | + int nm_irq; 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + nm_irq = netmap_rx_irq(adapter->netdev, rx_ring->queue_index, work_done); 55 | + if (nm_irq != NM_IRQ_PASS) { 56 | + *work_done = (nm_irq == NM_IRQ_RESCHED) ? work_to_do : 1; 57 | + return true; 58 | + } 59 | +#endif /* DEV_NETMAP */ 60 | i = rx_ring->next_to_clean; 61 | rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); 62 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 63 | @@ -2519,6 +2556,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 64 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 65 | if (!wait_loop) 66 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 67 | +#ifdef DEV_NETMAP 68 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 69 | +#endif /* DEV_NETMAP */ 70 | } 71 | 72 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 73 | @@ -2833,6 +2873,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 74 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 75 | 76 | ixgbe_rx_desc_queue_enable(adapter, ring); 77 | +#ifdef DEV_NETMAP 78 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 79 | + return; 80 | +#endif /* DEV_NETMAP */ 81 | ixgbe_alloc_rx_buffers(adapter, ring, IXGBE_DESC_UNUSED(ring)); 82 | } 83 | 84 | @@ -7048,6 +7092,11 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 85 | 86 | e_dev_info("Intel(R) 10 Gigabit Network Connection\n"); 87 | cards_found++; 88 | + 89 | +#ifdef DEV_NETMAP 90 | + ixgbe_netmap_attach(adapter); 91 | +#endif /* DEV_NETMAP */ 92 | + 93 | return 0; 94 | 95 | err_register: 96 | @@ -7088,6 +7137,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 97 | struct net_device *netdev = pci_get_drvdata(pdev); 98 | struct ixgbe_adapter *adapter = netdev_priv(netdev); 99 | 100 | +#ifdef DEV_NETMAP 101 | + netmap_detach(netdev); 102 | +#endif /* DEV_NETMAP */ 103 | + 104 | set_bit(__IXGBE_DOWN, &adapter->state); 105 | /* clear the module not found bit to make sure the worker won't 106 | * reschedule 107 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--20626--30100: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index 30f9ccf..e570fce 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -221,6 +221,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -826,6 +842,16 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | unsigned int total_bytes = 0, total_packets = 0; 30 | u16 i, eop, count = 0; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | i = tx_ring->next_to_clean; 43 | eop = tx_ring->tx_buffer_info[i].next_to_watch; 44 | eop_desc = IXGBE_TX_DESC_ADV(tx_ring, eop); 45 | @@ -1308,6 +1334,17 @@ static void ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 46 | u16 cleaned_count = 0; 47 | bool pkt_is_rsc = false; 48 | 49 | +#ifdef DEV_NETMAP 50 | + int nm_irq; 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + nm_irq = netmap_rx_irq(adapter->netdev, rx_ring->queue_index, work_done); 55 | + if (nm_irq != NM_IRQ_PASS) { 56 | + *work_done = (nm_irq == NM_IRQ_RESCHED) ? work_to_do : 1; 57 | + return; 58 | + } 59 | +#endif /* DEV_NETMAP */ 60 | i = rx_ring->next_to_clean; 61 | rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); 62 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 63 | @@ -2730,6 +2767,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 64 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 65 | if (!wait_loop) 66 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 67 | +#ifdef DEV_NETMAP 68 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 69 | +#endif /* DEV_NETMAP */ 70 | } 71 | 72 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 73 | @@ -3094,6 +3134,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 74 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 75 | 76 | ixgbe_rx_desc_queue_enable(adapter, ring); 77 | +#ifdef DEV_NETMAP 78 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 79 | + return; 80 | +#endif /* DEV_NETMAP */ 81 | ixgbe_alloc_rx_buffers(ring, IXGBE_DESC_UNUSED(ring)); 82 | } 83 | 84 | @@ -7450,6 +7494,11 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 85 | 86 | e_dev_info("Intel(R) 10 Gigabit Network Connection\n"); 87 | cards_found++; 88 | + 89 | +#ifdef DEV_NETMAP 90 | + ixgbe_netmap_attach(adapter); 91 | +#endif /* DEV_NETMAP */ 92 | + 93 | return 0; 94 | 95 | err_register: 96 | @@ -7490,6 +7539,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 97 | struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 98 | struct net_device *netdev = adapter->netdev; 99 | 100 | +#ifdef DEV_NETMAP 101 | + netmap_detach(netdev); 102 | +#endif /* DEV_NETMAP */ 103 | + 104 | set_bit(__IXGBE_DOWN, &adapter->state); 105 | 106 | /* 107 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--30100--30200: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index e1fcc95..262e92d 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -249,6 +249,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -801,6 +817,17 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | unsigned int total_bytes = 0, total_packets = 0; 30 | u16 i, eop, count = 0; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | + 43 | i = tx_ring->next_to_clean; 44 | eop = tx_ring->tx_buffer_info[i].next_to_watch; 45 | eop_desc = IXGBE_TX_DESC_ADV(tx_ring, eop); 46 | @@ -1303,6 +1330,17 @@ static void ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 47 | u16 cleaned_count = 0; 48 | bool pkt_is_rsc = false; 49 | 50 | +#ifdef DEV_NETMAP 51 | + int nm_irq; 52 | + /* 53 | + * Same as the txeof routine: only wakeup clients on intr. 54 | + */ 55 | + nm_irq = netmap_rx_irq(adapter->netdev, rx_ring->queue_index, work_done); 56 | + if (nm_irq != NM_IRQ_PASS) { 57 | + *work_done = (nm_irq == NM_IRQ_RESCHED) ? work_to_do : 1; 58 | + return; 59 | + } 60 | +#endif /* DEV_NETMAP */ 61 | i = rx_ring->next_to_clean; 62 | rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); 63 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 64 | @@ -2676,6 +2714,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 65 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 66 | if (!wait_loop) 67 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 68 | +#ifdef DEV_NETMAP 69 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 70 | +#endif /* DEV_NETMAP */ 71 | } 72 | 73 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 74 | @@ -3039,6 +3080,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 75 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 76 | 77 | ixgbe_rx_desc_queue_enable(adapter, ring); 78 | +#ifdef DEV_NETMAP 79 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 80 | + return; 81 | +#endif /* DEV_NETMAP */ 82 | ixgbe_alloc_rx_buffers(ring, ixgbe_desc_unused(ring)); 83 | } 84 | 85 | @@ -7696,6 +7741,11 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 86 | 87 | e_dev_info("Intel(R) 10 Gigabit Network Connection\n"); 88 | cards_found++; 89 | + 90 | +#ifdef DEV_NETMAP 91 | + ixgbe_netmap_attach(adapter); 92 | +#endif /* DEV_NETMAP */ 93 | + 94 | return 0; 95 | 96 | err_register: 97 | @@ -7732,6 +7782,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 98 | struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 99 | struct net_device *netdev = adapter->netdev; 100 | 101 | +#ifdef DEV_NETMAP 102 | + netmap_detach(netdev); 103 | +#endif /* DEV_NETMAP */ 104 | + 105 | set_bit(__IXGBE_DOWN, &adapter->state); 106 | cancel_work_sync(&adapter->service_task); 107 | 108 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--30200--30400: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index 8ef92d1..ce93cea 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -188,6 +188,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -745,6 +761,17 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | unsigned int budget = q_vector->tx.work_limit; 30 | u16 i = tx_ring->next_to_clean; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | + 43 | tx_buffer = &tx_ring->tx_buffer_info[i]; 44 | tx_desc = IXGBE_TX_DESC_ADV(tx_ring, i); 45 | 46 | @@ -1253,6 +1280,15 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 47 | u16 cleaned_count = 0; 48 | bool pkt_is_rsc = false; 49 | 50 | +#ifdef DEV_NETMAP 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + int dummy, nm_irq; 55 | + nm_irq = netmap_rx_irq(adapter->netdev, rx_ring->queue_index, &dummy); 56 | + if (nm_irq != NM_IRQ_PASS) 57 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 58 | +#endif /* DEV_NETMAP */ 59 | i = rx_ring->next_to_clean; 60 | rx_desc = IXGBE_RX_DESC_ADV(rx_ring, i); 61 | staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 62 | @@ -2420,6 +2456,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 63 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 64 | if (!wait_loop) 65 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 66 | +#ifdef DEV_NETMAP 67 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 68 | +#endif /* DEV_NETMAP */ 69 | } 70 | 71 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 72 | @@ -2783,6 +2822,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 73 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 74 | 75 | ixgbe_rx_desc_queue_enable(adapter, ring); 76 | +#ifdef DEV_NETMAP 77 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 78 | + return; 79 | +#endif /* DEV_NETMAP */ 80 | ixgbe_alloc_rx_buffers(ring, ixgbe_desc_unused(ring)); 81 | } 82 | 83 | @@ -7710,6 +7753,11 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 84 | 85 | e_dev_info("Intel(R) 10 Gigabit Network Connection\n"); 86 | cards_found++; 87 | + 88 | +#ifdef DEV_NETMAP 89 | + ixgbe_netmap_attach(adapter); 90 | +#endif /* DEV_NETMAP */ 91 | + 92 | return 0; 93 | 94 | err_register: 95 | @@ -7746,6 +7794,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 96 | struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 97 | struct net_device *netdev = adapter->netdev; 98 | 99 | +#ifdef DEV_NETMAP 100 | + netmap_detach(netdev); 101 | +#endif /* DEV_NETMAP */ 102 | + 103 | set_bit(__IXGBE_DOWN, &adapter->state); 104 | cancel_work_sync(&adapter->service_task); 105 | 106 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--30400--30500: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index 467948e9..ff180b6 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -204,6 +204,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -749,6 +765,17 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | if (test_bit(__IXGBE_DOWN, &adapter->state)) 30 | return true; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | + 43 | tx_buffer = &tx_ring->tx_buffer_info[i]; 44 | tx_desc = IXGBE_TX_DESC(tx_ring, i); 45 | i -= tx_ring->count; 46 | @@ -1629,6 +1656,16 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 47 | #endif /* IXGBE_FCOE */ 48 | u16 cleaned_count = ixgbe_desc_unused(rx_ring); 49 | 50 | +#ifdef DEV_NETMAP 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + int dummy, nm_irq; 55 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy); 56 | + if (nm_irq != NM_IRQ_PASS) 57 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 58 | +#endif /* DEV_NETMAP */ 59 | + 60 | do { 61 | struct ixgbe_rx_buffer *rx_buffer; 62 | union ixgbe_adv_rx_desc *rx_desc; 63 | @@ -2683,6 +2720,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 64 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 65 | if (!wait_loop) 66 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 67 | +#ifdef DEV_NETMAP 68 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 69 | +#endif /* DEV_NETMAP */ 70 | } 71 | 72 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 73 | @@ -3032,6 +3072,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 74 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 75 | 76 | ixgbe_rx_desc_queue_enable(adapter, ring); 77 | +#ifdef DEV_NETMAP 78 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 79 | + return; 80 | +#endif /* DEV_NETMAP */ 81 | ixgbe_alloc_rx_buffers(ring, ixgbe_desc_unused(ring)); 82 | } 83 | 84 | @@ -4764,6 +4808,7 @@ static int ixgbe_open(struct net_device *netdev) 85 | 86 | ixgbe_up_complete(adapter); 87 | 88 | + 89 | return 0; 90 | 91 | err_req_irq: 92 | @@ -7152,6 +7197,11 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 93 | 94 | e_dev_info("%s\n", ixgbe_default_device_descr); 95 | cards_found++; 96 | + 97 | +#ifdef DEV_NETMAP 98 | + ixgbe_netmap_attach(adapter); 99 | +#endif /* DEV_NETMAP */ 100 | + 101 | return 0; 102 | 103 | err_register: 104 | @@ -7187,6 +7237,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 105 | struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 106 | struct net_device *netdev = adapter->netdev; 107 | 108 | +#ifdef DEV_NETMAP 109 | + netmap_detach(netdev); 110 | +#endif /* DEV_NETMAP */ 111 | + 112 | set_bit(__IXGBE_DOWN, &adapter->state); 113 | cancel_work_sync(&adapter->service_task); 114 | 115 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--30500--30700: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index e242104..5a995de 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -204,6 +204,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -764,6 +780,17 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | if (test_bit(__IXGBE_DOWN, &adapter->state)) 30 | return true; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | + 43 | tx_buffer = &tx_ring->tx_buffer_info[i]; 44 | tx_desc = IXGBE_TX_DESC(tx_ring, i); 45 | i -= tx_ring->count; 46 | @@ -1665,6 +1692,16 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 47 | #endif /* IXGBE_FCOE */ 48 | u16 cleaned_count = ixgbe_desc_unused(rx_ring); 49 | 50 | +#ifdef DEV_NETMAP 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + int dummy, nm_irq; 55 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy); 56 | + if (nm_irq != NM_IRQ_PASS) 57 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 58 | +#endif /* DEV_NETMAP */ 59 | + 60 | do { 61 | struct ixgbe_rx_buffer *rx_buffer; 62 | union ixgbe_adv_rx_desc *rx_desc; 63 | @@ -2725,6 +2762,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 64 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 65 | if (!wait_loop) 66 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 67 | +#ifdef DEV_NETMAP 68 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 69 | +#endif /* DEV_NETMAP */ 70 | } 71 | 72 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 73 | @@ -3102,6 +3142,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 74 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 75 | 76 | ixgbe_rx_desc_queue_enable(adapter, ring); 77 | +#ifdef DEV_NETMAP 78 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 79 | + return; 80 | +#endif /* DEV_NETMAP */ 81 | ixgbe_alloc_rx_buffers(ring, ixgbe_desc_unused(ring)); 82 | } 83 | 84 | @@ -4827,6 +4871,7 @@ static int ixgbe_open(struct net_device *netdev) 85 | 86 | ixgbe_up_complete(adapter); 87 | 88 | + 89 | return 0; 90 | 91 | err_req_irq: 92 | @@ -7358,6 +7403,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 93 | e_err(probe, "failed to allocate sysfs resources\n"); 94 | #endif /* CONFIG_IXGBE_HWMON */ 95 | 96 | +#ifdef DEV_NETMAP 97 | + ixgbe_netmap_attach(adapter); 98 | +#endif /* DEV_NETMAP */ 99 | + 100 | return 0; 101 | 102 | err_register: 103 | @@ -7393,6 +7442,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 104 | struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 105 | struct net_device *netdev = adapter->netdev; 106 | 107 | +#ifdef DEV_NETMAP 108 | + netmap_detach(netdev); 109 | +#endif /* DEV_NETMAP */ 110 | + 111 | set_bit(__IXGBE_DOWN, &adapter->state); 112 | cancel_work_sync(&adapter->service_task); 113 | 114 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--30700--30a00: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index fa3d552..12785e3 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -205,6 +205,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -766,6 +782,17 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | if (test_bit(__IXGBE_DOWN, &adapter->state)) 30 | return true; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | + 43 | tx_buffer = &tx_ring->tx_buffer_info[i]; 44 | tx_desc = IXGBE_TX_DESC(tx_ring, i); 45 | i -= tx_ring->count; 46 | @@ -1791,6 +1818,16 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 47 | #endif /* IXGBE_FCOE */ 48 | u16 cleaned_count = ixgbe_desc_unused(rx_ring); 49 | 50 | +#ifdef DEV_NETMAP 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + int dummy, nm_irq; 55 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy); 56 | + if (nm_irq != NM_IRQ_PASS) 57 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 58 | +#endif /* DEV_NETMAP */ 59 | + 60 | do { 61 | union ixgbe_adv_rx_desc *rx_desc; 62 | struct sk_buff *skb; 63 | @@ -2788,6 +2825,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 64 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 65 | if (!wait_loop) 66 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 67 | +#ifdef DEV_NETMAP 68 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 69 | +#endif /* DEV_NETMAP */ 70 | } 71 | 72 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 73 | @@ -3157,6 +3197,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 74 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 75 | 76 | ixgbe_rx_desc_queue_enable(adapter, ring); 77 | +#ifdef DEV_NETMAP 78 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 79 | + return; 80 | +#endif /* DEV_NETMAP */ 81 | ixgbe_alloc_rx_buffers(ring, ixgbe_desc_unused(ring)); 82 | } 83 | 84 | @@ -4903,6 +4947,7 @@ static int ixgbe_open(struct net_device *netdev) 85 | 86 | ixgbe_up_complete(adapter); 87 | 88 | + 89 | return 0; 90 | 91 | err_set_queues: 92 | @@ -7464,6 +7509,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, 93 | ixgbe_dbg_adapter_init(adapter); 94 | #endif /* CONFIG_DEBUG_FS */ 95 | 96 | +#ifdef DEV_NETMAP 97 | + ixgbe_netmap_attach(adapter); 98 | +#endif /* DEV_NETMAP */ 99 | + 100 | return 0; 101 | 102 | err_register: 103 | @@ -7498,6 +7547,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) 104 | struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 105 | struct net_device *netdev = adapter->netdev; 106 | 107 | +#ifdef DEV_NETMAP 108 | + netmap_detach(netdev); 109 | +#endif /* DEV_NETMAP */ 110 | + 111 | #ifdef CONFIG_DEBUG_FS 112 | ixgbe_dbg_adapter_exit(adapter); 113 | #endif /*CONFIG_DEBUG_FS */ 114 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--ixgbe--30a00--30d00: -------------------------------------------------------------------------------- 1 | diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c 2 | index d30fbdd..0326ffd 100644 3 | --- a/ixgbe/ixgbe_main.c 4 | +++ b/ixgbe/ixgbe_main.c 5 | @@ -248,6 +248,22 @@ static const struct ixgbe_reg_info ixgbe_reg_info_tbl[] = { 6 | {} 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +/* 11 | + * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to 12 | + * be a reference on how to implement netmap support in a driver. 13 | + * Additional comments are in ixgbe_netmap_linux.h . 14 | + * 15 | + * The code is originally developed on FreeBSD and in the interest 16 | + * of maintainability we try to limit differences between the two systems. 17 | + * 18 | + * contains functions for netmap support 19 | + * that extend the standard driver. 20 | + * It also defines DEV_NETMAP so further conditional sections use 21 | + * that instead of CONFIG_NETMAP 22 | + */ 23 | +#include 24 | +#endif 25 | 26 | /* 27 | * ixgbe_regdump - register printout routine 28 | @@ -872,6 +888,17 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, 29 | if (test_bit(__IXGBE_DOWN, &adapter->state)) 30 | return true; 31 | 32 | +#ifdef DEV_NETMAP 33 | + /* 34 | + * In netmap mode, all the work is done in the context 35 | + * of the client thread. Interrupt handlers only wake up 36 | + * clients, which may be sleeping on individual rings 37 | + * or on a global resource for all rings. 38 | + */ 39 | + if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) 40 | + return 1; /* seems to be ignored */ 41 | +#endif /* DEV_NETMAP */ 42 | + 43 | tx_buffer = &tx_ring->tx_buffer_info[i]; 44 | tx_desc = IXGBE_TX_DESC(tx_ring, i); 45 | i -= tx_ring->count; 46 | @@ -1906,6 +1933,16 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, 47 | #endif /* IXGBE_FCOE */ 48 | u16 cleaned_count = ixgbe_desc_unused(rx_ring); 49 | 50 | +#ifdef DEV_NETMAP 51 | + /* 52 | + * Same as the txeof routine: only wakeup clients on intr. 53 | + */ 54 | + int dummy, nm_irq; 55 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy); 56 | + if (nm_irq != NM_IRQ_PASS) 57 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 58 | +#endif /* DEV_NETMAP */ 59 | + 60 | do { 61 | union ixgbe_adv_rx_desc *rx_desc; 62 | struct sk_buff *skb; 63 | @@ -2905,6 +2942,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, 64 | } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); 65 | if (!wait_loop) 66 | e_err(drv, "Could not enable Tx Queue %d\n", reg_idx); 67 | +#ifdef DEV_NETMAP 68 | + ixgbe_netmap_configure_tx_ring(adapter, reg_idx); 69 | +#endif /* DEV_NETMAP */ 70 | } 71 | 72 | static void ixgbe_setup_mtqc(struct ixgbe_adapter *adapter) 73 | @@ -3266,6 +3306,10 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, 74 | IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); 75 | 76 | ixgbe_rx_desc_queue_enable(adapter, ring); 77 | +#ifdef DEV_NETMAP 78 | + if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) 79 | + return; 80 | +#endif /* DEV_NETMAP */ 81 | ixgbe_alloc_rx_buffers(ring, ixgbe_desc_unused(ring)); 82 | } 83 | 84 | @@ -5037,6 +5081,7 @@ static int ixgbe_open(struct net_device *netdev) 85 | 86 | ixgbe_up_complete(adapter); 87 | 88 | + 89 | return 0; 90 | 91 | err_set_queues: 92 | @@ -7658,6 +7703,10 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 93 | IXGBE_LINK_SPEED_10GB_FULL | IXGBE_LINK_SPEED_1GB_FULL, 94 | true); 95 | 96 | +#ifdef DEV_NETMAP 97 | + ixgbe_netmap_attach(adapter); 98 | +#endif /* DEV_NETMAP */ 99 | + 100 | return 0; 101 | 102 | err_register: 103 | @@ -7692,6 +7741,10 @@ static void ixgbe_remove(struct pci_dev *pdev) 104 | struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 105 | struct net_device *netdev = adapter->netdev; 106 | 107 | +#ifdef DEV_NETMAP 108 | + netmap_detach(netdev); 109 | +#endif /* DEV_NETMAP */ 110 | + 111 | ixgbe_dbg_adapter_exit(adapter); 112 | 113 | set_bit(__IXGBE_DOWN, &adapter->state); 114 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--r8169.c--20620--20625: -------------------------------------------------------------------------------- 1 | diff --git a/r8169.c b/r8169.c 2 | index 0fe2fc9..5d363e5 100644 3 | --- a/r8169.c 4 | +++ b/r8169.c 5 | @@ -537,6 +537,10 @@ static int rtl8169_poll(struct napi_struct *napi, int budget); 6 | static const unsigned int rtl8169_rx_config = 7 | (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | static void mdio_write(void __iomem *ioaddr, int reg_addr, int value) 14 | { 15 | int i; 16 | @@ -3210,6 +3214,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 17 | 18 | device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); 19 | 20 | +#ifdef DEV_NETMAP 21 | + re_netmap_attach(tp); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | out: 25 | return rc; 26 | 27 | @@ -3236,6 +3244,10 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) 28 | 29 | unregister_netdev(dev); 30 | 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(dev); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | /* restore original MAC address */ 36 | rtl_rar_set(tp, dev->perm_addr); 37 | 38 | @@ -3993,6 +4005,11 @@ static struct sk_buff *rtl8169_alloc_rx_skb(struct pci_dev *pdev, 39 | static void rtl8169_rx_clear(struct rtl8169_private *tp) 40 | { 41 | unsigned int i; 42 | +#ifdef DEV_NETMAP 43 | + re_netmap_tx_init(tp); 44 | + if (re_netmap_rx_init(tp)) 45 | + return; 46 | +#endif /* DEV_NETMAP */ 47 | 48 | for (i = 0; i < NUM_RX_DESC; i++) { 49 | if (tp->Rx_skbuff[i]) { 50 | @@ -4372,6 +4389,11 @@ static void rtl8169_tx_interrupt(struct net_device *dev, 51 | { 52 | unsigned int dirty_tx, tx_left; 53 | 54 | +#ifdef DEV_NETMAP 55 | + if (netmap_tx_irq(dev, 0)) 56 | + return; 57 | +#endif /* DEV_NETMAP */ 58 | + 59 | dirty_tx = tp->dirty_tx; 60 | smp_rmb(); 61 | tx_left = tp->cur_tx - dirty_tx; 62 | @@ -4468,6 +4490,11 @@ static int rtl8169_rx_interrupt(struct net_device *dev, 63 | unsigned int cur_rx, rx_left; 64 | unsigned int delta, count; 65 | 66 | +#ifdef DEV_NETMAP 67 | + if (netmap_rx_irq(dev, 0, &count)) 68 | + return count; 69 | +#endif /* DEV_NETMAP */ 70 | + 71 | cur_rx = tp->cur_rx; 72 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; 73 | rx_left = min(rx_left, budget); 74 | @@ -4688,6 +4715,7 @@ static void rtl8169_down(struct net_device *dev) 75 | napi_disable(&tp->napi); 76 | 77 | core_down: 78 | + 79 | spin_lock_irq(&tp->lock); 80 | 81 | rtl8169_asic_down(ioaddr); 82 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--r8169.c--20625--20626: -------------------------------------------------------------------------------- 1 | diff --git a/r8169.c b/r8169.c 2 | index 53b13de..ced4849 100644 3 | --- a/r8169.c 4 | +++ b/r8169.c 5 | @@ -535,6 +535,10 @@ static int rtl8169_poll(struct napi_struct *napi, int budget); 6 | static const unsigned int rtl8169_rx_config = 7 | (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | static void mdio_write(void __iomem *ioaddr, int reg_addr, int value) 14 | { 15 | int i; 16 | @@ -3229,6 +3233,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 17 | if (pci_dev_run_wake(pdev)) 18 | pm_runtime_put_noidle(&pdev->dev); 19 | 20 | +#ifdef DEV_NETMAP 21 | + re_netmap_attach(tp); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | out: 25 | return rc; 26 | 27 | @@ -3257,6 +3265,10 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) 28 | if (pci_dev_run_wake(pdev)) 29 | pm_runtime_get_noresume(&pdev->dev); 30 | 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(dev); 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | /* restore original MAC address */ 36 | rtl_rar_set(tp, dev->perm_addr); 37 | 38 | @@ -4018,6 +4030,11 @@ static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc) 39 | static int rtl8169_rx_fill(struct rtl8169_private *tp) 40 | { 41 | unsigned int i; 42 | +#ifdef DEV_NETMAP 43 | + re_netmap_tx_init(tp); 44 | + if (re_netmap_rx_init(tp)) 45 | + return 0; // success 46 | +#endif /* DEV_NETMAP */ 47 | 48 | for (i = 0; i < NUM_RX_DESC; i++) { 49 | void *data; 50 | @@ -4395,6 +4412,11 @@ static void rtl8169_tx_interrupt(struct net_device *dev, 51 | { 52 | unsigned int dirty_tx, tx_left; 53 | 54 | +#ifdef DEV_NETMAP 55 | + if (netmap_tx_irq(dev, 0)) 56 | + return; 57 | +#endif /* DEV_NETMAP */ 58 | + 59 | dirty_tx = tp->dirty_tx; 60 | smp_rmb(); 61 | tx_left = tp->cur_tx - dirty_tx; 62 | @@ -4490,6 +4512,11 @@ static int rtl8169_rx_interrupt(struct net_device *dev, 63 | unsigned int count; 64 | int polling = (budget != ~(u32)0) ? 1 : 0; 65 | 66 | +#ifdef DEV_NETMAP 67 | + if (netmap_rx_irq(dev, 0, &count)) 68 | + return count; 69 | +#endif /* DEV_NETMAP */ 70 | + 71 | cur_rx = tp->cur_rx; 72 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; 73 | rx_left = min(rx_left, budget); 74 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--r8169.c--20626--30400: -------------------------------------------------------------------------------- 1 | diff --git a/r8169.c b/r8169.c 2 | index 7ffdb80..fc92723 100644 3 | --- a/r8169.c 4 | +++ b/r8169.c 5 | @@ -590,6 +590,10 @@ static int rtl8169_poll(struct napi_struct *napi, int budget); 6 | static const unsigned int rtl8169_rx_config = 7 | (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg) 14 | { 15 | void __iomem *ioaddr = tp->mmio_addr; 16 | @@ -3207,6 +3211,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 17 | if (pci_dev_run_wake(pdev)) 18 | pm_runtime_put_noidle(&pdev->dev); 19 | 20 | +#ifdef DEV_NETMAP 21 | + re_netmap_attach(tp); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | netif_carrier_off(dev); 25 | 26 | out: 27 | @@ -3238,6 +3246,9 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) 28 | cancel_delayed_work_sync(&tp->task); 29 | 30 | rtl_release_firmware(tp); 31 | +#ifdef DEV_NETMAP 32 | + netmap_detach(dev); 33 | +#endif /* DEV_NETMAP */ 34 | 35 | unregister_netdev(dev); 36 | 37 | @@ -4074,6 +4085,11 @@ static inline void rtl8169_mark_as_last_descriptor(struct RxDesc *desc) 38 | static int rtl8169_rx_fill(struct rtl8169_private *tp) 39 | { 40 | unsigned int i; 41 | +#ifdef DEV_NETMAP 42 | + re_netmap_tx_init(tp); 43 | + if (re_netmap_rx_init(tp)) 44 | + return 0; // success 45 | +#endif /* DEV_NETMAP */ 46 | 47 | for (i = 0; i < NUM_RX_DESC; i++) { 48 | void *data; 49 | @@ -4452,6 +4468,11 @@ static void rtl8169_tx_interrupt(struct net_device *dev, 50 | { 51 | unsigned int dirty_tx, tx_left; 52 | 53 | +#ifdef DEV_NETMAP 54 | + if (netmap_tx_irq(dev, 0)) 55 | + return; 56 | +#endif /* DEV_NETMAP */ 57 | + 58 | dirty_tx = tp->dirty_tx; 59 | smp_rmb(); 60 | tx_left = tp->cur_tx - dirty_tx; 61 | @@ -4547,6 +4568,11 @@ static int rtl8169_rx_interrupt(struct net_device *dev, 62 | unsigned int count; 63 | int polling = (budget != ~(u32)0) ? 1 : 0; 64 | 65 | +#ifdef DEV_NETMAP 66 | + if (netmap_rx_irq(dev, 0, &count)) 67 | + return count; 68 | +#endif /* DEV_NETMAP */ 69 | + 70 | cur_rx = tp->cur_rx; 71 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; 72 | rx_left = min(rx_left, budget); 73 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--veth.c--20620--30900: -------------------------------------------------------------------------------- 1 | diff --git a/veth.c b/veth.c 2 | index 52af501..a416e43 100644 3 | --- a/veth.c 4 | +++ b/veth.c 5 | @@ -38,6 +38,10 @@ struct veth_priv { 6 | unsigned ip_summed; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /* 14 | * ethtool interface 15 | */ 16 | @@ -284,6 +288,9 @@ static int veth_dev_init(struct net_device *dev) 17 | 18 | priv = netdev_priv(dev); 19 | priv->stats = stats; 20 | +#ifdef DEV_NETMAP 21 | + veth_netmap_attach(dev); 22 | +#endif /* DEV_NETMAP */ 23 | return 0; 24 | } 25 | 26 | @@ -291,6 +298,9 @@ static void veth_dev_free(struct net_device *dev) 27 | { 28 | struct veth_priv *priv; 29 | 30 | +#ifdef DEV_NETMAP 31 | + netmap_detach(dev); 32 | +#endif /* DEV_NETMAP */ 33 | priv = netdev_priv(dev); 34 | free_percpu(priv->stats); 35 | free_netdev(dev); 36 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--veth.c--30900--30f00: -------------------------------------------------------------------------------- 1 | diff --git a/veth.c b/veth.c 2 | index 07a4af0..672375e 100644 3 | --- a/veth.c 4 | +++ b/veth.c 5 | @@ -36,6 +36,10 @@ struct veth_priv { 6 | atomic64_t dropped; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /* 14 | * ethtool interface 15 | */ 16 | @@ -234,11 +238,17 @@ static int veth_dev_init(struct net_device *dev) 17 | if (!dev->vstats) 18 | return -ENOMEM; 19 | 20 | +#ifdef DEV_NETMAP 21 | + veth_netmap_attach(dev); 22 | +#endif /* DEV_NETMAP */ 23 | return 0; 24 | } 25 | 26 | static void veth_dev_free(struct net_device *dev) 27 | { 28 | +#ifdef DEV_NETMAP 29 | + netmap_detach(dev); 30 | +#endif /* DEV_NETMAP */ 31 | free_percpu(dev->vstats); 32 | free_netdev(dev); 33 | } 34 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--veth.c--30f00--99999: -------------------------------------------------------------------------------- 1 | diff --git a/veth.c b/veth.c 2 | index b4a10bc..52b7c37 100644 3 | --- a/veth.c 4 | +++ b/veth.c 5 | @@ -37,6 +37,10 @@ struct veth_priv { 6 | atomic64_t dropped; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /* 14 | * ethtool interface 15 | */ 16 | @@ -239,11 +243,17 @@ static int veth_dev_init(struct net_device *dev) 17 | dev->vstats = netdev_alloc_pcpu_stats(struct pcpu_vstats); 18 | if (!dev->vstats) 19 | return -ENOMEM; 20 | +#ifdef DEV_NETMAP 21 | + veth_netmap_attach(dev); 22 | +#endif /* DEV_NETMAP */ 23 | return 0; 24 | } 25 | 26 | static void veth_dev_free(struct net_device *dev) 27 | { 28 | +#ifdef DEV_NETMAP 29 | + netmap_detach(dev); 30 | +#endif /* DEV_NETMAP */ 31 | free_percpu(dev->vstats); 32 | free_netdev(dev); 33 | } 34 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--20622--20625: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index b0577dd..0c873c4 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -64,6 +64,10 @@ struct virtnet_info 6 | struct page *pages; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -121,6 +125,10 @@ static void skb_xmit_done(struct virtqueue *svq) 17 | /* Suppress further interrupts. */ 18 | svq->vq_ops->disable_cb(svq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, 0)) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_queue(vi->dev); 26 | } 27 | @@ -470,7 +478,17 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi); 29 | void *buf; 30 | unsigned int len, received = 0; 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + int nm_irq = netmap_rx_irq(vi->dev, 0, &work_done); 34 | 35 | + if (nm_irq == NM_IRQ_COMPLETED) { 36 | + napi_complete(napi); 37 | + return 1; 38 | + } else if (nm_irq == NM_IRQ_RESCHED) { 39 | + return budget; 40 | + } 41 | +#endif 42 | again: 43 | while (received < budget && 44 | (buf = vi->rvq->vq_ops->get_buf(vi->rvq, &len)) != NULL) { 45 | @@ -638,6 +656,9 @@ static int virtnet_open(struct net_device *dev) 46 | { 47 | struct virtnet_info *vi = netdev_priv(dev); 48 | 49 | +#ifdef DEV_NETMAP 50 | + virtio_netmap_init_buffers(vi); 51 | +#endif 52 | napi_enable(&vi->napi); 53 | 54 | /* If all buffers were filled by other side before we napi_enabled, we 55 | @@ -985,6 +1006,10 @@ static int virtnet_probe(struct virtio_device *vdev) 56 | goto unregister; 57 | } 58 | 59 | +#ifdef DEV_NETMAP 60 | + virtio_netmap_attach(vi); 61 | +#endif 62 | + 63 | vi->status = VIRTIO_NET_S_LINK_UP; 64 | virtnet_update_status(vi); 65 | netif_carrier_on(dev); 66 | @@ -1027,7 +1052,14 @@ static void free_unused_bufs(struct virtnet_info *vi) 67 | static void __devexit virtnet_remove(struct virtio_device *vdev) 68 | { 69 | struct virtnet_info *vi = vdev->priv; 70 | +#ifdef DEV_NETMAP 71 | + /* Save the pointer, will go away after netmap_detach(). */ 72 | + struct netmap_adapter *token = NA(vi->dev); 73 | 74 | + netmap_detach(vi->dev); 75 | + virtio_netmap_clean_used_rings(vi, token); 76 | + virtio_netmap_reclaim_unused(vi); 77 | +#endif 78 | /* Stop all the virtqueues. */ 79 | vdev->config->reset(vdev); 80 | 81 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--20625--20626: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index b6d4028..60bb2b2 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -67,6 +67,10 @@ struct virtnet_info { 6 | struct scatterlist tx_sg[MAX_SKB_FRAGS + 2]; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -124,6 +128,10 @@ static void skb_xmit_done(struct virtqueue *svq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(svq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, 0)) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_queue(vi->dev); 26 | } 27 | @@ -467,7 +475,17 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi); 29 | void *buf; 30 | unsigned int len, received = 0; 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + int nm_irq = netmap_rx_irq(vi->dev, 0, &work_done); 34 | 35 | + if (nm_irq == NM_IRQ_COMPLETED) { 36 | + napi_complete(napi); 37 | + return 1; 38 | + } else if (nm_irq == NM_IRQ_RESCHED) { 39 | + return budget; 40 | + } 41 | +#endif 42 | again: 43 | while (received < budget && 44 | (buf = virtqueue_get_buf(vi->rvq, &len)) != NULL) { 45 | @@ -638,6 +656,9 @@ static int virtnet_open(struct net_device *dev) 46 | { 47 | struct virtnet_info *vi = netdev_priv(dev); 48 | 49 | +#ifdef DEV_NETMAP 50 | + virtio_netmap_init_buffers(vi); 51 | +#endif 52 | napi_enable(&vi->napi); 53 | 54 | /* If all buffers were filled by other side before we napi_enabled, we 55 | @@ -986,6 +1007,10 @@ static int virtnet_probe(struct virtio_device *vdev) 56 | goto unregister; 57 | } 58 | 59 | +#ifdef DEV_NETMAP 60 | + virtio_netmap_attach(vi); 61 | +#endif 62 | + 63 | /* Assume link up if device can't report link status, 64 | otherwise get link status from config. */ 65 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 66 | @@ -1034,7 +1059,14 @@ static void free_unused_bufs(struct virtnet_info *vi) 67 | static void __devexit virtnet_remove(struct virtio_device *vdev) 68 | { 69 | struct virtnet_info *vi = vdev->priv; 70 | +#ifdef DEV_NETMAP 71 | + /* Save the pointer, will go away after netmap_detach(). */ 72 | + struct netmap_adapter *token = NA(vi->dev); 73 | 74 | + netmap_detach(vi->dev); 75 | + virtio_netmap_clean_used_rings(vi, token); 76 | + virtio_netmap_reclaim_unused(vi); 77 | +#endif 78 | /* Stop all the virtqueues. */ 79 | vdev->config->reset(vdev); 80 | 81 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--20626--30300: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 82dba5a..06324f8 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -67,6 +67,10 @@ struct virtnet_info { 6 | struct scatterlist tx_sg[MAX_SKB_FRAGS + 2]; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -124,6 +128,10 @@ static void skb_xmit_done(struct virtqueue *svq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(svq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, 0)) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_queue(vi->dev); 26 | } 27 | @@ -481,7 +489,17 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi); 29 | void *buf; 30 | unsigned int len, received = 0; 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + int nm_irq = netmap_rx_irq(vi->dev, 0, &work_done); 34 | 35 | + if (nm_irq == NM_IRQ_COMPLETED) { 36 | + napi_complete(napi); 37 | + return 1; 38 | + } else if (nm_irq == NM_IRQ_RESCHED) { 39 | + return budget; 40 | + } 41 | +#endif 42 | again: 43 | while (received < budget && 44 | (buf = virtqueue_get_buf(vi->rvq, &len)) != NULL) { 45 | @@ -652,6 +670,9 @@ static int virtnet_open(struct net_device *dev) 46 | { 47 | struct virtnet_info *vi = netdev_priv(dev); 48 | 49 | +#ifdef DEV_NETMAP 50 | + virtio_netmap_init_buffers(vi); 51 | +#endif 52 | virtnet_napi_enable(vi); 53 | return 0; 54 | } 55 | @@ -991,6 +1012,10 @@ static int virtnet_probe(struct virtio_device *vdev) 56 | goto unregister; 57 | } 58 | 59 | +#ifdef DEV_NETMAP 60 | + virtio_netmap_attach(vi); 61 | +#endif 62 | + 63 | /* Assume link up if device can't report link status, 64 | otherwise get link status from config. */ 65 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 66 | @@ -1039,7 +1064,14 @@ static void free_unused_bufs(struct virtnet_info *vi) 67 | static void __devexit virtnet_remove(struct virtio_device *vdev) 68 | { 69 | struct virtnet_info *vi = vdev->priv; 70 | +#ifdef DEV_NETMAP 71 | + /* Save the pointer, will go away after netmap_detach(). */ 72 | + struct netmap_adapter *token = NA(vi->dev); 73 | 74 | + netmap_detach(vi->dev); 75 | + virtio_netmap_clean_used_rings(vi, token); 76 | + virtio_netmap_reclaim_unused(vi); 77 | +#endif 78 | /* Stop all the virtqueues. */ 79 | vdev->config->reset(vdev); 80 | 81 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30300--30500: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 4880aa8..64e3625 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -80,6 +80,10 @@ struct virtnet_info { 6 | struct scatterlist tx_sg[MAX_SKB_FRAGS + 2]; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -137,6 +141,10 @@ static void skb_xmit_done(struct virtqueue *svq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(svq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, 0)) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_queue(vi->dev); 26 | } 27 | @@ -517,7 +525,17 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi); 29 | void *buf; 30 | unsigned int len, received = 0; 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + int nm_irq = netmap_rx_irq(vi->dev, 0, &work_done); 34 | 35 | + if (nm_irq == NM_IRQ_COMPLETED) { 36 | + napi_complete(napi); 37 | + return 1; 38 | + } else if (nm_irq == NM_IRQ_RESCHED) { 39 | + return budget; 40 | + } 41 | +#endif 42 | again: 43 | while (received < budget && 44 | (buf = virtqueue_get_buf(vi->rvq, &len)) != NULL) { 45 | @@ -727,7 +745,14 @@ static void virtnet_netpoll(struct net_device *dev) 46 | static int virtnet_open(struct net_device *dev) 47 | { 48 | struct virtnet_info *vi = netdev_priv(dev); 49 | +#ifdef DEV_NETMAP 50 | + int ok = virtio_netmap_init_buffers(vi); 51 | 52 | + if (ok) { 53 | + virtnet_napi_enable(vi); 54 | + return 0; 55 | + } 56 | +#endif 57 | /* Make sure we have some buffers: if oom use wq. */ 58 | if (!try_fill_recv(vi, GFP_KERNEL)) 59 | queue_delayed_work(system_nrt_wq, &vi->refill, 0); 60 | @@ -1107,6 +1132,10 @@ static int virtnet_probe(struct virtio_device *vdev) 61 | goto unregister; 62 | } 63 | 64 | +#ifdef DEV_NETMAP 65 | + virtio_netmap_attach(vi); 66 | +#endif 67 | + 68 | /* Assume link up if device can't report link status, 69 | otherwise get link status from config. */ 70 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 71 | @@ -1169,7 +1198,14 @@ static void remove_vq_common(struct virtnet_info *vi) 72 | static void __devexit virtnet_remove(struct virtio_device *vdev) 73 | { 74 | struct virtnet_info *vi = vdev->priv; 75 | +#ifdef DEV_NETMAP 76 | + /* Save the pointer, will go away after netmap_detach(). */ 77 | + struct netmap_adapter *token = NA(vi->dev); 78 | 79 | + netmap_detach(vi->dev); 80 | + virtio_netmap_clean_used_rings(vi, token); 81 | + virtio_netmap_reclaim_unused(vi); 82 | +#endif 83 | unregister_netdev(vi->dev); 84 | 85 | remove_vq_common(vi); 86 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30500--30800: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index f18149a..cc935cf 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -90,6 +90,10 @@ struct virtnet_info { 6 | struct scatterlist tx_sg[MAX_SKB_FRAGS + 2]; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -147,6 +151,10 @@ static void skb_xmit_done(struct virtqueue *svq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(svq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, 0)) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_queue(vi->dev); 26 | } 27 | @@ -529,7 +537,17 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi); 29 | void *buf; 30 | unsigned int len, received = 0; 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + int nm_irq = netmap_rx_irq(vi->dev, 0, &work_done); 34 | 35 | + if (nm_irq == NM_IRQ_COMPLETED) { 36 | + napi_complete(napi); 37 | + return 1; 38 | + } else if (nm_irq == NM_IRQ_RESCHED) { 39 | + return budget; 40 | + } 41 | +#endif 42 | again: 43 | while (received < budget && 44 | (buf = virtqueue_get_buf(vi->rvq, &len)) != NULL) { 45 | @@ -742,6 +760,14 @@ static void virtnet_netpoll(struct net_device *dev) 46 | static int virtnet_open(struct net_device *dev) 47 | { 48 | struct virtnet_info *vi = netdev_priv(dev); 49 | +#ifdef DEV_NETMAP 50 | + int ok = virtio_netmap_init_buffers(vi); 51 | + 52 | + if (ok) { 53 | + virtnet_napi_enable(vi); 54 | + return 0; 55 | + } 56 | +#endif 57 | 58 | /* Make sure we have some buffers: if oom use wq. */ 59 | if (!try_fill_recv(vi, GFP_KERNEL)) 60 | @@ -1148,6 +1174,10 @@ static int virtnet_probe(struct virtio_device *vdev) 61 | goto unregister; 62 | } 63 | 64 | +#ifdef DEV_NETMAP 65 | + virtio_netmap_attach(vi); 66 | +#endif 67 | + 68 | /* Assume link up if device can't report link status, 69 | otherwise get link status from config. */ 70 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 71 | @@ -1210,7 +1240,14 @@ static void remove_vq_common(struct virtnet_info *vi) 72 | static void __devexit virtnet_remove(struct virtio_device *vdev) 73 | { 74 | struct virtnet_info *vi = vdev->priv; 75 | +#ifdef DEV_NETMAP 76 | + /* Save the pointer, will go away after netmap_detach(). */ 77 | + struct netmap_adapter *token = NA(vi->dev); 78 | 79 | + netmap_detach(vi->dev); 80 | + virtio_netmap_clean_used_rings(vi, token); 81 | + virtio_netmap_reclaim_unused(vi); 82 | +#endif 83 | /* Prevent config work handler from accessing the device. */ 84 | mutex_lock(&vi->config_lock); 85 | vi->config_enable = false; 86 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30800--30b00: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 35c00c5..bfbb178 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -132,6 +132,10 @@ struct virtnet_info { 6 | struct notifier_block nb; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -211,6 +215,10 @@ static void skb_xmit_done(struct virtqueue *vq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(vq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, vq2txq(vq))) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_subqueue(vi->dev, vq2txq(vq)); 26 | } 27 | @@ -603,7 +611,17 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | struct virtnet_info *vi = rq->vq->vdev->priv; 29 | void *buf; 30 | unsigned int len, received = 0; 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + int nm_irq = netmap_rx_irq(vi->dev, vq2rxq(rq->vq), &work_done); 34 | 35 | + if (nm_irq == NM_IRQ_COMPLETED) { 36 | + napi_complete(napi); 37 | + return 1; 38 | + } else if (nm_irq == NM_IRQ_RESCHED) { 39 | + return budget; 40 | + } 41 | +#endif 42 | again: 43 | while (received < budget && 44 | (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) { 45 | @@ -635,6 +653,15 @@ static int virtnet_open(struct net_device *dev) 46 | { 47 | struct virtnet_info *vi = netdev_priv(dev); 48 | int i; 49 | +#ifdef DEV_NETMAP 50 | + int ok = virtio_netmap_init_buffers(vi); 51 | + 52 | + if (ok) { 53 | + for (i = 0; i < vi->max_queue_pairs; i++) 54 | + virtnet_napi_enable(&vi->rq[i]); 55 | + return 0; 56 | + } 57 | +#endif 58 | 59 | for (i = 0; i < vi->max_queue_pairs; i++) { 60 | /* Make sure we have some buffers: if oom use wq. */ 61 | @@ -1572,6 +1599,10 @@ static int virtnet_probe(struct virtio_device *vdev) 62 | goto free_recv_bufs; 63 | } 64 | 65 | +#ifdef DEV_NETMAP 66 | + virtio_netmap_attach(vi); 67 | +#endif 68 | + 69 | /* Assume link up if device can't report link status, 70 | otherwise get link status from config. */ 71 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 72 | @@ -1617,7 +1648,14 @@ static void remove_vq_common(struct virtnet_info *vi) 73 | static void virtnet_remove(struct virtio_device *vdev) 74 | { 75 | struct virtnet_info *vi = vdev->priv; 76 | +#ifdef DEV_NETMAP 77 | + /* Save the pointer, will go away after netmap_detach(). */ 78 | + struct netmap_adapter *token = NA(vi->dev); 79 | 80 | + netmap_detach(vi->dev); 81 | + virtio_netmap_clean_used_rings(vi, token); 82 | + virtio_netmap_reclaim_unused(vi); 83 | +#endif 84 | unregister_hotcpu_notifier(&vi->nb); 85 | 86 | /* Prevent config work handler from accessing the device. */ 87 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30b00--31100: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 3d2a90a..2365434 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -131,6 +131,10 @@ struct virtnet_info { 6 | struct notifier_block nb; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -210,6 +214,10 @@ static void skb_xmit_done(struct virtqueue *vq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(vq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, vq2txq(vq))) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_subqueue(vi->dev, vq2txq(vq)); 26 | } 27 | @@ -603,7 +611,17 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | struct virtnet_info *vi = rq->vq->vdev->priv; 29 | void *buf; 30 | unsigned int r, len, received = 0; 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + int nm_irq = netmap_rx_irq(vi->dev, vq2rxq(rq->vq), &work_done); 34 | 35 | + if (nm_irq == NM_IRQ_COMPLETED) { 36 | + napi_complete(napi); 37 | + return 1; 38 | + } else if (nm_irq == NM_IRQ_RESCHED) { 39 | + return budget; 40 | + } 41 | +#endif 42 | again: 43 | while (received < budget && 44 | (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) { 45 | @@ -636,6 +654,15 @@ static int virtnet_open(struct net_device *dev) 46 | { 47 | struct virtnet_info *vi = netdev_priv(dev); 48 | int i; 49 | +#ifdef DEV_NETMAP 50 | + int ok = virtio_netmap_init_buffers(vi); 51 | + 52 | + if (ok) { 53 | + for (i = 0; i < vi->max_queue_pairs; i++) 54 | + virtnet_napi_enable(&vi->rq[i]); 55 | + return 0; 56 | + } 57 | +#endif 58 | 59 | for (i = 0; i < vi->max_queue_pairs; i++) { 60 | if (i < vi->curr_queue_pairs) 61 | @@ -1592,6 +1619,10 @@ static int virtnet_probe(struct virtio_device *vdev) 62 | goto free_recv_bufs; 63 | } 64 | 65 | +#ifdef DEV_NETMAP 66 | + virtio_netmap_attach(vi); 67 | +#endif 68 | + 69 | /* Assume link up if device can't report link status, 70 | otherwise get link status from config. */ 71 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 72 | @@ -1637,7 +1668,14 @@ static void remove_vq_common(struct virtnet_info *vi) 73 | static void virtnet_remove(struct virtio_device *vdev) 74 | { 75 | struct virtnet_info *vi = vdev->priv; 76 | +#ifdef DEV_NETMAP 77 | + /* Save the pointer, will go away after netmap_detach(). */ 78 | + struct netmap_adapter *token = NA(vi->dev); 79 | 80 | + netmap_detach(vi->dev); 81 | + virtio_netmap_clean_used_rings(vi, token); 82 | + virtio_netmap_reclaim_unused(vi); 83 | +#endif 84 | unregister_hotcpu_notifier(&vi->nb); 85 | 86 | /* Prevent config work handler from accessing the device. */ 87 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--31100--31300: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 59caa06..b64cb15 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -145,6 +145,10 @@ struct virtnet_info { 6 | struct notifier_block nb; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct skb_vnet_hdr { 14 | union { 15 | struct virtio_net_hdr hdr; 16 | @@ -224,6 +228,10 @@ static void skb_xmit_done(struct virtqueue *vq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(vq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, vq2txq(vq))) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_subqueue(vi->dev, vq2txq(vq)); 26 | } 27 | @@ -754,6 +762,19 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | container_of(napi, struct receive_queue, napi); 29 | unsigned int r, received = 0; 30 | 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + struct virtnet_info *vi = rq->vq->vdev->priv; 34 | + int nm_irq = netmap_rx_irq(vi->dev, vq2rxq(rq->vq), &work_done); 35 | + 36 | + if (nm_irq == NM_IRQ_COMPLETED) { 37 | + napi_complete(napi); 38 | + return 1; 39 | + } else if (nm_irq == NM_IRQ_RESCHED) { 40 | + return budget; 41 | + } 42 | +#endif 43 | + 44 | again: 45 | received += virtnet_receive(rq, budget - received); 46 | 47 | @@ -813,6 +834,15 @@ static int virtnet_open(struct net_device *dev) 48 | { 49 | struct virtnet_info *vi = netdev_priv(dev); 50 | int i; 51 | +#ifdef DEV_NETMAP 52 | + int ok = virtio_netmap_init_buffers(vi); 53 | + 54 | + if (ok) { 55 | + for (i = 0; i < vi->max_queue_pairs; i++) 56 | + virtnet_napi_enable(&vi->rq[i]); 57 | + return 0; 58 | + } 59 | +#endif 60 | 61 | for (i = 0; i < vi->max_queue_pairs; i++) { 62 | if (i < vi->curr_queue_pairs) 63 | @@ -1826,6 +1856,10 @@ static int virtnet_probe(struct virtio_device *vdev) 64 | goto free_recv_bufs; 65 | } 66 | 67 | +#ifdef DEV_NETMAP 68 | + virtio_netmap_attach(vi); 69 | +#endif 70 | + 71 | /* Assume link up if device can't report link status, 72 | otherwise get link status from config. */ 73 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 74 | @@ -1872,7 +1906,14 @@ static void remove_vq_common(struct virtnet_info *vi) 75 | static void virtnet_remove(struct virtio_device *vdev) 76 | { 77 | struct virtnet_info *vi = vdev->priv; 78 | +#ifdef DEV_NETMAP 79 | + /* Save the pointer, will go away after netmap_detach(). */ 80 | + struct netmap_adapter *token = NA(vi->dev); 81 | 82 | + netmap_detach(vi->dev); 83 | + virtio_netmap_clean_used_rings(vi, token); 84 | + virtio_netmap_reclaim_unused(vi); 85 | +#endif 86 | unregister_hotcpu_notifier(&vi->nb); 87 | 88 | /* Prevent config work handler from accessing the device. */ 89 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--31300--40100: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 059fdf1..d79cd6a 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -142,6 +142,10 @@ struct virtnet_info { 6 | struct notifier_block nb; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct padded_vnet_hdr { 14 | struct virtio_net_hdr_mrg_rxbuf hdr; 15 | /* 16 | @@ -214,6 +218,10 @@ static void skb_xmit_done(struct virtqueue *vq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(vq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, vq2txq(vq))) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_subqueue(vi->dev, vq2txq(vq)); 26 | } 27 | @@ -751,6 +759,19 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | container_of(napi, struct receive_queue, napi); 29 | unsigned int r, received = 0; 30 | 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + struct virtnet_info *vi = rq->vq->vdev->priv; 34 | + int nm_irq = netmap_rx_irq(vi->dev, vq2rxq(rq->vq), &work_done); 35 | + 36 | + if (nm_irq == NM_IRQ_COMPLETED) { 37 | + napi_complete(napi); 38 | + return 1; 39 | + } else if (nm_irq == NM_IRQ_RESCHED) { 40 | + return budget; 41 | + } 42 | +#endif 43 | + 44 | received += virtnet_receive(rq, budget - received); 45 | 46 | /* Out of packets? */ 47 | @@ -808,6 +829,15 @@ static int virtnet_open(struct net_device *dev) 48 | { 49 | struct virtnet_info *vi = netdev_priv(dev); 50 | int i; 51 | +#ifdef DEV_NETMAP 52 | + int ok = virtio_netmap_init_buffers(vi); 53 | + 54 | + if (ok) { 55 | + for (i = 0; i < vi->max_queue_pairs; i++) 56 | + virtnet_napi_enable(&vi->rq[i]); 57 | + return 0; 58 | + } 59 | +#endif 60 | 61 | for (i = 0; i < vi->max_queue_pairs; i++) { 62 | if (i < vi->curr_queue_pairs) 63 | @@ -1859,6 +1889,10 @@ static int virtnet_probe(struct virtio_device *vdev) 64 | goto free_recv_bufs; 65 | } 66 | 67 | +#ifdef DEV_NETMAP 68 | + virtio_netmap_attach(vi); 69 | +#endif 70 | + 71 | /* Assume link up if device can't report link status, 72 | otherwise get link status from config. */ 73 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 74 | @@ -1907,7 +1941,14 @@ static void remove_vq_common(struct virtnet_info *vi) 75 | static void virtnet_remove(struct virtio_device *vdev) 76 | { 77 | struct virtnet_info *vi = vdev->priv; 78 | +#ifdef DEV_NETMAP 79 | + /* Save the pointer, will go away after netmap_detach(). */ 80 | + struct netmap_adapter *token = NA(vi->dev); 81 | 82 | + netmap_detach(vi->dev); 83 | + virtio_netmap_clean_used_rings(vi, token); 84 | + virtio_netmap_reclaim_unused(vi); 85 | +#endif 86 | unregister_hotcpu_notifier(&vi->nb); 87 | 88 | /* Make sure no work handler is accessing the device. */ 89 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--40100--99999: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 63c7810..f5fc43c 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -142,6 +142,10 @@ struct virtnet_info { 6 | struct notifier_block nb; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | struct padded_vnet_hdr { 14 | struct virtio_net_hdr_mrg_rxbuf hdr; 15 | /* 16 | @@ -214,6 +218,10 @@ static void skb_xmit_done(struct virtqueue *vq) 17 | /* Suppress further interrupts. */ 18 | virtqueue_disable_cb(vq); 19 | 20 | +#ifdef DEV_NETMAP 21 | + if (netmap_tx_irq(vi->dev, vq2txq(vq))) 22 | + return; 23 | +#endif 24 | /* We were probably waiting for more output buffers. */ 25 | netif_wake_subqueue(vi->dev, vq2txq(vq)); 26 | } 27 | @@ -751,6 +759,19 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 28 | container_of(napi, struct receive_queue, napi); 29 | unsigned int r, received; 30 | 31 | +#ifdef DEV_NETMAP 32 | + int work_done = 0; 33 | + struct virtnet_info *vi = rq->vq->vdev->priv; 34 | + int nm_irq = netmap_rx_irq(vi->dev, vq2rxq(rq->vq), &work_done); 35 | + 36 | + if (nm_irq == NM_IRQ_COMPLETED) { 37 | + napi_complete(napi); 38 | + return 1; 39 | + } else if (nm_irq == NM_IRQ_RESCHED) { 40 | + return budget; 41 | + } 42 | +#endif 43 | + 44 | received = virtnet_receive(rq, budget); 45 | 46 | /* Out of packets? */ 47 | @@ -808,6 +829,15 @@ static int virtnet_open(struct net_device *dev) 48 | { 49 | struct virtnet_info *vi = netdev_priv(dev); 50 | int i; 51 | +#ifdef DEV_NETMAP 52 | + int ok = virtio_netmap_init_buffers(vi); 53 | + 54 | + if (ok) { 55 | + for (i = 0; i < vi->max_queue_pairs; i++) 56 | + virtnet_napi_enable(&vi->rq[i]); 57 | + return 0; 58 | + } 59 | +#endif 60 | 61 | for (i = 0; i < vi->max_queue_pairs; i++) { 62 | if (i < vi->curr_queue_pairs) 63 | @@ -1881,6 +1911,10 @@ static int virtnet_probe(struct virtio_device *vdev) 64 | goto free_recv_bufs; 65 | } 66 | 67 | +#ifdef DEV_NETMAP 68 | + virtio_netmap_attach(vi); 69 | +#endif 70 | + 71 | /* Assume link up if device can't report link status, 72 | otherwise get link status from config. */ 73 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 74 | @@ -1929,7 +1963,14 @@ static void remove_vq_common(struct virtnet_info *vi) 75 | static void virtnet_remove(struct virtio_device *vdev) 76 | { 77 | struct virtnet_info *vi = vdev->priv; 78 | +#ifdef DEV_NETMAP 79 | + /* Save the pointer, will go away after netmap_detach(). */ 80 | + struct netmap_adapter *token = NA(vi->dev); 81 | 82 | + netmap_detach(vi->dev); 83 | + virtio_netmap_clean_used_rings(vi, token); 84 | + virtio_netmap_reclaim_unused(vi); 85 | +#endif 86 | unregister_hotcpu_notifier(&vi->nb); 87 | 88 | /* Make sure no work handler is accessing the device. */ 89 | -------------------------------------------------------------------------------- /LINUX/netmap_set_adapter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #set -x # for debugging 4 | 5 | if [ -z "$NMSRC" ]; then 6 | NMSRC=~/netmap-release 7 | fi 8 | DRIVER="ixgbe" 9 | #IF="eth0" # force an interface 10 | 11 | if [ ! -f ${NMSRC}/LINUX/netmap_lin.ko ]; then 12 | echo "LINUX/netmap_lin.ko missing. Please compile netmap." 13 | exit 1 14 | fi 15 | 16 | if [ ! -f ${NMSRC}/LINUX/${DRIVER}/${DRIVER}.ko ]; then 17 | echo "LINUX/${DRIVER}/${DRIVER}.ko missing." 18 | echo "Please compile netmap or make sure to have netmap support for ${DRIVER}" 19 | exit 1 20 | fi 21 | 22 | NMLOADED=$(lsmod | grep netmap_lin | wc -l) 23 | DRVLOADED=$(lsmod | grep "${DRIVER}" | wc -l) 24 | 25 | # Unload the driver 26 | if [ $DRVLOADED != "0" ]; then 27 | sudo rmmod "$DRIVER" 28 | fi 29 | 30 | # Load netmap 31 | if [ $NMLOADED == "0" ]; then 32 | sudo insmod ${NMSRC}/LINUX/netmap_lin.ko 33 | fi 34 | 35 | if [ "$1" == "g" ]; then 36 | # In order to use generic netmap adapter, load the original driver module, that doesn't 37 | # have netmap support 38 | sudo modprobe ${DRIVER} 39 | echo "Generic netmap adapter." 40 | else 41 | # Use the driver modified with netmap support 42 | sudo insmod ${NMSRC}/LINUX/${DRIVER}/${DRIVER}.ko 43 | echo "Native netmap adapter." 44 | fi 45 | 46 | # Wait a bit for interface name changing 47 | sleep 2 48 | 49 | # Find all interfaces 50 | IFLIST=$(ip link | grep -o "^[0-9]\+: [^:]\+" | awk '{print $2}') 51 | IFLIST=$(echo ${IFLIST}) 52 | 53 | # Find the interface that match the driver $DRIVER 54 | for i in $IFLIST; do 55 | drv=$(sudo ethtool -i $i 2> /dev/null | grep "driver" | awk '{print $2}') 56 | if [ "$drv" == "$DRIVER" ]; then 57 | IF=$i 58 | echo " Found interface \"${IF}\"" 59 | fi 60 | done 61 | 62 | if [ "$IF" == "" ]; then 63 | echo "No interface using ${DRIVER} driver was found." 64 | exit 1 65 | fi 66 | 67 | sudo ip link set ${IF} up 68 | 69 | -------------------------------------------------------------------------------- /LINUX/read-vars.mak: -------------------------------------------------------------------------------- 1 | -include config.mak 2 | -include drivers.mak 3 | 4 | %@vars: FORCE 5 | @$(foreach v,$(filter $*@%,$(.VARIABLES)),echo drv_$(patsubst $*@%,%,$(v))=\"'$($(v))'\";)true 6 | 7 | FORCE: 8 | -------------------------------------------------------------------------------- /LINUX/scripts/help: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sed -n 's/^## \?//p' $1 | fmt 4 | -------------------------------------------------------------------------------- /LINUX/scripts/linux-pktgen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #set -x 4 | 5 | 6 | function pgset() 7 | { 8 | local result 9 | 10 | echo $1 > ${PGDEV} 11 | 12 | result=$(cat $PGDEV | fgrep "Result: OK:") 13 | if [ "$result" = "" ]; then 14 | cat $PGDEV | fgrep "Result:" 15 | fi 16 | } 17 | 18 | 19 | ##################### Script configuration ###################### 20 | N="$1" # number of TX kthreads minus one 21 | if [ -z "$1" ]; then 22 | N=0 23 | fi 24 | NCPUS="1" # number of CPUs on your machine minus one 25 | IF="ens4" # network interface to test 26 | DST_IP="10.216.8.1" # destination IP address 27 | SRC_MAC="00:00:00:00:00:00" # source MAC address 28 | DST_MAC="ff:ff:ff:ff:ff:ff" # destination MAC address 29 | PKT_SIZE="60" # packet size 30 | PKT_COUNT="0" # number of packets to send (0 means an infinite number) 31 | CLONE_SKB="0" # how many times a sk_buff is recycled (0 means always use the same skbuff) 32 | BURST_LEN="1" # burst-size (xmit_more skb flag) 33 | XMIT_MODE="start_xmit" # Transmit mode. start_xmit to put on wire, netif_receive to put into kernel stack 34 | 35 | 36 | # Load pktgen kernel module 37 | modprobe pktgen || exit 1 38 | 39 | 40 | # Clean the configuration for all the CPU-kthread (from 0 to ${NCPUS}) 41 | IDX=$(seq 0 1 ${NCPUS}) 42 | for cpu in ${IDX}; do 43 | PGDEV="/proc/net/pktgen/kpktgend_${cpu}" 44 | echo "Removing all devices (${cpu})" 45 | pgset "rem_device_all" 46 | done 47 | 48 | IDX=$(seq 0 1 ${N}) 49 | for cpu in ${IDX}; do 50 | # kthread-device configuration 51 | PGDEV="/proc/net/pktgen/kpktgend_${cpu}" 52 | echo "Configuring $PGDEV" 53 | echo "Adding ${IF}@${cpu}" 54 | pgset "add_device ${IF}@${cpu}" 55 | 56 | # Packets/mode configuration 57 | PGDEV="/proc/net/pktgen/${IF}@${cpu}" 58 | echo "Configuring $PGDEV" 59 | pgset "count ${PKT_COUNT}" 60 | pgset "clone_skb ${CLONE_SKB}" 61 | pgset "pkt_size ${PKT_SIZE}" 62 | pgset "burst ${BURST_LEN}" 63 | pgset "delay 0" 64 | pgset "src_mac $SRC_MAC" 65 | pgset "dst $DST_IP" 66 | pgset "dst_mac $DST_MAC" 67 | pgset "xmit_mode $XMIT_MODE" 68 | pgset "flag QUEUE_MAP_CPU" 69 | 70 | echo "" 71 | done 72 | 73 | 74 | # Run 75 | PGDEV="/proc/net/pktgen/pgctrl" 76 | echo "Running... Ctrl-C to stop" 77 | pgset "start" 78 | echo "Done." 79 | 80 | # Show results 81 | NUMS="" 82 | for cpu in ${IDX}; do 83 | TMP=$(cat /proc/net/pktgen/${IF}@${cpu} | grep -o "[0-9]\+pps" | grep -o "[0-9]\+") 84 | echo "$cpu $TMP" 85 | NUMS="${NUMS} ${TMP}" 86 | done 87 | 88 | echo "Total TX rate: $(echo $NUMS | tr ' ' '+' | bc)" 89 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # targets to build tarballs and diffs 3 | 4 | # build a distribution 5 | 6 | RELEASE_SRCS := ./sys/net ./sys/dev ./sys/modules ./examples 7 | RELEASE_SRCS += ./README* ./LINUX ./OSX 8 | RELEASE_EXCL := --exclude .svn --exclude examples/testmod 9 | RELEASE_EXCL += --exclude connlib\* 10 | RELEASE_EXCL += --exclude if_epair.diff 11 | #RELEASE_EXCL += --exclude \*-patches 12 | RELEASE_EXCL += --exclude \*bnx2x\* --exclude \*mellanox\* --exclude \*mlx4\* 13 | RELEASE_EXCL += --exclude OSX 14 | 15 | all: 16 | @echo "What do you want to do ?" 17 | 18 | 19 | diff-head: 20 | (cd ~/FreeBSD/head ; \ 21 | svn diff sys/conf sys/dev sbin/ifconfig ) > head-netmap.diff 22 | 23 | # XXX remember to patch sbin/ifconfig if not done yet 24 | diff-r8: 25 | (cd ~/FreeBSD/RELENG_8 ; \ 26 | svn diff sys/conf sys/dev sbin/ifconfig ) > r8-netmap.diff 27 | 28 | release: 29 | D=`date +%Y%m%d` && tar cvzf /tmp/$${D}-netmap.tgz \ 30 | -s'/^./netmap-release/' $(RELEASE_EXCL) $(RELEASE_SRCS) 31 | -------------------------------------------------------------------------------- /WINDOWS/Loader/loader.vcxproj.Filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* 6 | {5812DE36-9085-4806-BCEF-5D207860E7EB} 7 | 8 | 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | {17A6CE1C-7F02-4450-B574-B56BF6D65FDD} 11 | 12 | 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml 14 | {6D669535-8431-4815-AF9A-D0E3744A9963} 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /WINDOWS/includes/net/if_dl.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 4. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)if_dl.h 8.1 (Berkeley) 6/10/93 30 | * $FreeBSD: src/sys/net/if_dl.h,v 1.14 2005/01/07 01:45:34 imp Exp $ 31 | */ 32 | 33 | #ifndef _NET_IF_DL_H_ 34 | #define _NET_IF_DL_H_ 35 | 36 | /* 37 | * A Link-Level Sockaddr may specify the interface in one of two 38 | * ways: either by means of a system-provided index number (computed 39 | * anew and possibly differently on every reboot), or by a human-readable 40 | * string such as "il0" (for managerial convenience). 41 | * 42 | * Census taking actions, such as something akin to SIOCGCONF would return 43 | * both the index and the human name. 44 | * 45 | * High volume transactions (such as giving a link-level ``from'' address 46 | * in a recvfrom or recvmsg call) may be likely only to provide the indexed 47 | * form, (which requires fewer copy operations and less space). 48 | * 49 | * The form and interpretation of the link-level address is purely a matter 50 | * of convention between the device driver and its consumers; however, it is 51 | * expected that all drivers for an interface of a given if_type will agree. 52 | */ 53 | 54 | /* 55 | * Structure of a Link-Level sockaddr: 56 | */ 57 | struct sockaddr_dl { 58 | u_char sdl_len; /* Total length of sockaddr */ 59 | u_char sdl_family; /* AF_LINK */ 60 | u_short sdl_index; /* if != 0, system given index for interface */ 61 | u_char sdl_type; /* interface type */ 62 | u_char sdl_nlen; /* interface name length, no trailing 0 reqd. */ 63 | u_char sdl_alen; /* link level address length */ 64 | u_char sdl_slen; /* link layer selector length */ 65 | char sdl_data[46]; /* minimum work area, can be larger; 66 | contains both if name and ll address */ 67 | }; 68 | 69 | #define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen)) 70 | 71 | #ifndef _KERNEL 72 | 73 | #include 74 | 75 | __BEGIN_DECLS 76 | void link_addr(const char *, struct sockaddr_dl *); 77 | char *link_ntoa(const struct sockaddr_dl *); 78 | __END_DECLS 79 | 80 | #endif /* !_KERNEL */ 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /WINDOWS/my-project.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | v4.5 8 | 11.0 9 | 10 | Win8.1 Debug 11 | Win32 12 | $(MSBuildProjectName) 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | DbgengKernelDebugger 29 | $(SolutionDir)\..\sys;$(SolutionDir)\..;$(IncludePath) 30 | $(ProjectName) 31 | $(SolutionDir)\Output-$(ConfigurationName)\tmp\$(ProjectName)-unsigned\ 32 | $(SolutionDir)\Output-$(ConfigurationName)\tmp\$(ProjectName)-tmp\ 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /WINDOWS/netmap-pkg.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Utility 6 | Package 7 | true 8 | WindowsKernelModeDriver8.1 9 | 10 | 11 | 12 | 13 | {72648F4C-6AAA-4E69-99C9-66D9D6400EE9} 14 | {4605da2c-74a5-4865-98e1-152ef136825f} 15 | netmap-pkg 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | DbgengKernelDebugger 32 | False 33 | True 34 | 35 | 36 | 37 | False 38 | False 39 | True 40 | 41 | 133563 42 | $(SolutionDir)\Output-$(ConfigurationName)\ 43 | $(SolutionDir)\Output-$(ConfigurationName)\tmp\netmap-pkg\ 44 | 45 | 46 | 47 | 48 | 4 49 | true 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {789055e4-2677-413d-a638-3e2aed7c7427} 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /WINDOWS/netmap-pkg.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {8E41214B-6785-4CFE-B992-037D68949A14} 6 | inf;inv;inx;mof;mc; 7 | 8 | 9 | -------------------------------------------------------------------------------- /WINDOWS/netmap-pkg.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | False 5 | True 6 | DriverTest 7 | 8 | 9 | C:\Program Files (x86)\Windows Kits\8.1\Testing\Tests\Utilities\DefaultDriverPackageInstallationTask.dll 10 | 10.216.1.205 11 | 10.216.1.205 12 | 13 | Microsoft.DriverKit.DefaultDriverPackageInstallationClass.PerformDefaultDriverPackageInstallation 14 | 15 | True 16 | 17 | 18 | 19 | 20 | 21 | 22 | TestSign 23 | 24 | -------------------------------------------------------------------------------- /WINDOWS/netmap.inf: -------------------------------------------------------------------------------- 1 | ; 2 | ; Netmap.inf 3 | ; 4 | 5 | [Version] 6 | Signature="$WINDOWS NT$" 7 | Class=System 8 | ClassGuid={9BF68A6C-4C18-4FB4-A2FD-0E54B36F9252} 9 | Provider=%ManufacturerName% 10 | DriverVer=05/18/2015,0.0.1.1 11 | CatalogFile=Netmap.cat 12 | 13 | 14 | 15 | [SourceDisksNames] 16 | 1 = %DiskName%,,,"" 17 | 18 | [SourceDisksFiles] 19 | netmap.sys = 1 20 | 21 | [DestinationDirs] 22 | DefaultDestDir = 12 23 | 24 | ;[Manufacturer] 25 | ;%ManufacturerName%=Standard,NT$ARCH$ 26 | 27 | [Standard.NT$ARCH$] 28 | 29 | ;-------------- Installation 30 | 31 | [DefaultInstall] 32 | Copyfiles =@netmap.sys 33 | 34 | ;-------------- Service installation 35 | 36 | [DefaultInstall.Services] 37 | AddService = netmap,%SPSVCINST_ASSOCSERVICE%, Netmap_Service_Inst 38 | 39 | [Install.Remove.Services] 40 | ; TODO: Customize the name of your NT service here. 41 | ; The SPSVCINST_STOPSERVICE flag instructs SCM to stop the NT service 42 | ; before uninstalling the driver. 43 | DelService=netmap,0x200 ; SPSVCINST_STOPSERVICE 44 | 45 | ; -------------- Netmap driver install sections 46 | [Netmap_Service_Inst] 47 | DisplayName = %ClassName% 48 | ServiceType = 1 ; SERVICE_KERNEL_DRIVER 49 | StartType = 2 ; SERVICE_AUTO_START 50 | ErrorControl = 1 ; SERVICE_ERROR_NORMAL 51 | ServiceBinary = %12%\netmap.sys 52 | ;LoadOrderGroup = Extended Base 53 | 54 | [Strings] 55 | SPSVCINST_ASSOCSERVICE= 0x00000002 56 | ManufacturerName="Universita` di Pisa" 57 | ClassName="Universita` di Pisa netmap core" 58 | DiskName="Netmap Source Disk" 59 | -------------------------------------------------------------------------------- /WINDOWS/netmap.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {8E41214B-6785-4CFE-B992-037D68949A14} 18 | inf;inv;inx;mof;mc; 19 | 20 | 21 | {ec171439-91ad-4daf-9b3e-b1c954a0cbd5} 22 | 23 | 24 | {aafe88f5-1215-436d-9233-1a3b89a7c59a} 25 | 26 | 27 | 28 | 29 | Driver Files 30 | 31 | 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files\Windows Specific 56 | 57 | 58 | Source Files\Windows Specific 59 | 60 | 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files\Windows Specific 76 | 77 | 78 | 79 | 80 | Resource Files 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /WINDOWS/netmap.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | TestSign 9 | 10 | 11 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/filteruser.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) Microsoft. All rights reserved. 3 | // 4 | #ifndef __FILTERUSER_H__ 5 | #define __FILTERUSER_H__ 6 | 7 | // 8 | // Temp file to test filter 9 | // 10 | 11 | #define _NDIS_CONTROL_CODE(request,method) \ 12 | CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, request, method, FILE_ANY_ACCESS) 13 | 14 | #define IOCTL_FILTER_RESTART_ALL _NDIS_CONTROL_CODE(0, METHOD_BUFFERED) 15 | #define IOCTL_FILTER_RESTART_ONE_INSTANCE _NDIS_CONTROL_CODE(1, METHOD_BUFFERED) 16 | #define IOCTL_FILTER_ENUERATE_ALL_INSTANCES _NDIS_CONTROL_CODE(2, METHOD_BUFFERED) 17 | #define IOCTL_FILTER_QUERY_ALL_STAT _NDIS_CONTROL_CODE(3, METHOD_BUFFERED) 18 | #define IOCTL_FILTER_CLEAR_ALL_STAT _NDIS_CONTROL_CODE(4, METHOD_BUFFERED) 19 | #define IOCTL_FILTER_SET_OID_VALUE _NDIS_CONTROL_CODE(5, METHOD_BUFFERED) 20 | #define IOCTL_FILTER_QUERY_OID_VALUE _NDIS_CONTROL_CODE(6, METHOD_BUFFERED) 21 | #define IOCTL_FILTER_CANCEL_REQUEST _NDIS_CONTROL_CODE(7, METHOD_BUFFERED) 22 | #define IOCTL_FILTER_READ_DRIVER_CONFIG _NDIS_CONTROL_CODE(8, METHOD_BUFFERED) 23 | #define IOCTL_FILTER_WRITE_DRIVER_CONFIG _NDIS_CONTROL_CODE(9, METHOD_BUFFERED) 24 | #define IOCTL_FILTER_READ_ADAPTER_CONFIG _NDIS_CONTROL_CODE(10, METHOD_BUFFERED) 25 | #define IOCTL_FILTER_WRITE_ADAPTER_CONFIG _NDIS_CONTROL_CODE(11, METHOD_BUFFERED) 26 | #define IOCTL_FILTER_READ_INSTANCE_CONFIG _NDIS_CONTROL_CODE(12, METHOD_BUFFERED) 27 | #define IOCTL_FILTER_WRITE_INSTANCE_CONFIG _NDIS_CONTROL_CODE(13, METHOD_BUFFERED) 28 | 29 | 30 | #define MAX_FILTER_INSTANCE_NAME_LENGTH 256 31 | #define MAX_FILTER_CONFIG_KEYWORD_LENGTH 256 32 | typedef struct _FILTER_DRIVER_ALL_STAT 33 | { 34 | ULONG AttachCount; 35 | ULONG DetachCount; 36 | ULONG ExternalRequestFailedCount; 37 | ULONG ExternalRequestSuccessCount; 38 | ULONG InternalRequestFailedCount; 39 | } FILTER_DRIVER_ALL_STAT, * PFILTER_DRIVER_ALL_STAT; 40 | 41 | 42 | typedef struct _FILTER_SET_OID 43 | { 44 | WCHAR InstanceName[MAX_FILTER_INSTANCE_NAME_LENGTH]; 45 | ULONG InstanceNameLength; 46 | NDIS_OID Oid; 47 | NDIS_STATUS Status; 48 | UCHAR Data[sizeof(ULONG)]; 49 | 50 | }FILTER_SET_OID, *PFILTER_SET_OID; 51 | 52 | typedef struct _FILTER_QUERY_OID 53 | { 54 | WCHAR InstanceName[MAX_FILTER_INSTANCE_NAME_LENGTH]; 55 | ULONG InstanceNameLength; 56 | NDIS_OID Oid; 57 | NDIS_STATUS Status; 58 | UCHAR Data[sizeof(ULONG)]; 59 | 60 | }FILTER_QUERY_OID, *PFILTER_QUERY_OID; 61 | 62 | typedef struct _FILTER_READ_CONFIG 63 | { 64 | _Field_size_bytes_part_(MAX_FILTER_INSTANCE_NAME_LENGTH,InstanceNameLength) 65 | WCHAR InstanceName[MAX_FILTER_INSTANCE_NAME_LENGTH]; 66 | ULONG InstanceNameLength; 67 | _Field_size_bytes_part_(MAX_FILTER_CONFIG_KEYWORD_LENGTH,KeywordLength) 68 | WCHAR Keyword[MAX_FILTER_CONFIG_KEYWORD_LENGTH]; 69 | ULONG KeywordLength; 70 | NDIS_PARAMETER_TYPE ParameterType; 71 | NDIS_STATUS Status; 72 | UCHAR Data[sizeof(ULONG)]; 73 | }FILTER_READ_CONFIG, *PFILTER_READ_CONFIG; 74 | 75 | typedef struct _FILTER_WRITE_CONFIG 76 | { 77 | _Field_size_bytes_part_(MAX_FILTER_INSTANCE_NAME_LENGTH,InstanceNameLength) 78 | WCHAR InstanceName[MAX_FILTER_INSTANCE_NAME_LENGTH]; 79 | ULONG InstanceNameLength; 80 | _Field_size_bytes_part_(MAX_FILTER_CONFIG_KEYWORD_LENGTH,KeywordLength) 81 | WCHAR Keyword[MAX_FILTER_CONFIG_KEYWORD_LENGTH]; 82 | ULONG KeywordLength; 83 | NDIS_PARAMETER_TYPE ParameterType; 84 | NDIS_STATUS Status; 85 | UCHAR Data[sizeof(ULONG)]; 86 | }FILTER_WRITE_CONFIG, *PFILTER_WRITE_CONFIG; 87 | 88 | #endif //__FILTERUSER_H__ 89 | 90 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/nm-ndis-pkg.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | WindowsKernelModeDriver8.1 6 | Utility 7 | Package 8 | true 9 | 10 | 11 | 12 | 13 | 14 | WindowsKernelModeDriver8.1 15 | Utility 16 | Package 17 | true 18 | Win8.1 Debug 19 | 20 | 21 | 22 | {F54EA0D4-064F-4AD9-AA21-8F9F3B90AC8E} 23 | {EA453FB1-F3EF-493B-B384-DD83BAB817D3} 24 | $(MSBuildProjectName) 25 | nm-ndis-pkg 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | $(SolutionDir)\Output-$(ConfigurationName)\ 39 | $(SolutionDir)\Output-$(ConfigurationName)\tmp\$(ProjectName)\ 40 | 41 | 42 | 43 | DbgengKernelDebugger 44 | False 45 | False 46 | None 47 | 48 | 49 | 50 | 51 | 52 | %PathToInf% 53 | False 54 | False 55 | True 56 | 57 | 133563 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | {86BB0F88-ECD9-4E2C-AD47-AE4071D1DE10} 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/nm-ndis-pkg.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* 6 | {446F6A95-37A1-4B03-8A92-410687C4D886} 7 | 8 | 9 | h;hpp;hxx;hm;inl;inc;xsd 10 | {EA0E0C58-3231-40D0-8E7C-2C45BAC612B4} 11 | 12 | 13 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml 14 | {9ACC37D4-AA63-4917-A0A9-CE371E1BBD46} 15 | 16 | 17 | inf;inv;inx;mof;mc; 18 | {02639A71-564D-46D6-89B9-7E42931F9188} 19 | 20 | 21 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/nm-ndis-pkg.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | TestSign 5 | 6 | 7 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/nm-ndis.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | TestSign 5 | 6 | 7 | TestSign 8 | 9 | 10 | TestSign 11 | 12 | 13 | TestSign 14 | 15 | 16 | TestSign 17 | 18 | 19 | TestSign 20 | 21 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/precomp.h: -------------------------------------------------------------------------------- 1 | #pragma warning(disable:4201) //nonstandard extension used : nameless struct/union 2 | #include 3 | #include 4 | #include "flt_dbg.h" 5 | #include "filter.h" 6 | 7 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/precompsrc.c: -------------------------------------------------------------------------------- 1 | #include "precomp.h" -------------------------------------------------------------------------------- /apps/README: -------------------------------------------------------------------------------- 1 | This directory contains various netmap applications 2 | -------------------------------------------------------------------------------- /apps/bridge/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = bridge 4 | LIBNETMAP = 5 | 6 | CLEANFILES = $(PROGS) *.o 7 | 8 | SRCDIR ?= ../.. 9 | VPATH = $(SRCDIR)/apps/bridge 10 | 11 | NO_MAN= 12 | CFLAGS = -O2 -pipe 13 | CFLAGS += -Werror -Wall -Wunused-function 14 | CFLAGS += -I $(SRCDIR)/sys -I $(SRCDIR)/apps/include 15 | CFLAGS += -Wextra 16 | 17 | LDLIBS += -lpthread 18 | ifeq ($(shell uname),Linux) 19 | LDLIBS += -lrt # on linux 20 | endif 21 | 22 | PREFIX ?= /usr/local 23 | 24 | all: $(PROGS) 25 | 26 | clean: 27 | -@rm -rf $(CLEANFILES) 28 | 29 | .PHONY: install 30 | install: $(PROGS:%=install-%) 31 | 32 | install-%: 33 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 34 | -------------------------------------------------------------------------------- /apps/include/ctrs.h: -------------------------------------------------------------------------------- 1 | #ifndef CTRS_H_ 2 | #define CTRS_H_ 3 | 4 | #include 5 | 6 | /* counters to accumulate statistics */ 7 | struct my_ctrs { 8 | uint64_t pkts, bytes, events, drop; 9 | uint64_t min_space; 10 | struct timeval t; 11 | }; 12 | 13 | /* very crude code to print a number in normalized form. 14 | * Caller has to make sure that the buffer is large enough. 15 | */ 16 | static const char * 17 | norm2(char *buf, double val, char *fmt) 18 | { 19 | char *units[] = { "", "K", "M", "G", "T" }; 20 | u_int i; 21 | 22 | for (i = 0; val >=1000 && i < sizeof(units)/sizeof(char *) - 1; i++) 23 | val /= 1000; 24 | sprintf(buf, fmt, val, units[i]); 25 | return buf; 26 | } 27 | 28 | static __inline const char * 29 | norm(char *buf, double val) 30 | { 31 | return norm2(buf, val, "%.3f %s"); 32 | } 33 | 34 | static __inline int 35 | timespec_ge(const struct timespec *a, const struct timespec *b) 36 | { 37 | 38 | if (a->tv_sec > b->tv_sec) 39 | return (1); 40 | if (a->tv_sec < b->tv_sec) 41 | return (0); 42 | if (a->tv_nsec >= b->tv_nsec) 43 | return (1); 44 | return (0); 45 | } 46 | 47 | static __inline struct timespec 48 | timeval2spec(const struct timeval *a) 49 | { 50 | struct timespec ts = { 51 | .tv_sec = a->tv_sec, 52 | .tv_nsec = a->tv_usec * 1000 53 | }; 54 | return ts; 55 | } 56 | 57 | static __inline struct timeval 58 | timespec2val(const struct timespec *a) 59 | { 60 | struct timeval tv = { 61 | .tv_sec = a->tv_sec, 62 | .tv_usec = a->tv_nsec / 1000 63 | }; 64 | return tv; 65 | } 66 | 67 | 68 | static __inline struct timespec 69 | timespec_add(struct timespec a, struct timespec b) 70 | { 71 | struct timespec ret = { a.tv_sec + b.tv_sec, a.tv_nsec + b.tv_nsec }; 72 | if (ret.tv_nsec >= 1000000000) { 73 | ret.tv_sec++; 74 | ret.tv_nsec -= 1000000000; 75 | } 76 | return ret; 77 | } 78 | 79 | static __inline struct timespec 80 | timespec_sub(struct timespec a, struct timespec b) 81 | { 82 | struct timespec ret = { a.tv_sec - b.tv_sec, a.tv_nsec - b.tv_nsec }; 83 | if (ret.tv_nsec < 0) { 84 | ret.tv_sec--; 85 | ret.tv_nsec += 1000000000; 86 | } 87 | return ret; 88 | } 89 | 90 | static uint64_t 91 | wait_for_next_report(struct timeval *prev, struct timeval *cur, 92 | int report_interval) 93 | { 94 | struct timeval delta; 95 | 96 | delta.tv_sec = report_interval/1000; 97 | delta.tv_usec = (report_interval%1000)*1000; 98 | if (select(0, NULL, NULL, NULL, &delta) < 0 && errno != EINTR) { 99 | perror("select"); 100 | abort(); 101 | } 102 | gettimeofday(cur, NULL); 103 | timersub(cur, prev, &delta); 104 | return delta.tv_sec* 1000000 + delta.tv_usec; 105 | } 106 | #endif /* CTRS_H_ */ 107 | -------------------------------------------------------------------------------- /apps/lb/.gitignore: -------------------------------------------------------------------------------- 1 | lb 2 | -------------------------------------------------------------------------------- /apps/lb/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = lb 4 | LIBNETMAP = 5 | 6 | CLEANFILES = $(PROGS) *.o 7 | 8 | SRCDIR ?= ../.. 9 | VPATH = $(SRCDIR)/apps/lb 10 | 11 | NO_MAN= 12 | CFLAGS = -O2 -pipe 13 | CFLAGS += -Werror -Wall -Wunused-function 14 | CFLAGS += -I $(SRCDIR)/sys -I $(SRCDIR)/apps/include 15 | CFLAGS += -Wextra 16 | 17 | LDLIBS += -lpthread -lm 18 | ifeq ($(shell uname),Linux) 19 | LDLIBS += -lrt # on linux 20 | endif 21 | 22 | PREFIX ?= /usr/local 23 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 24 | 25 | all: $(PROGS) 26 | 27 | lb: lb.o pkt_hash.o 28 | 29 | clean: 30 | -@rm -rf $(CLEANFILES) 31 | 32 | .PHONY: install 33 | install: $(PROGS:%=install-%) 34 | 35 | install-%: 36 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 37 | -install -D -m 644 $(SRCDIR)/apps/lb/lb.8 $(DESTDIR)/$(MAN_PREFIX)/man8/lb.8 38 | -------------------------------------------------------------------------------- /apps/lb/pkt_hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 2015, Asim Jamshed, Robin Sommer, Seth Hall 3 | ** and the International Computer Science Institute. All rights reserved. 4 | ** 5 | ** Redistribution and use in source and binary forms, with or without 6 | ** modification, are permitted provided that the following conditions are met: 7 | ** 8 | ** (1) Redistributions of source code must retain the above copyright 9 | ** notice, this list of conditions and the following disclaimer. 10 | ** 11 | ** (2) Redistributions in binary form must reproduce the above copyright 12 | ** notice, this list of conditions and the following disclaimer in the 13 | ** documentation and/or other materials provided with the distribution. 14 | ** 15 | ** 16 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | ** POSSIBILITY OF SUCH DAMAGE. 27 | **/ 28 | #ifndef LB_PKT_HASH_H 29 | #define LB_PKT_HASH_H 30 | /*---------------------------------------------------------------------*/ 31 | /** 32 | ** Packet header hashing function utility - This file contains functions 33 | ** that parse the packet headers and computes hash functions based on 34 | ** the header fields. Please see pkt_hash.c for more details... 35 | **/ 36 | /*---------------------------------------------------------------------*/ 37 | /* for type def'n */ 38 | #include 39 | /*---------------------------------------------------------------------*/ 40 | #ifdef __GNUC__ 41 | #define likely(x) __builtin_expect(!!(x), 1) 42 | #define unlikely(x) __builtin_expect(!!(x), 0) 43 | #else 44 | #define likely(x) (x) 45 | #define unlikely(x) (x) 46 | #endif 47 | 48 | #define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | \ 49 | (((unsigned short)(n) & 0xFF00) >> 8)) 50 | #define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | \ 51 | (((unsigned short)(n) & 0xFF00) >> 8)) 52 | 53 | #define HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ 54 | ((((unsigned long)(n) & 0xFF00)) << 8) | \ 55 | ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ 56 | ((((unsigned long)(n) & 0xFF000000)) >> 24)) 57 | 58 | #define NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \ 59 | ((((unsigned long)(n) & 0xFF00)) << 8) | \ 60 | ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ 61 | ((((unsigned long)(n) & 0xFF000000)) >> 24)) 62 | /*---------------------------------------------------------------------*/ 63 | typedef struct vlanhdr { 64 | uint16_t pri_cfi_vlan; 65 | uint16_t proto; 66 | } vlanhdr; 67 | /*---------------------------------------------------------------------*/ 68 | /** 69 | ** Analyzes the packet header of computes a corresponding 70 | ** hash function. 71 | **/ 72 | uint32_t 73 | pkt_hdr_hash(const unsigned char *buffer, 74 | uint8_t hash_split, 75 | uint8_t seed); 76 | /*---------------------------------------------------------------------*/ 77 | #endif /* LB_PKT_HASH_H */ 78 | 79 | -------------------------------------------------------------------------------- /apps/nmreplay/.gitignore: -------------------------------------------------------------------------------- 1 | nmreplay 2 | -------------------------------------------------------------------------------- /apps/nmreplay/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = nmreplay 4 | LIBNETMAP = 5 | 6 | CLEANFILES = $(PROGS) *.o 7 | 8 | SRCDIR ?= ../.. 9 | VPATH = $(SRCDIR)/apps/nmreplay 10 | 11 | NO_MAN= 12 | CFLAGS = -O2 # -pipe -g 13 | CFLAGS += -Werror -Wall -Wunused-function 14 | CFLAGS += -I $(SRCDIR)/sys -I $(SRCDIR)/apps/include 15 | CFLAGS += -Wextra 16 | 17 | LDLIBS += -lpthread 18 | ifeq ($(shell uname),Linux) 19 | LDLIBS += -lrt # on linux 20 | endif 21 | 22 | PREFIX ?= /usr/local 23 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 24 | 25 | all: $(PROGS) 26 | 27 | testlock: testlock.c 28 | 29 | nmreplay: LDLIBS += -lm 30 | 31 | clean: 32 | -@rm -rf $(CLEANFILES) 33 | 34 | .PHONY: install install-docs 35 | install: $(PROGS:%=install-%) 36 | 37 | install-%: 38 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 39 | -install -D -m 644 $(SRCDIR)/apps/nmreplay/nmreplay.8 $(DESTDIR)/$(MAN_PREFIX)/man8/nmreplay.8 40 | -------------------------------------------------------------------------------- /apps/nmreplay/README: -------------------------------------------------------------------------------- 1 | A program to replay a pcap file through netmap 2 | -------------------------------------------------------------------------------- /apps/pkt-gen/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = pkt-gen pkt-gen-b 4 | LIBNETMAP = 5 | 6 | CLEANFILES = $(PROGS) *.o 7 | 8 | SRCDIR ?= ../.. 9 | VPATH = $(SRCDIR)/apps/pkt-gen 10 | 11 | NO_MAN= 12 | CFLAGS = -O2 -pipe 13 | CFLAGS += -Werror -Wall -Wunused-function 14 | CFLAGS += -I $(SRCDIR)/sys -I $(SRCDIR)/apps/include 15 | CFLAGS += -Wextra 16 | 17 | LDLIBS += -lpthread -lm 18 | ifeq ($(shell uname),Linux) 19 | LDLIBS += -lrt # on linux 20 | endif 21 | 22 | ifdef WITH_PCAP 23 | LDLIBS += -lpcap 24 | else 25 | CFLAGS += -DNO_PCAP 26 | endif 27 | 28 | PREFIX ?= /usr/local 29 | 30 | all: $(PROGS) 31 | 32 | clean: 33 | -@rm -rf $(CLEANFILES) 34 | 35 | .PHONY: install 36 | install: $(PROGS:%=install-%) 37 | 38 | install-%: 39 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 40 | 41 | pkt-gen-b: pkt-gen-b.o 42 | 43 | pkt-gen-b.o: pkt-gen.c 44 | $(CC) $(CFLAGS) -DBUSYWAIT -c $^ -o $@ 45 | -------------------------------------------------------------------------------- /apps/tlem/.gitignore: -------------------------------------------------------------------------------- 1 | tlem 2 | -------------------------------------------------------------------------------- /apps/tlem/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = tlem 4 | LIBNETMAP = 5 | 6 | CLEANFILES = $(PROGS) *.o 7 | 8 | SRCDIR ?= ../.. 9 | VPATH = $(SRCDIR)/apps/tlem 10 | 11 | NO_MAN= 12 | CFLAGS = -O2 -pipe 13 | CFLAGS += -Werror -Wall -Wunused-function 14 | CFLAGS += -I $(SRCDIR)/sys -I $(SRCDIR)/apps/include 15 | CFLAGS += -Wextra 16 | 17 | LDLIBS += -lpthread 18 | ifeq ($(shell uname),Linux) 19 | LDLIBS += -lrt # on linux 20 | endif 21 | 22 | PREFIX ?= /usr/local 23 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 24 | 25 | all: $(PROGS) 26 | 27 | testlock: testlock.c 28 | 29 | tlem: LDLIBS += -lm 30 | 31 | clean: 32 | -@rm -rf $(CLEANFILES) 33 | 34 | .PHONY: install 35 | install: $(PROGS:%=install-%) 36 | 37 | install-%: 38 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 39 | -install -D -m 644 $(SRCDIR)/apps/tlem/tlem.8 $(DESTDIR)/$(MAN_PREFIX)/man8/tlem.8 40 | -------------------------------------------------------------------------------- /apps/tlem/README: -------------------------------------------------------------------------------- 1 | This directory contains TLEM, a high performance link emulator. 2 | 3 | To test the program you must run a source, sink and emulator 4 | 5 | sudo ../../examples/pkt-gen -i vale0\{1 -f tx -l 1500 6 | sudo ../../examples/pkt-gen -i vale0\}2 7 | 8 | sudo ./tlem -i vale0\}1 -i vale0\{2 -D 20ms -C 2,3,4,5 9 | -------------------------------------------------------------------------------- /apps/vale-ctl/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = vale-ctl 4 | LIBNETMAP = 5 | 6 | CLEANFILES = $(PROGS) *.o 7 | 8 | SRCDIR ?= ../.. 9 | VPATH = $(SRCDIR)/apps/vale-ctl 10 | 11 | NO_MAN= 12 | CFLAGS = -O2 -pipe 13 | CFLAGS += -Werror -Wall -Wunused-function 14 | CFLAGS += -I $(SRCDIR)/sys -I $(SRCDIR)/apps/include 15 | CFLAGS += -Wextra 16 | 17 | LDLIBS += -lpthread -lm 18 | ifeq ($(shell uname),Linux) 19 | LDLIBS += -lrt # on linux 20 | endif 21 | 22 | ifdef WITH_PCAP 23 | LDLIBS += -lpcap 24 | else 25 | CFLAGS += -DNO_PCAP 26 | endif 27 | 28 | PREFIX ?= /usr/local 29 | 30 | all: $(PROGS) 31 | 32 | clean: 33 | -@rm -rf $(CLEANFILES) 34 | 35 | .PHONY: install 36 | install: $(PROGS:%=install-%) 37 | 38 | install-%: 39 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 40 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | os=$(uname -s) 4 | topdir=$(cd $(dirname $0); pwd) 5 | 6 | case $os in 7 | Linux) 8 | $topdir/LINUX/configure "$@";; 9 | FreeBSD) 10 | $topdir/FreeBSD/configure "$@";; 11 | *) 12 | echo "Sorry, $os is not supported" 13 | exit 1;; 14 | esac 15 | -------------------------------------------------------------------------------- /extra/python/Makefile: -------------------------------------------------------------------------------- 1 | PYTHON=python2 2 | 3 | 4 | build: always 5 | $(PYTHON) setup.py build 6 | 7 | install: build 8 | $(PYTHON) setup.py install 9 | 10 | clean: 11 | rm -rf build 12 | 13 | always: 14 | -------------------------------------------------------------------------------- /extra/python/onepacket.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Written by Vincenzo Maffione 4 | 5 | import netmap 6 | import time 7 | 8 | # open a netmap interface and register 9 | desc = netmap.NetmapDesc('netmap:enp2s0f1') 10 | 11 | while 1: 12 | print('Waiting for a packet to come') 13 | 14 | # sync RX rings with kernel 15 | desc.rxsync() 16 | 17 | # scan all the receive rings 18 | rxr = None 19 | for r in desc.receive_rings: 20 | if r.head != r.tail: 21 | # At least one packet has been received on 22 | # this ring 23 | rxr = r 24 | break 25 | 26 | if rxr == None: 27 | # no packets received on the rings, let's sleep a bit 28 | time.sleep(1) 29 | continue 30 | 31 | # slot pointed by rxr.head has been received 32 | # and can be extracted 33 | slot = rxr.slots[rxr.head] 34 | print('Received a packet with len %d' % (slot.len)) 35 | 36 | # convert the buffer associated to the slot to 37 | # a string of hexadecimal digits, up to the received length 38 | pktstr = '' 39 | for b in slot.buf[:slot.len].tolist(): 40 | pktstr += '%02x' % (b) 41 | 42 | # print the received packet 43 | print(pktstr) 44 | 45 | # update head and cur, managing index wraparound 46 | rxr.head = rxr.head + 1 47 | if rxr.head >= rxr.num_slots: 48 | rxr.head -= rxr.num_slots 49 | rxr.cur = rxr.head 50 | -------------------------------------------------------------------------------- /extra/python/setup.py: -------------------------------------------------------------------------------- 1 | import glob 2 | from distutils.core import setup, Extension 3 | 4 | 5 | netmap_bindings_module = Extension('netmap', 6 | include_dirs = ['../../sys'], 7 | sources = glob.glob('*.c'), 8 | extra_compile_args = []) 9 | 10 | setup(name = 'NetmapBindings', 11 | version = '11.0', 12 | description = 'python bindings for netmap', 13 | author = 'Vincenzo Maffione', 14 | author_email = 'v.maffione@gmail.com', 15 | url = 'http://info.iet.unipi.it/~luigi/netmap/', 16 | ext_modules = [netmap_bindings_module]) 17 | -------------------------------------------------------------------------------- /extra/python/test.py: -------------------------------------------------------------------------------- 1 | import netmap 2 | 3 | 4 | # see 'help(netmap)' for documentation 5 | n = netmap.Netmap() 6 | print n 7 | n.open() 8 | n.if_name = 'enp1s0f1' 9 | n.ringid = netmap.HwRing | 3 10 | n.arg3 = 2 11 | n.register() 12 | print n 13 | print n.interface 14 | n.close() 15 | -------------------------------------------------------------------------------- /extra/python/tx.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (C) 2013-2015, Vincenzo Maffione 3 | 4 | import netmap 5 | import time 6 | import struct 7 | import select 8 | import argparse # program argument parsing 9 | 10 | 11 | def build_packet(): 12 | fmt = '!6s6sH' + '46s' 13 | return struct.pack(fmt, '\xff'*6, '\x00'*6, 0x0800, '\x00'*50) 14 | 15 | 16 | ############################## MAIN ########################### 17 | 18 | parser = argparse.ArgumentParser(description = 'Minimal, high-performance packet '\ 19 | 'generator written in Python using '\ 20 | 'the netmap API', 21 | epilog = 'Press Ctrl-C to stop') 22 | parser.add_argument('-i', '--interface', help = 'the interface to register with netmap; ' 23 | 'can be in the form or , where ' 24 | 'OSNAME is the O.S. name for a network interface (e.g. "eth0"), ' 25 | ' is a valid VALE port name (e.g. "vale18:2")', 26 | default = 'vale0:0') 27 | 28 | args = parser.parse_args() 29 | 30 | pkt = build_packet() 31 | 32 | print("Opening interface %s" % (args.interface)) 33 | 34 | # open the netmap device and register an interface 35 | nm = netmap.Netmap() 36 | nm.open() 37 | nfd = nm.getfd() 38 | nm.if_name = args.interface 39 | nm.register() 40 | time.sleep(1) 41 | 42 | # fill in the netmap slots and netmap buffers for tx ring 0 43 | txr = nm.transmit_rings[0] 44 | num_slots = txr.num_slots 45 | for i in range(num_slots): 46 | txr.slots[i].buf[0:len(pkt)] = pkt 47 | txr.slots[i].len = len(pkt) 48 | 49 | print("Starting transmission, press Ctrl-C to stop") 50 | 51 | # transmit at maximum speed until Ctr-C is pressed 52 | cnt = 0 # packet counter 53 | batch = 256 54 | poller = select.poll() 55 | poller.register(nfd, select.POLLOUT) 56 | t_start = time.time() 57 | try: 58 | cur = txr.cur 59 | while 1: 60 | ready_list = poller.poll(2) 61 | if len(ready_list) == 0: 62 | print("Timeout occurred") 63 | break; 64 | n = txr.tail - cur # avail 65 | if n < 0: 66 | n += num_slots 67 | if n > batch: 68 | n = batch 69 | cur += n 70 | if cur >= num_slots: 71 | cur -= num_slots 72 | txr.cur = txr.head = cur # lazy update txr.cur and txr.head 73 | nm.txsync() 74 | cnt += n 75 | except KeyboardInterrupt: 76 | pass 77 | t_end = time.time() 78 | 79 | rate = 0.001 * cnt / (t_end - t_start) 80 | unit = 'K' 81 | if rate > 1000: 82 | rate /= 1000.0 83 | unit = 'M' 84 | 85 | print("\nPackets sent: %s, Avg rate %6.3f %spps" % (cnt, rate, unit)) 86 | 87 | nm.close() 88 | -------------------------------------------------------------------------------- /private/.gitattributes: -------------------------------------------------------------------------------- 1 | * merge=ignore -diff 2 | -------------------------------------------------------------------------------- /sys/dev/netmap/netmap_mbq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2014 Vincenzo Maffione 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | /* 28 | * $FreeBSD$ 29 | */ 30 | 31 | 32 | #ifndef _NET_NETMAP_MBQ_H__ 33 | #define _NET_NETMAP_MBQ_H__ 34 | 35 | /* 36 | * These function implement an mbuf tailq with an optional lock. 37 | * The base functions act ONLY ON THE QUEUE, whereas the "safe" 38 | * variants (mbq_safe_*) also handle the lock. 39 | */ 40 | 41 | /* XXX probably rely on a previous definition of SPINLOCK_T */ 42 | #ifdef linux 43 | #define SPINLOCK_T safe_spinlock_t 44 | #elif defined (_WIN32) 45 | #define SPINLOCK_T win_spinlock_t 46 | #else 47 | #define SPINLOCK_T struct mtx 48 | #endif 49 | 50 | /* A FIFO queue of mbufs with an optional lock. */ 51 | struct mbq { 52 | struct mbuf *head; 53 | struct mbuf *tail; 54 | int count; 55 | SPINLOCK_T lock; 56 | }; 57 | 58 | /* We should clarify whether init can be used while 59 | * holding a lock, and whether mbq_safe_destroy() is a NOP. 60 | */ 61 | void mbq_init(struct mbq *q); 62 | void mbq_fini(struct mbq *q); 63 | void mbq_enqueue(struct mbq *q, struct mbuf *m); 64 | struct mbuf *mbq_dequeue(struct mbq *q); 65 | void mbq_purge(struct mbq *q); 66 | 67 | static inline struct mbuf * 68 | mbq_peek(struct mbq *q) 69 | { 70 | return q->head ? q->head : NULL; 71 | } 72 | 73 | static inline void 74 | mbq_lock(struct mbq *q) 75 | { 76 | mtx_lock_spin(&q->lock); 77 | } 78 | 79 | static inline void 80 | mbq_unlock(struct mbq *q) 81 | { 82 | mtx_unlock_spin(&q->lock); 83 | } 84 | 85 | 86 | void mbq_safe_init(struct mbq *q); 87 | void mbq_safe_fini(struct mbq *q); 88 | void mbq_safe_enqueue(struct mbq *q, struct mbuf *m); 89 | struct mbuf *mbq_safe_dequeue(struct mbq *q); 90 | void mbq_safe_purge(struct mbq *q); 91 | 92 | static inline unsigned int mbq_len(struct mbq *q) 93 | { 94 | return q->count; 95 | } 96 | 97 | #endif /* _NET_NETMAP_MBQ_H_ */ 98 | -------------------------------------------------------------------------------- /sys/modules/netmap/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !Makefile 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /sys/modules/netmap/Makefile: -------------------------------------------------------------------------------- 1 | # $FreeBSD$ 2 | # 3 | # Compile netmap as a module, useful if you want a netmap bridge 4 | # or loadable drivers. 5 | 6 | .include # FreeBSD 10 and earlier 7 | # .include "${SYSDIR}/conf/kern.opts.mk" 8 | 9 | .PATH: ${.CURDIR}/../../dev/netmap 10 | .PATH.h: ${.CURDIR}/../../net 11 | CFLAGS += -I${.CURDIR}/../../ -D INET 12 | KMOD = netmap 13 | SRCS = device_if.h bus_if.h pci_if.h opt_netmap.h 14 | SRCS += netmap.c netmap.h netmap_kern.h 15 | SRCS += netmap_mem2.c netmap_mem2.h 16 | SRCS += netmap_generic.c 17 | SRCS += netmap_mbq.c netmap_mbq.h 18 | SRCS += netmap_vale.c 19 | SRCS += netmap_freebsd.c 20 | SRCS += netmap_offloadings.c 21 | SRCS += netmap_pipe.c 22 | SRCS += netmap_monitor.c 23 | SRCS += netmap_pt.c 24 | SRCS += if_ptnet.c 25 | SRCS += opt_inet.h opt_inet6.h 26 | 27 | .include 28 | -------------------------------------------------------------------------------- /utils/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = test_select testmmap test_nm producer 4 | X86PROGS = testlock testcsum 5 | LIBNETMAP = 6 | 7 | CLEANFILES = $(PROGS) $(X86PROGS) *.o 8 | 9 | SRCDIR ?= .. 10 | VPATH = $(SRCDIR)/utils 11 | 12 | NO_MAN= 13 | CFLAGS = -O2 -pipe 14 | CFLAGS += -Werror -Wall -Wunused-function 15 | CFLAGS += -I $(SRCDIR)/sys # -I/home/luigi/FreeBSD/head/sys -I../sys 16 | CFLAGS += -Wextra 17 | ifdef WITH_PCAP 18 | # do not use pcap by default, as it is not always available on linux 19 | LDLIBS += -lpcap 20 | else 21 | CFLAGS += -DNO_PCAP 22 | endif 23 | 24 | LDLIBS += -lpthread 25 | ifeq ($(shell uname),Linux) 26 | LDLIBS += -lrt -lm # on linux 27 | endif 28 | #SRCS = pkt-gen.c 29 | 30 | PREFIX ?= /usr/local 31 | 32 | all: $(PROGS) 33 | 34 | all-x86: $(PROGS) $(X86PROGS) 35 | 36 | kern_test: testmod/kern_test.c 37 | 38 | test_nm: test_nm.o 39 | 40 | clean: 41 | -@rm -rf $(CLEANFILES) 42 | 43 | testlock: testlock.c 44 | 45 | .PHONY: install 46 | install: $(PROGS:%=install-%) 47 | 48 | install-%: 49 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 50 | -------------------------------------------------------------------------------- /utils/Makefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | #PROGS += pingd 4 | PROGS += testlock test_select testmmap 5 | MORE_PROGS = kern_test 6 | 7 | CLEANFILES = $(PROGS) *.o 8 | NO_MAN= 9 | CFLAGS = -O2 -pipe 10 | CFLAGS += -Werror -Wall -Wunused-function 11 | CFLAGS += -I ../sys # -I/home/luigi/FreeBSD/head/sys -I../sys 12 | CFLAGS += -Wextra 13 | .ifdef WITH_PCAP 14 | LDFLAGS += -lpcap 15 | .else 16 | CFLAGS += -DNO_PCAP 17 | .endif 18 | 19 | LDFLAGS += -lpthread 20 | LDFLAGS += -lrt -lm # needed on linux, does not harm on BSD 21 | #SRCS = pkt-gen.c 22 | 23 | all: $(PROGS) 24 | 25 | kern_test: testmod/kern_test.c 26 | 27 | clean: 28 | -@rm -rf $(CLEANFILES) 29 | 30 | testlock: testlock.c 31 | $(CC) $(CFLAGS) -o testlock testlock.c -lpthread $(LDFLAGS) 32 | -------------------------------------------------------------------------------- /utils/README: -------------------------------------------------------------------------------- 1 | $FreeBSD: head/tools/tools/netmap/README 227614 2011-11-17 12:17:39Z luigi $ 2 | 3 | This directory contains examples that use netmap 4 | 5 | click* various click examples 6 | -------------------------------------------------------------------------------- /utils/click-test.cfg: -------------------------------------------------------------------------------- 1 | // 2 | // $FreeBSD: head/tools/tools/netmap/click-test.cfg 227614 2011-11-17 12:17:39Z luigi $ 3 | // 4 | // A sample test configuration for click 5 | // 6 | // 7 | // create a switch 8 | 9 | myswitch :: EtherSwitch; 10 | 11 | // two input devices 12 | 13 | c0 :: FromDevice(ix0, PROMISC true); 14 | c1 :: FromDevice(ix1, PROMISC true); 15 | 16 | // and now pass packets around 17 | 18 | c0[0] -> [0]sw[0] -> Queue(10000) -> ToDevice(ix0); 19 | c1[0] -> [1]sw[1] -> Queue(10000) -> ToDevice(ix1); 20 | -------------------------------------------------------------------------------- /utils/ctrs.h: -------------------------------------------------------------------------------- 1 | #ifndef CTRS_H_ 2 | #define CTRS_H_ 3 | 4 | #include 5 | 6 | /* counters to accumulate statistics */ 7 | struct my_ctrs { 8 | uint64_t pkts, bytes, events, drop; 9 | uint64_t min_space; 10 | struct timeval t; 11 | }; 12 | 13 | /* very crude code to print a number in normalized form. 14 | * Caller has to make sure that the buffer is large enough. 15 | */ 16 | static const char * 17 | norm2(char *buf, double val, char *fmt) 18 | { 19 | char *units[] = { "", "K", "M", "G", "T" }; 20 | u_int i; 21 | 22 | for (i = 0; val >=1000 && i < sizeof(units)/sizeof(char *) - 1; i++) 23 | val /= 1000; 24 | sprintf(buf, fmt, val, units[i]); 25 | return buf; 26 | } 27 | 28 | static __inline const char * 29 | norm(char *buf, double val) 30 | { 31 | return norm2(buf, val, "%.3f %s"); 32 | } 33 | 34 | static __inline int 35 | timespec_ge(const struct timespec *a, const struct timespec *b) 36 | { 37 | 38 | if (a->tv_sec > b->tv_sec) 39 | return (1); 40 | if (a->tv_sec < b->tv_sec) 41 | return (0); 42 | if (a->tv_nsec >= b->tv_nsec) 43 | return (1); 44 | return (0); 45 | } 46 | 47 | static __inline struct timespec 48 | timeval2spec(const struct timeval *a) 49 | { 50 | struct timespec ts = { 51 | .tv_sec = a->tv_sec, 52 | .tv_nsec = a->tv_usec * 1000 53 | }; 54 | return ts; 55 | } 56 | 57 | static __inline struct timeval 58 | timespec2val(const struct timespec *a) 59 | { 60 | struct timeval tv = { 61 | .tv_sec = a->tv_sec, 62 | .tv_usec = a->tv_nsec / 1000 63 | }; 64 | return tv; 65 | } 66 | 67 | 68 | static __inline struct timespec 69 | timespec_add(struct timespec a, struct timespec b) 70 | { 71 | struct timespec ret = { a.tv_sec + b.tv_sec, a.tv_nsec + b.tv_nsec }; 72 | if (ret.tv_nsec >= 1000000000) { 73 | ret.tv_sec++; 74 | ret.tv_nsec -= 1000000000; 75 | } 76 | return ret; 77 | } 78 | 79 | static __inline struct timespec 80 | timespec_sub(struct timespec a, struct timespec b) 81 | { 82 | struct timespec ret = { a.tv_sec - b.tv_sec, a.tv_nsec - b.tv_nsec }; 83 | if (ret.tv_nsec < 0) { 84 | ret.tv_sec--; 85 | ret.tv_nsec += 1000000000; 86 | } 87 | return ret; 88 | } 89 | 90 | static uint64_t 91 | wait_for_next_report(struct timeval *prev, struct timeval *cur, 92 | int report_interval) 93 | { 94 | struct timeval delta; 95 | 96 | delta.tv_sec = report_interval/1000; 97 | delta.tv_usec = (report_interval%1000)*1000; 98 | if (select(0, NULL, NULL, NULL, &delta) < 0 && errno != EINTR) { 99 | perror("select"); 100 | abort(); 101 | } 102 | gettimeofday(cur, NULL); 103 | timersub(cur, prev, &delta); 104 | return delta.tv_sec* 1000000 + delta.tv_usec; 105 | } 106 | #endif /* CTRS_H_ */ 107 | -------------------------------------------------------------------------------- /utils/test_nm.c: -------------------------------------------------------------------------------- 1 | /* simple test program for netmap library */ 2 | #include 3 | #include 4 | #define NETMAP_WITH_LIBS 5 | #include 6 | #include 7 | 8 | static void 9 | usage(const char *progname) 10 | { 11 | fprintf(stderr, "usage: %s IFNAME [w|r]\n", progname); 12 | exit(EXIT_FAILURE); 13 | } 14 | 15 | static void 16 | my_cb(u_char *arg, const struct nm_pkthdr *h, const u_char *buf) 17 | { 18 | int *count = (int *)arg; 19 | (*count)++; 20 | if (h->flags == 0) 21 | fprintf(stderr, "received %d bytes at %p count %d slot %p buf_index %d\n", 22 | h->len, buf, *count, h->slot, h->slot->buf_idx); 23 | } 24 | 25 | int 26 | main(int argc, char *argv[]) 27 | { 28 | struct nm_desc *d; 29 | struct pollfd pfd; 30 | char buf[2048]; 31 | int count = 0; 32 | 33 | if (argc < 2) { 34 | usage(argv[0]); 35 | } 36 | 37 | bzero(&pfd, sizeof(pfd)); 38 | 39 | d = nm_open(argv[1], NULL, 0, 0); 40 | if (d == NULL) { 41 | fprintf(stderr, "no netmap\n"); 42 | exit(0); 43 | } 44 | pfd.fd = d->fd; 45 | pfd.events = argv[2] && argv[2][0] == 'w' ? POLLOUT : POLLIN; 46 | fprintf(stderr, "working on %s in %s mode\n", argv[1], pfd.events == POLLIN ? "read" : "write"); 47 | 48 | for (;;) { 49 | if (pfd.events == POLLIN) { 50 | nm_dispatch(d, -1, my_cb, (void *)&count); 51 | } else { 52 | if (nm_inject(d, buf, 60) > 0) { 53 | count++; 54 | continue; 55 | } 56 | fprintf(stderr, "polling after sending %d\n", count); 57 | count = 0; 58 | } 59 | poll(&pfd, 1, 1000); 60 | } 61 | nm_close(d); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /utils/test_select.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test minimum select time 3 | * 4 | * ./prog usec [method [duration]] 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | enum { M_SELECT =0 , M_POLL, M_USLEEP }; 16 | static const char *names[] = { "select", "poll", "usleep" }; 17 | int 18 | main(int argc, char *argv[]) 19 | { 20 | struct timeval ta, tb, prev; 21 | int usec = 1, total = 0, method = M_SELECT; 22 | uint32_t *vals = NULL; 23 | uint32_t i, count = 0; 24 | #define LIM 1000000 25 | 26 | if (argc > 1) 27 | usec = atoi(argv[1]); 28 | if (usec <= 0) 29 | usec = 1; 30 | else if (usec > 500000) 31 | usec = 500000; 32 | if (argc > 2) { 33 | if (!strcmp(argv[2], "poll")) 34 | method = M_POLL; 35 | else if (!strcmp(argv[2], "usleep")) 36 | method = M_USLEEP; 37 | } 38 | if (argc > 3) 39 | total = atoi(argv[3]); 40 | if (total < 1) 41 | total = 1; 42 | else if (total > 10) 43 | total = 10; 44 | fprintf(stderr, "testing %s for %dus over %ds\n", 45 | names[method], usec, total); 46 | 47 | gettimeofday(&ta, NULL); 48 | prev = ta; 49 | vals = calloc(LIM, sizeof(uint32_t)); 50 | for (;;) { 51 | if (method == M_SELECT) { 52 | struct timeval to = { 0, usec }; 53 | select(0, NULL, NULL, NULL, &to); 54 | } else if (method == M_POLL) { 55 | poll(NULL, 0, usec/1000); 56 | } else { 57 | usleep(usec); 58 | } 59 | gettimeofday(&tb, NULL); 60 | timersub(&tb, &prev, &prev); 61 | if (count < LIM) 62 | vals[count] = prev.tv_usec; 63 | count++; 64 | prev = tb; 65 | timersub(&tb, &ta, &tb); 66 | if (tb.tv_sec > total) 67 | break; 68 | } 69 | fprintf(stderr, "%dus actually took %dus\n", 70 | usec, (int)(tb.tv_sec * 1000000 + tb.tv_usec) / count ); 71 | for (i = 0; i < count && i < LIM; i++) 72 | fprintf(stdout, "%d\n", vals[i]); 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /utils/testmod/Makefile: -------------------------------------------------------------------------------- 1 | # $Id 2 | # 3 | # Module for running tests in the kernel. 4 | KMOD= test 5 | SRCS= bus_if.h device_if.h isa_if.h card_if.h \ 6 | kern_test.c 7 | 8 | .include 9 | 10 | --------------------------------------------------------------------------------