Skip to content

Commit 7e9e5e7

Browse files
Merge branch 'next' into master
2 parents 3c8d8c9 + 92110ee commit 7e9e5e7

36 files changed

+2856
-426
lines changed

LINUX/Kbuild.in

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
MODNAME:=@MODNAME@
2+
SUBSYS:=@SUBSYS@
3+
SRCDIR:=@SRCDIR@
4+
5+
# list of objects for this module
6+
#
7+
# objects whose source file is in ../sys/dev/netmap
8+
# the source is not here so we need to specify a dependency
9+
$(foreach s,$(SUBSYS),$(eval CONFIG_NETMAP_$(shell echo $s|tr a-z A-Z)=y))
10+
11+
remoteobjs-y := netmap_mem2.o netmap_mbq.o
12+
13+
remoteobjs-$(CONFIG_NETMAP_VALE) += netmap_vale.o netmap_offloadings.o
14+
remoteobjs-$(CONFIG_NETMAP_PIPE) += netmap_pipe.o
15+
remoteobjs-$(CONFIG_NETMAP_MONITOR) += netmap_monitor.o
16+
remoteobjs-$(CONFIG_NETMAP_GENERIC) += netmap_generic.o
17+
18+
define remote_template
19+
$$(obj)/$(1): $$(SRCDIR)/../sys/dev/netmap/$(2) FORCE
20+
$$(call if_changed_rule,cc_o_c)
21+
endef
22+
$(foreach o,$(remoteobjs-y),$(eval $(call remote_template,$(o),$(o:.o=.c))))
23+
# we compile netmap.c into netmap_common.o to allow
24+
# for MODNAME=netmap
25+
$(eval $(call remote_template,netmap_common.o,netmap.c))
26+
27+
$(obj)/netmap_linux.o: $(SRCDIR)/netmap_linux.c FORCE
28+
$(call if_changed_rule,cc_o_c)
29+
30+
# all objects
31+
$(MODNAME)-objs := $(remoteobjs-y) netmap_common.o netmap_linux.o
32+
33+
obj-$(CONFIG_NETMAP) = $(MODNAME).o
34+
35+
ifdef NETMAP_DRIVER_SUFFIX
36+
$(foreach v,$(filter %.o,$(O_DRIVERS)),$(eval $(v:.o=$(NETMAP_DRIVER_SUFFIX)-objs) := $v))
37+
$(foreach v,$(filter %.o,$(O_DRIVERS)),$(info $(v:.o=$(NETMAP_DRIVER_SUFFIX)-objs) := $v))
38+
obj-m += $(O_DRIVERS:%.o=%$(NETMAP_DRIVER_SUFFIX).o)
39+
else
40+
obj-m += $(O_DRIVERS)
41+
endif

LINUX/Makefile

+12-170
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,16 @@
1-
# To build external modules, you must have a prebuilt kernel available
2-
# that contains the configuration and header files used in the build.
3-
# go in the kernel directory and do a
4-
# make oldconfig; make scripts; make prepare
5-
# or make defconfig; make scripts; make prepare
6-
#
1+
all: netmap drivers
72

3+
netmap drivers: netmap.mak
84

5+
-include netmap.mak
96

10-
# list of objects for this module
11-
#
12-
# objects whose source file is in ../sys/dev/netmap
13-
remoteobjs := netmap.o netmap_mem2.o \
14-
netmap_generic.o netmap_mbq.o netmap_vale.o \
15-
netmap_offloadings.o netmap_pipe.o \
16-
netmap_monitor.o
17-
# all objects
18-
netmap_lin-objs := $(remoteobjs) netmap_linux.o
7+
COMPAT_ARGS=$(if $(KSRC),--kernel-dir=$(KSRC),)\
8+
$(if $(SRC),--kernel-sources=$(SRC),)\
9+
$(if $(NODRIVERS),--no-drivers)
1910

