Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official NIC/DPDK component support to Composite #451

Merged
merged 74 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
bf06b90
wenyuan: make dpdk using the build system of composite. Haven't fix t…
WenyuanShao Jan 19, 2022
bcf2c96
wenyuan: delete fix a file which is not useful
WenyuanShao Jan 19, 2022
89fe11b
use private DPDK repo first
betahxy Jan 19, 2022
426db81
make dpdk lib work
betahxy Jan 19, 2022
a120aee
ar dpdk libs to libdpdk
betahxy Jan 19, 2022
b873502
test simple dpdk function in llbooter
betahxy Jan 19, 2022
c1eaaf5
compiling DPDK with musl libc in composite
betahxy Jan 22, 2022
50c23c0
compile DPDK witt musl in Composite automatically
betahxy Jan 23, 2022
b9fbab5
Merge branch 'loader' into dpdk-dev
betahxy Jan 29, 2022
70917bd
add posix lib into llbooter
betahxy Jan 29, 2022
820a117
Merge branch 'loader' into dpdk-dev
betahxy Jan 30, 2022
071882a
make tls set fs register correctly in x86_64
betahxy Jan 30, 2022
838e0f3
improve dpdk Makefile
betahxy Jan 30, 2022
ae1c995
init tls space when init libc
betahxy Jan 31, 2022
31565ac
Merge branch 'main' into dpdk-dev
betahxy Feb 1, 2022
67e6a40
compile DPDK drivers and change linker script
betahxy Feb 2, 2022
d07d0cd
add DPDK_COMPOSITE macro to DPDK lib
betahxy Feb 2, 2022
2e571ff
make rte_eal_init to begin rte_bus_scan
betahxy Feb 2, 2022
19367ba
add cos print in lib musl
betahxy Feb 2, 2022
82ff4f7
Merge remote-tracking branch 'origin/main' into dpdk-dev
betahxy Feb 5, 2022
7956866
remove warnings
betahxy Feb 5, 2022
e33593f
add cos_dpdk_adapter
betahxy Feb 13, 2022
a96fa22
make eal init work and probe e1000 pmd
betahxy Feb 26, 2022
86c5287
enable receiving packets
betahxy Mar 6, 2022
ab19128
fix compiling problem of x86_64
betahxy Mar 12, 2022
889601e
use a larger stack size in user level
betahxy Mar 13, 2022
634fca7
Qemu e1000 NIC rx/tx simple test OK
betahxy Mar 20, 2022
74aafde
enable libc_init and override defautl __init_tls
betahxy Mar 27, 2022
a8862e4
enable r/w fs gs base register
betahxy Mar 29, 2022
d85c8a6
remove compiling warnings and improve the dpdk build makefile
betahxy Apr 3, 2022
a2a5275
support log level in dpdk
betahxy Apr 3, 2022
28872b1
improve the dpdk build system
betahxy Apr 3, 2022
f37312d
add simple version of cos dpdk api
betahxy Apr 5, 2022
cb62e24
fix rx bug
betahxy Apr 5, 2022
dd5e8a5
change DPDK's Composite specific macro
betahxy Apr 5, 2022
ebbee4f
provide get cpu freq interface in dpdk adapter
betahxy Apr 5, 2022
c00b39f
remove compiling warnings
betahxy Apr 5, 2022
786d668
remove mmap2 and improve dpdk makefile
betahxy Apr 9, 2022
1fad07a
fix the makefile build system
betahxy Apr 9, 2022
31a494c
fix the makefile build system
betahxy Apr 10, 2022
8768620
add dpdk component
betahxy Apr 13, 2022
84c453c
Merge branch 'dpdk-dev'
betahxy Apr 13, 2022
fbb6c9c
remove test code
betahxy Apr 13, 2022
56cbc7e
add set tls sinv call
betahxy Apr 26, 2022
7f10ea9
tls bug fix
betahxy Apr 26, 2022
53d4f92
minor fixes according to PR feedback
betahxy Apr 26, 2022
f7fb0f0
fix minor bugs
betahxy Apr 29, 2022
2fa624a
update dpdk submodule
betahxy Apr 29, 2022
1452049
minor fixes
betahxy Apr 29, 2022
7e3b615
add get_virt_to_phys_addr through memmgr
betahxy Apr 30, 2022
0940bfa
reserve 256MB memory to memmgr
betahxy May 1, 2022
5589508
add memmgr_map_phys_to_virt to memmgr interface
betahxy May 1, 2022
1713e27
minor bug fixes
betahxy May 1, 2022
be7d3dc
minor fixes
betahxy May 1, 2022
e768f15
clean lib posix
betahxy May 1, 2022
f5bfcfc
add nic interface
betahxy May 1, 2022
9535cf3
Merge remote-tracking branch 'upstream/main'
betahxy May 2, 2022
db23356
change dpdk url to GW's repo
betahxy May 2, 2022
e357580
update dpdk submodule
betahxy May 2, 2022
5b8fa8e
add init_env dependencies
betahxy May 2, 2022
8b67159
minor fix
betahxy May 2, 2022
cc8e98c
keep posix legacy as its original content
betahxy May 3, 2022
8c34fa5
add lwip submodule
betahxy May 11, 2022
ba66857
add lwip submodule
betahxy May 11, 2022
e307303
Merge branch 'main' of github.com:betahxy/composite
betahxy May 11, 2022
0950f94
add lwip submodule and successfully compile it
betahxy May 15, 2022
0868465
enable avx feature
betahxy May 15, 2022
f1c74a1
test lwip within nic component
betahxy May 29, 2022
8bd5569
enable lwip debug message
betahxy May 29, 2022
92585ca
add DPDK bench test and some minor changes
betahxy Jun 4, 2022
c1fb10c
change lwip submodule url to gwsystem
betahxy Jun 4, 2022
e68d887
minor fix
betahxy Jun 4, 2022
ca2f9f2
fix format
betahxy Jun 5, 2022
22d5f9a
minor fixes
betahxy Jun 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ constructor
kernel.iso
grub.cfg
gdbinit
src/components/lib/libc/musl-1.2.0/include/asm/
src/components/lib/libc/musl-1.2.0/include/asm-generic/
src/components/lib/libc/musl-1.2.0/include/linux/
src/components/lib/libc/musl-1.2.0/include/sys/queue.h
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
path = src/components/lib/ck/ck
url = https://github.com/gwsystems/ck.git
branch = cos_profile
[submodule "src/components/lib/dpdk/dpdk"]
path = src/components/lib/dpdk/dpdk
url = https://github.com/gwsystems/dpdk.git
branch = cos_dpdk
[submodule "src/components/lib/lwip/lwip"]
path = src/components/lib/lwip/lwip
url = https://github.com/gwsystems/lwip.git
branch = cos_stable_2_1_x
30 changes: 30 additions & 0 deletions composition_scripts/bench_dpdk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[system]
description = "Simple DPDK component: test if it can drive NIC and sent/receive packets"

