├── .clang-format ├── .gitignore ├── .travis.yml ├── GNUmakefile ├── LICENSE ├── LINUX ├── Kbuild.in ├── README.md ├── 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 │ ├── custom--virtio_net.c--4.9 │ ├── intel--e1000e--3.3.5 │ ├── intel--e1000e--3.3.5.10 │ ├── intel--e1000e--3.3.5.3 │ ├── intel--e1000e--3.3.6 │ ├── intel--e1000e--3.4.0.2 │ ├── intel--e1000e--3.4.1.1 │ ├── intel--e1000e--3.4.2.1 │ ├── intel--e1000e--3.4.2.3 │ ├── intel--e1000e--3.4.2.4 │ ├── intel--e1000e--3.5.1 │ ├── intel--e1000e--3.6.0 │ ├── intel--e1000e--3.8.4 │ ├── intel--e1000e--3.8.7 │ ├── intel--e1000e--netmap-3.6.0 │ ├── intel--i40e--1.5.25 │ ├── intel--i40e--1.6.42 │ ├── intel--i40e--2.0.19 │ ├── intel--i40e--2.0.26 │ ├── intel--i40e--2.0.30 │ ├── intel--i40e--2.1.26 │ ├── intel--i40e--2.10.19.30 │ ├── intel--i40e--2.10.19.82 │ ├── intel--i40e--2.11.21 │ ├── intel--i40e--2.11.25 │ ├── intel--i40e--2.11.29 │ ├── intel--i40e--2.12.6 │ ├── intel--i40e--2.13.10 │ ├── intel--i40e--2.14.13 │ ├── intel--i40e--2.15.9 │ ├── intel--i40e--2.16.11 │ ├── intel--i40e--2.17.15 │ ├── intel--i40e--2.17.4 │ ├── intel--i40e--2.18.9 │ ├── intel--i40e--2.19.3 │ ├── intel--i40e--2.20.12 │ ├── intel--i40e--2.21.12 │ ├── intel--i40e--2.22.18 │ ├── intel--i40e--2.22.20 │ ├── intel--i40e--2.22.8 │ ├── intel--i40e--2.23.17 │ ├── intel--i40e--2.24.6 │ ├── intel--i40e--2.25.11 │ ├── intel--i40e--2.27.8 │ ├── intel--i40e--2.3.6 │ ├── intel--i40e--2.4.10 │ ├── intel--i40e--2.4.3 │ ├── intel--i40e--2.4.6 │ ├── intel--i40e--2.7.11 │ ├── intel--i40e--2.7.12 │ ├── intel--i40e--2.7.26 │ ├── intel--i40e--2.7.29 │ ├── intel--i40e--2.8.43 │ ├── intel--i40e--2.9.21 │ ├── intel--ice--1.10.1.2 │ ├── intel--ice--1.10.1.2.2 │ ├── intel--ice--1.11.14 │ ├── intel--ice--1.11.17.1 │ ├── intel--ice--1.12.18 │ ├── intel--ice--1.12.6 │ ├── intel--ice--1.12.7 │ ├── intel--ice--1.13.7 │ ├── intel--ice--1.14.13 │ ├── intel--ice--1.15.4 │ ├── intel--ice--1.16.3 │ ├── intel--ice--1.7.15 │ ├── intel--ice--1.7.16 │ ├── intel--ice--1.8.3 │ ├── intel--ice--1.8.8 │ ├── intel--ice--1.8.9 │ ├── intel--ice--1.9.11 │ ├── intel--ice--1.9.7 │ ├── intel--igb--5.10.2 │ ├── intel--igb--5.11.4 │ ├── intel--igb--5.12.3 │ ├── intel--igb--5.13.16 │ ├── intel--igb--5.13.20 │ ├── intel--igb--5.13.7 │ ├── intel--igb--5.14.16 │ ├── intel--igb--5.15.6 │ ├── intel--igb--5.16.10 │ ├── intel--igb--5.18.7 │ ├── intel--igb--5.3.5.10 │ ├── intel--igb--5.3.5.12 │ ├── intel--igb--5.3.5.15 │ ├── intel--igb--5.3.5.18 │ ├── intel--igb--5.3.5.20 │ ├── intel--igb--5.3.5.22 │ ├── intel--igb--5.3.5.36 │ ├── intel--igb--5.3.5.39 │ ├── intel--igb--5.3.5.4 │ ├── intel--igb--5.3.5.42 │ ├── intel--igb--5.3.5.61 │ ├── intel--igb--5.3.6 │ ├── intel--igb--5.4.6 │ ├── intel--igb--5.5.2 │ ├── intel--igb--5.7.2 │ ├── intel--igb--5.8.5 │ ├── intel--igb--5.9.3 │ ├── intel--ixgbe--4.4.6 │ ├── intel--ixgbe--4.5.4 │ ├── intel--ixgbe--5.0.4 │ ├── intel--ixgbe--5.1.3 │ ├── intel--ixgbe--5.10.2 │ ├── intel--ixgbe--5.11.3 │ ├── intel--ixgbe--5.12.5 │ ├── intel--ixgbe--5.13.4 │ ├── intel--ixgbe--5.14.6 │ ├── intel--ixgbe--5.15.2 │ ├── intel--ixgbe--5.16.5 │ ├── intel--ixgbe--5.17.1 │ ├── intel--ixgbe--5.18.11 │ ├── intel--ixgbe--5.18.13 │ ├── intel--ixgbe--5.18.6 │ ├── intel--ixgbe--5.19.6 │ ├── intel--ixgbe--5.19.9 │ ├── intel--ixgbe--5.2.1 │ ├── intel--ixgbe--5.2.3 │ ├── intel--ixgbe--5.2.4 │ ├── intel--ixgbe--5.20.10 │ ├── intel--ixgbe--5.3.3 │ ├── intel--ixgbe--5.3.4 │ ├── intel--ixgbe--5.3.5 │ ├── intel--ixgbe--5.3.6 │ ├── intel--ixgbe--5.3.7 │ ├── intel--ixgbe--5.3.8 │ ├── intel--ixgbe--5.5.1 │ ├── intel--ixgbe--5.5.2 │ ├── intel--ixgbe--5.5.3 │ ├── intel--ixgbe--5.5.5 │ ├── intel--ixgbe--5.6.1 │ ├── intel--ixgbe--5.6.3 │ ├── intel--ixgbe--5.6.5 │ ├── intel--ixgbe--5.7.1 │ ├── intel--ixgbe--5.8.1 │ ├── intel--ixgbe--5.9.4 │ ├── intel--ixgbe--6.0.5 │ ├── intel--ixgbe--6.0.6 │ ├── intel--ixgbevf--3.2.2 │ ├── intel--ixgbevf--3.3.2 │ ├── intel--ixgbevf--4.0.3 │ ├── intel--ixgbevf--4.1.2 │ ├── intel--ixgbevf--4.10.2 │ ├── intel--ixgbevf--4.11.1 │ ├── intel--ixgbevf--4.12.4 │ ├── intel--ixgbevf--4.13.3 │ ├── intel--ixgbevf--4.14.5 │ ├── intel--ixgbevf--4.15.1 │ ├── intel--ixgbevf--4.16.5 │ ├── intel--ixgbevf--4.17.11 │ ├── intel--ixgbevf--4.17.13 │ ├── intel--ixgbevf--4.17.5 │ ├── intel--ixgbevf--4.18.7 │ ├── intel--ixgbevf--4.18.9 │ ├── intel--ixgbevf--4.19.10 │ ├── intel--ixgbevf--4.2.1 │ ├── intel--ixgbevf--4.2.2 │ ├── intel--ixgbevf--4.3.2 │ ├── intel--ixgbevf--4.3.3 │ ├── intel--ixgbevf--4.3.4 │ ├── intel--ixgbevf--4.3.5 │ ├── intel--ixgbevf--4.3.6 │ ├── intel--ixgbevf--4.5.1 │ ├── intel--ixgbevf--4.5.2 │ ├── intel--ixgbevf--4.5.3 │ ├── intel--ixgbevf--4.6.1 │ ├── intel--ixgbevf--4.6.3 │ ├── intel--ixgbevf--4.7.1 │ ├── intel--ixgbevf--4.8.1 │ ├── intel--ixgbevf--4.9.3 │ ├── intel--ixgbevf--5.0.2 │ ├── mellanox--mlx5--3.3 │ ├── mellanox--mlx5--4.5 │ ├── mellanox--mlx5--4.6 │ ├── mellanox--mlx5--5.0 │ ├── mellanox--mlx5--5.1 │ ├── mellanox--mlx5--5.2 │ ├── mellanox--mlx5--5.3 │ ├── mellanox--mlx5--5.4 │ ├── mellanox--mlx5--5.8 │ ├── vanilla--e1000--20620--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--40e00 │ ├── vanilla--i40e--40e00--41000 │ ├── vanilla--i40e--41000--41400 │ ├── vanilla--i40e--41400--50800 │ ├── vanilla--i40e--50800--50a00 │ ├── vanilla--i40e--50a00--50f00 │ ├── vanilla--i40e--50f00--51000 │ ├── vanilla--i40e--51000--60400 │ ├── vanilla--i40e--60400--99999 │ ├── vanilla--ice--50500--50800 │ ├── vanilla--ice--50800--50c00 │ ├── vanilla--ice--50c00--50d00 │ ├── vanilla--ice--50d00--50e00 │ ├── vanilla--ice--50e00--51000 │ ├── vanilla--ice--51000--51100 │ ├── vanilla--ice--51100--51200 │ ├── vanilla--ice--51200--60300 │ ├── vanilla--ice--60300--60b00 │ ├── vanilla--ice--60b00--99999 │ ├── vanilla--igb--20621--20623 │ ├── vanilla--igb--20623--30200 │ ├── vanilla--igb--30200--30800 │ ├── vanilla--igb--30800--30f00 │ ├── vanilla--igb--30f00--40100 │ ├── vanilla--igb--40100--40400 │ ├── vanilla--igb--40400--50a00 │ ├── vanilla--igb--50a00--50c00 │ ├── vanilla--igb--50c00--99999 │ ├── vanilla--igc--41400--50100 │ ├── vanilla--igc--50100--50600 │ ├── vanilla--igc--50600--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--41000 │ ├── vanilla--ixgbe--41000--41400 │ ├── vanilla--ixgbe--41400--50800 │ ├── vanilla--ixgbe--50800--50a00 │ ├── vanilla--ixgbe--50a00--50c00 │ ├── vanilla--ixgbe--50c00--99999 │ ├── vanilla--ixgbevf--20622--30500 │ ├── vanilla--ixgbevf--30500--30600 │ ├── vanilla--ixgbevf--30600--30700 │ ├── vanilla--ixgbevf--30700--30d00 │ ├── vanilla--ixgbevf--30d00--30e00 │ ├── vanilla--ixgbevf--30e00--30f00 │ ├── vanilla--ixgbevf--30f00--31200 │ ├── vanilla--ixgbevf--31200--31300 │ ├── vanilla--ixgbevf--31300--40000 │ ├── vanilla--ixgbevf--40000--40700 │ ├── vanilla--ixgbevf--40700--40800 │ ├── vanilla--ixgbevf--40800--40900 │ ├── vanilla--ixgbevf--40900--41100 │ ├── vanilla--ixgbevf--41100--50800 │ ├── vanilla--ixgbevf--50800--50c00 │ ├── vanilla--ixgbevf--50c00--99999 │ ├── vanilla--r8169.c--20620--20625 │ ├── vanilla--r8169.c--20625--20626 │ ├── vanilla--r8169.c--20626--30400 │ ├── vanilla--stmmac--40900--40a00 │ ├── vanilla--stmmac--40a00--40c00 │ ├── vanilla--veth.c--20620--30900 │ ├── vanilla--veth.c--30900--30f00 │ ├── vanilla--veth.c--30f00--41300 │ ├── vanilla--veth.c--41300--41400 │ ├── vanilla--veth.c--41400--60700 │ ├── vanilla--veth.c--60700--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--30a00 │ ├── vanilla--virtio_net.c--30a00--30b00 │ ├── vanilla--virtio_net.c--30b00--31100 │ ├── vanilla--virtio_net.c--31100--31300 │ ├── vanilla--virtio_net.c--31300--40100 │ ├── vanilla--virtio_net.c--40100--40900 │ ├── vanilla--virtio_net.c--40900--40c00 │ ├── vanilla--virtio_net.c--40c00--40f00 │ ├── vanilla--virtio_net.c--40f00--41000 │ ├── vanilla--virtio_net.c--41000--41100 │ ├── vanilla--virtio_net.c--41100--50b00 │ ├── vanilla--virtio_net.c--50b00--60500 │ ├── vanilla--virtio_net.c--60500--60800 │ ├── vanilla--virtio_net.c--60800--60b00 │ ├── vanilla--virtio_net.c--60b00--60c00 │ ├── vanilla--virtio_net.c--60c00--99999 │ ├── vanilla--vmxnet3--31000--40d00 │ ├── vanilla--vmxnet3--40d00--60600 │ └── vanilla--vmxnet3--60600--99999 ├── forcedeth_netmap.h ├── i40e_netmap_linux.h ├── ice_netmap_linux.h ├── if_e1000_netmap.h ├── if_e1000e_netmap.h ├── if_igb_netmap.h ├── if_igc_netmap.h ├── if_re_netmap_linux.h ├── if_stmmac_netmap_linux.h ├── if_virtio_net_netmap.h ├── if_vmxnet3_netmap.h ├── if_vmxnet3_netmap_v2.h ├── intel-fix.sh_ ├── ixgbe_netmap_linux.h ├── mlx5-prepare.sh ├── mlx5_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_net.mak └── virtio_netmap.h ├── Makefile ├── PORTING ├── README.md ├── README.ptnetmap.md ├── SECURITY.md ├── 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.8 │ └── bridge.c ├── dedup │ ├── GNUmakefile │ ├── dedup-main.c │ ├── dedup.c │ ├── dedup.h │ └── mark-adler-hash.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.8 │ └── pkt-gen.c ├── tlem │ ├── .gitignore │ ├── GNUmakefile │ ├── README │ ├── tlem.8 │ └── tlem.c └── vale-ctl │ ├── GNUmakefile │ ├── vale-ctl.4 │ └── vale-ctl.c ├── ci ├── build-linux └── run-integration-tests ├── configure ├── extra ├── libvirt │ └── libvirt-3.0.0.patch └── 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 ├── libnetmap ├── GNUmakefile ├── libnetmap.h ├── nmctx-pthreads.c ├── nmctx.c ├── nmport.c └── nmreq.c ├── pre-commit ├── share └── man │ └── man4 │ ├── netmap.4 │ ├── ptnet.4 │ └── vale.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_bdg.c │ │ ├── netmap_bdg.h │ │ ├── netmap_freebsd.c │ │ ├── netmap_generic.c │ │ ├── netmap_kern.h │ │ ├── netmap_kloop.c │ │ ├── netmap_legacy.c │ │ ├── netmap_mbq.c │ │ ├── netmap_mbq.h │ │ ├── netmap_mem2.c │ │ ├── netmap_mem2.h │ │ ├── netmap_monitor.c │ │ ├── netmap_null.c │ │ ├── netmap_offloadings.c │ │ ├── netmap_pipe.c │ │ └── netmap_vale.c ├── modules │ └── netmap │ │ ├── .gitignore │ │ └── Makefile └── net │ ├── netmap.h │ ├── netmap_legacy.h │ ├── netmap_user.h │ └── netmap_virt.h └── utils ├── GNUmakefile ├── Makefile ├── README ├── click-test.cfg ├── ctrl-api-test.c ├── extmem-example.c ├── fd_server-legacy.c ├── fd_server-legacy.h ├── fd_server.c ├── fd_server.h ├── functional-legacy.c ├── functional.c ├── get_avail_tx_packets.c ├── get_max_tx_packets.c ├── producer.c ├── randomized_tests ├── switch-modules ├── ovs-2.4.0 │ └── 0001-datapath-netmap-VALE-support.patch └── ovs-2.6.1 │ └── 0001-datapath-netmap-VALE-support.patch ├── sync_kloop_test.c ├── test_lib ├── test_nm.c ├── test_select.c ├── testcsum.c ├── testlock.c ├── testmmap.c ├── testmod ├── Makefile └── kern_test.c └── tests ├── 001_exclusive_open_ephemeral_vale_port_test ├── 002_exclusive_open_persistent_vale_port_test ├── 003_exclusive_open_pipe_test ├── 004_extra_buf_send_rec_ephemeral_vale_ports_test ├── 005_extra_buf_send_rec_persistent_vale_ports_test ├── 006_extra_buf_send_rec_pipe_test ├── 007_learning_bridge_test ├── 008_partial_read_pipe_test ├── 009_persistent_vale_port_destroy ├── 010_persistent_vale_port_double_attach ├── 011_persistent_vale_port_double_create ├── 012_rec_cp_mon_ephemeral_vale_port_test ├── 013_rec_cp_mon_persistent_vale_port_test ├── 014_rec_cp_mon_pipe_test ├── 015_rec_zcp_mon_ephemeral_vale_port_test ├── 016_rec_zcp_mon_persistent_vale_port_test ├── 017_rec_zcp_mon_pipe_test ├── 018_send_cp_mon_ephemeral_vale_port_test ├── 019_send_cp_mon_persistent_vale_port_test ├── 020_send_cp_mon_pipe_test ├── 021_send_rec_ephemeral_vale_ports_test ├── 022_send_rec_persistent_vale_ports_test ├── 023_send_rec_pipe_test ├── 024_send_rec_veth_test ├── 025_send_zcp_mon_ephemeral_vale_port_test ├── 026_send_zcp_mon_persistent_vale_port_test └── 027_send_zcp_mon_pipe_test /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | AllowShortIfStatementsOnASingleLine: false 3 | AlignConsecutiveAssignments: true 4 | AlwaysBreakAfterDefinitionReturnType: None 5 | AlwaysBreakAfterReturnType: TopLevelDefinitions 6 | BreakBeforeBraces: Linux 7 | ConstructorInitializerIndentWidth: 8 8 | ContinuationIndentWidth: 4 9 | IndentCaseLabels: false 10 | IndentWidth: 8 11 | SortIncludes: false 12 | UseTab: ForIndentation 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | .*.cmd 4 | *.ko 5 | *.mod.c 6 | *.orig 7 | .*.swp 8 | config 9 | tags 10 | cscope.* 11 | modules.order 12 | Module.symvers 13 | .tmp_versions 14 | cache/ 15 | cnic_if.h 16 | e1000/ 17 | e1000e*/ 18 | forcedeth.c 19 | xen-netfront.c 20 | r8169.c 21 | get-drivers 22 | igb*/ 23 | ixgbe*/ 24 | vmxnet*/ 25 | log/ 26 | scripts/conf 27 | virtio_net.c 28 | config.log 29 | Kbuild 30 | netmap.mak 31 | config.status 32 | drivers.mak 33 | patches 34 | get-* 35 | netmap-tmpdir 36 | netmap_linux_config.h 37 | netmap-tmp.c 38 | i40e*/ 39 | veth.c 40 | failed-patches 41 | apps/lb/lb 42 | apps/nmreplay/nmreplay 43 | apps/tlem/tlem 44 | apps/bridge/bridge 45 | apps/bridge/bridge-b 46 | apps/pkt-gen/pkt-gen 47 | apps/pkt-gen/pkt-gen-b 48 | utils/test_select 49 | utils/testcsum 50 | utils/testlock 51 | utils/testmmap 52 | utils/vale-ctl 53 | utils/test_nm 54 | utils/cygwin1.dll 55 | utils/ctrl-api-test 56 | utils/functional 57 | utils/fd_server 58 | utils/get_tx_rings_avail_sends 59 | utils/get_tx_rings_max_sends 60 | utils/extmem-example 61 | examples/pkt-gen.exe 62 | examples/pkt-gen.exe.stackdump 63 | examples/pkt-gen-b.exe 64 | examples/pkt-gen-b.exe.stackdump 65 | build*/ 66 | LINUX/tmp-patches 67 | LINUX/veth.c 68 | *.gcno 69 | *.core 70 | *.suo 71 | *.sdf 72 | *.opensdf 73 | *~ 74 | cscope.out 75 | *.7 76 | default-config.mak 77 | drv-subdir.mak 78 | read-vars.mak 79 | !LINUX/default-config.mak 80 | !LINUX/drv-subdir.mak 81 | !LINUX/read-vars.mak 82 | !LINUX/final-patches/* 83 | LINUX/scripts/conf 84 | config.mak 85 | *.rej 86 | utils/producer 87 | .cache.mk 88 | utils/sync_kloop_test 89 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | sudo: required 3 | language: c 4 | env: 5 | - KERNEL_VERSION=local ARCH=x86_64 6 | - KERNEL_VERSION=3.0 ARCH=x86_64 7 | - KERNEL_VERSION=3.1 ARCH=x86_64 8 | - KERNEL_VERSION=3.2 ARCH=x86_64 9 | - KERNEL_VERSION=3.3 ARCH=x86_64 10 | - KERNEL_VERSION=3.4 ARCH=x86_64 11 | - KERNEL_VERSION=3.5 ARCH=x86_64 12 | - KERNEL_VERSION=3.6 ARCH=x86_64 13 | - KERNEL_VERSION=3.7 ARCH=x86_64 14 | - KERNEL_VERSION=3.8 ARCH=x86_64 15 | - KERNEL_VERSION=3.9 ARCH=x86_64 16 | - KERNEL_VERSION=3.10.108 ARCH=x86_64 17 | - KERNEL_VERSION=3.11 ARCH=x86_64 18 | - KERNEL_VERSION=3.12 ARCH=x86_64 19 | - KERNEL_VERSION=3.13 ARCH=x86_64 20 | - KERNEL_VERSION=3.14 ARCH=x86_64 21 | - KERNEL_VERSION=3.15 ARCH=x86_64 22 | - KERNEL_VERSION=3.16 ARCH=x86_64 23 | - KERNEL_VERSION=3.17 ARCH=x86_64 24 | - KERNEL_VERSION=3.18 ARCH=x86_64 25 | - KERNEL_VERSION=3.19 ARCH=x86_64 26 | - KERNEL_VERSION=4.0 ARCH=x86_64 27 | - KERNEL_VERSION=4.1 ARCH=x86_64 28 | - KERNEL_VERSION=4.2 ARCH=x86_64 29 | - KERNEL_VERSION=4.3 ARCH=x86_64 30 | - KERNEL_VERSION=4.4 ARCH=x86_64 31 | - KERNEL_VERSION=4.5 ARCH=x86_64 32 | - KERNEL_VERSION=4.6 ARCH=x86_64 33 | - KERNEL_VERSION=4.7 ARCH=x86_64 34 | - KERNEL_VERSION=4.8 ARCH=x86_64 35 | - KERNEL_VERSION=4.9 ARCH=x86_64 36 | - KERNEL_VERSION=4.10 ARCH=x86_64 37 | - KERNEL_VERSION=4.11 ARCH=x86_64 38 | - KERNEL_VERSION=4.12 ARCH=x86_64 39 | - KERNEL_VERSION=4.13 ARCH=x86_64 40 | - KERNEL_VERSION=4.14 ARCH=x86_64 41 | - KERNEL_VERSION=4.15 ARCH=x86_64 42 | - KERNEL_VERSION=4.16 ARCH=x86_64 43 | - KERNEL_VERSION=4.17 ARCH=x86_64 44 | - KERNEL_VERSION=4.18 ARCH=x86_64 45 | - KERNEL_VERSION=4.19 ARCH=x86_64 46 | - KERNEL_VERSION=4.20 ARCH=x86_64 47 | - KERNEL_VERSION=3.16 ARCH=i386 48 | script: 49 | - "./ci/build-linux $KERNEL_VERSION $ARCH" 50 | - "[ ${KERNEL_VERSION} != local ] || ./ci/run-integration-tests" 51 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | all: 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 | 10 | netmap.mak: 11 | @echo 'The new way to build netmap is to run the provided configure script first,' 12 | @echo 'followed by make.' 13 | ifneq ($(MAKECMDGOALS),clean) 14 | ifneq ($(MAKECMDGOALS),distclean) 15 | @echo 'We run configure for you now, with compatible arguments, and restart make.' 16 | @echo 'Please run configure again if this is not what you want.' 17 | ./configure $(COMPAT_ARGS) 18 | endif 19 | endif 20 | -------------------------------------------------------------------------------- /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 netmap_legacy.o netmap_bdg.o netmap_kloop.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-$(CONFIG_NETMAP_NULL) += netmap_null.o 18 | 19 | define remote_template 20 | $$(obj)/$(1): %.o: $$(SRCDIR)/../sys/dev/netmap/$(2) FORCE 21 | $$(call if_changed_rule,cc_o_c) 22 | endef 23 | $(foreach o,$(remoteobjs-y),$(eval $(call remote_template,$(o),$(o:.o=.c)))) 24 | # we compile netmap.c into netmap_common.o to allow 25 | # for MODNAME=netmap 26 | $(eval $(call remote_template,netmap_common.o,netmap.c)) 27 | 28 | $(obj)/netmap_linux.o: %.o: $(SRCDIR)/netmap_linux.c FORCE 29 | $(call if_changed_rule,cc_o_c) 30 | 31 | # all objects 32 | $(MODNAME)-objs := $(remoteobjs-y) netmap_common.o netmap_linux.o 33 | 34 | ifdef CONFIG_NETMAP_PTNETMAP 35 | $(obj)/netmap_ptnet.o: %.o: $(SRCDIR)/netmap_ptnet.c FORCE 36 | $(call if_changed_rule,cc_o_c) 37 | 38 | $(MODNAME)-objs += netmap_ptnet.o 39 | endif 40 | 41 | obj-$(CONFIG_NETMAP) = $(MODNAME).o 42 | 43 | ifdef NETMAP_DRIVER_SUFFIX 44 | $(foreach v,$(filter %.o,$(O_DRIVERS)),$(eval $(v:.o=$(NETMAP_DRIVER_SUFFIX)-objs) := $v)) 45 | $(foreach v,$(filter %.o,$(O_DRIVERS)),$(info $(v:.o=$(NETMAP_DRIVER_SUFFIX)-objs) := $v)) 46 | obj-m += $(O_DRIVERS:%.o=%$(NETMAP_DRIVER_SUFFIX).o) 47 | else 48 | obj-m += $(O_DRIVERS) 49 | endif 50 | -------------------------------------------------------------------------------- /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 with" 5 | echo ">>> a '_netmap.ko' suffix, so that they don't replace the" 6 | echo ">>> official ones provided by the linux package." 7 | echo ">>> You should therefore manually unload the official ones and" 8 | echo ">>> load the patched ones." 9 | echo ">>> Alternatively, you can use /etc/modules-load.d/ and" 10 | echo ">>> /etc/modprobe.d/ to automatically load patched drivers and" 11 | echo ">>> blacklist the official ones." 12 | } 13 | 14 | ## arg 1: the new package version 15 | post_install() { 16 | post_common 17 | } 18 | 19 | ## arg 1: the new package version 20 | ## arg 2: the old package version 21 | post_upgrade() { 22 | post_common 23 | } 24 | 25 | ## arg 1: the old package version 26 | post_remove() { 27 | post_common 28 | } 29 | 30 | -------------------------------------------------------------------------------- /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 | **Disclaimer** 5 | The dkms build infrastructure is not the official way to build netmap and its 6 | patched drivers. 7 | This alternative build system is not actively maintained, so you may need some 8 | tweaks to make it work on your platform. 9 | 10 | Please prefer the standard ./configure && make && make install process to 11 | build netmap. 12 | ************** 13 | 14 | Some prerequisites: 15 | # apt-get install dkms linux-source linux-headers-$(uname -r) devscripts 16 | 17 | 18 | First way is a plain dkms installation: 19 | ``` 20 | make install-dkms 21 | dkms install netmap/ 22 | ``` 23 | 24 | Or make .deb package with sources: 25 | ``` 26 | make install-dkms 27 | dkms mkdeb netmap/0.0.1 --source-only 28 | ``` 29 | -------------------------------------------------------------------------------- /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' kernelver=$kernelver" 9 | BUILT_MODULE_NAME[0]=netmap 10 | DEST_MODULE_LOCATION[0]=/kernel/net/netmap/ 11 | 12 | # forcedeth driver 13 | BUILT_MODULE_NAME[1]=forcedeth 14 | DEST_MODULE_LOCATION[1]=/kernel/drivers/net/ethernet/nvidia/ 15 | 16 | # veth driver 17 | BUILT_MODULE_NAME[2]=veth 18 | DEST_MODULE_LOCATION[2]=/kernel/drivers/net/ 19 | 20 | # virtio_net driver 21 | BUILT_MODULE_NAME[3]=virtio_net 22 | DEST_MODULE_LOCATION[3]=/kernel/drivers/net/ 23 | 24 | # e1000 driver 25 | BUILT_MODULE_NAME[4]=e1000 26 | BUILT_MODULE_LOCATION[4]=e1000/ 27 | DEST_MODULE_LOCATION[4]=/kernel/drivers/net/ethernet/intel/e1000/ 28 | 29 | # e1000e driver 30 | BUILT_MODULE_NAME[5]=e1000e 31 | BUILT_MODULE_LOCATION[5]=e1000e/ 32 | DEST_MODULE_LOCATION[5]=/kernel/drivers/net/ethernet/intel/e1000e/ 33 | 34 | # igb driver 35 | BUILT_MODULE_NAME[6]=igb 36 | BUILT_MODULE_LOCATION[6]=igb/ 37 | DEST_MODULE_LOCATION[6]=/kernel/drivers/net/ethernet/intel/igb/ 38 | 39 | # ixgbe driver 40 | BUILT_MODULE_NAME[7]=ixgbe 41 | BUILT_MODULE_LOCATION[7]=ixgbe/ 42 | DEST_MODULE_LOCATION[7]=/kernel/drivers/net/ethernet/intel/ixgbe/ 43 | 44 | # i40e driver 45 | BUILT_MODULE_NAME[8]=i40e 46 | BUILT_MODULE_LOCATION[8]=i40e/ 47 | DEST_MODULE_LOCATION[8]=/kernel/drivers/net/ethernet/intel/i40e/ 48 | 49 | # vmxnet3 driver 50 | BUILT_MODULE_NAME[9]=vmxnet3 51 | BUILT_MODULE_LOCATION[9]=vmxnet3/ 52 | DEST_MODULE_LOCATION[9]=/kernel/drivers/net/vmxnet3/ 53 | 54 | # mlx5 driver 55 | BUILT_MODULE_NAME[10]=mlx5_core 56 | BUILT_MODULE_LOCATION[10]=mlx5/drivers/net/ethernet/mellanox/mlx5/core 57 | DEST_MODULE_LOCATION[10]=/kernel/drivers/net/ethernet/mellanox/mlx5/ 58 | 59 | BUILT_MODULE_NAME[11]=mlxfw 60 | BUILT_MODULE_LOCATION[11]=mlx5/drivers/net/ethernet/mellanox/mlxfw/ 61 | DEST_MODULE_LOCATION[11]=/kernel/drivers/net/ethernet/mellanox/mlx5/ 62 | 63 | BUILT_MODULE_NAME[12]=mlx_compat 64 | BUILT_MODULE_LOCATION[12]=mlx5/compat/ 65 | DEST_MODULE_LOCATION[12]=/kernel/drivers/net/ethernet/mellanox/mlx5/ 66 | 67 | BUILT_MODULE_NAME[13]=auxiliary 68 | BUILT_MODULE_LOCATION[13]=mlx5/drivers/base/ 69 | DEST_MODULE_LOCATION[13]=/kernel/drivers/net/ethernet/mellanox/mlx5/ 70 | 71 | BUILT_MODULE_NAME[14]=mlxdevm 72 | BUILT_MODULE_LOCATION[14]=mlx5/net/mlxdevm/ 73 | DEST_MODULE_LOCATION[14]=/kernel/drivers/net/ethernet/mellanox/mlx5/ 74 | -------------------------------------------------------------------------------- /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/luigirizzo/netmap/e71c1888da0fd2b7eeed114d9312b1a34721b121/LINUX/drvname2config -------------------------------------------------------------------------------- /LINUX/ext-drivers/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /LINUX/final-patches/intel--e1000e--netmap-3.6.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luigirizzo/netmap/e71c1888da0fd2b7eeed114d9312b1a34721b121/LINUX/final-patches/intel--e1000e--netmap-3.6.0 -------------------------------------------------------------------------------- /LINUX/final-patches/intel--ice--1.7.15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luigirizzo/netmap/e71c1888da0fd2b7eeed114d9312b1a34721b121/LINUX/final-patches/intel--ice--1.7.15 -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--forcedeth.c--20626--99999: -------------------------------------------------------------------------------- 1 | diff --git a/forcedeth.c b/forcedeth.c 2 | index 9c0b1bac6af6..b081d6ba11a2 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--igb--20621--20623: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index c881347cb26d..a2af3799f5a8 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 cea37e0837ff..81fd28b8cb4e 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--30800--30f00: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index 31cfe2ec75df..2776ed444bf4 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 16430a8440fa..c2c462218ec3 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--40400: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index a0a9b1fcb5e8..85be1ebd02ab 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--igb--40400--50a00: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index ea7b09887245..ddb376efc198 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -253,6 +253,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 | @@ -2540,6 +2544,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 | @@ -2809,6 +2817,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 | @@ -3292,6 +3304,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 | @@ -6409,6 +6424,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) != NM_IRQ_PASS) 54 | + return true; /* 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 | @@ -6916,6 +6935,15 @@ static int 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 | + /* 65 | + * Same as the txeof routine: only wakeup clients on intr. 66 | + */ 67 | + int nm_irq; 68 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets); 69 | + if (nm_irq != NM_IRQ_PASS) 70 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 71 | +#endif /* DEV_NETMAP */ 72 | while (likely(total_packets < budget)) { 73 | union e1000_adv_rx_desc *rx_desc; 74 | 75 | @@ -7033,6 +7061,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 76 | struct igb_rx_buffer *bi; 77 | u16 i = rx_ring->next_to_use; 78 | 79 | +#ifdef DEV_NETMAP 80 | + if (igb_netmap_configure_rx_ring(rx_ring)) 81 | + return; 82 | +#endif /* DEV_NETMAP */ 83 | + 84 | /* nothing to do */ 85 | if (!cleaned_count) 86 | return; 87 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--50a00--50c00: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index 0d343d050973..ddee5da89ba3 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -241,6 +241,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 | @@ -3489,6 +3493,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 | @@ -3798,6 +3806,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 | @@ -4302,6 +4314,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 | @@ -8043,6 +8058,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector, int napi_budget) 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) != NM_IRQ_PASS) 54 | + return true; /* 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 | @@ -8682,6 +8701,16 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) 60 | unsigned int xdp_xmit = 0; 61 | struct xdp_buff xdp; 62 | 63 | +#ifdef DEV_NETMAP 64 | + /* 65 | + * Same as the txeof routine: only wakeup clients on intr. 66 | + */ 67 | + int nm_irq; 68 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets); 69 | + if (nm_irq != NM_IRQ_PASS) 70 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 71 | +#endif /* DEV_NETMAP */ 72 | + 73 | xdp.rxq = &rx_ring->xdp_rxq; 74 | 75 | /* Frame size depend on rx_ring setup when PAGE_SIZE=4K */ 76 | @@ -8861,6 +8890,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 77 | u16 i = rx_ring->next_to_use; 78 | u16 bufsz; 79 | 80 | +#ifdef DEV_NETMAP 81 | + if (igb_netmap_configure_rx_ring(rx_ring)) 82 | + return; 83 | +#endif /* DEV_NETMAP */ 84 | + 85 | /* nothing to do */ 86 | if (!cleaned_count) 87 | return; 88 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igb--50c00--99999: -------------------------------------------------------------------------------- 1 | diff --git a/igb/igb_main.c b/igb/igb_main.c 2 | index a45cd2b416c8..8a7712bb2a5d 100644 3 | --- a/igb/igb_main.c 4 | +++ b/igb/igb_main.c 5 | @@ -241,6 +241,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 | @@ -3489,6 +3493,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 | @@ -3798,6 +3806,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 | @@ -4302,6 +4314,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 | @@ -8030,6 +8045,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector, int napi_budget) 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) != NM_IRQ_PASS) 54 | + return true; /* 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 | @@ -8674,6 +8693,16 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) 60 | u32 frame_sz = 0; 61 | int rx_buf_pgcnt; 62 | 63 | +#ifdef DEV_NETMAP 64 | + /* 65 | + * Same as the txeof routine: only wakeup clients on intr. 66 | + */ 67 | + int nm_irq; 68 | + nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets); 69 | + if (nm_irq != NM_IRQ_PASS) 70 | + return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; 71 | +#endif /* DEV_NETMAP */ 72 | + 73 | /* Frame size depend on rx_ring setup when PAGE_SIZE=4K */ 74 | #if (PAGE_SIZE < 8192) 75 | frame_sz = igb_rx_frame_truesize(rx_ring, 0); 76 | @@ -8852,6 +8881,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) 77 | u16 i = rx_ring->next_to_use; 78 | u16 bufsz; 79 | 80 | +#ifdef DEV_NETMAP 81 | + if (igb_netmap_configure_rx_ring(rx_ring)) 82 | + return; 83 | +#endif /* DEV_NETMAP */ 84 | + 85 | /* nothing to do */ 86 | if (!cleaned_count) 87 | return; 88 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igc--41400--50100: -------------------------------------------------------------------------------- 1 | diff --git a/igc/igc_main.c b/igc/igc_main.c 2 | index 9d85707e8a81..45868726cc24 100644 3 | --- a/igc/igc_main.c 4 | +++ b/igc/igc_main.c 5 | @@ -58,6 +58,12 @@ static void igc_irq_enable(struct igc_adapter *adapter); 6 | static void igc_configure_msix(struct igc_adapter *adapter); 7 | static bool igc_alloc_mapped_page(struct igc_ring *rx_ring, 8 | struct igc_rx_buffer *bi); 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +static void igc_up(struct igc_adapter *adapter); 11 | +static void igc_down(struct igc_adapter *adapter); 12 | +static void igc_reset(struct igc_adapter *adapter); 13 | +#include 14 | +#endif 15 | 16 | enum latency_range { 17 | lowest_latency = 0, 18 | @@ -596,6 +602,9 @@ static void igc_configure_tx_ring(struct igc_adapter *adapter, 19 | 20 | txdctl |= IGC_TXDCTL_QUEUE_ENABLE; 21 | wr32(IGC_TXDCTL(reg_idx), txdctl); 22 | +#ifdef DEV_NETMAP 23 | + igc_netmap_configure_tx_ring(adapter, reg_idx); 24 | +#endif /* DEV_NETMAP */ 25 | } 26 | 27 | /** 28 | @@ -1333,6 +1342,11 @@ static void igc_alloc_rx_buffers(struct igc_ring *rx_ring, u16 cleaned_count) 29 | struct igc_rx_buffer *bi; 30 | u16 bufsz; 31 | 32 | +#ifdef DEV_NETMAP 33 | + if (igc_netmap_configure_rx_ring(rx_ring)) 34 | + return; 35 | +#endif /* DEV_NETMAP */ 36 | + 37 | /* nothing to do */ 38 | if (!cleaned_count) 39 | return; 40 | @@ -1398,6 +1412,11 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) 41 | struct sk_buff *skb = rx_ring->skb; 42 | u16 cleaned_count = igc_desc_unused(rx_ring); 43 | 44 | +#ifdef DEV_NETMAP 45 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) 46 | + return true; 47 | +#endif /* DEV_NETMAP */ 48 | + 49 | while (likely(total_packets < budget)) { 50 | union igc_adv_rx_desc *rx_desc; 51 | struct igc_rx_buffer *rx_buffer; 52 | @@ -1548,6 +1567,11 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) 53 | if (test_bit(__IGC_DOWN, &adapter->state)) 54 | return true; 55 | 56 | +#ifdef DEV_NETMAP 57 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 58 | + return true; /* cleaned ok */ 59 | +#endif /* DEV_NETMAP */ 60 | + 61 | tx_buffer = &tx_ring->tx_buffer_info[i]; 62 | tx_desc = IGC_TX_DESC(tx_ring, i); 63 | i -= tx_ring->count; 64 | @@ -3687,6 +3711,10 @@ static int igc_probe(struct pci_dev *pdev, 65 | /* Check if Media Autosense is enabled */ 66 | adapter->ei = *ei; 67 | 68 | +#ifdef DEV_NETMAP 69 | + igc_netmap_attach(adapter); 70 | +#endif /* DEV_NETMAP */ 71 | + 72 | /* print pcie link status and MAC address */ 73 | pcie_print_link_status(pdev); 74 | netdev_info(netdev, "MAC: %pM\n", netdev->dev_addr); 75 | @@ -3738,6 +3766,11 @@ static void igc_remove(struct pci_dev *pdev) 76 | * would have already happened in close and is redundant. 77 | */ 78 | igc_release_hw_control(adapter); 79 | + 80 | +#ifdef DEV_NETMAP 81 | + netmap_detach(netdev); 82 | +#endif /* DEV_NETMAP */ 83 | + 84 | unregister_netdev(netdev); 85 | 86 | igc_clear_interrupt_scheme(adapter); 87 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igc--50100--50600: -------------------------------------------------------------------------------- 1 | diff --git a/igc/igc_main.c b/igc/igc_main.c 2 | index 87a11879bf2d..8da49a957b29 100644 3 | --- a/igc/igc_main.c 4 | +++ b/igc/igc_main.c 5 | @@ -60,6 +60,9 @@ static void igc_irq_enable(struct igc_adapter *adapter); 6 | static void igc_configure_msix(struct igc_adapter *adapter); 7 | static bool igc_alloc_mapped_page(struct igc_ring *rx_ring, 8 | struct igc_rx_buffer *bi); 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | 13 | enum latency_range { 14 | lowest_latency = 0, 15 | @@ -598,6 +601,9 @@ static void igc_configure_tx_ring(struct igc_adapter *adapter, 16 | 17 | txdctl |= IGC_TXDCTL_QUEUE_ENABLE; 18 | wr32(IGC_TXDCTL(reg_idx), txdctl); 19 | +#ifdef DEV_NETMAP 20 | + igc_netmap_configure_tx_ring(adapter, reg_idx); 21 | +#endif /* DEV_NETMAP */ 22 | } 23 | 24 | /** 25 | @@ -1335,6 +1341,11 @@ static void igc_alloc_rx_buffers(struct igc_ring *rx_ring, u16 cleaned_count) 26 | struct igc_rx_buffer *bi; 27 | u16 bufsz; 28 | 29 | +#ifdef DEV_NETMAP 30 | + if (igc_netmap_configure_rx_ring(rx_ring)) 31 | + return; 32 | +#endif /* DEV_NETMAP */ 33 | + 34 | /* nothing to do */ 35 | if (!cleaned_count) 36 | return; 37 | @@ -1400,6 +1411,11 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) 38 | struct sk_buff *skb = rx_ring->skb; 39 | u16 cleaned_count = igc_desc_unused(rx_ring); 40 | 41 | +#ifdef DEV_NETMAP 42 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) 43 | + return true; 44 | +#endif /* DEV_NETMAP */ 45 | + 46 | while (likely(total_packets < budget)) { 47 | union igc_adv_rx_desc *rx_desc; 48 | struct igc_rx_buffer *rx_buffer; 49 | @@ -1550,6 +1566,11 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) 50 | if (test_bit(__IGC_DOWN, &adapter->state)) 51 | return true; 52 | 53 | +#ifdef DEV_NETMAP 54 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 55 | + return true; /* cleaned ok */ 56 | +#endif /* DEV_NETMAP */ 57 | + 58 | tx_buffer = &tx_ring->tx_buffer_info[i]; 59 | tx_desc = IGC_TX_DESC(tx_ring, i); 60 | i -= tx_ring->count; 61 | @@ -3723,6 +3744,10 @@ static int igc_probe(struct pci_dev *pdev, 62 | /* Check if Media Autosense is enabled */ 63 | adapter->ei = *ei; 64 | 65 | +#ifdef DEV_NETMAP 66 | + igc_netmap_attach(adapter); 67 | +#endif /* DEV_NETMAP */ 68 | + 69 | /* print pcie link status and MAC address */ 70 | pcie_print_link_status(pdev); 71 | netdev_info(netdev, "MAC: %pM\n", netdev->dev_addr); 72 | @@ -3774,6 +3799,11 @@ static void igc_remove(struct pci_dev *pdev) 73 | * would have already happened in close and is redundant. 74 | */ 75 | igc_release_hw_control(adapter); 76 | + 77 | +#ifdef DEV_NETMAP 78 | + netmap_detach(netdev); 79 | +#endif /* DEV_NETMAP */ 80 | + 81 | unregister_netdev(netdev); 82 | 83 | igc_clear_interrupt_scheme(adapter); 84 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--igc--50600--99999: -------------------------------------------------------------------------------- 1 | diff --git a/igc/igc_main.c b/igc/igc_main.c 2 | index d9d5425fe8d9..7d9f5b80f28b 100644 3 | --- a/igc/igc_main.c 4 | +++ b/igc/igc_main.c 5 | @@ -52,6 +52,10 @@ static const struct pci_device_id igc_pci_tbl[] = { 6 | 7 | MODULE_DEVICE_TABLE(pci, igc_pci_tbl); 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | enum latency_range { 14 | lowest_latency = 0, 15 | low_latency = 1, 16 | @@ -612,6 +616,9 @@ static void igc_configure_tx_ring(struct igc_adapter *adapter, 17 | 18 | txdctl |= IGC_TXDCTL_QUEUE_ENABLE; 19 | wr32(IGC_TXDCTL(reg_idx), txdctl); 20 | +#ifdef DEV_NETMAP 21 | + igc_netmap_configure_tx_ring(adapter, reg_idx); 22 | +#endif /* DEV_NETMAP */ 23 | } 24 | 25 | /** 26 | @@ -1801,6 +1808,11 @@ static void igc_alloc_rx_buffers(struct igc_ring *rx_ring, u16 cleaned_count) 27 | struct igc_rx_buffer *bi; 28 | u16 bufsz; 29 | 30 | +#ifdef DEV_NETMAP 31 | + if (igc_netmap_configure_rx_ring(rx_ring)) 32 | + return; 33 | +#endif /* DEV_NETMAP */ 34 | + 35 | /* nothing to do */ 36 | if (!cleaned_count) 37 | return; 38 | @@ -1866,6 +1878,11 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) 39 | struct sk_buff *skb = rx_ring->skb; 40 | u16 cleaned_count = igc_desc_unused(rx_ring); 41 | 42 | +#ifdef DEV_NETMAP 43 | + if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) 44 | + return true; 45 | +#endif /* DEV_NETMAP */ 46 | + 47 | while (likely(total_packets < budget)) { 48 | union igc_adv_rx_desc *rx_desc; 49 | struct igc_rx_buffer *rx_buffer; 50 | @@ -1970,6 +1987,11 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) 51 | if (test_bit(__IGC_DOWN, &adapter->state)) 52 | return true; 53 | 54 | +#ifdef DEV_NETMAP 55 | + if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) 56 | + return true; /* cleaned ok */ 57 | +#endif /* DEV_NETMAP */ 58 | + 59 | tx_buffer = &tx_ring->tx_buffer_info[i]; 60 | tx_desc = IGC_TX_DESC(tx_ring, i); 61 | i -= tx_ring->count; 62 | @@ -4788,6 +4810,10 @@ static int igc_probe(struct pci_dev *pdev, 63 | /* Check if Media Autosense is enabled */ 64 | adapter->ei = *ei; 65 | 66 | +#ifdef DEV_NETMAP 67 | + igc_netmap_attach(adapter); 68 | +#endif /* DEV_NETMAP */ 69 | + 70 | /* print pcie link status and MAC address */ 71 | pcie_print_link_status(pdev); 72 | netdev_info(netdev, "MAC: %pM\n", netdev->dev_addr); 73 | @@ -4840,6 +4866,11 @@ static void igc_remove(struct pci_dev *pdev) 74 | * would have already happened in close and is redundant. 75 | */ 76 | igc_release_hw_control(adapter); 77 | + 78 | +#ifdef DEV_NETMAP 79 | + netmap_detach(netdev); 80 | +#endif /* DEV_NETMAP */ 81 | + 82 | unregister_netdev(netdev); 83 | 84 | igc_clear_interrupt_scheme(adapter); 85 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--r8169.c--20620--20625: -------------------------------------------------------------------------------- 1 | diff --git a/r8169.c b/r8169.c 2 | index 0fe2fc90f207..5d363e589803 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 53b13deade95..ced4849577f0 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 7ffdb80adf40..fc9272305d02 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 52af5017c46b..a416e437bebf 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 07a4af0aa3dc..672375e5c5c8 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--41300: -------------------------------------------------------------------------------- 1 | diff --git a/veth.c b/veth.c 2 | index b4a10bcb66a0..52b7c371f06b 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--veth.c--41300--41400: -------------------------------------------------------------------------------- 1 | diff --git a/veth.c b/veth.c 2 | index 41a00cd76955..ce884d392a01 100644 3 | --- a/veth.c 4 | +++ b/veth.c 5 | @@ -60,6 +60,10 @@ struct veth_priv { 6 | unsigned int requested_headroom; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /* 14 | * ethtool interface 15 | */ 16 | @@ -765,7 +769,6 @@ static int veth_open(struct net_device *dev) 17 | netif_carrier_on(dev); 18 | netif_carrier_on(peer); 19 | } 20 | - 21 | return 0; 22 | } 23 | 24 | @@ -825,12 +828,18 @@ static int veth_dev_init(struct net_device *dev) 25 | return err; 26 | } 27 | 28 | +#ifdef DEV_NETMAP 29 | + veth_netmap_attach(dev); 30 | +#endif /* DEV_NETMAP */ 31 | return 0; 32 | } 33 | 34 | static void veth_dev_free(struct net_device *dev) 35 | { 36 | veth_free_queues(dev); 37 | +#ifdef DEV_NETMAP 38 | + netmap_detach(dev); 39 | +#endif /* DEV_NETMAP */ 40 | free_percpu(dev->vstats); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--veth.c--41400--60700: -------------------------------------------------------------------------------- 1 | diff --git a/veth.c b/veth.c 2 | index 890fa5b905e2..ad8f96f1a6a8 100644 3 | --- a/veth.c 4 | +++ b/veth.c 5 | @@ -63,6 +63,10 @@ struct veth_priv { 6 | unsigned int requested_headroom; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /* 14 | * ethtool interface 15 | */ 16 | @@ -891,7 +895,6 @@ static int veth_open(struct net_device *dev) 17 | netif_carrier_on(dev); 18 | netif_carrier_on(peer); 19 | } 20 | - 21 | return 0; 22 | } 23 | 24 | @@ -953,12 +956,18 @@ static int veth_dev_init(struct net_device *dev) 25 | return err; 26 | } 27 | 28 | +#ifdef DEV_NETMAP 29 | + veth_netmap_attach(dev); 30 | +#endif /* DEV_NETMAP */ 31 | return 0; 32 | } 33 | 34 | static void veth_dev_free(struct net_device *dev) 35 | { 36 | veth_free_queues(dev); 37 | +#ifdef DEV_NETMAP 38 | + netmap_detach(dev); 39 | +#endif /* DEV_NETMAP */ 40 | free_percpu(dev->lstats); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--veth.c--60700--99999: -------------------------------------------------------------------------------- 1 | diff --git a/veth.c b/veth.c 2 | index 977861c46b1f..22ec126909ea 100644 3 | --- a/veth.c 4 | +++ b/veth.c 5 | @@ -82,6 +82,10 @@ struct veth_xdp_tx_bq { 6 | unsigned int count; 7 | }; 8 | 9 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) 10 | +#include 11 | +#endif 12 | + 13 | /* 14 | * ethtool interface 15 | */ 16 | @@ -1487,6 +1491,10 @@ static int veth_alloc_queues(struct net_device *dev) 17 | u64_stats_init(&priv->rq[i].stats.syncp); 18 | } 19 | 20 | +#ifdef DEV_NETMAP 21 | + veth_netmap_attach(dev); 22 | +#endif /* DEV_NETMAP */ 23 | + 24 | return 0; 25 | } 26 | 27 | @@ -1505,6 +1513,10 @@ static int veth_dev_init(struct net_device *dev) 28 | static void veth_dev_free(struct net_device *dev) 29 | { 30 | veth_free_queues(dev); 31 | + 32 | +#ifdef DEV_NETMAP 33 | + netmap_detach(dev); 34 | +#endif /* DEV_NETMAP */ 35 | } 36 | 37 | #ifdef CONFIG_NET_POLL_CONTROLLER 38 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--20622--20625: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index b0577dd1a42d..0c873c4ae173 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 b6d402806ae6..60bb2b2cc257 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 82dba5aaf423..06324f8b2593 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 4880aa8b4c28..6521c7e1b366 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,11 @@ 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 | +#endif 54 | /* Make sure we have some buffers: if oom use wq. */ 55 | if (!try_fill_recv(vi, GFP_KERNEL)) 56 | queue_delayed_work(system_nrt_wq, &vi->refill, 0); 57 | @@ -1107,6 +1129,10 @@ static int virtnet_probe(struct virtio_device *vdev) 58 | goto unregister; 59 | } 60 | 61 | +#ifdef DEV_NETMAP 62 | + virtio_netmap_attach(vi); 63 | +#endif 64 | + 65 | /* Assume link up if device can't report link status, 66 | otherwise get link status from config. */ 67 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 68 | @@ -1169,7 +1195,14 @@ static void remove_vq_common(struct virtnet_info *vi) 69 | static void __devexit virtnet_remove(struct virtio_device *vdev) 70 | { 71 | struct virtnet_info *vi = vdev->priv; 72 | +#ifdef DEV_NETMAP 73 | + /* Save the pointer, will go away after netmap_detach(). */ 74 | + struct netmap_adapter *token = NA(vi->dev); 75 | 76 | + netmap_detach(vi->dev); 77 | + virtio_netmap_clean_used_rings(vi, token); 78 | + virtio_netmap_reclaim_unused(vi); 79 | +#endif 80 | unregister_netdev(vi->dev); 81 | 82 | remove_vq_common(vi); 83 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30500--30800: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index f18149ae2588..19d344ac1326 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,7 +760,11 @@ 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 | +#endif 54 | /* Make sure we have some buffers: if oom use wq. */ 55 | if (!try_fill_recv(vi, GFP_KERNEL)) 56 | queue_delayed_work(system_nrt_wq, &vi->refill, 0); 57 | @@ -1148,6 +1170,10 @@ static int virtnet_probe(struct virtio_device *vdev) 58 | goto unregister; 59 | } 60 | 61 | +#ifdef DEV_NETMAP 62 | + virtio_netmap_attach(vi); 63 | +#endif 64 | + 65 | /* Assume link up if device can't report link status, 66 | otherwise get link status from config. */ 67 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 68 | @@ -1210,7 +1236,14 @@ static void remove_vq_common(struct virtnet_info *vi) 69 | static void __devexit virtnet_remove(struct virtio_device *vdev) 70 | { 71 | struct virtnet_info *vi = vdev->priv; 72 | +#ifdef DEV_NETMAP 73 | + /* Save the pointer, will go away after netmap_detach(). */ 74 | + struct netmap_adapter *token = NA(vi->dev); 75 | 76 | + netmap_detach(vi->dev); 77 | + virtio_netmap_clean_used_rings(vi, token); 78 | + virtio_netmap_reclaim_unused(vi); 79 | +#endif 80 | /* Prevent config work handler from accessing the device. */ 81 | mutex_lock(&vi->config_lock); 82 | vi->config_enable = false; 83 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30800--30a00: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 35c00c5ea02a..93a37247e2c8 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,8 +653,14 @@ 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 | +#endif 52 | 53 | for (i = 0; i < vi->max_queue_pairs; i++) { 54 | +#ifdef DEV_NETMAP 55 | + if (!ok) 56 | +#endif 57 | /* Make sure we have some buffers: if oom use wq. */ 58 | if (!try_fill_recv(&vi->rq[i], GFP_KERNEL)) 59 | schedule_delayed_work(&vi->refill, 0); 60 | @@ -1572,6 +1596,10 @@ static int virtnet_probe(struct virtio_device *vdev) 61 | goto free_recv_bufs; 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 | @@ -1617,7 +1645,14 @@ static void remove_vq_common(struct virtnet_info *vi) 72 | static void 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_hotcpu_notifier(&vi->nb); 84 | 85 | /* Prevent config work handler from accessing the device. */ 86 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30a00--30b00: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index c9e00387d999..3d4fcc032940 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 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,8 +653,14 @@ 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 | +#endif 52 | 53 | for (i = 0; i < vi->max_queue_pairs; i++) { 54 | +#ifdef DEV_NETMAP 55 | + if (!ok) 56 | +#endif 57 | if (i < vi->curr_queue_pairs) 58 | /* Make sure we have some buffers: if oom use wq. */ 59 | if (!try_fill_recv(&vi->rq[i], GFP_KERNEL)) 60 | @@ -1594,6 +1618,10 @@ static int virtnet_probe(struct virtio_device *vdev) 61 | goto free_recv_bufs; 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 | @@ -1639,7 +1667,14 @@ static void remove_vq_common(struct virtnet_info *vi) 72 | static void 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_hotcpu_notifier(&vi->nb); 84 | 85 | /* Prevent config work handler from accessing the device. */ 86 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--30b00--31100: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 3d2a90a62649..435ad46baab3 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,8 +654,14 @@ 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 | +#endif 52 | 53 | for (i = 0; i < vi->max_queue_pairs; i++) { 54 | +#ifdef DEV_NETMAP 55 | + if (!ok) 56 | +#endif 57 | if (i < vi->curr_queue_pairs) 58 | /* Make sure we have some buffers: if oom use wq. */ 59 | if (!try_fill_recv(&vi->rq[i], GFP_KERNEL)) 60 | @@ -1592,6 +1616,10 @@ static int virtnet_probe(struct virtio_device *vdev) 61 | goto free_recv_bufs; 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 | @@ -1637,7 +1665,14 @@ static void remove_vq_common(struct virtnet_info *vi) 72 | static void 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_hotcpu_notifier(&vi->nb); 84 | 85 | /* Prevent config work handler from accessing the device. */ 86 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--31100--31300: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 59caa06f34a6..2480ecd71b1d 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,8 +834,14 @@ 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 | +#endif 54 | 55 | for (i = 0; i < vi->max_queue_pairs; i++) { 56 | +#ifdef DEV_NETMAP 57 | + if (!ok) 58 | +#endif 59 | if (i < vi->curr_queue_pairs) 60 | /* Make sure we have some buffers: if oom use wq. */ 61 | if (!try_fill_recv(&vi->rq[i], GFP_KERNEL)) 62 | @@ -1826,6 +1853,10 @@ static int virtnet_probe(struct virtio_device *vdev) 63 | goto free_recv_bufs; 64 | } 65 | 66 | +#ifdef DEV_NETMAP 67 | + virtio_netmap_attach(vi); 68 | +#endif 69 | + 70 | /* Assume link up if device can't report link status, 71 | otherwise get link status from config. */ 72 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 73 | @@ -1872,7 +1903,14 @@ static void remove_vq_common(struct virtnet_info *vi) 74 | static void virtnet_remove(struct virtio_device *vdev) 75 | { 76 | struct virtnet_info *vi = vdev->priv; 77 | +#ifdef DEV_NETMAP 78 | + /* Save the pointer, will go away after netmap_detach(). */ 79 | + struct netmap_adapter *token = NA(vi->dev); 80 | 81 | + netmap_detach(vi->dev); 82 | + virtio_netmap_clean_used_rings(vi, token); 83 | + virtio_netmap_reclaim_unused(vi); 84 | +#endif 85 | unregister_hotcpu_notifier(&vi->nb); 86 | 87 | /* Prevent config work handler from accessing the device. */ 88 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--31300--40100: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 059fdf1bf5ee..8c97bc74d8a5 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,8 +829,14 @@ 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 | +#endif 54 | 55 | for (i = 0; i < vi->max_queue_pairs; i++) { 56 | +#ifdef DEV_NETMAP 57 | + if (!ok) 58 | +#endif 59 | if (i < vi->curr_queue_pairs) 60 | /* Make sure we have some buffers: if oom use wq. */ 61 | if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL)) 62 | @@ -1859,6 +1886,10 @@ static int virtnet_probe(struct virtio_device *vdev) 63 | goto free_recv_bufs; 64 | } 65 | 66 | +#ifdef DEV_NETMAP 67 | + virtio_netmap_attach(vi); 68 | +#endif 69 | + 70 | /* Assume link up if device can't report link status, 71 | otherwise get link status from config. */ 72 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 73 | @@ -1907,7 +1938,14 @@ static void remove_vq_common(struct virtnet_info *vi) 74 | static void virtnet_remove(struct virtio_device *vdev) 75 | { 76 | struct virtnet_info *vi = vdev->priv; 77 | +#ifdef DEV_NETMAP 78 | + /* Save the pointer, will go away after netmap_detach(). */ 79 | + struct netmap_adapter *token = NA(vi->dev); 80 | 81 | + netmap_detach(vi->dev); 82 | + virtio_netmap_clean_used_rings(vi, token); 83 | + virtio_netmap_reclaim_unused(vi); 84 | +#endif 85 | unregister_hotcpu_notifier(&vi->nb); 86 | 87 | /* Make sure no work handler is accessing the device. */ 88 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--40100--40900: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 63c7810e1545..0115f62b92fe 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,8 +829,14 @@ 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 | +#endif 54 | 55 | for (i = 0; i < vi->max_queue_pairs; i++) { 56 | +#ifdef DEV_NETMAP 57 | + if (!ok) 58 | +#endif 59 | if (i < vi->curr_queue_pairs) 60 | /* Make sure we have some buffers: if oom use wq. */ 61 | if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL)) 62 | @@ -1881,6 +1908,10 @@ static int virtnet_probe(struct virtio_device *vdev) 63 | goto free_recv_bufs; 64 | } 65 | 66 | +#ifdef DEV_NETMAP 67 | + virtio_netmap_attach(vi); 68 | +#endif 69 | + 70 | /* Assume link up if device can't report link status, 71 | otherwise get link status from config. */ 72 | if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 73 | @@ -1929,7 +1960,14 @@ static void remove_vq_common(struct virtnet_info *vi) 74 | static void virtnet_remove(struct virtio_device *vdev) 75 | { 76 | struct virtnet_info *vi = vdev->priv; 77 | +#ifdef DEV_NETMAP 78 | + /* Save the pointer, will go away after netmap_detach(). */ 79 | + struct netmap_adapter *token = NA(vi->dev); 80 | 81 | + netmap_detach(vi->dev); 82 | + virtio_netmap_clean_used_rings(vi, token); 83 | + virtio_netmap_reclaim_unused(vi); 84 | +#endif 85 | unregister_hotcpu_notifier(&vi->nb); 86 | 87 | /* Make sure no work handler is accessing the device. */ 88 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--41100--50b00: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 032e1ac10a30..7e92e484d0ab 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -212,6 +212,10 @@ struct virtnet_info { 6 | unsigned long guest_offloads; 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 | @@ -308,6 +312,11 @@ 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 | + 25 | if (napi->weight) 26 | virtqueue_napi_schedule(napi, vq); 27 | else 28 | @@ -1277,6 +1286,18 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 29 | unsigned int received, qp; 30 | bool xdp_xmit = false; 31 | 32 | +#ifdef DEV_NETMAP 33 | + int work_done = 0; 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 | virtnet_poll_cleantx(rq); 45 | 46 | received = virtnet_receive(rq, budget, &xdp_xmit); 47 | @@ -1300,8 +1321,14 @@ static int virtnet_open(struct net_device *dev) 48 | { 49 | struct virtnet_info *vi = netdev_priv(dev); 50 | int i, err; 51 | +#ifdef DEV_NETMAP 52 | + int ok = virtio_netmap_init_buffers(vi); 53 | +#endif 54 | 55 | for (i = 0; i < vi->max_queue_pairs; i++) { 56 | +#ifdef DEV_NETMAP 57 | + if (!ok) 58 | +#endif 59 | if (i < vi->curr_queue_pairs) 60 | /* Make sure we have some buffers: if oom use wq. */ 61 | if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL)) 62 | @@ -2871,6 +2898,10 @@ static int virtnet_probe(struct virtio_device *vdev) 63 | 64 | virtnet_set_queues(vi, vi->curr_queue_pairs); 65 | 66 | +#ifdef DEV_NETMAP 67 | + virtio_netmap_attach(vi); 68 | +#endif 69 | + 70 | /* Assume link up if device can't report link status, 71 | otherwise get link status from config. */ 72 | netif_carrier_off(dev); 73 | @@ -2921,7 +2952,14 @@ static void remove_vq_common(struct virtnet_info *vi) 74 | static void virtnet_remove(struct virtio_device *vdev) 75 | { 76 | struct virtnet_info *vi = vdev->priv; 77 | +#ifdef DEV_NETMAP 78 | + /* Save the pointer, will go away after netmap_detach(). */ 79 | + struct netmap_adapter *token = NA(vi->dev); 80 | 81 | + netmap_detach(vi->dev); 82 | + virtio_netmap_clean_used_rings(vi, token); 83 | + virtio_netmap_reclaim_unused(vi); 84 | +#endif 85 | virtnet_cpu_notif_remove(vi); 86 | 87 | /* Make sure no work handler is accessing the device. */ 88 | @@ -2988,6 +3026,9 @@ static unsigned int features_legacy[] = { 89 | VIRTNET_FEATURES, 90 | VIRTIO_NET_F_GSO, 91 | VIRTIO_F_ANY_LAYOUT, 92 | +#ifdef VIRTIO_NET_F_PTNETMAP 93 | + VIRTIO_NET_F_PTNETMAP, 94 | +#endif 95 | }; 96 | 97 | static struct virtio_driver virtio_net_driver = { 98 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--virtio_net.c--60c00--99999: -------------------------------------------------------------------------------- 1 | diff --git a/virtio_net.c b/virtio_net.c 2 | index 53a038fcbe99..37fd3e5fa584 100644 3 | --- a/virtio_net.c 4 | +++ b/virtio_net.c 5 | @@ -483,6 +483,10 @@ struct virtnet_info { 6 | u64 device_stats_cap; 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_v1_hash hdr; 15 | /* 16 | @@ -734,6 +738,11 @@ 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 | + 25 | if (napi->weight) 26 | virtqueue_napi_schedule(napi, vq); 27 | else 28 | @@ -2838,6 +2847,18 @@ static int virtnet_poll(struct napi_struct *napi, int budget) 29 | unsigned int xdp_xmit = 0; 30 | bool napi_complete; 31 | 32 | +#ifdef DEV_NETMAP 33 | + int work_done = 0; 34 | + int nm_irq = netmap_rx_irq(vi->dev, vq2rxq(rq->vq), &work_done); 35 | + 36 | + if (nm_irq == NM_IRQ_COMPLETED) { 37 | + nm_napi_complete(napi); 38 | + return 1; 39 | + } else if (nm_irq == NM_IRQ_RESCHED) { 40 | + return budget; 41 | + } 42 | +#endif 43 | + 44 | virtnet_poll_cleantx(rq, budget); 45 | 46 | received = virtnet_receive(rq, budget, &xdp_xmit); 47 | @@ -2933,6 +2954,15 @@ static int virtnet_open(struct net_device *dev) 48 | { 49 | struct virtnet_info *vi = netdev_priv(dev); 50 | int i, err; 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].vq, &vi->rq[i].napi); 57 | + return 0; 58 | + } 59 | +#endif 60 | 61 | enable_delayed_refill(vi); 62 | 63 | @@ -6677,6 +6707,9 @@ static int virtnet_probe(struct virtio_device *vdev) 64 | vi->device_stats_cap = le64_to_cpu(v); 65 | } 66 | 67 | +#ifdef DEV_NETMAP 68 | + virtio_netmap_attach(vi); 69 | +#endif 70 | /* Assume link up if device can't report link status, 71 | otherwise get link status from config. */ 72 | netif_carrier_off(dev); 73 | @@ -6737,7 +6770,14 @@ static void remove_vq_common(struct virtnet_info *vi) 74 | static void virtnet_remove(struct virtio_device *vdev) 75 | { 76 | struct virtnet_info *vi = vdev->priv; 77 | +#ifdef DEV_NETMAP 78 | + /* Save the pointer, will go away after netmap_detach(). */ 79 | + struct netmap_adapter *token = NA(vi->dev); 80 | 81 | + netmap_detach(vi->dev); 82 | + virtio_netmap_clean_used_rings(vi, token); 83 | + virtio_netmap_reclaim_unused(vi); 84 | +#endif 85 | virtnet_cpu_notif_remove(vi); 86 | 87 | /* Make sure no work handler is accessing the device. */ 88 | @@ -6819,6 +6859,9 @@ static unsigned int features_legacy[] = { 89 | VIRTNET_FEATURES, 90 | VIRTIO_NET_F_GSO, 91 | VIRTIO_F_ANY_LAYOUT, 92 | +#ifdef VIRTIO_NET_F_PTNETMAP 93 | + VIRTIO_NET_F_PTNETMAP, 94 | +#endif 95 | }; 96 | 97 | static struct virtio_driver virtio_net_driver = { 98 | -------------------------------------------------------------------------------- /LINUX/final-patches/vanilla--vmxnet3--31000--40d00: -------------------------------------------------------------------------------- 1 | diff --git a/vmxnet3/vmxnet3_drv.c b/vmxnet3/vmxnet3_drv.c 2 | old mode 100644 3 | new mode 100755 4 | index b76f7dcde0db..f87199abe09e 5 | --- a/vmxnet3/vmxnet3_drv.c 6 | +++ b/vmxnet3/vmxnet3_drv.c 7 | @@ -308,6 +308,11 @@ static u32 get_bitfield32(const __le32 *bitfield, u32 pos, u32 size) 8 | #endif /* __BIG_ENDIAN_BITFIELD */ 9 | 10 | 11 | +#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) || defined(DEV_NETMAP) 12 | +#include "if_vmxnet3_netmap.h" 13 | +#endif 14 | + 15 | + 16 | static void 17 | vmxnet3_unmap_tx_buf(struct vmxnet3_tx_buf_info *tbi, 18 | struct pci_dev *pdev) 19 | @@ -367,6 +372,14 @@ vmxnet3_tq_tx_complete(struct vmxnet3_tx_queue *tq, 20 | int completed = 0; 21 | union Vmxnet3_GenericDesc *gdesc; 22 | 23 | +#ifdef DEV_NETMAP 24 | + struct net_device *netdev = adapter->netdev; 25 | + 26 | + if (netmap_tx_irq(netdev, 0) != NM_IRQ_PASS) 27 | + return 0; 28 | +#endif 29 | + 30 | + 31 | gdesc = tq->comp_ring.base + tq->comp_ring.next2proc; 32 | while (VMXNET3_TCD_GET_GEN(&gdesc->tcd) == tq->comp_ring.gen) { 33 | completed += vmxnet3_unmap_pkt(VMXNET3_TCD_GET_TXIDX( 34 | @@ -1164,6 +1177,15 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, 35 | struct Vmxnet3_RxDesc rxCmdDesc; 36 | struct Vmxnet3_RxCompDesc rxComp; 37 | #endif 38 | + 39 | +#ifdef DEV_NETMAP 40 | + u_int total_packets = 0; 41 | + struct net_device *netdev = adapter->netdev; 42 | + 43 | + if (netmap_rx_irq(netdev, 0, &total_packets) != NM_IRQ_PASS) 44 | + return 1; 45 | +#endif /* DEV_NETMAP */ 46 | + 47 | vmxnet3_getRxComp(rcd, &rq->comp_ring.base[rq->comp_ring.next2proc].rcd, 48 | &rxComp); 49 | while (rcd->gen == rq->comp_ring.gen) { 50 | @@ -2262,6 +2284,10 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter) 51 | adapter->rx_queue[0].rx_ring[0].size, 52 | adapter->rx_queue[0].rx_ring[1].size); 53 | 54 | +#ifdef DEV_NETMAP 55 | + vmxnet3_netmap_init_buffers(adapter); 56 | +#endif /* DEV_NETMAP */ 57 | + 58 | vmxnet3_tq_init_all(adapter); 59 | err = vmxnet3_rq_init_all(adapter); 60 | if (err) { 61 | @@ -3103,6 +3129,11 @@ vmxnet3_probe_device(struct pci_dev *pdev, 62 | goto err_register; 63 | } 64 | 65 | + 66 | +#ifdef DEV_NETMAP 67 | + vmxnet3_netmap_attach(adapter); 68 | +#endif /* DEV_NETMAP */ 69 | + 70 | vmxnet3_check_link(adapter, false); 71 | return 0; 72 | 73 | @@ -3154,6 +3185,10 @@ vmxnet3_remove_device(struct pci_dev *pdev) 74 | 75 | unregister_netdev(netdev); 76 | 77 | +#ifdef DEV_NETMAP 78 | + vmxnet3_netmap_detach(netdev); 79 | +#endif /* DEV_NETMAP */ 80 | + 81 | vmxnet3_free_intr_resources(adapter); 82 | vmxnet3_free_pci_resources(adapter); 83 | #ifdef VMXNET3_RSS 84 | -------------------------------------------------------------------------------- /LINUX/intel-fix.sh_: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd $1 4 | 5 | [ -e common.mk ] || exit 0 6 | 7 | patch -p1 <|#include "linux/auxiliary_bus.h"|' *_client.h || true 24 | fi 25 | -------------------------------------------------------------------------------- /LINUX/mlx5-prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | KSRC=$1 4 | 5 | if [ -e mlx5/config.mk ]; then 6 | exit 0 7 | fi 8 | 9 | cd mlx5 10 | scripts/mlnx_en_patch.sh -s $KSRC -j$(grep -c processor /proc/cpuinfo) 11 | -------------------------------------------------------------------------------- /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 extdrv-versions.mak 2 | -include default-config.mak 3 | -include config.mak 4 | -include drivers.mak 5 | 6 | %@vars: FORCE 7 | $(foreach v,$(filter $*@%,$(.VARIABLES)),drv_$(patsubst $*@%,%,$(v))='$($(v))';)true 8 | 9 | FORCE: 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /LINUX/virtio_net.mak: -------------------------------------------------------------------------------- 1 | ifneq ($(KERNELRELEASE),) 2 | 3 | # virtio_net_src.c is just a symbolic link to virtio_net.c 4 | # This workaround is needed because when defining modulename-y 5 | # it is not possible to have a source called "modulename.c". 6 | # Note that this is a problem only when NETMAP_DRIVER_SUFFIX 7 | # is empty. 8 | obj-m := virtio_net$(NETMAP_DRIVER_SUFFIX).o 9 | virtio_net$(NETMAP_DRIVER_SUFFIX)-y := virtio_net_src.o 10 | 11 | else 12 | 13 | KSRC ?= /lib/modules/$(shell uname -r)/build 14 | 15 | all: virtio_net.c 16 | $(MAKE) -C "${KSRC}" M=$(shell pwd) modules 17 | 18 | install: 19 | $(MAKE) -C "${KSRC}" M=$(shell pwd) modules_install 20 | 21 | clean: 22 | $(MAKE) -C "${KSRC}" M=$(shell pwd) clean 23 | 24 | endif 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | Reporting a Vulnerability 2 | ========================= 3 | 4 | Please report suspected vulnerabilities to giuseppe.lettieri@unipi.it. You will receive a response as soon as possible. 5 | Patches will target the master branch. 6 | -------------------------------------------------------------------------------- /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/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.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 | 25 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 26 | 27 | 28 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 29 | 30 | 31 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 32 | 33 | 34 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 35 | 36 | -------------------------------------------------------------------------------- /WINDOWS/netmap.inf: -------------------------------------------------------------------------------- 1 | ; 2 | ; Netmap.inf 3 | ; 4 | 5 | [Version] 6 | Signature="$WINDOWS NT$" 7 | Class=System 8 | ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} 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.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | CN="WDKTestCert Ali,131544860236513530" | ECEA8629ADED6CB0522E374EB5072BC9D2D865C9 5 | 6 | 7 | TestSign 8 | 9 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/nm-ndis-pkg.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {8E41214B-6785-4CFE-B992-037D68949A14} 6 | inf;inv;inx;mof;mc; 7 | 8 | 9 | -------------------------------------------------------------------------------- /WINDOWS/nm-ndis/nm-ndis-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 | 25 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 26 | 27 | 28 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 29 | 30 | 31 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 32 | 33 | 34 | CN="WDKTestCert Ali,131544860649071360" | 10000FDB00D12EF1C204354F46F27C83B8A54118 35 | 36 | -------------------------------------------------------------------------------- /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 | 22 | TestSign 23 | 24 | 25 | TestSign 26 | 27 | -------------------------------------------------------------------------------- /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 bridge-b 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 -I$(SRCDIR)/libnetmap 15 | CFLAGS += -Wextra 16 | 17 | LDFLAGS += -L $(BUILDDIR)/build-libnetmap 18 | LDLIBS += -lnetmap 19 | ifeq ($(shell uname),Linux) 20 | LDLIBS += -lrt # on linux 21 | endif 22 | 23 | PREFIX ?= /usr/local 24 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 25 | 26 | all: $(PROGS) 27 | 28 | clean: 29 | -@rm -rf $(CLEANFILES) 30 | 31 | .PHONY: install 32 | install: $(PROGS:%=install-%) 33 | 34 | install-%: 35 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 36 | -install -D -m 644 $(SRCDIR)/apps/bridge/bridge.8 $(DESTDIR)/$(MAN_PREFIX)/man8/bridge.8 37 | 38 | bridge-b: bridge-b.o 39 | 40 | bridge-b.o: bridge.c 41 | $(CC) $(CFLAGS) -DBUSYWAIT -c $^ -o $@ 42 | -------------------------------------------------------------------------------- /apps/dedup/GNUmakefile: -------------------------------------------------------------------------------- 1 | # For multiple programs using a single source file each, 2 | # we can just define 'progs' and create custom targets. 3 | PROGS = dedup 4 | LIBNETMAP = 5 | 6 | CLEANFILES = $(PROGS) *.o 7 | 8 | SRCDIR ?= ../.. 9 | VPATH = $(SRCDIR)/apps/dedup 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 | #CFLAGS += -DDEDUP_HASH_STAT 17 | 18 | LDLIBS += -lpthread 19 | ifeq ($(shell uname),Linux) 20 | LDLIBS += -lrt # on linux 21 | endif 22 | 23 | PREFIX ?= /usr/local 24 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 25 | 26 | all: $(PROGS) 27 | 28 | dedup: dedup.o dedup-main.o 29 | 30 | dedup.o: dedup.h 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 | -install -D -m 644 $(SRCDIR)/apps/lb/lb.8 $(DESTDIR)/$(MAN_PREFIX)/man8/lb.8 41 | -------------------------------------------------------------------------------- /apps/dedup/dedup.h: -------------------------------------------------------------------------------- 1 | #ifndef DEDUP_H_ 2 | #define DEDUP_H_ 3 | 4 | #ifndef _BSD_SOURCE 5 | #define _BSD_SOURCE 6 | #endif 7 | #include 8 | #include 9 | 10 | struct dedup_ptr { 11 | unsigned long r; /* free running, wraps naturally */ 12 | unsigned short o; /* wraps at out_ring-size */ 13 | unsigned short f; /* wraps at fifo_size */ 14 | }; 15 | 16 | struct dedup_fifo_entry { 17 | struct timeval arrival; 18 | unsigned short hashmap_entry; 19 | unsigned int bucket_next; /* collision chain */ 20 | }; 21 | 22 | struct dedup_hashmap_entry { 23 | int valid; 24 | #ifdef DEDUP_HASH_STAT 25 | unsigned int bucket_size; 26 | #endif 27 | unsigned long bucket_head; 28 | }; 29 | 30 | struct dedup { 31 | /* input ring */ 32 | struct netmap_ring *in_ring; 33 | struct netmap_slot *in_slot; 34 | int in_memid; 35 | 36 | /* output ring */ 37 | struct netmap_ring *out_ring; 38 | struct netmap_slot *out_slot; 39 | int out_memid; 40 | 41 | /* fifo */ 42 | struct dedup_fifo_entry *fifo; 43 | struct netmap_ring *fifo_ring; 44 | struct netmap_slot *fifo_slot; 45 | int fifo_memid; 46 | 47 | /* pointers */ 48 | struct dedup_ptr *next_to_send; 49 | struct dedup_ptr fifo_in; 50 | struct dedup_ptr fifo_out; 51 | 52 | /* hash map */ 53 | struct dedup_hashmap_entry *hashmap; 54 | unsigned int hashmap_mask; 55 | 56 | /* configuration */ 57 | unsigned int fifo_size; 58 | struct timeval win_size; 59 | int zcopy_in_out; 60 | }; 61 | 62 | int dedup_init(struct dedup *d, unsigned int fifo_size, struct netmap_ring *in, 63 | struct netmap_ring *out); 64 | uint32_t dedup_set_fifo_buffers(struct dedup *d, struct netmap_ring *ring, uint32_t buf_head); 65 | void dedup_get_fifo_buffers(struct dedup *d, struct netmap_ring *ring, uint32_t *buf_head); 66 | 67 | static inline void dedup_ptr_inc(struct dedup *d, struct dedup_ptr *p) 68 | { 69 | p->r++; 70 | p->o++; 71 | if (unlikely(p->o >= d->out_ring->num_slots)) 72 | p->o = 0; 73 | p->f++; 74 | if (unlikely(p->f >= d->fifo_size)) 75 | p->f = 0; 76 | } 77 | 78 | int dedup_push_in(struct dedup *d, const struct timeval *now); 79 | 80 | void dedup_fini(struct dedup *d); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /apps/include/ctrs.h: -------------------------------------------------------------------------------- 1 | #ifndef CTRS_H_ 2 | #define CTRS_H_ 3 | 4 | /* $FreeBSD$ */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /* counters to accumulate statistics */ 11 | struct my_ctrs { 12 | uint64_t pkts, bytes, events; 13 | uint64_t drop, drop_bytes; 14 | uint64_t min_space; 15 | struct timeval t; 16 | uint32_t oq_n; /* number of elements in overflow queue (used in lb) */ 17 | }; 18 | 19 | /* very crude code to print a number in normalized form. 20 | * Caller has to make sure that the buffer is large enough. 21 | */ 22 | static const char * 23 | norm2(char *buf, double val, const char *fmt, int normalize) 24 | { 25 | const char *units[] = { "", "K", "M", "G", "T" }; 26 | u_int i; 27 | if (normalize) 28 | for (i = 0; val >=1000 && i < sizeof(units)/sizeof(const char *) - 1; i++) 29 | val /= 1000; 30 | else 31 | i=0; 32 | sprintf(buf, fmt, val, units[i]); 33 | return buf; 34 | } 35 | 36 | static __inline const char * 37 | norm(char *buf, double val, int normalize) 38 | { 39 | if (normalize) 40 | return norm2(buf, val, "%.3f %s", normalize); 41 | else 42 | return norm2(buf, val, "%.0f %s", normalize); 43 | } 44 | 45 | static __inline int 46 | timespec_ge(const struct timespec *a, const struct timespec *b) 47 | { 48 | 49 | if (a->tv_sec > b->tv_sec) 50 | return (1); 51 | if (a->tv_sec < b->tv_sec) 52 | return (0); 53 | if (a->tv_nsec >= b->tv_nsec) 54 | return (1); 55 | return (0); 56 | } 57 | 58 | static __inline struct timespec 59 | timeval2spec(const struct timeval *a) 60 | { 61 | struct timespec ts = { 62 | .tv_sec = a->tv_sec, 63 | .tv_nsec = a->tv_usec * 1000 64 | }; 65 | return ts; 66 | } 67 | 68 | static __inline struct timeval 69 | timespec2val(const struct timespec *a) 70 | { 71 | struct timeval tv = { 72 | .tv_sec = a->tv_sec, 73 | .tv_usec = a->tv_nsec / 1000 74 | }; 75 | return tv; 76 | } 77 | 78 | 79 | static __inline struct timespec 80 | timespec_add(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 >= 1000000000) { 84 | ret.tv_sec++; 85 | ret.tv_nsec -= 1000000000; 86 | } 87 | return ret; 88 | } 89 | 90 | static __inline struct timespec 91 | timespec_sub(struct timespec a, struct timespec b) 92 | { 93 | struct timespec ret = { a.tv_sec - b.tv_sec, a.tv_nsec - b.tv_nsec }; 94 | if (ret.tv_nsec < 0) { 95 | ret.tv_sec--; 96 | ret.tv_nsec += 1000000000; 97 | } 98 | return ret; 99 | } 100 | 101 | static __inline uint64_t 102 | wait_for_next_report(struct timeval *prev, struct timeval *cur, 103 | int report_interval) 104 | { 105 | struct timeval delta; 106 | 107 | delta.tv_sec = report_interval/1000; 108 | delta.tv_usec = (report_interval%1000)*1000; 109 | if (select(0, NULL, NULL, NULL, &delta) < 0 && errno != EINTR) { 110 | perror("select"); 111 | abort(); 112 | } 113 | gettimeofday(cur, NULL); 114 | timersub(cur, prev, &delta); 115 | return delta.tv_sec* 1000000 + delta.tv_usec; 116 | } 117 | #endif /* CTRS_H_ */ 118 | 119 | -------------------------------------------------------------------------------- /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 -I $(SRCDIR)/libnetmap 15 | CFLAGS += -Wextra 16 | 17 | LDFLAGS += -L $(BUILDDIR)/build-libnetmap 18 | LDLIBS += -lnetmap -lpthread -lm 19 | ifeq ($(shell uname),Linux) 20 | LDLIBS += -lrt # on linux 21 | endif 22 | 23 | PREFIX ?= /usr/local 24 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 25 | 26 | all: $(PROGS) 27 | 28 | lb: lb.o pkt_hash.o 29 | 30 | clean: 31 | -@rm -rf $(CLEANFILES) 32 | 33 | .PHONY: install 34 | install: $(PROGS:%=install-%) 35 | 36 | install-%: 37 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 38 | -install -D -m 644 $(SRCDIR)/apps/lb/lb.8 $(DESTDIR)/$(MAN_PREFIX)/man8/lb.8 39 | -------------------------------------------------------------------------------- /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 -I $(SRCDIR)/libnetmap 15 | CFLAGS += -Wextra 16 | 17 | LDFLAGS += -L $(BUILDDIR)/build-libnetmap 18 | LDLIBS += -lnetmap -lpthread 19 | ifeq ($(shell uname),Linux) 20 | LDLIBS += -lrt # on linux 21 | endif 22 | 23 | PREFIX ?= /usr/local 24 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 25 | 26 | all: $(PROGS) 27 | 28 | testlock: testlock.c 29 | 30 | nmreplay: LDLIBS += -lm 31 | 32 | clean: 33 | -@rm -rf $(CLEANFILES) 34 | 35 | .PHONY: install install-docs 36 | install: $(PROGS:%=install-%) 37 | 38 | install-%: 39 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 40 | -install -D -m 644 $(SRCDIR)/apps/nmreplay/nmreplay.8 $(DESTDIR)/$(MAN_PREFIX)/man8/nmreplay.8 41 | -------------------------------------------------------------------------------- /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 -I $(SRCDIR)/libnetmap 15 | CFLAGS += -Wextra -Wno-address-of-packed-member 16 | 17 | LDFLAGS += -L $(BUILDDIR)/build-libnetmap 18 | LDLIBS += -lpthread -lm -lnetmap 19 | ifeq ($(shell uname),Linux) 20 | LDLIBS += -lrt # on linux 21 | endif 22 | 23 | ifdef WITH_PCAP 24 | LDLIBS += -lpcap 25 | else 26 | CFLAGS += -DNO_PCAP 27 | endif 28 | 29 | PREFIX ?= /usr/local 30 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 31 | 32 | all: $(PROGS) 33 | 34 | clean: 35 | -@rm -rf $(CLEANFILES) 36 | 37 | .PHONY: install 38 | install: $(PROGS:%=install-%) 39 | 40 | install-%: 41 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 42 | -install -D -m 644 $(SRCDIR)/apps/pkt-gen/pkt-gen.8 $(DESTDIR)/$(MAN_PREFIX)/man8/pkt-gen.8 43 | 44 | pkt-gen-b: pkt-gen-b.o 45 | 46 | pkt-gen-b.o: pkt-gen.c 47 | $(CC) $(CFLAGS) -DBUSYWAIT -c $^ -o $@ 48 | -------------------------------------------------------------------------------- /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 -g 13 | CFLAGS += -Werror -Wall -Wunused-function -Wno-address-of-packed-member 14 | CFLAGS += -I $(SRCDIR)/sys -I $(SRCDIR)/apps/include -I$(SRCDIR)/libnetmap 15 | CFLAGS += -Wextra 16 | 17 | LDFLAGS += -L $(BUILDDIR)/build-libnetmap 18 | LDLIBS += -lnetmap -lpthread 19 | ifeq ($(shell uname),Linux) 20 | LDLIBS += -lrt # on linux 21 | endif 22 | 23 | PREFIX ?= /usr/local 24 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 25 | 26 | all: $(PROGS) 27 | 28 | testlock: testlock.c 29 | 30 | tlem: LDLIBS += -lm 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 | -install -D -m 644 $(SRCDIR)/apps/tlem/tlem.8 $(DESTDIR)/$(MAN_PREFIX)/man8/tlem.8 41 | -------------------------------------------------------------------------------- /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 -I $(SRCDIR)/libnetmap 15 | CFLAGS += -Wextra 16 | 17 | LDFLAGS += -L $(BUILDDIR)/build-libnetmap 18 | LDLIBS = -lnetmap 19 | PREFIX ?= /usr/local 20 | MAN_PREFIX = $(if $(filter-out /,$(PREFIX)),$(PREFIX),/usr)/share/man 21 | 22 | all: $(PROGS) 23 | 24 | clean: 25 | -@rm -rf $(CLEANFILES) 26 | 27 | .PHONY: install 28 | install: $(PROGS:%=install-%) 29 | 30 | install-%: 31 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 32 | -install -D -m 644 $(SRCDIR)/apps/vale-ctl/vale-ctl.4 $(DESTDIR)/$(MAN_PREFIX)/man4/vale-ctl.4 33 | -------------------------------------------------------------------------------- /ci/run-integration-tests: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | 3 | sudo modprobe netmap 4 | sudo make unitest 5 | sudo rmmod netmap 6 | 7 | # Run integration tests 8 | sudo make intest 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libnetmap/GNUmakefile: -------------------------------------------------------------------------------- 1 | SRCDIR ?= ../ 2 | PREFIX ?= usr/local 3 | CFLAGS=-O2 -pipe -Wall -Werror 4 | CFLAGS +=-g 5 | CFLAGS += -I $(SRCDIR)/sys 6 | VPATH = $(SRCDIR)/libnetmap 7 | SRCS=$(notdir $(wildcard $(SRCDIR)/libnetmap/*.c)) 8 | OBJS=$(SRCS:.c=.o) 9 | 10 | all: libnetmap.a 11 | 12 | $(OBJS): libnetmap.h 13 | 14 | libnetmap.a: $(OBJS) 15 | $(AR) r $@ $^ 16 | 17 | .PHONY: clean distclean install 18 | clean: 19 | rm -f *.o 20 | 21 | distclean: clean 22 | rm -f libnetmap.a 23 | 24 | install: 25 | install -D libnetmap.a $(DESTDIR)/$(PREFIX)/lib/libnetmap.a 26 | 27 | +%: 28 | @echo $*=$($*) 29 | -------------------------------------------------------------------------------- /libnetmap/nmctx-pthreads.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 | * 4 | * Copyright (C) 2018 Universita` di Pisa 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include "libnetmap.h" 44 | 45 | struct nmctx_pthread { 46 | struct nmctx up; 47 | pthread_mutex_t mutex; 48 | }; 49 | 50 | static struct nmctx_pthread nmctx_pthreadsafe; 51 | 52 | static void 53 | nmctx_pthread_lock(struct nmctx *ctx, int lock) 54 | { 55 | struct nmctx_pthread *ctxp = 56 | (struct nmctx_pthread *)ctx; 57 | if (lock) { 58 | pthread_mutex_lock(&ctxp->mutex); 59 | } else { 60 | pthread_mutex_unlock(&ctxp->mutex); 61 | } 62 | } 63 | 64 | void __attribute__ ((constructor)) 65 | nmctx_set_threadsafe(void) 66 | { 67 | struct nmctx *old; 68 | 69 | pthread_mutex_init(&nmctx_pthreadsafe.mutex, NULL); 70 | old = nmctx_set_default(&nmctx_pthreadsafe.up); 71 | nmctx_pthreadsafe.up = *old; 72 | nmctx_pthreadsafe.up.lock = nmctx_pthread_lock; 73 | } 74 | 75 | int nmctx_threadsafe; 76 | -------------------------------------------------------------------------------- /pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if git rev-parse --verify HEAD >/dev/null 2>&1 4 | then 5 | against=HEAD 6 | else 7 | # Initial commit: diff against an empty tree object 8 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 9 | fi 10 | 11 | # If you want to allow non-ASCII filenames set this variable to true. 12 | allownonascii=$(git config --bool hooks.allownonascii) 13 | 14 | # Redirect output to stderr. 15 | exec 1>&2 16 | 17 | # Cross platform projects tend to avoid non-ASCII filenames; prevent 18 | # them from being added to the repository. We exploit the fact that the 19 | # printable range starts at the space character and ends with tilde. 20 | if [ "$allownonascii" != "true" ] && 21 | # Note that the use of brackets around a tr range is ok here, (it's 22 | # even required, for portability to Solaris 10's /usr/bin/tr), since 23 | # the square bracket bytes happen to fall in the designated range. 24 | test $(git diff --cached --name-only --diff-filter=A -z $against | 25 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 26 | then 27 | cat <<\EOF 28 | Error: Attempt to add a non-ASCII file name. 29 | 30 | This can cause problems if you want to work with people on other platforms. 31 | 32 | To be portable it is advisable to rename the file. 33 | 34 | If you know what you are doing you can disable this check using: 35 | 36 | git config hooks.allownonascii true 37 | EOF 38 | exit 1 39 | fi 40 | 41 | ########### netmap specific checks ############ 42 | files="sys/dev/netmap/netmap_vale.c sys/dev/netmap/netmap_monitor.c sys/dev/netmap/netmap_pipe.c sys/dev/netmap/netmap.c sys/dev/netmap/netmap_generic.c sys/dev/netmap/netmap_freebsd.c sys/dev/netmap/netmap_legacy.c LINUX/netmap_linux.c LINUX/bsd_glue.h LINUX/i40e_netmap_linux.h LINUX/if_e1000_netmap.h LINUX/if_e1000e_netmap.h LINUX/if_igb_netmap.h LINUX/if_re_netmap_linux.h LINUX/ixgbe_netmap_linux.h LINUX/veth_netmap.h LINUX/virtio_netmap.h LINUX/netmap_ptnet.c LINUX/forcedeth_netmap.h apps/bridge/bridge.c apps/lb/lb.c apps/vale-ctl/vale-ctl.c apps/dedup/dedup.c apps/include/ctrs.h" 43 | 44 | for f in $files; do 45 | ERR=$(git grep --line-number "^\( \)\+" $f | head -n1) 46 | if [ "$ERR" != "" ]; then 47 | echo "Wrong indentation in $f" 48 | echo "$ERR" 49 | exit 1 50 | fi 51 | done 52 | 53 | for f in $files; do 54 | ERR=$(git grep --line-number " \+$" $f | head -n1) 55 | if [ "$ERR" != "" ]; then 56 | echo "Trailing whitespaces in $f" 57 | echo "$ERR" 58 | exit 1 59 | fi 60 | done 61 | 62 | for f in $files; do 63 | ERR=$(git grep --line-number "^[$(printf '\t') ]\+$" $f | head -n1) 64 | if [ "$ERR" != "" ]; then 65 | echo "Line with only spaces or tabs in $f" 66 | echo "$ERR" 67 | exit 1 68 | fi 69 | done 70 | ########### end of netmap specific checks ############ 71 | 72 | # If there are whitespace errors, print the offending file names and fail. 73 | exec git diff-index --check --cached $against ":(exclude)LINUX/final-patches" 74 | -------------------------------------------------------------------------------- /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 -D VIMAGE 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_kloop.c 24 | SRCS += netmap_legacy.c 25 | SRCS += netmap_bdg.c 26 | SRCS += netmap_null.c 27 | SRCS += if_ptnet.c 28 | SRCS += opt_inet.h opt_inet6.h 29 | 30 | .include 31 | -------------------------------------------------------------------------------- /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 functional ctrl-api-test fd_server 4 | PROGS += functional-legacy fd_server-legacy 5 | PROGS += get_avail_tx_packets get_max_tx_packets extmem-example sync_kloop_test 6 | X86PROGS = testlock testcsum producer 7 | LIBNETMAP = 8 | 9 | CLEANFILES = $(PROGS) $(X86PROGS) *.o 10 | 11 | SRCDIR ?= .. 12 | PREFIX ?= usr/local 13 | VPATH = $(SRCDIR)/utils 14 | 15 | NO_MAN= 16 | CFLAGS = -O2 -pipe 17 | CFLAGS += -Werror -Wall -Wunused-function 18 | CFLAGS += -I $(SRCDIR)/sys # -I/home/luigi/FreeBSD/head/sys -I../sys 19 | CFLAGS += -I $(SRCDIR)/libnetmap 20 | CFLAGS += -Wextra -g 21 | CFLAGS += $(SUBSYS_FLAGS) 22 | ifdef WITH_PCAP 23 | # do not use pcap by default, as it is not always available on linux 24 | LDLIBS += -lpcap 25 | else 26 | CFLAGS += -DNO_PCAP 27 | endif 28 | 29 | ifdef BUILDDIR 30 | LDFLAGS += -L $(BUILDDIR)/build-libnetmap 31 | else 32 | LDFLAGS += -L $(SRCDIR)/libnetmap 33 | endif 34 | LDLIBS += -lnetmap -lpthread -lm 35 | ifeq ($(shell uname),Linux) 36 | LDLIBS += -lrt # on linux 37 | endif 38 | #SRCS = pkt-gen.c 39 | 40 | PREFIX ?= /usr/local 41 | 42 | .PHONY: install clean all-x86 all inttest 43 | 44 | all: $(PROGS) 45 | 46 | inttest: 47 | $(shell if [ "$(shell uname)" = "Linux" ] ; then modprobe netmap ;fi) 48 | ./randomized_tests 49 | 50 | all-x86: $(PROGS) $(X86PROGS) 51 | 52 | kern_test: testmod/kern_test.c 53 | 54 | clean: 55 | -@rm -rf $(CLEANFILES) 56 | 57 | testlock: testlock.c 58 | 59 | install: $(PROGS:%=install-%) 60 | 61 | install-%: 62 | install -D $* $(DESTDIR)/$(PREFIX)/bin/$* 63 | -------------------------------------------------------------------------------- /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$ 2 | 3 | This directory contains miscellaneous programs related to netmap 4 | 5 | ctrl-api-test.c suite of unit tests for the netmap control ABI 6 | sync_kloop_test.c example program for the CSB mode with sync-kloop 7 | extmem-example.c example program for the extmem feature 8 | producer.c transmitter example with constant per-packet 9 | work 10 | testmmap.c test program for interactively test the netmap 11 | control ABI (open, mmap, NIOCREGIF, NIOCGETINFO) 12 | test_nm.c example program for nm_inject and nm_dispatch 13 | fd_server.[ch] helper program for integration tests 14 | get_avail_tx_packets.c " 15 | get_max_tx_packets.c " 16 | functional.c " 17 | tests/ suite of integration tests (shell scripts) 18 | test_lib helper shell functions for integration tests 19 | randomized_tests script to run all the integration tests 20 | switch-modules/ (old) patches for Open VSwitch to use netmap 21 | click-test.cfg (old) simple click example 22 | testcsum.c (old) benchmarks for checksum computation 23 | testlock.c (old) benchmarks for locks and concurrency 24 | test_select.c (old) benchmarks for select() and poll() 25 | testmod/ (old) benchmarks for FreeBSD kernel 26 | -------------------------------------------------------------------------------- /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/fd_server-legacy.h: -------------------------------------------------------------------------------- 1 | #ifndef FD_LIB_H 2 | #define FD_LIB_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define SOCKET_NAME "/tmp/netmap-fdserver-legacy" 9 | 10 | struct fd_request { 11 | #define FD_GET 1 12 | #define FD_RELEASE 2 13 | #define FD_CLOSE 3 14 | #define FD_STOP 4 15 | uint8_t action; 16 | char if_name[NETMAP_REQ_IFNAMSIZ]; 17 | }; 18 | 19 | struct fd_response { 20 | int32_t result; 21 | struct nmreq req; 22 | }; 23 | 24 | int send_fd(int socket, int fd, void *buf, size_t buf_size); 25 | 26 | int recv_fd(int socket, int *fd, void *buf, size_t buf_size); 27 | 28 | #endif /* FD_LIB_H */ 29 | -------------------------------------------------------------------------------- /utils/fd_server.h: -------------------------------------------------------------------------------- 1 | #ifndef FD_LIB_H 2 | #define FD_LIB_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define SOCKET_NAME "/tmp/netmap-fdserver" 9 | 10 | struct fd_request { 11 | #define FD_GET 1 12 | #define FD_RELEASE 2 13 | #define FD_CLOSE 3 14 | #define FD_STOP 4 15 | uint8_t action; 16 | char if_name[NETMAP_REQ_IFNAMSIZ]; 17 | }; 18 | 19 | struct fd_response { 20 | int32_t result; 21 | struct nmreq_header hdr; 22 | struct nmreq_register reg; 23 | }; 24 | 25 | int send_fd(int socket, int fd, void *buf, size_t buf_size); 26 | 27 | int recv_fd(int socket, int *fd, void *buf, size_t buf_size); 28 | 29 | #endif /* FD_LIB_H */ 30 | -------------------------------------------------------------------------------- /utils/get_avail_tx_packets.c: -------------------------------------------------------------------------------- 1 | /* Given an interface name and a packet length (optional), prints to stdout 2 | * the maximum number of packets (each within that length) that fits in the 3 | * currently available TX slots. If the packet length is not specified, it 4 | * is assumed that any packet to be transmitted fits within a single netmap 5 | * slot, hence printing the number of available TX slots. 6 | * On error, "-1" is printed. 7 | * Arguments: 8 | * $1 -> interface name 9 | * $2 -> packet length 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #define NETMAP_WITH_LIBS 18 | #include 19 | 20 | uint64_t 21 | slots_per_packet(struct netmap_ring *ring, unsigned pkt_len) 22 | { 23 | return (uint64_t)(ceil((double)pkt_len / (double)ring->nr_buf_size)); 24 | } 25 | 26 | uint64_t 27 | ring_avail_tx_packets(struct netmap_ring *ring, unsigned pkt_len) 28 | { 29 | if (pkt_len == 0) { 30 | return nm_ring_space(ring); 31 | } 32 | 33 | return nm_ring_space(ring) / slots_per_packet(ring, pkt_len); 34 | } 35 | 36 | uint64_t 37 | nmport_avail_tx_packets(struct nm_desc *nmd, unsigned pkt_len) 38 | { 39 | uint64_t total = 0; 40 | unsigned int i; 41 | 42 | for (i = nmd->first_tx_ring; i <= nmd->last_tx_ring; i++) { 43 | struct netmap_ring *ring = NETMAP_TXRING(nmd->nifp, i); 44 | 45 | total += ring_avail_tx_packets(ring, pkt_len); 46 | } 47 | 48 | return total; 49 | } 50 | 51 | int 52 | main(int argc, char **argv) 53 | { 54 | uint64_t avail_tx_packets; 55 | struct nm_desc *nmd; 56 | const char *if_name; 57 | uint64_t pkt_len; 58 | 59 | if (argc == 2) { 60 | pkt_len = 0; 61 | } else if (argc == 3) { 62 | pkt_len = atoi(argv[2]); 63 | if (pkt_len == 0) { 64 | printf("-1"); 65 | exit(EXIT_FAILURE); 66 | } 67 | } else { 68 | printf("-1"); 69 | exit(EXIT_FAILURE); 70 | } 71 | 72 | fclose(stderr); 73 | if_name = argv[1]; 74 | nmd = nm_open(if_name, NULL, 0, NULL); 75 | if (nmd == NULL) { 76 | printf("-1"); 77 | exit(EXIT_FAILURE); 78 | } 79 | 80 | avail_tx_packets = nmport_avail_tx_packets(nmd, pkt_len); 81 | printf("%" PRId64, avail_tx_packets); 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /utils/get_max_tx_packets.c: -------------------------------------------------------------------------------- 1 | /* Given an interface name and a packet length (optional), prints to stdout 2 | * the maximum number of packets (each within that length) that fits in the 3 | * transmit rings, assuming they are all empty. If the packet length is not 4 | * specified, it is assumed that any packet to be transmitted fits within a 5 | * single netmap slot, hence printing the total number of TX slots. 6 | * On error, "-1" is printed. 7 | * Arguments: 8 | * $1 -> interface name 9 | * $2 -> packet length 10 | */ 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #define NETMAP_WITH_LIBS 17 | #include 18 | 19 | uint64_t 20 | slots_per_packet(struct netmap_ring *ring, unsigned pkt_len) 21 | { 22 | return (uint64_t)(ceil((double)pkt_len / (double)ring->nr_buf_size)); 23 | } 24 | 25 | uint64_t 26 | ring_max_tx_packets(struct netmap_ring *ring, unsigned pkt_len) 27 | { 28 | if (pkt_len == 0) { 29 | return nm_ring_space(ring) - 1; 30 | } 31 | 32 | return (ring->num_slots - 1) / slots_per_packet(ring, pkt_len); 33 | } 34 | 35 | uint64_t 36 | nmport_max_tx_packets(struct nm_desc *nmd, unsigned pkt_len) 37 | { 38 | uint64_t total = 0; 39 | unsigned int i; 40 | 41 | for (i = nmd->first_tx_ring; i <= nmd->last_tx_ring; i++) { 42 | struct netmap_ring *ring = NETMAP_TXRING(nmd->nifp, i); 43 | 44 | total += ring_max_tx_packets(ring, pkt_len); 45 | } 46 | 47 | return total; 48 | } 49 | 50 | int 51 | main(int argc, char **argv) 52 | { 53 | uint64_t max_tx_packets; 54 | struct nm_desc *nmd; 55 | const char *if_name; 56 | uint64_t pkt_len; 57 | 58 | if (argc == 2) { 59 | pkt_len = 0; 60 | } else if (argc == 3) { 61 | pkt_len = atoi(argv[2]); 62 | if (pkt_len == 0) { 63 | printf("-1"); 64 | exit(EXIT_FAILURE); 65 | } 66 | } else { 67 | printf("-1"); 68 | exit(EXIT_FAILURE); 69 | } 70 | 71 | fclose(stderr); 72 | if_name = argv[1]; 73 | nmd = nm_open(if_name, NULL, 0, NULL); 74 | if (nmd == NULL) { 75 | printf("-1"); 76 | exit(EXIT_FAILURE); 77 | } 78 | 79 | max_tx_packets = nmport_max_tx_packets(nmd, pkt_len); 80 | printf("%" PRId64, max_tx_packets); 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /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 | 18 | int 19 | main(int argc, char *argv[]) 20 | { 21 | struct timeval ta, tb, prev; 22 | int usec = 1, total = 0, method = M_SELECT; 23 | uint32_t *vals = NULL; 24 | uint32_t i, count = 0; 25 | #define LIM 1000000 26 | 27 | if (argc > 1) 28 | usec = atoi(argv[1]); 29 | if (usec <= 0) 30 | usec = 1; 31 | else if (usec > 500000) 32 | usec = 500000; 33 | if (argc > 2) { 34 | if (!strcmp(argv[2], "poll")) 35 | method = M_POLL; 36 | else if (!strcmp(argv[2], "usleep")) 37 | method = M_USLEEP; 38 | } 39 | if (argc > 3) 40 | total = atoi(argv[3]); 41 | if (total < 1) 42 | total = 1; 43 | else if (total > 10) 44 | total = 10; 45 | fprintf(stderr, "testing %s for %dus over %ds\n", 46 | names[method], usec, total); 47 | 48 | gettimeofday(&ta, NULL); 49 | prev = ta; 50 | vals = calloc(LIM, sizeof(uint32_t)); 51 | for (;;) { 52 | if (method == M_SELECT) { 53 | struct timeval to = { 0, usec }; 54 | select(0, NULL, NULL, NULL, &to); 55 | } else if (method == M_POLL) { 56 | poll(NULL, 0, usec/1000); 57 | } else { 58 | usleep(usec); 59 | } 60 | gettimeofday(&tb, NULL); 61 | timersub(&tb, &prev, &prev); 62 | if (count < LIM) 63 | vals[count] = prev.tv_usec; 64 | count++; 65 | prev = tb; 66 | timersub(&tb, &ta, &tb); 67 | if (tb.tv_sec > total) 68 | break; 69 | } 70 | fprintf(stderr, "%dus actually took %dus\n", 71 | usec, (int)(tb.tv_sec * 1000000 + tb.tv_usec) / count ); 72 | for (i = 0; i < count && i < LIM; i++) 73 | fprintf(stdout, "%d\n", vals[i]); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /utils/tests/001_exclusive_open_ephemeral_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check that an ephemeral VALE port opened with the exclusive 4 | # flag can't be opened again. 5 | ################################################################################ 6 | source test_lib 7 | 8 | parse_send_recv_arguments "$@" 9 | verbosity="${verbosity:-}" 10 | 11 | bridge="vale0" 12 | port="v0" 13 | 14 | # We open ${bridge}:${port} with the exclusive flag from the file descriptor. 15 | $FUNCTIONAL $verbosity -i "${bridge}:${port}/x" 16 | check_success $? "exclusive-open ${bridge}:${port}/x" 17 | 18 | # Then we open the same interface again, this time without requesting it from 19 | # the file descriptor, causing a second nm_open(). 20 | $FUNCTIONAL $verbosity -I "${bridge}:${port}" 21 | check_failure $? "no-open ${bridge}:${port}" 22 | 23 | # Check that another exclusive open request fails. 24 | $FUNCTIONAL $verbosity -I "${bridge}:${port}/x" 25 | check_failure $? "no-open ${bridge}:${port}/x" 26 | -------------------------------------------------------------------------------- /utils/tests/002_exclusive_open_persistent_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check that an persistent VALE port opened with the exclusive 4 | # flag can't be opened again. 5 | ################################################################################ 6 | source test_lib 7 | 8 | parse_send_recv_arguments "$@" 9 | verbosity="${verbosity:-}" 10 | 11 | bridge="vale0" 12 | port="v0" 13 | 14 | create_vale_persistent_port "$port" 15 | attach_to_vale_bridge "$bridge" "$port" 16 | 17 | # We open the persistent port with the exclusive flag from the file descriptor. 18 | $FUNCTIONAL $verbosity -i "${bridge}:${port}/x" 19 | check_success $? "exclusive-open ${bridge}:${port}/x" 20 | 21 | # Then we open the same interface again, this time without requesting it from 22 | # the file descriptor, causing a second nm_open(). 23 | $FUNCTIONAL $verbosity -I "${bridge}:${port}" 24 | check_failure $? "no-open ${bridge}:${port}" 25 | 26 | # Check that another exclusive open request fails. 27 | $FUNCTIONAL $verbosity -I "${bridge}:${port}/x" 28 | check_failure $? "no-open ${bridge}:${port}/x" 29 | -------------------------------------------------------------------------------- /utils/tests/003_exclusive_open_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check that a netmap pipe opened with the exclusive flag can't 4 | # be opened again. 5 | ################################################################################ 6 | source test_lib 7 | 8 | parse_send_recv_arguments "$@" 9 | verbosity="${verbosity:-}" 10 | 11 | pipe="pipeA{1" 12 | 13 | # We open pipeA{1 with the exclusive flag from the file descriptor. 14 | $FUNCTIONAL $verbosity -i "netmap:${pipe}/x" 15 | check_success $? "exclusive-open netmap:${pipe}/x" 16 | 17 | # Then we open the same interface again, this time without requesting it from 18 | # the file descriptor, causing a second nm_open(). 19 | $FUNCTIONAL $verbosity -I "netmap:${pipe}" 20 | check_failure $? "no-open netmap:${pipe}" 21 | 22 | # Check that another exclusive open request fails. 23 | $FUNCTIONAL $verbosity -I "netmap:${pipe}/x" 24 | check_failure $? "no-open netmap:${pipe}/x" 25 | -------------------------------------------------------------------------------- /utils/tests/004_extra_buf_send_rec_ephemeral_vale_ports_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if we can send packets through ephimeral VALE ports 4 | # while using extra buffers. 5 | # Operations: 6 | # 1) send from vale0:v0 using extra buffers, and check that both, vale0:v1 and 7 | # vale0:v2, receive. 8 | ################################################################################ 9 | source test_lib 10 | 11 | parse_send_recv_arguments "$@" 12 | verbosity="${verbosity:-}" 13 | fill="${fill:-c}" 14 | len="${len:-274}" 15 | num="${num:-1}" 16 | seq="${seq:-}" 17 | 18 | e_buf_num="${e_buf_num:-12}" 19 | 20 | # Pre-opening interface that will be needed. This is needed to avoid a race 21 | # condition between the sending and receiving ports. 22 | $FUNCTIONAL $verbosity -i "vale0:v1" 23 | check_success $? "pre-open vale0:v1" 24 | $FUNCTIONAL $verbosity -i "vale0:v2" 25 | check_success $? "pre-open vale0:v2" 26 | 27 | # v0 ---> v1, v2 28 | $FUNCTIONAL $verbosity -i "vale0:v1" -r "${len}:${fill}:${num}" $seq & 29 | p1=$! 30 | $FUNCTIONAL $verbosity -i "vale0:v2" -r "${len}:${fill}:${num}" $seq & 31 | p2=$! 32 | $FUNCTIONAL $verbosity -I "vale0:v0" -t "${len}:${fill}:${num}" -e "$e_buf_num" $seq 33 | e3=$? 34 | wait $p1 35 | e1=$? 36 | wait $p2 37 | e2=$? 38 | check_success $e1 "receive-${num} vale0:v1" 39 | check_success $e2 "receive-${num} vale0:v2" 40 | check_success $e3 "send-${num} vale0:v0" 41 | -------------------------------------------------------------------------------- /utils/tests/005_extra_buf_send_rec_persistent_vale_ports_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if we can send packets through persistent VALE ports 4 | # while using extra buffers. 5 | # Operations: 6 | # 1) create 3 persistent VALE ports (v0, v1, v2) and attach them to vale0. 7 | # 2) send from vale0:v2 using extra buffers, and check that both, vale0:v0 and 8 | # vale0:v1, receive. 9 | ################################################################################ 10 | source test_lib 11 | 12 | parse_send_recv_arguments "$@" 13 | verbosity="${verbosity:-}" 14 | fill="${fill:-c}" 15 | len="${len:-274}" 16 | num="${num:-1}" 17 | seq="${seq:-}" 18 | 19 | e_buf_num="${e_buf_num:-12}" 20 | 21 | create_vale_persistent_port "v0" 22 | create_vale_persistent_port "v1" 23 | create_vale_persistent_port "v2" 24 | attach_to_vale_bridge "vale0" "v0" 25 | attach_to_vale_bridge "vale0" "v1" 26 | attach_to_vale_bridge "vale0" "v2" 27 | # Pre-opening interface that will be needed. This is needed to avoid a race 28 | # condition between the sending and receiving ports. 29 | $FUNCTIONAL $verbosity -i "vale0:v0" 30 | check_success $? "pre-open vale0:v0" 31 | $FUNCTIONAL $verbosity -i "vale0:v1" 32 | check_success $? "pre-open vale0:v1" 33 | 34 | # v2 ---> v0, v1 35 | $FUNCTIONAL $verbosity -i "vale0:v0" -r "${len}:${fill}:${num}" $seq & 36 | p1=$! 37 | $FUNCTIONAL $verbosity -i "vale0:v1" -r "${len}:${fill}:${num}" $seq & 38 | p2=$! 39 | $FUNCTIONAL $verbosity -I "vale0:v2" -t "${len}:${fill}:${num}" -e "$e_buf_num" $seq 40 | e3=$? 41 | wait $p1 42 | e1=$? 43 | wait $p2 44 | e2=$? 45 | check_success $e1 "receive-${num} vale0:v0" 46 | check_success $e2 "receive-${num} vale0:v1" 47 | check_success $e3 "send-${num} vale0:v2" 48 | -------------------------------------------------------------------------------- /utils/tests/006_extra_buf_send_rec_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if we can send packets through netmap pipes while using 4 | # extra buffers. 5 | # Operations: 6 | # 1) create a pair of netmap pipes (pipeA{1, pipeA}1). 7 | # 2) send from pipeA{1 using extra buffers and check if pipeA}1 receives. 8 | ################################################################################ 9 | source test_lib 10 | 11 | parse_send_recv_arguments "$@" 12 | verbosity="${verbosity:-}" 13 | fill="${fill:-c}" 14 | len="${len:-274}" 15 | num="${num:-1}" 16 | seq="${seq:-}" 17 | 18 | e_buf_num="${e_buf_num:-12}" 19 | 20 | # Pre-opening interface that will be needed. This is needed to avoid a race 21 | # condition between the sending and receiving ports. 22 | $FUNCTIONAL $verbosity -i "netmap:pipeA{1" 23 | check_success $? "pre-open netmap:pipeA{1" 24 | 25 | # pipeA}1 ---> pipeA{1 26 | $FUNCTIONAL $verbosity -i "netmap:pipeA{1" -r "${len}:${fill}:${num}" $seq & 27 | p1=$! 28 | $FUNCTIONAL $verbosity -I "netmap:pipeA}1" -t "${len}:${fill}:${num}" -e "$e_buf_num" $seq 29 | e2=$? 30 | wait $p1 31 | e1=$? 32 | check_success $e1 "receive-${num} netmap:pipeA{1" 33 | check_success $e2 "send-${num} netmap:pipeA}1" 34 | -------------------------------------------------------------------------------- /utils/tests/007_learning_bridge_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if the switch learning algorithm is working. 4 | # Operations: 5 | # 1) connect 3 ephemeral VALE ports (v0, v1, v2) to the same VALE switch. 6 | # 2) send from v2 specifying a source MAC address and check that v0 and v1 7 | # receive the frame. 8 | # 3) send from v0 using the previous MAC address as the destination MAC address 9 | # and check that v2 receives the frame while v1 does not. 10 | ################################################################################ 11 | source test_lib 12 | 13 | parse_send_recv_arguments "$@" 14 | verbosity="${verbosity:-}" 15 | fill="${fill:-d}" 16 | len="${len:-150}" 17 | 18 | s_MAC=$(get_random_MAC) 19 | d_MAC="FF:FF:FF:FF:FF:FF" 20 | 21 | # Pre-opening interface that will be needed. This is needed to avoid a race 22 | # condition between the sending and receiving ports. 23 | $FUNCTIONAL $verbosity -i vale0:v0 24 | check_success $? "pre-open vale0:v0" 25 | $FUNCTIONAL $verbosity -i vale0:v1 26 | check_success $? "pre-open vale0:v1" 27 | $FUNCTIONAL $verbosity -i vale0:v2 28 | check_success $? "pre-open vale0:v2" 29 | 30 | # First send, every port should receive the frame. 31 | $FUNCTIONAL $verbosity -i vale0:v0 -r "${len}:${fill}" -s "$s_MAC" -d "$d_MAC" & 32 | p1=$! 33 | $FUNCTIONAL $verbosity -i vale0:v1 -r "${len}:${fill}" -s "$s_MAC" -d "$d_MAC" & 34 | p2=$! 35 | $FUNCTIONAL $verbosity -i vale0:v2 -t "${len}:${fill}" -s "$s_MAC" -d "$d_MAC" 36 | e3=$? 37 | wait $p1 38 | e1=$? 39 | wait $p2 40 | e2=$? 41 | check_success $e1 "receive vale0:v0" 42 | check_success $e2 "receive vale0:v1" 43 | check_success $e3 "send vale0:v2" 44 | 45 | # Second send, only v2 should receive the frame. 46 | $FUNCTIONAL $verbosity -i vale0:v2 -r "${len}:${fill}" -d "$s_MAC" & 47 | p4=$! 48 | $FUNCTIONAL $verbosity -i vale0:v1 -r "${len}:${fill}" -d "$s_MAC" -n & 49 | p5=$! 50 | $FUNCTIONAL $verbosity -i vale0:v0 -t "${len}:${fill}" -d "$s_MAC" 51 | e6=$? 52 | wait $p4 53 | e4=$? 54 | wait $p5 55 | e5=$? 56 | check_success $e1 "receive vale0:v0" 57 | check_success $e2 "receive vale0:v1" 58 | check_success $e3 "send vale0:v2" 59 | -------------------------------------------------------------------------------- /utils/tests/008_partial_read_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check that if the receiving pipe receives less than the 4 | # sending pipe sent, the non-received slot are left inside the 5 | # sending pipe ring. 6 | # Operations: 7 | # 1) create a pair of netmap pipes (pipe{1, pipe}1). 8 | # 2) send X packets to pipe}1 and receive X-Y packets from pipe{1. 9 | # 2) check that pipe{1 still has X-Y slots pending for transmission. 10 | ################################################################################ 11 | source test_lib 12 | 13 | parse_send_recv_arguments "$@" 14 | verbosity="${verbosity:-}" 15 | seq="${seq:-}" 16 | 17 | fill='h' 18 | len=274 19 | num_send=10 20 | num_recv=7 21 | pipe="pipeA" 22 | 23 | # Pre-open netmap ports for the test. This is needed to avoid a race 24 | # condition between the sending and receiving ports. 25 | $FUNCTIONAL $verbosity -i "netmap:${pipe}{1" 26 | check_success $? "pre-open netmap:${pipe}{1" 27 | $FUNCTIONAL $verbosity -i "netmap:${pipe}}1" 28 | check_success $? "pre-open netmap:${pipe}}1" 29 | 30 | $FUNCTIONAL $verbosity -i "netmap:${pipe}{1" -r "${len}:${fill}:${num_recv}" $seq & 31 | p1=$! 32 | $FUNCTIONAL $verbosity -i "netmap:${pipe}}1" -t "${len}:${fill}:${num_send}" $seq 33 | e2=$? 34 | wait $p1 35 | e1=$? 36 | check_success $e1 "receive-7 netmap:${pipe}{1" 37 | check_success $e2 "send-10 netmap:${pipe}}1" 38 | 39 | # At the moment get_max_tx_packets and get_avail_tx_packets do not get the 40 | # netmap port fd from fd_server. They request it directly through nm_open(). 41 | # However, they still read the correct values stored inside each struct 42 | # netmap ring, because the netmap ports have not been closed in the meanwhile. 43 | exit_status=0 44 | max_packets=$(get_max_tx_packets "netmap:${pipe}}1" "$len") 45 | if [ "$max_packets" == -1 ] ; then 46 | exit_status=1 47 | fi 48 | check_success $exit_status "get_max_tx_packets netmap:${pipe}}1 $len" 49 | 50 | exit_status=0 51 | avail_packets=$(get_avail_tx_packets "netmap:${pipe}}1" "$len") 52 | if [ "$avail_packets" == -1 ] ; then 53 | exit_status=1 54 | fi 55 | check_success $exit_status "get_avail_tx_packets netmap:${pipe}}1 $len" 56 | 57 | exit_status=0 58 | pending_packets="$(($max_packets - $avail_packets))" 59 | pending_transmissions="$(($num_send - $num_recv))" 60 | if [ $pending_packets != $pending_transmissions ] ; then 61 | exit_status=1 62 | fi 63 | check_exit $pending_transmissions $pending_packets "pending_transmissions=pending_packets" 64 | 65 | num_send="$(($avail_packets + 1))" 66 | $FUNCTIONAL $verbosity -i "netmap:${pipe}}1" -t "${len}:${fill}:${num_send}" $seq 67 | check_failure $? "send-${num_send} netmap:${pipe}}1" 68 | -------------------------------------------------------------------------------- /utils/tests/009_persistent_vale_port_destroy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check that we can't create two persistent VALE ports with the 4 | # same name. 5 | ################################################################################ 6 | source test_lib 7 | 8 | parse_send_recv_arguments "$@" 9 | verbosity="${verbosity:-}" 10 | 11 | bridge="vale0" 12 | bridgeA="${bridge}A" 13 | bridgeB="${bridge}B" 14 | port="v0" 15 | 16 | create_vale_persistent_port "$port" 0 17 | destroy_vale_persistent_port "$port" 0 18 | 19 | create_vale_persistent_port "$port" 0 20 | 21 | attach_to_vale_bridge "$bridgeA" "$port" 0 22 | destroy_vale_persistent_port "$port" 1 23 | 24 | attach_to_vale_bridge "$bridgeB" "$port" 0 25 | destroy_vale_persistent_port "$port" 1 26 | 27 | detach_from_vale_bridge "$bridgeB" "$port" 0 28 | destroy_vale_persistent_port "$port" 1 29 | 30 | detach_from_vale_bridge "$bridgeA" "$port" 0 31 | destroy_vale_persistent_port "$port" 0 32 | -------------------------------------------------------------------------------- /utils/tests/010_persistent_vale_port_double_attach: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check that a persistent VALE port can't be attached 2 times 4 | # to the same VALE bridge, but can be attached to 2 different 5 | # bridges. 6 | ################################################################################ 7 | source test_lib 8 | 9 | parse_send_recv_arguments "$@" 10 | verbosity="${verbosity:-}" 11 | 12 | bridge="vale0" 13 | bridgeA="${bridge}A" 14 | bridgeB="${bridge}B" 15 | port="v0" 16 | 17 | create_vale_persistent_port "$port" 0 18 | attach_to_vale_bridge "$bridgeA" "$port" 0 19 | attach_to_vale_bridge "$bridgeA" "$port" 1 20 | attach_to_vale_bridge "$bridgeB" "$port" 0 21 | -------------------------------------------------------------------------------- /utils/tests/011_persistent_vale_port_double_create: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check that we can't create two persistent VALE ports with the 4 | # same name. 5 | ################################################################################ 6 | source test_lib 7 | 8 | parse_send_recv_arguments "$@" 9 | verbosity="${verbosity:-}" 10 | 11 | bridge="vale0" 12 | bridgeA="${bridge}A" 13 | bridgeB="${bridge}B" 14 | port="v0" 15 | 16 | create_vale_persistent_port "$port" 0 17 | create_vale_persistent_port "$port" 1 18 | 19 | attach_to_vale_bridge "$bridgeA" "$port" 0 20 | create_vale_persistent_port "$port" 1 21 | 22 | attach_to_vale_bridge "$bridgeB" "$port" 0 23 | create_vale_persistent_port "$port" 1 24 | -------------------------------------------------------------------------------- /utils/tests/012_rec_cp_mon_ephemeral_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a receive copy monitor receives frames when its 4 | # monitored ephemeral VALE port is receiving, even if the 5 | # monitored port hasn't yet read the frame. 6 | # Operations: 7 | # 1) connect two ephemeral VALE ports (v0, v1) to the same VALE switch. 8 | # 2) open a receiving copy monitor vo/r for v0. 9 | # 3) send from v1 and don't read from v0, check that v0/r receives the frame. 10 | # 4) receive from v0. 11 | ################################################################################ 12 | source test_lib 13 | 14 | parse_send_recv_arguments "$@" 15 | verbosity="${verbosity:-}" 16 | fill="${fill:-d}" 17 | len="${len:-150}" 18 | num="${num:-1}" 19 | seq="${seq:-}" 20 | 21 | # Pre-opening interface that will be needed. This is needed to avoid a race 22 | # condition between the sending and receiving ports. 23 | $FUNCTIONAL $verbosity -i vale0:v0 24 | check_success $? "pre-open vale0:v0" 25 | $FUNCTIONAL $verbosity -i vale0:v0/r 26 | check_success $? "pre-open vale0:v0/r" 27 | $FUNCTIONAL $verbosity -i vale0:v1 28 | check_success $? "pre-open vale0:v1" 29 | 30 | # First we send without reading from v0 31 | $FUNCTIONAL $verbosity -i vale0:v0/r -r "${len}:${fill}:${num}" $seq & 32 | p1=$! 33 | $FUNCTIONAL $verbosity -i vale0:v1 -t "${len}:${fill}:${num}" $seq 34 | e2=$? 35 | wait $p1 36 | e1=$? 37 | check_success $e1 "receive-${num} vale0:v0/r" 38 | check_success $e2 "send-${num} vale0:v1" 39 | 40 | # Then we read from v0 41 | $FUNCTIONAL $verbosity -i vale0:v0 -r "${len}:${fill}:${num}" $seq 42 | e3=$? 43 | check_success $e3 "receive-${num} vale0:v0" 44 | -------------------------------------------------------------------------------- /utils/tests/013_rec_cp_mon_persistent_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a receive copy monitor receives frames when its 4 | # monitored persistent VALE port is receiving, even if the 5 | # monitored port hasn't yet read the frame. 6 | # Operations: 7 | # 1) create a persistent VALE port (v0). 8 | # 2) connect v0 and a VALE ephimeral port (v1) to the same VALE switch. 9 | # 3) open a receiving copy monitor vo/r for v0. 10 | # 4) send from v1 and don't read from v0, check that v0/r receives the frame. 11 | # 5) receive from v0. 12 | ################################################################################ 13 | source test_lib 14 | 15 | parse_send_recv_arguments "$@" 16 | verbosity="${verbosity:-}" 17 | fill="${fill:-d}" 18 | len="${len:-150}" 19 | num="${num:-1}" 20 | seq="${seq:-}" 21 | 22 | create_vale_persistent_port "v0" 23 | attach_to_vale_bridge "vale0" "v0" 24 | # Pre-opening interface that will be needed. This is needed to avoid a race 25 | # condition between the sending and receiving ports. 26 | $FUNCTIONAL $verbosity -i vale0:v0 27 | check_success $? "pre-open vale0:v0" 28 | $FUNCTIONAL $verbosity -i netmap:v0/r 29 | check_success $? "pre-open netmap:v0/r" 30 | $FUNCTIONAL $verbosity -i vale0:v1 31 | check_success $? "pre-open vale0:v1" 32 | 33 | # First we send without reading from v0 34 | $FUNCTIONAL $verbosity -i netmap:v0/r -r "${len}:${fill}:${num}" $seq & 35 | p1=$! 36 | $FUNCTIONAL $verbosity -i vale0:v1 -t "${len}:${fill}:${num}" $seq 37 | e2=$? 38 | wait $p1 39 | e1=$? 40 | check_success $e1 "receive-${num} netmap:v0/r" 41 | check_success $e2 "send-${num} vale0:v1" 42 | 43 | # Then we read from v0 44 | $FUNCTIONAL $verbosity -i vale0:v0 -r "${len}:${fill}:${num}" $seq 45 | e3=$? 46 | check_success $e3 "receive-${num} vale0:v0" 47 | -------------------------------------------------------------------------------- /utils/tests/014_rec_cp_mon_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a receive copy monitor receives frames when its 4 | # monitored netmap pipe is receiving, even if the monitored pipe 5 | # hasn't yet read the frame. 6 | # Operations: 7 | # 1) create a pair of netmap pipes (pipe{1, pipe}1). 8 | # 2) open a receive copy monitor pipe{1/r for pipe{1. 9 | # 3) send from pipe}1 and don't read from pipe{1, check that pipe{1/r receives 10 | # the frame. 11 | # 4) receive from pipe{1. 12 | ################################################################################ 13 | source test_lib 14 | 15 | parse_send_recv_arguments "$@" 16 | verbosity="${verbosity:-}" 17 | fill="${fill:-d}" 18 | len="${len:-150}" 19 | num="${num:-1}" 20 | seq="${seq:-}" 21 | 22 | # Pre-opening interface that will be needed. This is needed to avoid a race 23 | # condition between the sending and receiving ports. 24 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" 25 | check_success $? "pre-open netmap:pipe{1" 26 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/r" 27 | check_success $? "pre-open netmap:pipe{1/r" 28 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" 29 | check_success $? "pre-open netmap:pipe}1" 30 | 31 | # First we send without reading from pipe{1 32 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/r" -r "${len}:${fill}:${num}" $seq & 33 | p1=$! 34 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" -t "${len}:${fill}:${num}" $seq 35 | e2=$? 36 | wait $p1 37 | e1=$? 38 | check_success $e1 "receive-${num}${seq} netmap:pipe{1/r" 39 | check_success $e2 "send-${num}${seq} netmap:pipe}1" 40 | 41 | # Then we read from pipe{1 42 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" -r "${len}:${fill}:${num}" $seq 43 | e3=$? 44 | check_success $e3 "receive-${num}${seq} netmap:pipe{1" 45 | -------------------------------------------------------------------------------- /utils/tests/015_rec_zcp_mon_ephemeral_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a zero-copy monitor is correctly blocked until the 4 | # monitored ephemeral VALE port reads the frame. 5 | # Operations: 6 | # 1) connect two ephemeral VALE ports (v0, v1) to the same VALE switch. 7 | # 2) open a zero-copy monitor v0/z for v0. 8 | # 3) send from v1 without receiving from v0, check that v0/z doesn't receive the 9 | # rame. 10 | # 4) receive from v0, check that v0/z receives the frame. 11 | ################################################################################ 12 | source test_lib 13 | 14 | parse_send_recv_arguments "$@" 15 | verbosity="${verbosity:-}" 16 | fill="${fill:-d}" 17 | len="${len:-150}" 18 | num="${num:-1}" 19 | seq="${seq:-}" 20 | 21 | # Pre-opening interface that will be needed. This is needed to avoid a race 22 | # condition between the sending and receiving ports. 23 | $FUNCTIONAL $verbosity -i "vale0:v0" 24 | check_success $? "pre-open vale0:v0" 25 | $FUNCTIONAL $verbosity -i "vale0:v0/z" 26 | check_success $? "pre-open vale0:v0/z" 27 | $FUNCTIONAL $verbosity -i "vale0:v1" 28 | check_success $? "pre-open vale0:v1" 29 | 30 | # Initially we don't receive with the monitored VALE port v0, therefore the 31 | # monitor should not receive the frame. 32 | $FUNCTIONAL $verbosity -i vale0:v0/z -r "${len}:${fill}:${num}" $seq -n & 33 | p1=$! 34 | $FUNCTIONAL $verbosity -i vale0:v1 -t "${len}:${fill}:${num}" $seq 35 | e2=$? 36 | wait $p1 37 | e1=$? 38 | check_success $e1 "no-receive-${num} vale0:v0/z" 39 | check_success $e2 "send-${num} vale0:v0" 40 | 41 | # Now we receive with the monitored VALE port v0, therefore the monitor should 42 | # receive the frame. 43 | $FUNCTIONAL $verbosity -i "vale0:v0" -r "${len}:${fill}:${num}" $seq & 44 | p3=$! 45 | $FUNCTIONAL $verbosity -i "vale0:v0/z" -r "${len}:${fill}:${num}" $seq 46 | e4=$? 47 | wait $p3 48 | e3=$? 49 | check_success $e3 "receive-${num} vale0:v0" 50 | check_success $e4 "receive-${num} vale0:v0/z" 51 | -------------------------------------------------------------------------------- /utils/tests/016_rec_zcp_mon_persistent_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a zero-copy monitor is correctly blocked until the 4 | # monitored persistent VALE port reads the frame. 5 | # Operations: 6 | # 1) create a persistent VALE port (v0). 7 | # 2) connect v0 and a VALE ephimeral port (v1) to the same VALE switch (vale0). 8 | # 3) open a zero-copy monitor v0/z for v0. 9 | # 4) send from v1 without receiving from v0, check that v0/z doesn't receive the 10 | # rame. 11 | # 5) receive from v0, check that v0/z receives the frame. 12 | ################################################################################ 13 | source test_lib 14 | 15 | parse_send_recv_arguments "$@" 16 | verbosity="${verbosity:-}" 17 | fill="${fill:-d}" 18 | len="${len:-150}" 19 | num="${num:-1}" 20 | seq="${seq:-}" 21 | 22 | create_vale_persistent_port "v0" 23 | attach_to_vale_bridge "vale0" "v0" 24 | # Pre-opening interface that will be needed. This is needed to avoid a race 25 | # condition between the sending and receiving ports. 26 | $FUNCTIONAL $verbosity -i "vale0:v0" 27 | check_success $? "pre-open vale0:v0" 28 | $FUNCTIONAL $verbosity -i "netmap:v0/z" 29 | check_success $? "pre-open netmap:v0/z" 30 | $FUNCTIONAL $verbosity -i "vale0:v1" 31 | check_success $? "pre-open vale0:v1" 32 | 33 | # Initially we don't receive with the monitored VALE port v0, therefore the 34 | # monitor should not receive the frame. 35 | $FUNCTIONAL $verbosity -i netmap:v0/z -r "${len}:${fill}:${num}" $seq -n & 36 | p1=$! 37 | $FUNCTIONAL $verbosity -i vale0:v1 -t "${len}:${fill}:${num}" $seq 38 | e2=$? 39 | wait $p1 40 | e1=$? 41 | check_success $e1 "no-receive-${num} netmap:v0/z" 42 | check_success $e2 "send-${num} vale0:v0" 43 | 44 | # Now we receive with the monitored VALE port v0, therefore the monitor should 45 | # receive the frame. 46 | $FUNCTIONAL $verbosity -i "vale0:v0" -r "${len}:${fill}:${num}" $seq & 47 | p3=$! 48 | $FUNCTIONAL $verbosity -i "netmap:v0/z" -r "${len}:${fill}:${num}" $seq 49 | e4=$? 50 | wait $p3 51 | e3=$? 52 | check_success $e3 "receive-${num} vale0:v0" 53 | check_success $e4 "receive-${num} netmap:v0/z" 54 | -------------------------------------------------------------------------------- /utils/tests/017_rec_zcp_mon_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a zero-copy monitor is correctly blocked until the 4 | # monitored netmap pipe reads the frame. 5 | # Operations: 6 | # 1) create a pair of netmap pipes (pipe{1, pipe}1). 7 | # 2) open a zero-copy monitor pipe{1/z for pipe{1. 8 | # 3) send from pipe}1 without receiving from pipe{1, check that pipe{1/z doesn't 9 | # receive the frame. 10 | # 4) receive from pipe{1, check that pipe{1/z receives the frame. 11 | ################################################################################ 12 | source test_lib 13 | 14 | parse_send_recv_arguments "$@" 15 | verbosity="${verbosity:-}" 16 | fill="${fill:-d}" 17 | len="${len:-150}" 18 | num="${num:-1}" 19 | seq="${seq:-}" 20 | 21 | # Pre-opening interface that will be needed. This is needed to avoid a race 22 | # condition between the sending and receiving ports. 23 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" 24 | check_success $? "pre-open netmap:pipe{1" 25 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/z" 26 | check_success $? "pre-open netmap:pipe{1/z" 27 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" 28 | check_success $? "pre-open netmap:pipe}1" 29 | 30 | # Initially we don't receive with the monitored pipe pipe{1, therefore the 31 | # monitor should not receive the frame. 32 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/z" -r "${len}:${fill}:${num}" $seq -n & 33 | p1=$! 34 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" -t "${len}:${fill}:${num}" $seq 35 | e2=$? 36 | wait $p1 37 | e1=$? 38 | check_success $e1 "no-receive-${num} netmap:pipe{1" 39 | check_success $e2 "send-${num} netmap:pipe{1" 40 | 41 | # Now we receive with the monitored pipe pipe{1, therefore the monitor should 42 | # receive the frame. 43 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" -r "${len}:${fill}:${num}" $seq & 44 | p3=$! 45 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/z" -r "${len}:${fill}:${num}" $seq 46 | e4=$? 47 | wait $p3 48 | e3=$? 49 | check_success $e3 "receive-${num} netmap:pipe{1" 50 | check_success $e4 "receive-${num} netmap:pipe{1/z" 51 | -------------------------------------------------------------------------------- /utils/tests/018_send_cp_mon_ephemeral_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a send copy monitor receives frames when its 4 | # monitored ephemeral VALE port is sending. 5 | # Operations: 6 | # 1) create a persistent VALE port (v0). 7 | # 2) open a send copy monitor v0/t for v0. 8 | # 3) send from v0, check that both v0/t and v1 receive the frame. 9 | ################################################################################ 10 | source test_lib 11 | 12 | parse_send_recv_arguments "$@" 13 | verbosity="${verbosity:-}" 14 | fill="${fill:-d}" 15 | len="${len:-150}" 16 | num="${num:-1}" 17 | seq="${seq:-}" 18 | 19 | # Pre-opening interface that will be needed. This is needed to avoid a race 20 | # condition between the sending and receiving ports. 21 | $FUNCTIONAL $verbosity -i vale0:v0 22 | check_success $? "pre-open vale0:v0" 23 | $FUNCTIONAL $verbosity -i vale0:v0/t 24 | check_success $? "pre-open vale0:v0/t" 25 | $FUNCTIONAL $verbosity -i vale0:v1 26 | check_success $? "pre-open vale0:v1" 27 | 28 | # First we send without reading from v1 29 | $FUNCTIONAL $verbosity -i vale0:v0/t -r "${len}:${fill}:${num}" $seq & 30 | p1=$! 31 | $FUNCTIONAL $verbosity -i vale0:v0 -t "${len}:${fill}:${num}" $seq 32 | e2=$? 33 | wait $p1 34 | e1=$? 35 | check_success $e1 "receive-${num} vale0:v0/t" 36 | check_success $e2 "send-${num} vale0:v0" 37 | 38 | # Then we read from v1 39 | $FUNCTIONAL $verbosity -i vale0:v1 -r "${len}:${fill}:${num}" $seq 40 | e3=$? 41 | check_success $e3 "receive-${num} vale0:v1" 42 | -------------------------------------------------------------------------------- /utils/tests/019_send_cp_mon_persistent_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a send copy monitor receives frames when its 4 | # monitored persistent VALE port is sending. 5 | # Operations: 6 | # 1) create a persistent VALE port (v0). 7 | # 2) connect v0 and a VALE ephimeral port (v1) to the same VALE switch. 8 | # 3) open a send copy monitor v0/t for v0. 9 | # 4) send from v0, check that both v0/t and v1 receive the frame. 10 | ################################################################################ 11 | source test_lib 12 | 13 | parse_send_recv_arguments "$@" 14 | verbosity="${verbosity:-}" 15 | fill="${fill:-d}" 16 | len="${len:-150}" 17 | num="${num:-1}" 18 | seq="${seq:-}" 19 | 20 | create_vale_persistent_port "v0" 21 | attach_to_vale_bridge "vale0" "v0" 22 | # Pre-opening interface that will be needed. This is needed to avoid a race 23 | # condition between the sending and receiving ports. 24 | $FUNCTIONAL $verbosity -i vale0:v0 25 | check_success $? "pre-open vale0:v0" 26 | $FUNCTIONAL $verbosity -i netmap:v0/t 27 | check_success $? "pre-open netmap:v0/t" 28 | $FUNCTIONAL $verbosity -i vale0:v1 29 | check_success $? "pre-open vale0:v1" 30 | 31 | # First we send without reading from v1 32 | $FUNCTIONAL $verbosity -i netmap:v0/t -r "${len}:${fill}:${num}" $seq & 33 | p1=$! 34 | $FUNCTIONAL $verbosity -i vale0:v0 -t "${len}:${fill}:${num}" $seq 35 | e2=$? 36 | wait $p1 37 | e1=$? 38 | check_success $e1 "receive-${num} netmap:v0/t" 39 | check_success $e2 "send-${num} vale0:v0" 40 | 41 | # Then we read from v1 42 | $FUNCTIONAL $verbosity -i vale0:v1 -r "${len}:${fill}:${num}" $seq 43 | e3=$? 44 | check_success $e3 "receive-${num} vale0:v1" 45 | -------------------------------------------------------------------------------- /utils/tests/020_send_cp_mon_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a send copy monitor receives frames when its 4 | # monitored netmap pipe is sending, even if the non-monitored 5 | # port hasn't yet read the frame. 6 | # Operations: 7 | # 1) create a pair of netmap pipes (pipe{1, pipe}1). 8 | # 2) open a send copy monitor pipe{1/t for pipe{1. 9 | # 3) send from pipe{1 and don't read from pipe}1, check that pipe{1/t receives 10 | # the frame. 11 | # 4) receive from pipe}1. 12 | ################################################################################ 13 | source test_lib 14 | 15 | parse_send_recv_arguments "$@" 16 | verbosity="${verbosity:-}" 17 | fill="${fill:-d}" 18 | len="${len:-150}" 19 | num="${num:-1}" 20 | seq="${seq:-}" 21 | 22 | # Pre-opening interface that will be needed. This is needed to avoid a race 23 | # condition between the sending and receiving ports. 24 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" 25 | check_success $? "pre-open netmap:pipe{1" 26 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/t" 27 | check_success $? "pre-open netmap:pipe{1/t" 28 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" 29 | check_success $? "pre-open netmap:pipe}1" 30 | 31 | # First we send without reading from pipe}1 32 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/t" -r "${len}:${fill}:${num}" $seq & 33 | p1=$! 34 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" -t "${len}:${fill}:${num}" $seq 35 | e2=$? 36 | wait $p1 37 | e1=$? 38 | check_success $e1 "receive-${num} netmap:pipe{1/t" 39 | check_success $e2 "send-${num} netmap:pipe{1" 40 | 41 | # Then we read from pipe}1 42 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" -r "${len}:${fill}:${num}" $seq 43 | e3=$? 44 | check_success $e3 "receive-${num} netmap:pipe}1" 45 | -------------------------------------------------------------------------------- /utils/tests/021_send_rec_ephemeral_vale_ports_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if we can send and receive packets through ephimeral 4 | # VALE ports. 5 | # Operations: 6 | # 1) send from vale0:v2 and check that both, vale0:v0 and vale0:v1, receive. 7 | # 2) send from vale0:v0 and check that both, vale0:v1 and vale0:v2, receive. 8 | ################################################################################ 9 | source test_lib 10 | 11 | parse_send_recv_arguments "$@" 12 | verbosity="${verbosity:-}" 13 | fill="${fill:-c}" 14 | len="${len:-274}" 15 | num="${num:-1}" 16 | seq="${seq:-}" 17 | 18 | # Pre-opening interface that will be needed. This is needed to avoid a race 19 | # condition between the sending and receiving ports. 20 | $FUNCTIONAL $verbosity -i "vale0:v0" 21 | check_success $? "pre-open vale0:v0" 22 | $FUNCTIONAL $verbosity -i "vale0:v1" 23 | check_success $? "pre-open vale0:v1" 24 | $FUNCTIONAL $verbosity -i "vale0:v2" 25 | check_success $? "pre-open vale0:v2" 26 | 27 | # v2 ---> v0, v1 28 | $FUNCTIONAL $verbosity -i "vale0:v0" -r "${len}:${fill}:${num}" $seq & 29 | p1=$! 30 | $FUNCTIONAL $verbosity -i "vale0:v1" -r "${len}:${fill}:${num}" $seq & 31 | p2=$! 32 | $FUNCTIONAL $verbosity -i "vale0:v2" -t "${len}:${fill}:${num}" $seq 33 | e3=$? 34 | wait $p1 35 | e1=$? 36 | wait $p2 37 | e2=$? 38 | check_success $e1 "receive-${num} vale0:v0" 39 | check_success $e2 "receive-${num} vale0:v1" 40 | check_success $e3 "send-${num} vale0:v2" 41 | 42 | # v0 ---> v1, v2 43 | $FUNCTIONAL $verbosity -i "vale0:v1" -r "${len}:${fill}:${num}" $seq & 44 | p4=$! 45 | $FUNCTIONAL $verbosity -i "vale0:v2" -r "${len}:${fill}:${num}" $seq & 46 | p5=$! 47 | $FUNCTIONAL $verbosity -i "vale0:v0" -t "${len}:${fill}:${num}" $seq 48 | e6=$? 49 | wait $p4 50 | e4=$? 51 | wait $p5 52 | e5=$? 53 | check_success $e4 "receive-${num} vale0:v1" 54 | check_success $e5 "receive-${num} vale0:v2" 55 | check_success $e6 "send-${num} vale0:v0" 56 | -------------------------------------------------------------------------------- /utils/tests/022_send_rec_persistent_vale_ports_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if we can send and receive packets through persistent 4 | # VALE ports. 5 | # Operations: 6 | # 1) create 3 persistent VALE ports (v0, v1, v2) and attach them to vale0. 7 | # 2) send from vale0:v2 and check that both, vale0:v0 and vale0:v1, receive. 8 | # 3) send from vale0:v0 and check that both, vale0:v1 and vale0:v2, receive. 9 | ################################################################################ 10 | source test_lib 11 | 12 | parse_send_recv_arguments "$@" 13 | verbosity="${verbosity:-}" 14 | fill="${fill:-c}" 15 | len="${len:-274}" 16 | num="${num:-1}" 17 | seq="${seq:-}" 18 | 19 | create_vale_persistent_port "v0" 20 | create_vale_persistent_port "v1" 21 | create_vale_persistent_port "v2" 22 | attach_to_vale_bridge "vale0" "v0" 23 | attach_to_vale_bridge "vale0" "v1" 24 | attach_to_vale_bridge "vale0" "v2" 25 | # Pre-opening interface that will be needed. This is needed to avoid a race 26 | # condition between the sending and receiving ports. 27 | $FUNCTIONAL $verbosity -i "vale0:v0" 28 | check_success $? "pre-open vale0:v0" 29 | $FUNCTIONAL $verbosity -i "vale0:v1" 30 | check_success $? "pre-open vale0:v1" 31 | $FUNCTIONAL $verbosity -i "vale0:v2" 32 | check_success $? "pre-open vale0:v2" 33 | 34 | # v2 ---> v0, v1 35 | $FUNCTIONAL $verbosity -i "vale0:v0" -r "${len}:${fill}:${num}" $seq & 36 | p1=$! 37 | $FUNCTIONAL $verbosity -i "vale0:v1" -r "${len}:${fill}:${num}" $seq & 38 | p2=$! 39 | $FUNCTIONAL $verbosity -i "vale0:v2" -t "${len}:${fill}:${num}" $seq 40 | e3=$? 41 | wait $p1 42 | e1=$? 43 | wait $p2 44 | e2=$? 45 | check_success $e1 "receive-${num} vale0:v0" 46 | check_success $e2 "receive-${num} vale0:v1" 47 | check_success $e3 "send-${num} vale0:v2" 48 | 49 | # v0 ---> v1, v2 50 | $FUNCTIONAL $verbosity -i "vale0:v1" -r "${len}:${fill}:${num}" $seq & 51 | p4=$! 52 | $FUNCTIONAL $verbosity -i "vale0:v2" -r "${len}:${fill}:${num}" $seq & 53 | p5=$! 54 | $FUNCTIONAL $verbosity -i "vale0:v0" -t "${len}:${fill}:${num}" $seq 55 | e6=$? 56 | wait $p4 57 | e4=$? 58 | wait $p5 59 | e5=$? 60 | check_success $e4 "receive-${num} vale0:v1" 61 | check_success $e5 "receive-${num} vale0:v2" 62 | check_success $e6 "send-${num} vale0:v0" 63 | -------------------------------------------------------------------------------- /utils/tests/023_send_rec_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if we can send and receive packets through netmap pipes. 4 | # Operations: 5 | # 1) create a pair of netmap pipes (pipeA{1, pipeA}1). 6 | # 2) send from pipeA{1 and check if pipeA}1 receives. 7 | # 3) send from pipeA}1 and check if pipeA{1 receives. 8 | ################################################################################ 9 | source test_lib 10 | 11 | parse_send_recv_arguments "$@" 12 | verbosity="${verbosity:-}" 13 | fill="${fill:-c}" 14 | len="${len:-274}" 15 | num="${num:-1}" 16 | seq="${seq:-}" 17 | 18 | # Pre-opening interface that will be needed. This is needed to avoid a race 19 | # condition between the sending and receiving ports. 20 | $FUNCTIONAL $verbosity -i "netmap:pipeA{1" 21 | check_success $? "pre-open netmap:pipeA{1" 22 | $FUNCTIONAL $verbosity -i "netmap:pipeA}1" 23 | check_success $? "pre-open netmap:pipeA}1" 24 | 25 | # pipeA}1 ---> pipeA{1 26 | $FUNCTIONAL $verbosity -i "netmap:pipeA{1" -r "${len}:${fill}:${num}" $seq & 27 | p1=$! 28 | $FUNCTIONAL $verbosity -i "netmap:pipeA}1" -t "${len}:${fill}:${num}" $seq 29 | e2=$? 30 | wait $p1 31 | e1=$? 32 | check_success $e1 "receive-${num} netmap:pipeA{1" 33 | check_success $e2 "send-${num} netmap:pipeA}1" 34 | 35 | # pipeA{1 ---> pipeA}1 36 | $FUNCTIONAL $verbosity -i "netmap:pipeA}1" -r "${len}:${fill}:${num}" $seq & 37 | p3=$! 38 | $FUNCTIONAL $verbosity -i "netmap:pipeA{1" -t "${len}:${fill}:${num}" $seq 39 | e4=$? 40 | wait $p3 41 | e2=$? 42 | check_success $e2 "receive-${num} netmap:pipeA}1" 43 | check_success $e4 "send-${num} netmap:pipeA{1" 44 | -------------------------------------------------------------------------------- /utils/tests/024_send_rec_veth_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if we can send and receive through veth interfaces. 4 | # Operations: 5 | # 1) create a pair of veth interfaces (veth1A, veth1B). 6 | # 2) send from veth1B and check if veth1A receives. 7 | # 3) send from veth1A and check if veth1B receives. 8 | ################################################################################ 9 | source test_lib 10 | 11 | exit 0 # Test currently disabled. 12 | 13 | parse_send_recv_arguments "$@" 14 | verbosity="${verbosity:-}" 15 | fill="${fill:-d}" 16 | len="${len:-150}" 17 | num="${num:-1}" 18 | seq="${seq:-}" 19 | 20 | create_veth_interfaces "veth1" 21 | # Pre-opening interface that will be needed. This is needed to avoid a race 22 | # condition between the sending and receiving ports. 23 | $FUNCTIONAL $verbosity -i netmap:veth1A 24 | check_success $? "pre-open netmap:veth1A" 25 | $FUNCTIONAL $verbosity -i netmap:veth1B 26 | check_success $? "pre-open netmap:veth1B" 27 | 28 | # veth1B --> veth1A 29 | $FUNCTIONAL $verbosity -i netmap:veth1A -r "${len}:${fill}:${num}" $seq & 30 | p1=$! 31 | $FUNCTIONAL $verbosity -i netmap:veth1B -t "${len}:${fill}:${num}" $seq 32 | e2=$? 33 | wait $p1 34 | e1=$? 35 | check_success $e1 "receive-${num} netmap:veth1A" 36 | check_success $e2 "send-${num} netmap:veth1B" 37 | 38 | # veth1A --> veth1B 39 | $FUNCTIONAL $verbosity -i netmap:veth1B -r "${len}:${fill}:${num}" $seq & 40 | p3=$! 41 | $FUNCTIONAL $verbosity -i netmap:veth1A -t "${len}:${fill}:${num}" $seq 42 | e4=$? 43 | wait $p3 44 | e3=$? 45 | check_success $e3 "receive-${num} netmap:veth1B" 46 | check_success $e4 "send-${num} netmap:veth1A" 47 | -------------------------------------------------------------------------------- /utils/tests/025_send_zcp_mon_ephemeral_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a zero-copy monitor receives frames when its 4 | # monitored ephemeral VALE port is sending, even if the 5 | # destination port hasn't yet read the frame (this happens 6 | # because VALE switches do not use zero-copy). 7 | # Operations: 8 | # 1) connect two ephemeral VALE ports (v0, v1) to the same VALE switch. 9 | # 2) open a zero-copy monitor v0/z for v0. 10 | # 3) send from v0 and don't read from v1, check that v0/z receives the frame. 11 | # 4) receive from v1. 12 | ################################################################################ 13 | source test_lib 14 | 15 | parse_send_recv_arguments "$@" 16 | verbosity="${verbosity:-}" 17 | fill="${fill:-d}" 18 | len="${len:-150}" 19 | num="${num:-1}" 20 | seq="${seq:-}" 21 | 22 | # Pre-opening interface that will be needed. This is needed to avoid a race 23 | # condition between the sending and receiving ports. 24 | $FUNCTIONAL $verbosity -i vale0:v0 25 | check_success $? "pre-open vale0:v0" 26 | $FUNCTIONAL $verbosity -i vale0:v0/z 27 | check_success $? "pre-open vale0:v0/z" 28 | $FUNCTIONAL $verbosity -i vale0:v1 29 | check_success $? "pre-open vale0:v1" 30 | 31 | # First we send without reading from v1 32 | $FUNCTIONAL $verbosity -i vale0:v0/z -r "${len}:${fill}:${num}" $seq & 33 | p1=$! 34 | $FUNCTIONAL $verbosity -i vale0:v0 -t "${len}:${fill}:${num}" $seq 35 | e2=$? 36 | wait $p1 37 | e1=$? 38 | check_success $e1 "receive-${num} vale0:v0/z" 39 | check_success $e2 "send-${num} vale0:v0" 40 | 41 | # Then we read from v1 42 | $FUNCTIONAL $verbosity -i vale0:v1 -r "${len}:${fill}:${num}" $seq 43 | e3=$? 44 | check_success $e3 "receive-${num} vale0:v1" 45 | -------------------------------------------------------------------------------- /utils/tests/026_send_zcp_mon_persistent_vale_port_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a zero-copy monitor receives frames when its 4 | # monitored persistent VALE port is sending, even if the 5 | # destination port hasn't yet read the frame (this happens 6 | # because VALE switches do not use zero-copy). 7 | # Operations: 8 | # 1) create a persistent VALE port (v0). 9 | # 2) connect v0 and a VALE ephimeral port (v1) to the same VALE switch. 10 | # 3) open a zero-copy monitor v0/z for v0. 11 | # 4) send from v0 and don't read from v1, check that v0/z receives the frame. 12 | # 5) receive from v1. 13 | ################################################################################ 14 | source test_lib 15 | 16 | parse_send_recv_arguments "$@" 17 | verbosity="${verbosity:-}" 18 | fill="${fill:-d}" 19 | len="${len:-150}" 20 | num="${num:-1}" 21 | seq="${seq:-}" 22 | 23 | create_vale_persistent_port "v0" 24 | attach_to_vale_bridge "vale0" "v0" 25 | # Pre-opening interface that will be needed. This is needed to avoid a race 26 | # condition between the sending and receiving ports. 27 | $FUNCTIONAL $verbosity -i vale0:v0 28 | check_success $? "pre-open vale0:v0" 29 | $FUNCTIONAL $verbosity -i netmap:v0/z 30 | check_success $? "pre-open netmap:v0/z" 31 | $FUNCTIONAL $verbosity -i vale0:v1 32 | check_success $? "pre-open vale0:v1" 33 | 34 | # First we send without reading from v1 35 | $FUNCTIONAL $verbosity -i netmap:v0/z -r "${len}:${fill}:${num}" $seq & 36 | p1=$! 37 | $FUNCTIONAL $verbosity -i vale0:v0 -t "${len}:${fill}:${num}" $seq 38 | e2=$? 39 | wait $p1 40 | e1=$? 41 | check_success $e1 "receive-${num} netmap:v0/z" 42 | check_success $e2 "send-${num} vale0:v0" 43 | 44 | # Then we read from v1 45 | $FUNCTIONAL $verbosity -i vale0:v1 -r "${len}:${fill}:${num}" $seq 46 | e3=$? 47 | check_success $e3 "receive-${num} vale0:v1" 48 | -------------------------------------------------------------------------------- /utils/tests/027_send_zcp_mon_pipe_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################################################################ 3 | # Test objective: check if a zero-copy monitor is correctly blocked until the 4 | # non-monitored netmap pipe reads the frame (and the slot is 5 | # given back to the sending pipe). 6 | # Operations: 7 | # 1) create a pair of netmap pipes (pipe{1, pipe}1). 8 | # 2) open a zero-copy monitor pipe{1/z for pipe{1. 9 | # 3) send from pipe{1 without receiving from pipe}1, check that pipe{1/z doesn't 10 | # receive the frame. 11 | # 4) receive from pipe}1, send again from pipe{1 (slots are returned during a 12 | # txsync action) and check that pipe{1/z receives the frame. 13 | ################################################################################ 14 | source test_lib 15 | 16 | parse_send_recv_arguments "$@" 17 | verbosity="${verbosity:-}" 18 | fill="${fill:-d}" 19 | len="${len:-150}" 20 | num="${num:-1}" 21 | seq="${seq:-}" 22 | 23 | # Pre-opening interface that will be needed. This is needed to avoid a race 24 | # condition between the sending and receiving ports. 25 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" 26 | check_success $? "pre-open netmap:pipe{1" 27 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/z" 28 | check_success $? "pre-open netmap:pipe{1/z" 29 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" 30 | check_success $? "pre-open netmap:pipe}1" 31 | 32 | # Initially we don't receive with the non-monitored pipe end, therefore the 33 | # monitor should not receive the frame. 34 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/z" -r "${len}:${fill}:${num}" $seq -n & 35 | p1=$! 36 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" -t "${len}:${fill}:${num}" $seq 37 | e2=$? 38 | wait $p1 39 | e1=$? 40 | check_success $e1 "no-receive-${num} netmap:pipe{1/z" 41 | check_success $e2 "send-${num} netmap:pipe{1" 42 | 43 | # Now we receive with the non-monitored pipe end. We need to send again with the 44 | # monitored pipe otherwise the zero-copy monitor won't be able to see the 45 | # packet, as the slot is returned to the monitored pipe only during a txsync 46 | # action. 47 | $FUNCTIONAL $verbosity -i "netmap:pipe{1/z" -r "${len}:${fill}:${num}" $seq & 48 | p3=$! 49 | $FUNCTIONAL $verbosity -i "netmap:pipe}1" -r "${len}:${fill}:${num}" $seq 50 | e4=$? 51 | $FUNCTIONAL $verbosity -i "netmap:pipe{1" -t "${len}:${fill}:${num}" $seq 52 | e5=$? 53 | wait $p3 54 | e3=$? 55 | check_success $e4 "receive-${num} netmap:pipe}1" 56 | check_success $e5 "send-${num} netmap:pipe{1" 57 | check_success $e3 "receive-${num} netmap:pipe{1/z" 58 | --------------------------------------------------------------------------------