20-
obj-$(CONFIG_NETMAP) = netmap_lin.o
21-
22-
ifndef NODRIVERS
23-
# list of modules to be built (actually also forcedeth and r8169)
24-
MOD_LIST:= CONFIG_E1000=m CONFIG_E1000E=m \
25-
CONFIG_IXGBE=m CONFIG_IGB=m \
26-
CONFIG_BNX2X=m CONFIG_MLX4=m \
27-
CONFIG_VIRTIO_NET=m
28-
obj-m += $(O_DRIVERS)
29-
GET_DRIVERS := get-drivers
30-
else
31-
MOD_LIST:=
32-
endif
33-
34-
# DRIVER_SRCS names of the driver sources is only used to
35-
# clean files that we copied.
36-
DRIVER_SRCS = r8169.c forcedeth.c e1000/ e1000e/ ixgbe/ igb/
37-
DRIVER_SRCS += bnx2x/ mellanox/ mlx4/ virtio_net.c
38-
39-
# _DRV_SUBDIRS contains the subdirs with driver sources.
40-
# In old linuxes everything is under drivers/net, newer versions
41-
# have them in source/drivers/net/ethernet/$(manufacturer)
42-
43-
_DRV_SUBDIRS= nvidia realtek intel broadcom . ..
44-
45-
# The following commands are needed to build the modules as out-of-tree,
46-
# in fact the kernel sources path must be specified.
47-
48-
PWD ?= $(CURDIR)
49-
M:=$(PWD)
50-
51-
# Additional compile flags (e.g. header location)
52-
EXTRA_CFLAGS := -I$(M) -I$(M)/../sys -I$(M)/../sys/dev -DCONFIG_NETMAP
53-
EXTRA_CFLAGS += -Wno-unused-but-set-variable
54-
55-
# We use KSRC for the kernel configuration and sources.
56-
# If the sources are elsewhere, then use SRC to point to them.
57-
KSRC ?= /lib/modules/$(shell uname -r)/build
58-
SRC ?= $(KSRC)
59-
60-
# extract version number.
61-
# version.h can be in two different places.
62-
# NOTE- A.B.C translates to aXXYY where XXYY are hex
63-
LIN_VER = $(shell V=linux/version.h; G=. ; \
64-
[ -f $(KSRC)/include/$${V} ] || G=generated/uapi ;\
65-
grep LINUX_VERSION_CODE $(KSRC)/include/$${G}/linux/version.h | \
66-
awk '{printf "%03x%02x", $$3/256, $$3%256} ')
67-
68-
patcheslink := $(shell \
69-
[ -L $(PWD)/patches ] || \
70-
{ rm $(PWD)/patches; ln -s final-patches $(PWD)/patches; })
71-
72-
# produce a list of applicable patches for this version
73-
PATCHES := $(shell \
74-
cd $(PWD)/patches; ls diff--* | awk -v v=$(LIN_VER) -F -- \
75-
'{ if ((!$$3 || $$3 <= v"") && (!$$4 || v"" < $$4)) print $$0; }')
76-
77-
# source drivers to copy. Names derived from the patches
78-
S_DRIVERS := $(shell \
79-
cd $(PWD)/patches; ls diff--* | awk -v v=$(LIN_VER) -F -- \
80-
'{ if ((!$$3 || $$3 <= v"") && (!$$4 || v"" < $$4)) print $$2 }' )
81-
82-
# actual drivers after copy and patch
83-
DRIVERS = $(shell [ "$(PATCHES)" != "" ] && ls -dAp \
84-
`echo $(PATCHES:diff--%=%) | sed -r 's/--[0-9a-f-]+//g'` 2> /dev/null)
85-
86-
# Compile v1000 (vhost porting to e1000) only if
87-
# the LIN_VER >= 3.8.0, because we don't want to deal
88-
# with backporting problems for v1000.
89-
ifeq ($(word 1, $(sort 30800 $(LIN_VER))), 30800)
90-
CONFIG_V1000:=m
91-
else
92-
CONFIG_V1000:=n
93-
endif
94-
95-
CONFIG_V1000:=n # force disable by now
96-
97-
obj-$(CONFIG_V1000) += vhost-port/
98-
99-
100-
all: build
101-
102-
build: $(GET_DRIVERS)
103-
$(MAKE) -C $(KSRC) M=$(PWD) CONFIG_NETMAP=m $(MOD_LIST) \
104-
EXTRA_CFLAGS='$(EXTRA_CFLAGS)' \
105-
O_DRIVERS="$(DRIVERS:%.c=%.o)" modules
106-
@ls -l `find . -name \*.ko`
107-
108-
109-
test:
110-
@echo "version $(LIN_VER)"
111-
@echo "patches $(PATCHES)"
112-
@echo "drivers $(DRIVERS)"
113-
114-
clean:
115-
-@ $(MAKE) -C $(KSRC) M=$(PWD) clean 2> /dev/null
116-
-@ (rm -rf $(DRIVER_SRCS) *.orig *.rej *.ko *.o .*.d \
117-
.tmp_versions *.mod.c modules.order \
118-
Module.symvers .*.cmd get-drivers )
119-
120-
# the source is not here so we need to specify a dependency
121-
define remote_template
122-
$$(obj)/$(1): $$(M)/../sys/dev/netmap/$(1:.o=.c)
123-
$$(call cmd,cc_o_c)
124-
$$(call cmd,modversions)
125-
endef
126-
$(foreach o,$(remoteobjs),$(eval $(call remote_template,$(o))))
127-
128-
#-- copy and patch initial files
129-
# The location changes depending on the OS version, so ...
130-
get-drivers:
131-
-@( \
132-
if [ -d "$(DRIVER_SRC)" ] ; then \
133-
cd "$(DRIVER_SRC)"; s=.; what="`ls -dp *`" ; \
134-
else \
135-
cd $(SRC); [ -d source ] && cd source ; \
136-
cd drivers/net; s=. ; \
137-
[ -d ethernet ] && cd ethernet && s="$(_DRV_SUBDIRS)" ; \
138-
what="$(S_DRIVERS)" ; \
139-
fi ; \
140-
echo "LIN_VER $(LIN_VER)" ; \
141-
[ "$${what}" = "" ] && echo "-- NO DRIVERS --" && return; \
142-
echo "---- Building from `pwd`"; \
143-
echo "---- copying $${what} ---" ; \
144-
what="$${what} cnic_if.h"; \
145-
for i in $$s; do (cd $$i ; \
146-
echo " From `pwd` :"; \
147-
ls -ldp $${what} 2> /dev/null | sed 's/^/ /' ; \
148-
cp -Rp $${what} $(PWD) 2>/dev/null ); \
149-
done ; \
150-
cd $(PWD) ; \
151-
for i in $(PATCHES) ; \
152-
do echo "** patch with $$i"; \
153-
patch --posix --quiet --force -p1 < patches/$$i; \
154-
done ; \
155-
echo "Building the following drivers: $(S_DRIVERS)" )
156-
@touch get-drivers
157-
158-
159-
test3:
160-
@echo "from $(PATCHES) -- to $(MYDRIVERS)"
161-
@echo "Drivers is $(DRIVERS)"
162-
@echo "Actually have `ls -d $(DRIVERS) 2> /dev/null`"
163-
164-
# compute the diffs for the original files
165-
diffs:
166-
@for i in `find . -name \*.orig`; do \
167-
diff -urp $$i $${i%.orig} ; \
168-
done
169-
170-
apps:
171-
(cd ../examples; $(MAKE))
172-
173-
+%:
174-
@echo $($*)
11+
netmap.mak:
12+
@echo 'The new way to build netmap is to run the provided configure script first,'
13+
@echo 'followed by make.'
14+
@echo 'We run configure for you now, with compatible arguments, and restart make.'
15+
@echo 'Please run configure again if this is not what you want.'
16+
./configure $(COMPAT_ARGS)