[[components]]
name = "booter"
img = "no_interface.llbooter"
implements = [{interface = "init"}, {interface = "addr"}]
deps = [{srv = "kernel", interface = "init", variant = "kernel"}]
constructor = "kernel"

[[components]]
name = "capmgr"
img = "capmgr.simple"
deps = [{srv = "booter", interface = "init"}, {srv = "booter", interface = "addr"}]
implements = [{interface = "capmgr"}, {interface = "init"}, {interface = "memmgr"}, {interface = "capmgr_create"}]
constructor = "booter"

[[components]]
name = "sched"
img = "sched.root_fprr"
deps = [{srv = "capmgr", interface = "init"}, {srv = "capmgr", interface = "capmgr"}, {srv = "capmgr", interface = "memmgr"}]
implements = [{interface = "sched"}, {interface = "init"}]
constructor = "booter"

[[components]]
name = "dpdk"
img = "tests.bench_dpdk"
deps = [{srv = "sched", interface = "sched"}, {srv = "sched", interface = "init"}, {srv = "capmgr", interface = "capmgr_create"}, {srv = "capmgr", interface = "memmgr"}]
baseaddr = "0x1600000"
constructor = "booter"
21 changes: 16 additions & 5 deletions cos
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ build()
}

clean()
{
echo "[cos executing] make -C src clean"
make -C src clean
}

