blob: c84565eea6d7307d5d4a33ad796927d481d4a2ca [file] [log] [blame]
developere5e687d2023-08-08 16:05:33 +08001# SPDX-License-Identifier: GPL-2.0-or-later
2#
3# Copyright (C) 2023 Mediatek Inc. All Rights Reserved.
4# Author: Ren-Ting Wang <ren-ting.wang@mediatek.com>
5#
6
7include $(TOPDIR)/rules.mk
8include $(INCLUDE_DIR)/kernel.mk
9
10PKG_NAME:=tops
11PKG_RELEASE:=1
12
13include $(INCLUDE_DIR)/package.mk
14include $(INCLUDE_DIR)/package-defaults.mk
15
16EXTRA_KCONFIG+= \
17 CONFIG_MTK_TOPS_SUPPORT=m \
18 CONFIG_MTK_TOPS_GRE=$(CONFIG_MTK_TOPS_GRE) \
19 CONFIG_MTK_TOPS_GRETAP=$(CONFIG_MTK_TOPS_GRETAP) \
20 CONFIG_MTK_TOPS_L2TP=$(CONFIG_MTK_TOPS_L2TP) \
21 CONFIG_MTK_TOPS_UDP_L2TP_DATA=$(CONFIG_MTK_TOPS_UDP_L2TP_DATA) \
22 CONFIG_MTK_TOPS_SECURE_FW=$(CONFIG_MTK_TOPS_SECURE_FW)
23
24EXTRA_CFLAGS+= \
25 $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
26 $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG))))
27
28EXTRA_CFLAGS+= \
29 -I$(LINUX_DIR)/drivers/net/ethernet/mediatek/ \
30 -I$(LINUX_DIR)/drivers/dma/ \
31 -I$(KERNEL_BUILD_DIR)/pce/inc/ \
32 -DCONFIG_TOPS_TNL_NUM=$(CONFIG_TOPS_TNL_NUM) \
33 -DCONFIG_TOPS_TNL_MAP_BIT=$(CONFIG_TOPS_TNL_MAP_BIT) \
34 -Wall -Werror
35
36define Build/Prepare
37 mkdir -p $(PKG_BUILD_DIR)
38 $(CP) ./firmware $(PKG_BUILD_DIR)/firmware
39 $(CP) ./src/* $(PKG_BUILD_DIR)/
40endef
41
42define Package/tops-rebb-fw-release
43 TITLE:=Mediatek Tunnel Offload Processor System ReBB Firmware
44 SECTION:=firmware
45 CATEGORY:=Firmware
46 DEPENDS:=@MTK_TOPS_FIRMWARE_RELEASE
47endef
48
49define Package/tops-rebb-fw-release/description
50 Support for Mediatek Tunnel Offload Processor System ReBB firmware. The
51 firmware offload and accerlerate APMCU's tunnel protocols traffic. Available
52 offload tunnel include L2oGRE, L2TP.
53endef
54
55define Package/tops-rebb-fw-release/install
56 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
57 $(CP) \
58 $(PKG_BUILD_DIR)/firmware/rebb/mt7988_mgmt/tops-mgmt.img \
59 $(PKG_BUILD_DIR)/firmware/rebb/mt7988_offload/tops-offload.img \
60 $(1)/lib/firmware/mediatek
61endef
62
63define KernelPackage/tops
64 CATEGORY:=MTK Properties
65 SUBMENU:=Drivers
66 TITLE:= MTK Tunnel Offload Processor System Driver
67 FILES+=$(PKG_BUILD_DIR)/tops.ko
68 KCONFIG:=
69 DEFAULT:=y
70 DEPENDS:= \
71 @TARGET_mediatek_mt7988 \
72 kmod-mediatek_hnat \
73 +kmod-pce \
74 +@KERNEL_RELAY
75endef
76
77define KernelPackage/tops/description
78 Support for MTK Tunnel Offload Processor System. This system reduces the
79 loading of APMCU's tunnel protocol overhead and improve tunnel protocol's
80 throughput.
81endef
82
83define KernelPackage/tops/config
84 source "$(SOURCE)/Config.in"
85endef
86
87define KernelPackage/tops-autoload
88 CATEGORY:=MTK Properties
89 SUBMENU:=Drivers
90 TITLE:= MTK Tunnel Offload Processor System Auto Load
91 AUTOLOAD:=$(call AutoLoad,51,tops)
92 KCONFIG:=
93 DEPENDS:= \
94 kmod-tops \
95 +kmod-pce-autoload
96endef
97
98define KernelPackage/tops-autoload/description
99 Support for MTK Tunnel Offload Processor System auto load on system
100 boot process.
101endef
102
103define Build/Compile
104 $(MAKE) -C "$(LINUX_DIR)" \
105 $(KERNEL_MAKE_FLAGS) \
106 M="$(PKG_BUILD_DIR)" \
107 EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
108 $(EXTRA_KCONFIG) \
109 modules
110endef
111
112$(eval $(call BuildPackage,tops-rebb-fw-release))
113$(eval $(call KernelPackage,tops))
114$(eval $(call KernelPackage,tops-autoload))