forked from coolsnowwolf/lede
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cb6036
commit 89e39d8
Showing
9 changed files
with
391 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
BPF_DEPENDS := @HAS_BPF_TOOLCHAIN | ||
LLVM_VER:= | ||
|
||
CLANG_MIN_VER:=12 | ||
|
||
ifneq ($(CONFIG_USE_LLVM_HOST),) | ||
BPF_TOOLCHAIN_HOST_PATH:=$(call qstrip,$(CONFIG_BPF_TOOLCHAIN_HOST_PATH)) | ||
ifneq ($(BPF_TOOLCHAIN_HOST_PATH),) | ||
BPF_PATH:=$(BPF_TOOLCHAIN_HOST_PATH)/bin:$(PATH) | ||
else | ||
BPF_PATH:=$(PATH) | ||
endif | ||
CLANG:=$(firstword $(shell PATH='$(BPF_PATH)' command -v clang clang-13 clang-12 clang-11)) | ||
LLVM_VER:=$(subst clang,,$(notdir $(CLANG))) | ||
endif | ||
ifneq ($(CONFIG_USE_LLVM_PREBUILT),) | ||
CLANG:=$(TOPDIR)/llvm-bpf/bin/clang | ||
endif | ||
ifneq ($(CONFIG_USE_LLVM_BUILD),) | ||
CLANG:=$(STAGING_DIR_HOST)/llvm-bpf/bin/clang | ||
endif | ||
|
||
LLVM_PATH:=$(dir $(CLANG)) | ||
LLVM_LLC:=$(LLVM_PATH)/llc$(LLVM_VER) | ||
LLVM_DIS:=$(LLVM_PATH)/llvm-dis$(LLVM_VER) | ||
LLVM_OPT:=$(LLVM_PATH)/opt$(LLVM_VER) | ||
LLVM_STRIP:=$(LLVM_PATH)/llvm-strip$(LLVM_VER) | ||
|
||
BPF_KARCH:=mips | ||
BPF_ARCH:=mips$(if $(CONFIG_ARCH_64BIT),64)$(if $(CONFIG_BIG_ENDIAN),,el) | ||
BPF_TARGET:=bpf$(if $(CONFIG_BIG_ENDIAN),eb,el) | ||
|
||
BPF_HEADERS_DIR:=$(STAGING_DIR)/bpf-headers | ||
|
||
BPF_KERNEL_INCLUDE := \ | ||
-nostdinc -isystem $(TOOLCHAIN_DIR)/include \ | ||
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include \ | ||
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/asm/mach-generic \ | ||
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/generated \ | ||
-I$(BPF_HEADERS_DIR)/include \ | ||
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/uapi \ | ||
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/generated/uapi \ | ||
-I$(BPF_HEADERS_DIR)/include/uapi \ | ||
-I$(BPF_HEADERS_DIR)/include/generated/uapi \ | ||
-I$(BPF_HEADERS_DIR)/tools/lib \ | ||
-I$(BPF_HEADERS_DIR)/tools/testing/selftests \ | ||
-I$(BPF_HEADERS_DIR)/samples/bpf \ | ||
-include linux/kconfig.h -include asm_goto_workaround.h | ||
|
||
BPF_CFLAGS := \ | ||
$(BPF_KERNEL_INCLUDE) -I$(PKG_BUILD_DIR) \ | ||
-D__KERNEL__ -D__BPF_TRACING__ -DCONFIG_GENERIC_CSUM \ | ||
-D__TARGET_ARCH_${BPF_KARCH} \ | ||
-m$(if $(CONFIG_BIG_ENDIAN),big,little)-endian \ | ||
-fno-stack-protector -Wall \ | ||
-Wno-unused-value -Wno-pointer-sign \ | ||
-Wno-compare-distinct-pointer-types \ | ||
-Wno-gnu-variable-sized-type-not-at-end \ | ||
-Wno-address-of-packed-member -Wno-tautological-compare \ | ||
-Wno-unknown-warning-option \ | ||
-fno-asynchronous-unwind-tables \ | ||
-Wno-uninitialized -Wno-unused-variable \ | ||
-Wno-unused-label \ | ||
-O2 -emit-llvm -Xclang -disable-llvm-passes | ||
|
||
ifeq ($(DUMP),) | ||
CLANG_VER:=$(shell $(CLANG) -dM -E - < /dev/null | grep __clang_major__ | cut -d' ' -f3) | ||
CLANG_VER_VALID:=$(shell [ "$(CLANG_VER)" -ge "$(CLANG_MIN_VER)" ] && echo 1 ) | ||
ifeq ($(CLANG_VER_VALID),) | ||
$(error ERROR: LLVM/clang version too old. Minimum required: $(CLANG_MIN_VER), found: $(CLANG_VER)) | ||
endif | ||
endif | ||
|
||
define CompileBPF | ||
$(CLANG) -g -target $(BPF_ARCH)-linux-gnu $(BPF_CFLAGS) $(2) \ | ||
-c $(1) -o $(patsubst %.c,%.bc,$(1)) | ||
$(LLVM_OPT) -O2 -mtriple=$(BPF_TARGET) < $(patsubst %.c,%.bc,$(1)) > $(patsubst %.c,%.opt,$(1)) | ||
$(LLVM_DIS) < $(patsubst %.c,%.opt,$(1)) > $(patsubst %.c,%.S,$(1)) | ||
$(LLVM_LLC) -march=$(BPF_TARGET) -mcpu=v3 -filetype=obj -o $(patsubst %.c,%.o,$(1)) < $(patsubst %.c,%.S,$(1)) | ||
$(CP) $(patsubst %.c,%.o,$(1)) $(patsubst %.c,%.debug.o,$(1)) | ||
$(LLVM_STRIP) --strip-debug $(patsubst %.c,%.o,$(1)) | ||
endef | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# | ||
# Copyright (C) 2006-2009 OpenWrt.org | ||
# | ||
# This is free software, licensed under the GNU General Public License v2. | ||
# See /LICENSE for more information. | ||
# | ||
include $(TOPDIR)/rules.mk | ||
|
||
override QUILT:= | ||
override HOST_QUILT:= | ||
|
||
include $(INCLUDE_DIR)/kernel.mk | ||
|
||
|
||
PKG_NAME:=linux | ||
PKG_PATCHVER:=5.15 | ||
# Manually include kernel version and hash from kernel details file | ||
include $(INCLUDE_DIR)/kernel-$(PKG_PATCHVER) | ||
|
||
PKG_VERSION:=$(PKG_PATCHVER)$(strip $(LINUX_VERSION-$(PKG_PATCHVER))) | ||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz | ||
PKG_SOURCE_URL:=$(LINUX_SITE) | ||
PKG_HASH:=$(LINUX_KERNEL_HASH-$(strip $(PKG_VERSION))) | ||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/bpf-headers/$(PKG_NAME)-$(PKG_VERSION) | ||
|
||
GENERIC_PLATFORM_DIR := $(CURDIR)/../../../target/linux/generic | ||
GENERIC_BACKPORT_DIR := $(GENERIC_PLATFORM_DIR)/backport$(if $(wildcard $(GENERIC_PLATFORM_DIR)/backport-$(PKG_PATCHVER)),-$(PKG_PATCHVER)) | ||
GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/pending$(if $(wildcard $(GENERIC_PLATFORM_DIR)/pending-$(PKG_PATCHVER)),-$(PKG_PATCHVER)) | ||
GENERIC_HACK_DIR := $(GENERIC_PLATFORM_DIR)/hack$(if $(wildcard $(GENERIC_PLATFORM_DIR)/hack-$(PKG_PATCHVER)),-$(PKG_PATCHVER)) | ||
GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(PKG_PATCHVER)),"$(dir)") | ||
PATCH_DIR := $(CURDIR)/patches | ||
FILES_DIR := | ||
|
||
REAL_LINUX_DIR := $(LINUX_DIR) | ||
LINUX_DIR := $(PKG_BUILD_DIR) | ||
|
||
include $(INCLUDE_DIR)/bpf.mk | ||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/bpf-headers | ||
SECTION:=kernel | ||
CATEGORY:=Kernel | ||
TITLE:=eBPF kernel headers | ||
BUILDONLY:=1 | ||
HIDDEN:=1 | ||
endef | ||
|
||
PKG_CONFIG_PATH:= | ||
|
||
export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include | ||
|
||
KERNEL_MAKE := \ | ||
$(MAKE) -C $(PKG_BUILD_DIR) \ | ||
ARCH=$(BPF_KARCH) \ | ||
CROSS_COMPILE=$(BPF_ARCH)-linux- \ | ||
LLVM=1 CC="$(CLANG)" LD="$(TARGET_CROSS)ld" \ | ||
HOSTCC="$(HOSTCC)" \ | ||
HOSTCXX="$(HOSTCXX)" \ | ||
HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \ | ||
KBUILD_HOSTLDLIBS="-L$(STAGING_DIR_HOST)/lib" \ | ||
CONFIG_SHELL="$(BASH)" \ | ||
INSTALL_HDR_PATH="$(PKG_BUILD_DIR)/user_headers" | ||
|
||
define Build/Patch | ||
$(Kernel/Patch/Default) | ||
endef | ||
|
||
BPF_DOC = $(PKG_BUILD_DIR)/scripts/bpf_doc.py | ||
|
||
define Build/Configure/64 | ||
echo 'CONFIG_CPU_MIPS64_R2=y' >> $(PKG_BUILD_DIR)/.config | ||
echo 'CONFIG_64BIT=y' >> $(PKG_BUILD_DIR)/.config | ||
endef | ||
|
||
define Build/Configure | ||
grep -vE 'CONFIG_(CPU_.*ENDIAN|HZ)' $(PKG_BUILD_DIR)/arch/mips/configs/generic_defconfig > $(PKG_BUILD_DIR)/.config | ||
echo 'CONFIG_CPU_$(if $(CONFIG_BIG_ENDIAN),BIG,LITTLE)_ENDIAN=y' >> $(PKG_BUILD_DIR)/.config | ||
$(if $(CONFIG_ARCH_64BIT),$(Build/Configure/64)) | ||
grep CONFIG_HZ $(REAL_LINUX_DIR)/.config >> $(PKG_BUILD_DIR)/.config | ||
yes '' | $(KERNEL_MAKE) oldconfig | ||
grep 'CONFIG_HZ=' $(REAL_LINUX_DIR)/.config | \ | ||
cut -d= -f2 | \ | ||
bc -q $(LINUX_DIR)/kernel/time/timeconst.bc \ | ||
> $(LINUX_DIR)/include/generated/timeconst.h | ||
$(BPF_DOC) --header \ | ||
--file $(LINUX_DIR)/tools/include/uapi/linux/bpf.h \ | ||
> $(PKG_BUILD_DIR)/tools/lib/bpf/bpf_helper_defs.h | ||
endef | ||
|
||
define Build/Compile | ||
$(KERNEL_MAKE) archprepare headers_install | ||
endef | ||
|
||
define Build/InstallDev | ||
mkdir -p $(1)/bpf-headers/arch $(1)/bpf-headers/tools | ||
$(CP) \ | ||
$(PKG_BUILD_DIR)/arch/$(BPF_KARCH) \ | ||
$(1)/bpf-headers/arch/ | ||
$(CP) \ | ||
$(PKG_BUILD_DIR)/tools/lib \ | ||
$(PKG_BUILD_DIR)/tools/testing \ | ||
$(1)/bpf-headers/tools/ | ||
$(CP) \ | ||
$(PKG_BUILD_DIR)/include \ | ||
$(PKG_BUILD_DIR)/samples \ | ||
$(PKG_BUILD_DIR)/scripts \ | ||
$(PKG_BUILD_DIR)/user_headers \ | ||
$(1)/bpf-headers | ||
$(CP) \ | ||
$(CURDIR)/files/stdarg.h \ | ||
$(1)/bpf-headers/include | ||
endef | ||
|
||
$(eval $(call BuildPackage,bpf-headers)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _STDARG_H | ||
#define _STDARG_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef __builtin_va_list va_list; | ||
|
||
#define va_start(v,l) __builtin_va_start(v,l) | ||
#define va_end(v) __builtin_va_end(v) | ||
#define va_arg(v,l) __builtin_va_arg(v,l) | ||
#define va_copy(d,s) __builtin_va_copy(d,s) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
20 changes: 20 additions & 0 deletions
20
package/kernel/bpf-headers/patches/100-support_hz_300.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- a/arch/mips/Kconfig | ||
+++ b/arch/mips/Kconfig | ||
@@ -2988,6 +2988,9 @@ choice | ||
config HZ_256 | ||
bool "256 HZ" if SYS_SUPPORTS_256HZ || SYS_SUPPORTS_ARBIT_HZ | ||
|
||
+ config HZ_300 | ||
+ bool "300 HZ" if SYS_SUPPORTS_ARBIT_HZ | ||
+ | ||
config HZ_1000 | ||
bool "1000 HZ" if SYS_SUPPORTS_1000HZ || SYS_SUPPORTS_ARBIT_HZ | ||
|
||
@@ -3039,6 +3042,7 @@ config HZ | ||
default 128 if HZ_128 | ||
default 250 if HZ_250 | ||
default 256 if HZ_256 | ||
+ default 300 if HZ_300 | ||
default 1000 if HZ_1000 | ||
default 1024 if HZ_1024 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef __LINUX_BOUNDS_H__ | ||
#define __LINUX_BOUNDS_H__ | ||
/* | ||
* DO NOT MODIFY. | ||
* | ||
* This file was generated by Kbuild | ||
*/ | ||
|
||
#define NR_PAGEFLAGS 23 /* __NR_PAGEFLAGS */ | ||
#define MAX_NR_ZONES 4 /* __MAX_NR_ZONES */ | ||
#define NR_CPUS_BITS 1 /* ilog2(CONFIG_NR_CPUS) */ | ||
#define SPINLOCK_SIZE 64 /* sizeof(spinlock_t) */ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Copyright (C) 2021 OpenWrt.org | ||
# | ||
# This is free software, licensed under the GNU General Public License v2. | ||
# See /LICENSE for more information. | ||
# | ||
|
||
include $(TOPDIR)/rules.mk | ||
|
||
override MAKEFLAGS= | ||
|
||
LLVM_VERSION := $(shell cat $(STAGING_DIR_HOST)/llvm-bpf/.llvm-version) | ||
|
||
LLVM_BPF_PREFIX := llvm-bpf-$(LLVM_VERSION).$(HOST_OS)-$(HOST_ARCH) | ||
LLVM_TAR := $(BIN_DIR)/$(LLVM_BPF_PREFIX).tar.xz | ||
|
||
$(LLVM_TAR): $(STAGING_DIR_HOST)/llvm-bpf/.llvm-version | ||
tar -C $(STAGING_DIR_HOST) \ | ||
-I '$(STAGING_DIR_HOST)/bin/xz -7e -T$(if $(filter 1,$(NPROC)),2,0)' \ | ||
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \ | ||
-cf $@.tmp llvm-bpf $(LLVM_BPF_PREFIX) | ||
mv $@.tmp $@ | ||
|
||
download: | ||
prepare: | ||
compile: $(LLVM_TAR) | ||
install: compile | ||
|
||
clean: | ||
rm -f $(LLVM_TAR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.