distclean()
{
echo "[cos executing] make -C src clean"
make -C src distclean
Expand Down Expand Up @@ -85,10 +91,10 @@ run()

if [ "${elf_type}" == "ELF64" ]
then
tools/run.sh ${dir}/cos.iso x86_64
tools/run.sh ${dir}/cos.iso x86_64 ${enable_nic}
elif [ "${elf_type}" == "ELF32" ]
then
tools/run.sh ${dir}/cos.iso i386
tools/run.sh ${dir}/cos.iso i386 ${enable_nic}
else
echo "Unsupported image type: ${elf_type} !"
fi
Expand Down Expand Up @@ -117,10 +123,10 @@ debug_run()

if [ "${elf_type}" == "ELF64" ]
then
tools/run.sh ${dir}/cos.iso x86_64 debug
tools/run.sh ${dir}/cos.iso x86_64 debug ${enable_nic}
elif [ "${elf_type}" == "ELF32" ]
then
tools/run.sh ${dir}/cos.iso i386 debug
tools/run.sh ${dir}/cos.iso i386 debug ${enable_nic}
else
echo "Unsupported image type!"
fi
Expand All @@ -133,7 +139,7 @@ gdb()

usage()
{
echo "Usage: " $0 " init <arch: [x86_64|i386|armv7a]>|build|clean|compose <script> <output name>|run <composite name>|debug_run <composite name>|gdb"
echo "Usage: " $0 " init <arch: [x86_64|i386|armv7a]>|build|clean|compose <script> <output name>|run <composite name> [enable-nic]|debug_run <composite name> [enable_nic]|gdb | distclean"
exit 1
}

Expand All @@ -156,15 +162,20 @@ case $1 in
run )
binary=$2
name=$2
enable_nic=$3
run
;;
debug_run )
name=$2
enable_nic=$3
debug_run
;;
gdb )
gdb
;;
distclean )
distclean
;;
* )
usage
esac
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ comps:
platclean:
$(MAKE) $(MAKEOPTIONS) PLATFORM=$(shell cat $(PLAT_FILE)) -C platform clean

plat: platclean
plat:
$(info )
$(info ***********************************************)
$(info ***** Building $(shell cat $(PLAT_FILE)) Platform and Kernel *****)
Expand Down Expand Up @@ -80,7 +80,7 @@ config-i386: config-gen
@echo "ARCH_ASFLAGS= -m32 -D__x86__ -D__WORD_SIZE_32__ -D__ASM__" >> Makefile.arch
@echo "ARCH_LDFLAGS=-melf_i386" >> Makefile.arch
@echo "Configuring the system with clock speed and directory structure."
@cat /proc/cpuinfo | grep "model name" -m 1 | sed 's/.*\([0-9]\.[0-9]*\).*/\#define CPU_GHZ \1/' > ./kernel/include/chal/shared/cpu_ghz.h
@cpu_freq=`cat /var/log/dmesg | grep "MHz processor" | awk -F ] '{print $$2}' | awk -F . '{print $$1}' |grep -o '[[:digit:]]*'`;cpu_freq=`awk 'BEGIN{printf "%.2f\n",'$$cpu_freq'/'1000'}'`;echo "#define CPU_GHZ $$cpu_freq" > ./kernel/include/chal/shared/cpu_ghz.h
@if [ -z "`cat /proc/cpuinfo | grep \"physical id\"`" ]; then echo "#define NUM_CPU_SOCKETS 1" >> ./kernel/include/chal/shared/cpu_ghz.h; else cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l | sed 's/.*\([0-9]\).*/\#define NUM_CPU_SOCKETS \1/' >> ./kernel/include/chal/shared/cpu_ghz.h; fi
@echo "Please view Makefile.cosconfig and kernel/include/chal/shared/cpu_ghz.h to make sure they're accurate."
@echo "Do _not_ 'git add' either of these files."
Expand All @@ -106,7 +106,7 @@ config-x86_64: config-gen
@echo "ARCH_ASFLAGS= -m64 -D__x86_64__ -D__WORD_SIZE_64__ -D__ASM__ -mcmodel=large" >> Makefile.arch
@echo "ARCH_LDFLAGS= -melf_x86_64" >> Makefile.arch
@echo "Configuring the system with clock speed and directory structure."
@cat /proc/cpuinfo | grep "model name" -m 1 | sed 's/.*\([0-9]\.[0-9]*\).*/\#define CPU_GHZ \1/' > ./kernel/include/chal/shared/cpu_ghz.h
@cpu_freq=`cat /var/log/dmesg | grep "MHz processor" | awk -F ] '{print $$2}' | awk -F . '{print $$1}' |grep -o '[[:digit:]]*'`;cpu_freq=`awk 'BEGIN{printf "%.2f\n",'$$cpu_freq'/'1000'}'`;echo "#define CPU_GHZ $$cpu_freq" > ./kernel/include/chal/shared/cpu_ghz.h
@if [ -z "`cat /proc/cpuinfo | grep \"physical id\"`" ]; then echo "#define NUM_CPU_SOCKETS 1" >> ./kernel/include/chal/shared/cpu_ghz.h; else cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l | sed 's/.*\([0-9]\).*/\#define NUM_CPU_SOCKETS \1/' >> ./kernel/include/chal/shared/cpu_ghz.h; fi
@echo "Please view Makefile.cosconfig and kernel/include/chal/shared/cpu_ghz.h to make sure they're accurate."
@echo "Do _not_ 'git add' either of these files."
Expand Down
22 changes: 18 additions & 4 deletions src/components/implementation/Makefile.subdir
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INCLUDES=$(DEPENDENCY_INCPATH) $(CINC)
OBJS=$(patsubst %.c,%.o,$(wildcard *.c)) $(patsubst %.S,%.o,$(wildcard *.S)) $(patsubst %.cc,%.o,$(wildcard *.cc))