LINUX/README

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ HOW TO BUILD THE CODE
3939
1. make sure you have kernel sources/headers matching your installed system
4040

4141
2. do the following
42-
make clean; make SRC=/usr/src/linux-source KSRC=/usr/src/linux-header
42+
./configure
43+
make
4344
this produces ./netmap_lin.ko and other kernel modules.
45+
(If your kernel sources are not in standard places, follow the
46+
instructions in the errors output by ./configure)
4447

4548
3. to build sample applications, run
46-
(cd ../examples; make )
49+
make apps
4750
(you will need the pthreads and libpcap-dev packages to build them)
4851

4952
If you want support for additional drivers please have a look at

LINUX/archlinux/PKGBUILD

+63-28
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,77 @@
33

44
# Maintainer: Vincenzo Maffione <v.maffione@gmail.com>
55
pkgname=netmap
6-
pkgver=2.0
7-
pkgrel=2
6+
pkgver=3.16
7+
pkgrel=1
88
pkgdesc="Netmap is a framework for high speed network packet I/O."
99
arch=('any')
1010
url="http://info.iet.unipi.it/~luigi/netmap"
1111
license=('BSD')
1212
groups=()
1313
depends=('linux' 'glibc')
14-
makedepends=('git' 'sed' 'gzip' 'linux-headers')
14+
makedepends=('git' 'sed' 'gzip' 'linux-headers' 'abs' 'pacman')
1515
provides=()
1616
conflicts=()
1717
replaces=()
1818
backup=()
1919
options=()
2020
install="netmap.install"
21-
source=()
21+
source=("netmap.install")
2222
noextract=()
23-
md5sums=() #generate with 'makepkg -g'
23+
md5sums=("047aa5adec4c52ddbf86d12dbf300f71")
2424

