# All rights reserved. # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mt_wifi MT7981_FW_DIR := mt7981-fw-20230717 MT7986_FW_DIR := mt7986-fw-20230421 ifeq ($(CONFIG_MTK_CHIP_MT7981),y) PKG_SUFFIX:=mt7981 else ifeq ($(CONFIG_MTK_CHIP_MT7986),y) PKG_SUFFIX:=mt7986 endif endif PKG_BUILD_DEPENDS:=warp PKG_SOURCE:=mt798x-7.6.6.1-src.tar.xz PKG_VERSION:=7.6.6.1-$(PKG_SUFFIX) PKG_BUILD_PARALLEL:=1 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME) PKG_KCONFIG:= \ AP_SUPPORT \ RT_FIRST_CARD \ RT_SECOND_CARD \ RT_FIRST_IF_RF_OFFSET \ RT_SECOND_IF_RF_OFFSET \ MT_WIFI \ WIFI_BASIC_FUNC \ MT_WIFI_PATH \ FIRST_IF_NONE \ FIRST_IF_EEPROM_FLASH \ FIRST_IF_EEPROM_EFUSE \ RT_FIRST_CARD_EEPROM \ SECOND_IF_NONE \ SECOND_IF_EEPROM_FLASH \ SECOND_IF_EEPROM_PROM \ SECOND_IF_EEPROM_EFUSE \ RT_SECOND_CARD_EEPROM \ MULTI_INF_SUPPORT \ WIFI_BASIC_FUNC \ WIRELESS_EXT \ WEXT_SPY \ WEXT_PRIV \ DOT11_N_SUPPORT \ DOT11_VHT_AC \ DOT11_HE_AX \ CFG_SUPPORT_FALCON_MURU \ CFG_SUPPORT_FALCON_TXCMD_DBG \ CFG_SUPPORT_FALCON_SR \ CFG_SUPPORT_FALCON_PP \ WIFI_DRIVER \ G_BAND_256QAM_SUPPORT \ BRCM_256QAM_SUPPORT \ ICAP_SUPPORT \ MT_AP_SUPPORT \ BACKGROUND_SCAN_SUPPORT \ SMART_CARRIER_SENSE_SUPPORT \ SCS_FW_OFFLOAD \ THERMAL_PROTECT_SUPPORT \ MT_DFS_SUPPORT \ HDR_TRANS_TX_SUPPORT \ CHIP_MT7615E \ HDR_TRANS_RX_SUPPORT \ DBDC_MODE \ MULTI_PROFILE_SUPPORT \ DEFAULT_5G_PROFILE \ SUPPORT_DYNAMIC_TXOP \ WSC_INCLUDED \ MT_STA_SUPPORT \ WSC_V2_SUPPORT \ DOT11W_PMF_SUPPORT \ PASSPOINT_R2 \ TXBF_SUPPORT \ IGMP_SNOOP_SUPPORT \ RATE_ADAPTION \ RATE_ADAPT_AGBS_SUPPORT \ RTMP_FLASH_SUPPORT \ ATE_SUPPORT \ WLAN_SERVICE \ UAPSD \ RLT_MAC \ RLT_BBP \ RLT_RF \ RTMP_MAC \ RTMP_BBP \ RTMP_RF \ RTMP_PCI_SUPPORT \ RTMP_USB_SUPPORT \ RTMP_RBUS_SUPPORT \ WIFI_MODE_AP \ WIFI_MODE_STA \ WIRELESS_EXT \ WEXT_SPY \ WEXT_PRIV \ WDS_SUPPORT \ MBSS_SUPPORT \ APCLI_SUPPORT \ APCLI_CERT_SUPPORT \ APCLI_CONNECTION_TRIAL \ MAC_REPEATER_SUPPORT \ RALINK_RT6352 \ RALINK_MT7620 \ RALINK_MT7603E \ CON_WPS_SUPPORT \ VOW_SUPPORT \ BAND_STEERING \ TXOP_ARBITER \ CFG_SUPPORT_DYNAMIC_TXOP \ WIFI_MODE_BOTH \ WIFI_RLT_MAC \ RLT_MAC \ WIFI_RTMP_MAC \ RTMP_MAC \ WIFI_MT_MAC \ CHIP_MT7603E \ CHIP_MT7615E \ MT_MAC \ RATE_ADAPTION \ SUPPORT_OPENWRT \ SDK_USER_LIGHTY \ MUMIMO_SUPPORT \ MU_RA_SUPPORT \ LED_CONTROL_SUPPORT \ RA_HW_NAT \ RA_HW_NAT_WIFI_NEW_ARCH \ CFG80211_SUPPORT \ SER_SUPPORT \ GREENAP_SUPPORT \ RADIUS_ACCOUNTING_SUPPORT \ TPC_SUPPORT \ RLM_CAL_CACHE_SUPPORT \ CAL_BIN_FILE_SUPPORT \ RF_LOCKDOWN_SUPPORT \ PASSPOINT_R2 \ RED_SUPPORT \ FIRST_IF_EPAELNA \ FIRST_IF_IPAILNA \ FIRST_IF_IPAELNA \ FIRST_IF_EPAILNA \ SECOND_IF_EPAELNA \ SECOND_IF_IPAILNA \ SECOND_IF_IPAELNA \ SECOND_IF_EPAILNA \ THIRD_IF_EPAELNA \ THIRD_IF_IPAILNA \ THIRD_IF_IPAELNA \ THIRD_IF_EPAILNA \ WIFI_PKT_FWD \ DOT11K_RRM_SUPPORT \ DOT11R_FT_SUPPORT \ ENTERPRISE_AP_SUPPORT \ WIFI_EAP_FEATURE \ TXRX_STAT_SUPPORT \ ANTENNA_CONTROL_SUPPORT \ MGMT_TXPWR_CTRL \ TXD_MGMT_TXPWR_CTRL \ CHUTIL_SUPPORT \ NF_SUPPORT \ RA_PHY_RATE_SUPPORT \ MBSS_DTIM_SUPPORT \ AMPDU_CONF_SUPPORT \ ACK_CTS_TIMEOUT_SUPPORT \ HIGHPRI_RATE_SPECIFIC \ RADIUS_MAC_AUTH_SUPPORT \ ZERO_LOSS_CSA_SUPPORT \ VLAN_SUPPORT \ DYNAMIC_VLAN_SUPPORT \ IAP_VENDOR1_FEATURE_SUPPORT \ CUSTOMISED_HOSTAPD_SUPPORT \ HOSTAPD_WPA3_SUPPORT \ HOSTAPD_WPA3R3_SUPPORT \ DBDC_ONE_BAND_SUPPORT \ APCLI_STA_SUPPORT \ WDS_STA_SUPPORT \ MBSS_AS_WDS_AP_SUPPORT \ MBO_SUPPORT \ MAP_SUPPORT \ MAP_R2_VER_SUPPORT \ MAP_R3_VER_SUPPORT \ QOS_R1_SUPPORT \ WPA3_SUPPORT \ OWE_SUPPORT \ WIFI_PKT_FWD_V1 \ FIRST_IF_MT7615E \ FIRST_IF_MT7622 \ FIRST_IF_MT7626 \ FIRST_IF_AXE \ FIRST_IF_MT7915 \ FIRST_IF_MT7916 \ FIRST_IF_MT7986 \ FIRST_IF_MT7981 \ SECOND_IF_MT7915 \ SECOND_IF_MT7916 \ SECOND_IF_MT7615E \ SECOND_IF_AXE \ THIRD_IF_NONE \ THIRD_IF_MT7615E \ THIRD_IF_MT7916 \ CHIP_AXE \ CHIP_MT7915 \ CHIP_MT7916 \ CHIP_MT7986 \ CHIP_MT7981 \ RT_THIRD_CARD \ RT_THIRD_IF_RF_OFFSET \ THIRD_IF_EEPROM_FLASH \ THIRD_IF_EEPROM_PROM \ THIRD_IF_EEPROM_EFUSE \ RT_THIRD_CARD_EEPROM \ SPECTRUM_SUPPORT \ PHY_ICS_SUPPORT \ MULTI_PROFILE_SUPPORT \ PRE_CAL_TRX_SET1_SUPPORT \ MWDS \ MCAST_RATE_SPECIFIC \ WLAN_HOOK \ COEX_SUPPORT \ EASY_SETUP_SUPPORT \ EVENT_NOTIFIER_SUPPORT \ AIR_MONITOR \ OFFCHANNEL_SCAN_FEATURE \ WNM_SUPPORT \ INTERWORKING \ LINUX_NET_TXQ_SUPPORT \ CHIP_MT7622 \ CHIP_MT7626 \ MEMORY_SHRINK \ MEMORY_SHRINK_AGGRESS \ RPS_EFFICIENCY \ WHNAT_SUPPORT \ FAST_NAT_SUPPORT \ PRE_CAL_TRX_SET2_SUPPORT \ LINK_TEST_SUPPORT \ TCP_RACK_SUPPORT \ FQ_SCH_SUPPORT \ BRCM_256QAM_SUPPORT \ VHT_TXBF_2G_EPIGRAM_IE_SUPPORT \ DSCP_QOS_MAP_SUPPORT \ DSCP_PRI_SUPPORT \ PCIE_ASPM_DYM_CTRL_SUPPORT \ MIN_PHY_RATE_SUPPORT \ FAST_UP_RATE_SUPPORT \ TXRX_STAT_SUPPORT \ VENDOR_FEATURE11_SUPPORT \ WIFI_TWT_SUPPORT \ CTXD_MEM_CPY_SUPPORT \ CTXD_SCATTER_AND_GATHER_SUPPORT \ SINGLE_SKU \ SNIFFER_SUPPORT \ SNIFFER_RADIOTAP_SUPPORT \ WF_RESET_SUPPORT \ WIFI_SYSDVT \ WARP_V2 \ OCE_SUPPORT \ WTBL_TDD_SUPPORT \ SW_CONNECT_SUPPORT \ 6G_SUPPORT \ BSSMGR_CROSS_MODULE_SUPPORT \ WIFI_FW_BIN_LOAD \ CONNINFRA_APSOC \ MLME_MULTI_QUEUE_SUPPORT \ WIFI_SKU_TYPE \ MAP_R2_6E_SUPPORT \ MAP_R3_6E_SUPPORT \ WIFI_SKB_USES_SLAB \ WIFI_CSI_CN_INFO_SUPPORT \ 6G_AFC_SUPPORT \ PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c))) PKG_PREPARED_DEPENDS:= CONFIG_MTK_MT7986_NEW_FW CONFIG_MTK_MT7981_NEW_FW include $(INCLUDE_DIR)/package.mk TAR_CMD=$(HOST_TAR) -C $(1)/ $(TAR_OPTIONS) define KernelPackage/mt_wifi CATEGORY:=MTK Properties TITLE:=MTK wifi AP driver DEPENDS:=+wifi-profile DEPENDS+=+kmod-conninfra DEPENDS+=+kmod-mediatek_hnat FILES:=$(PKG_BUILD_DIR)/mt_wifi_ap/mt_wifi.ko \ $(PKG_BUILD_DIR)/mt_wifi/embedded/plug_in/warp_proxy/mtk_warp_proxy.ko DEPENDS+=+kmod-warp AUTOLOAD:=$(call AutoProbe,mt_wifi mtk_warp_proxy) SUBMENU:=Drivers MENU:=1 endef define KernelPackage/mt_wifi/config source "$(SOURCE)/config.in" endef define FIXUP_NEW_MCU_FW_API @if [ "$$(CONFIG_MTK_MT7981_NEW_FW)" = "y" ] || [ "$$(CONFIG_MTK_MT7986_NEW_FW)" = "y" ]; then \ echo "Fixup new mcu fw API"; \ patch -p1 -d $(PKG_BUILD_DIR) < ./files/fix-new-mcu-fw-api.patch; \ fi endef Hooks/Prepare/Post := FIXUP_NEW_MCU_FW_API define Build/Compile +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ $(KERNEL_MAKE_FLAGS) \ M="$(PKG_BUILD_DIR)/mt_wifi_ap" \ LINUX_DIR="$(KERNEL_BUILD_DIR)" \ $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MTK_$c),CONFIG_$(c)=$(CONFIG_MTK_$(c)))) \ modules endef define KernelPackage/mt_wifi/install if [ "$$(CONFIG_MTK_WIFI_FW_BIN_LOAD)" = "y" ]; then \ rm -rf $(1)/lib/firmware/; \ $(INSTALL_DIR) $(1)/lib/firmware/; \ if [ "$$(CONFIG_MTK_CHIP_MT7986)" = "y" ] ; then \ if [ "$$(CONFIG_MTK_MT7986_NEW_FW)" = "y" ]; then \ $(INSTALL_BIN) ./files/$$(MT7986_FW_DIR)/WIFI_RAM_CODE_MT7986.bin \ ./files/$$(MT7986_FW_DIR)/WIFI_RAM_CODE_MT7986_MT7975.bin \ ./files/$$(MT7986_FW_DIR)/mt7986_patch_e1_hdr.bin \ ./files/$$(MT7986_FW_DIR)/mt7986_patch_e1_hdr_mt7975.bin \ ./files/$$(MT7986_FW_DIR)/7986_WACPU_RAM_CODE_release.bin $(1)/lib/firmware/; \ else \ $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7986/rebb/WIFI_RAM_CODE_MT7986.bin \ $(PKG_BUILD_DIR)/bin/mt7986/rebb/WIFI_RAM_CODE_MT7986_MT7975.bin \ $(PKG_BUILD_DIR)/bin/mt7986/rebb/mt7986_patch_e1_hdr.bin \ $(PKG_BUILD_DIR)/bin/mt7986/rebb/mt7986_patch_e1_hdr_mt7975.bin \ $(PKG_BUILD_DIR)/bin/mt7986/rebb/7986_WACPU_RAM_CODE_release.bin $(1)/lib/firmware/; \ fi ; \ if [ "$$(CONFIG_MTK_WIFI_SKU_TYPE)" = "AX6000" -o "$$(CONFIG_MTK_WIFI_SKU_TYPE)" = "AX8400" ] ; then \ $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7986/rebb/MT7986_iPAiLNA_EEPROM_AX6000.bin $(PKG_BUILD_DIR)/bin/mt7986/rebb/MT7986_ePAeLNA_EEPROM_AX6000.bin \ $(1)/lib/firmware/; \ fi; \ if [ "$$(CONFIG_MTK_WIFI_SKU_TYPE)" = "AX4200" ] ; then \ $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7986/rebb/MT7986_ePAeLNA_EEPROM_ONEADIE_DBDC.bin \ $(1)/lib/firmware/; \ fi; \ fi; \ if [ "$$(CONFIG_MTK_CHIP_MT7916)" = "y" ] ; then \ $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7916/rebb/* $(1)/lib/firmware/; \ fi; \ if [ "$$(CONFIG_MTK_CHIP_MT7981)" = "y" ] ; then \ $(INSTALL_BIN) ./files/mt7981-default-eeprom/MT7981_iPAiLNA_EEPROM.bin \ ./files/mt7981-default-eeprom/MT7981_ePAeLNA_EEPROM.bin $(1)/lib/firmware/; \ if [ "$$(CONFIG_MTK_MT7981_NEW_FW)" = "y" ]; then \ $(INSTALL_BIN) ./files/$$(MT7981_FW_DIR)/WIFI_RAM_CODE_MT7981.bin \ ./files/$$(MT7981_FW_DIR)/7981_WACPU_RAM_CODE_release.bin \ ./files/$$(MT7981_FW_DIR)/mt7981_patch_e1_hdr.bin \ $(1)/lib/firmware/; \ else \ $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/mt7981/rebb/WIFI_RAM_CODE_MT7981.bin \ $(PKG_BUILD_DIR)/bin/mt7981/rebb/7981_WACPU_RAM_CODE_release.bin \ $(PKG_BUILD_DIR)/bin/mt7981/rebb/mt7981_patch_e1_hdr.bin \ $(1)/lib/firmware/; \ fi ; \ fi; \ fi endef $(eval $(call KernelPackage,mt_wifi))