#NOTE: assembly files don't have dependencies generated for them
SOURCE_DEPENDENCIES=$($(wildcard *.c):%.c=%.d) $($(wildcard *.cc):%.cc=%.d)
SOURCE_DEPENDENCIES=$(OBJS:%.o=%.d)

.PHONY: all
all: print $(SOURCE_DEPENDENCIES) $(CLIB) subdirs
Expand Down Expand Up @@ -44,11 +44,25 @@ endif

# see the make manual: create the .d dependencies from include
# statements.
# redirect error output to /dev/null so that it will not display
# errors when cleaning, this does not affect gcc's error output when
# building the system because that is in a different target path
%.d:%.c
$(info | [DEP] Creating dependency file for $@)
@set +e; rm -f $@; \
$(CC) -M $(INCLUDES) $(CFLAGS) $< > $@.$$$$ 2>/dev/null; \
if [ -s $@.$$$$ ]; then \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
fi; \
rm -f $@.$$$$

%.d:%.cc
# $(info | [DEP] Creating dependency file for $<)
@set -e; rm -f $@; \
$(CC) -M $(INCLUDE) $(CFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
@set +e; rm -f $@; \
$(CXX) -M $(INCLUDES) $(LIBSTDCXXINC) $(CXXFLAGS) $< > $@.$$$$ 2>/dev/null; \
if [ -s $@.$$$$ ]; then \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
fi; \
rm -f $@.$$$$

.PHONY: clean
Expand Down
23 changes: 16 additions & 7 deletions src/components/implementation/Makefile.subsubdir
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ LIB_MANDATORY=$(DEPENDENCY_LIBOBJS)
# references
LIB_FLAGS =$(LIB_MANDATORY) $(if $(wildcard ../*.a), -L.. -linterfacelib) $(DEPENDENCY_LIBPATH) $(DEPENDENCY_LIBS) $(DEPENDENCY_LIBS)

COMP_LD_SCRIPT=$(IMPLDIR)/comp.ld
TAR_SYMBOL_NAME=crt_init.tar

ifeq ($(PLATFORM), i386)
LINKFLAG=-Xlinker -melf_i386
COMP_LD_SCRIPT=$(IMPLDIR)/comp_i386.ld
else ifeq ($(PLATFORM), x86_64)
LINKFLAG=-Xlinker -melf_x86_64
COMP_LD_SCRIPT=$(IMPLDIR)/comp_x86_64.ld
else ifeq ($(PLATFORM), armv7a)
LINKFLAG=-Xlinker -marmelf
COMP_LD_SCRIPT=$(IMPLDIR)/comp_armv7a.ld
endif

.PHONY: all
Expand Down Expand Up @@ -109,16 +111,23 @@ component: clean comp_header $(COMPOBJ)

# see the make manual: create the .d dependencies from include
# statements.
# redirect error output to /dev/null so that it will not display
# errors when cleaning, this does not affect gcc's error output when
# building the system because that is in a different target path
%.d:%.c
@set -e; rm -f $@; \
$(CC) -M $(INCLUDE) $(CFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
@set +e; rm -f $@; \
$(CC) -M $(INCLUDE) $(CFLAGS) $< > $@.$$$$ 2>/dev/null; \
if [ -s $@.$$$$ ]; then \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
fi; \
rm -f $@.$$$$

%.d:%.cc
@set -e; rm -f $@; \
$(CXX) -M $(INCLUDE) $(LIBSTDCXXINC) $(CXXFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
@set +e; rm -f $@; \
$(CXX) -M $(INCLUDE) $(LIBSTDCXXINC) $(CXXFLAGS) $< > $@.$$$$ 2>/dev/null; \
if [ -s $@.$$$$ ]; then \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
fi; \
rm -f $@.$$$$

.PHONY: clean
Expand Down
34 changes: 32 additions & 2 deletions src/components/implementation/capmgr/simple/capmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ SS_STATIC_SLAB(asnd, struct cm_asnd, MAX_NUM_THREADS);

/* 64 MiB */
#define MB2PAGES(mb) (round_up_to_page(mb * 1024 * 1024) / PAGE_SIZE)
#define MM_NPAGES (MB2PAGES(64))
#define MM_NPAGES (MB2PAGES(256))
SS_STATIC_SLAB(page, struct mm_page, MM_NPAGES);
SS_STATIC_SLAB(span, struct mm_span, MM_NPAGES);

Expand Down Expand Up @@ -113,7 +113,6 @@ cm_comp_alloc_with(char *name, compid_t id, struct crt_comp_resources *resources
return c;
}


struct cm_rcv *
cm_rcv_alloc_in(struct crt_comp *c, struct crt_rcv *sched, thdclosure_index_t closure_id, crt_rcv_flags_t flags)
{
Expand Down Expand Up @@ -224,6 +223,28 @@ memmgr_heap_page_allocn_aligned(unsigned long num_pages, unsigned long align)
return (vaddr_t)p->mappings[0].addr;
}

vaddr_t
memmgr_virt_to_phys(vaddr_t vaddr)
{
struct cm_comp *c;

c = ss_comp_get(cos_inv_token());
if (!c) return 0;

return call_cap_op(c->comp.comp_res->ci.pgtbl_cap, CAPTBL_OP_INTROSPECT, (vaddr_t)vaddr, 0, 0, 0);
}

vaddr_t
memmgr_map_phys_to_virt(paddr_t paddr, size_t size)
{
struct cm_comp *c;

c = ss_comp_get(cos_inv_token());
if (!c) return 0;

return (vaddr_t)cos_hw_map(&c->comp.comp_res->ci, BOOT_CAPTBL_SELF_INITHW_BASE, paddr, size);
}

vaddr_t
memmgr_heap_page_allocn(unsigned long num_pages)
{
Expand Down Expand Up @@ -486,6 +507,15 @@ execute(void)
crt_compinit_execute(crtcomp_get);
}

void
capmgr_set_tls(thdcap_t cap, void* tls_addr)
{
compid_t cid = (compid_t)cos_inv_token();
struct crt_comp* c = crtcomp_get(cid);

cos_thd_mod(&c->comp_res->ci, cap, tls_addr);
}

void
init_done(int parallel_init, init_main_t main_type)
{
Expand Down
70 changes: 70 additions & 0 deletions src/components/implementation/comp_i386.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
PHDRS
{
text PT_LOAD ;
data PT_LOAD ;
}

SECTIONS
{
ENTRY(__cosrt_upcall_entry)

. = SIZEOF_HEADERS;

/* start the text/read-only sections */
.text : ALIGN(4096) { *(.text*) } :text
.rodata : { *(.rodata*) }
.eh_frame : { *(.eh_frame*) }

. = ALIGN(4096);
/* start the data sections */
.ctors : {
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
} :data
.dtors : {
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
__DTOR_END__ = .;
}
.init_array : {
__init_array_start = .;
__INIT_ARRAY_LIST__ = .;
LONG((__INIT_ARRAY_END__ - __INIT_ARRAY_LIST__) / 4 - 2)
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
LONG(0)
__INIT_ARRAY_END__ = .;
__init_array_end = .;
}
.fini_array : {
__fini_array_start = .;
__FINI_ARRAY_LIST__ = .;
LONG((__FINI_ARRAY_END__ - __FINI_ARRAY_LIST__) / 4 - 2)
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
LONG(0)
__FINI_ARRAY_END__ = .;
__fini_array_end = .;
}
.crecov : {
__CRECOV_LIST__ = .;
LONG((__CRECOV_END__ - __CRECOV_LIST__) / 4 - 2)
*(.crecov)
LONG(0)
__CRECOV_END__ = .;
}
.data : {
*(.data*);
*(.ucap*);
*(.initonce*);
*(.initfile*);
}
.bss : { *(.bss*) }

__crt_static_heap_ptr = .;
}
Loading