2525
_gitroot="https://v.maffione@code.google.com/p/netmap/"
2626
_gitname="netmap"
2727

2828
build() {
29-
cd "$srcdir"
30-
msg "Connecting to GIT server...."
29+
# Download the latest netmap code from the public repository
30+
cd "$srcdir"
31+
msg "Connecting to GIT server...."
32+
if [[ -d "$_gitname" ]]; then
33+
cd "$_gitname" && git pull origin
34+
msg "The local files are updated."
35+
else
36+
git clone "$_gitroot" "$_gitname"
37+
cd "$srcdir/$_gitname"
38+
git branch next origin/next
39+
git checkout next
40+
fi
41+
msg "GIT checkout done or server timeout"
3142

32-
if [[ -d "$_gitname" ]]; then
33-
cd "$_gitname" && git pull origin
34-
msg "The local files are updated."
35-
else
36-
git clone "$_gitroot" "$_gitname"
37-
fi
43+
# Download kernel sources using ABS, checking that the version is the
44+
# same as the running kernel
45+
msg "Downloading kernel sources..."
46+
mkdir -p $srcdir/abs
47+
cd $srcdir/abs
48+
ABSROOT=. abs core/linux
49+
cd $srcdir/abs/core/linux
50+
grep "pkgver[ ]*=" PKGBUILD > .ksver
51+
KSVER=$(sed 's|pkgver[ ]*=[ ]*||g' .ksver)
52+
rm .ksver
53+
RKVER=$(uname -r | sed 's|-.*||g')
54+
if [ "$KSVER" != "$RKVER" ]; then
55+
msg "Kernel sources version ($KSVER) differs from running kernel version ($RKVER): Cannot continue"
56+
return 1
57+
fi
58+
KMAJVER=$(echo "$KSVER" | sed 's|\.[0-9]\+$||g')
59+
makepkg --nobuild
60+
msg "Kernel sources are ready"
3861

39-
msg "GIT checkout done or server timeout"
40-
msg "Starting build..."
41-
42-
rm -rf "$srcdir/$_gitname-build"
43-
git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build"
44-
cd "$srcdir/$_gitname-build"
45-
46-
# Build the netmap kernel module
47-
cd "$srcdir/$_gitname-build/LINUX"
48-
make || return 1
62+
# Build the netmap kernel module and all modified drivers, using the
63+
# kernel sources downloaded in the previous steps to copy the NIC
64+
# drivers. Note however that the kernel modules are built against the
65+
# running kernel, and not against the downloaded sources.
66+
msg "Starting to build netmap"
67+
cd "$srcdir/$_gitname/LINUX"
68+
unset SRC
69+
unset KSRC
70+
unset NODRIVERS
71+
make SRC=$srcdir/abs/core/linux/src/linux-$KMAJVER || return 1
4972
# Build pkt-gen and vale-ctl
50-
cd "$srcdir/$_gitname-build/examples"
73+
cd "$srcdir/$_gitname/examples"
74+
make clean # amend for existing .o
5175
make pkt-gen vale-ctl || return 1
76+
msg "Build complete"
5277
}
5378

5479
package() {
@@ -58,21 +83,31 @@ package() {
5883

5984
# Install the netmap module into the extramodules-VERSION directory
6085
mkdir -p "$pkgdir/lib/modules/extramodules-${KVER2}"
61-
cp "$srcdir/$_gitname-build/LINUX/netmap_lin.ko" "$pkgdir/lib/modules/extramodules-${KVER2}"
86+
cp "$srcdir/$_gitname/LINUX/netmap_lin.ko" "$pkgdir/lib/modules/extramodules-${KVER2}"
6287

6388
# Install pkt-gen and valectl into /usr/bin
6489
mkdir -p "$pkgdir/usr/bin"
65-
cp "$srcdir/$_gitname-build/examples/pkt-gen" "$pkgdir/usr/bin"
66-
cp "$srcdir/$_gitname-build/examples/vale-ctl" "$pkgdir/usr/bin"
90+
cp "$srcdir/$_gitname/examples/pkt-gen" "$pkgdir/usr/bin"
91+
cp "$srcdir/$_gitname/examples/vale-ctl" "$pkgdir/usr/bin"
6792

6893
# Install the netmap public headers
6994
mkdir -p "$pkgdir/usr/include/net"
7095
cp "$srcdir/$_gitname/sys/net/netmap.h" "$srcdir/$_gitname/sys/net/netmap_user.h" "$pkgdir/usr/include/net"
7196

7297
# Install the netmap man page
7398
mkdir -p "$pkgdir/usr/share/man/man4"
74-
cp "$srcdir/$_gitname-build/share/man/man4/netmap.4" "$pkgdir/usr/share/man/man4"
99+
cp "$srcdir/$_gitname/share/man/man4/netmap.4" "$pkgdir/usr/share/man/man4"
75100
gzip "$pkgdir/usr/share/man/man4/netmap.4"
101+
102+
#Find and install the modified NIC drivers
103+
cd "$srcdir/$_gitname/LINUX"
104+
DRIVERS=$(find . -name "*.ko" -and ! -name "netmap_lin.ko")
105+
if [ -n "$DRIVERS" ]; then
106+
mkdir -p "$pkgdir/lib/modules/extramodules-${KVER2}/netmap-drivers"
107+
cp --parent $DRIVERS "$pkgdir/lib/modules/extramodules-${KVER2}/netmap-drivers"
108+
cd "$pkgdir/lib/modules/extramodules-${KVER2}/netmap-drivers"
109+
find . -name "*.ko" -exec sh -c "mv {} \$(echo {} | sed 's|\.ko|_netmap\.ko|g')" \;
110+
fi
76111
}
77112

78113
# vim:set ts=2 sw=2 et:

0 commit comments

Comments
 (0)