From 4e049fb7c3501bfe717933293c804f2a1ab9e5d1 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Sun, 24 May 2009 19:33:45 +0000 Subject: [PATCH] [8.09] put back mac80211 from r15965 since rdc uses it for rt61pci SVN-Revision: 16037 --- package/mac80211/Makefile | 207 ++++++++++++++++++ package/mac80211/files/lib/wifi/mac80211.sh | 192 ++++++++++++++++ .../patches/001-disable_drivers.patch | 147 +++++++++++++ .../patches/004-allow-ap-vlan-modes.patch | 25 +++ 4 files changed, 571 insertions(+) create mode 100644 package/mac80211/Makefile create mode 100644 package/mac80211/files/lib/wifi/mac80211.sh create mode 100644 package/mac80211/patches/001-disable_drivers.patch create mode 100644 package/mac80211/patches/004-allow-ap-vlan-modes.patch diff --git a/package/mac80211/Makefile b/package/mac80211/Makefile new file mode 100644 index 0000000000..d2369b0ec1 --- /dev/null +++ b/package/mac80211/Makefile @@ -0,0 +1,207 @@ +# +# Copyright (C) 2007-2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# $Id: Makefile 7440 2007-06-02 02:22:01Z nbd $ + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=mac80211 +PKG_RELEASE:=2 + +PKG_VERSION:=2008-08-06 +PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=http://www.orbit-lab.org/kernel/compat-wireless-2.6/2008/08/ +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/mac80211 + SUBMENU:=Wireless Drivers + TITLE:=Linux 802.11 Wireless Networking Stack + DEPENDS:=@LINUX_2_6 +kmod-crypto-arc4 +kmod-crypto-aes +wireless-tools @!TARGET_avr32 + FILES:= \ + $(PKG_BUILD_DIR)/net/mac80211/mac80211.$(LINUX_KMOD_SUFFIX) \ + $(PKG_BUILD_DIR)/net/wireless/cfg80211.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,20,cfg80211 mac80211) +endef + +define KernelPackage/mac80211/description +Linux 802.11 Wireless Networking Stack +endef + +# Ralink rt2x00 drivers +RT61FW:=RT61_Firmware_V1.2.zip +RT71FW:=RT71W_Firmware_V1.8.zip + +define Download/rt61 + FILE:=$(RT61FW) + URL:=http://www.ralinktech.com.tw/data/ + MD5SUM:=d4c690c93b470bc9a681297c2adc6281 +endef +$(eval $(call Download,rt61)) + +define Download/rt71w + FILE:=$(RT71FW) + URL:=http://www.ralinktech.com.tw/data/ + MD5SUM:=1e7a5dc574e0268574fcda3fd5cf52f7 +endef +$(eval $(call Download,rt71w)) + +define KernelPackage/rt2x00/Default + SUBMENU:=Wireless Drivers + TITLE:=Ralink Drivers for RT2x00 cards +endef + +define KernelPackage/rt2x00-lib +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT||USB_SUPPORT +kmod-mac80211 +kmod-crc-itu-t + TITLE+= (LIB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00lib.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,25,blkcipher ecb arc4 rt2x00lib) +endef + +define KernelPackage/rt2x00-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-lib +kmod-eeprom-93cx6 + TITLE+= (PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00pci.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,26,rt2x00pci) +endef + +define KernelPackage/rt2x00-usb +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @USB_SUPPORT +kmod-rt2x00-lib +kmod-usb-core + TITLE+= (USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2x00usb.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,26,rt2x00usb) +endef + +define KernelPackage/rt2400-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci + TITLE+= (RT2400 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2400pci.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,27,rt2400pci) +endef + +define KernelPackage/rt2500-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci + TITLE+= (RT2500 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2500pci.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,27,rt2500pci) +endef + +define KernelPackage/rt2500-usb +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb + TITLE+= (RT2500 USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt2500usb.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,27,rt2500usb) +endef + +define KernelPackage/rt61-pci +$(call KernelPackage/rt2x00/Default) + DEPENDS+= @PCI_SUPPORT +kmod-rt2x00-pci + TITLE+= (RT2x61 PCI) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt61pci.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,27,rt61pci) +endef + +define KernelPackage/rt73-usb + $(call KernelPackage/rt2x00/Default) + DEPENDS+= @USB_SUPPORT +kmod-rt2x00-usb + TITLE+= (RT73 USB) + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/rt2x00/rt73usb.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,27,rt73usb) +endef + +define KernelPackage/net-zd1211rw + SUBMENU:=Wireless Drivers + TITLE:=Zydas ZD1211 support + DEPENDS:=@LINUX_2_6_24||LINUX_2_6_25 @USB_SUPPORT +kmod-ieee80211-softmac + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/zd1211rw/zd1211rw.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,60,zd1211rw) +endef + +define KernelPackage/ath5k + SUBMENU:=Wireless Drivers + TITLE:=Atheros 5xxx wireless cards support + DEPENDS+= @PCI_SUPPORT +kmod-mac80211 + FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/ath5k/ath5k.$(LINUX_KMOD_SUFFIX) + AUTOLOAD:=$(call AutoLoad,27,ath5k) +endef + +BUILDFLAGS:= \ + $(foreach opt,$(CONFOPTS),-DCONFIG_$(opt)) \ + $(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS) \ + -D__CONFIG_MAC80211_RC_DEFAULT=pid \ + +MAKE_OPTS:= \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + EXTRA_CFLAGS="$(BUILDFLAGS)" \ + $(foreach opt,$(CONFOPTS),CONFIG_$(opt)=m) \ + CONFIG_NL80211=y \ + CONFIG_MAC80211_RC_PID=y \ + CONFIG_MAC80211_LEDS=$(CONFIG_LEDS_TRIGGERS) \ + LINUXINCLUDE="-I$(PKG_BUILD_DIR)/include -I$(LINUX_DIR)/include -include linux/autoconf.h" \ + KLIB_BUILD="$(LINUX_DIR)" \ + +define Build/Prepare + rm -rf $(PKG_BUILD_DIR) + mkdir -p $(PKG_BUILD_DIR) + $(PKG_UNPACK) + $(Build/Patch) + $(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used) + unzip -jod $(PKG_BUILD_DIR) $(DL_DIR)/$(RT61FW) + unzip -jod $(PKG_BUILD_DIR) $(DL_DIR)/$(RT71FW) + rm -rf $(PKG_BUILD_DIR)/include/linux/ssb +endef + +ifneq ($(CONFIG_PACKAGE_kmod-mac80211),) + define Build/Compile/kmod + $(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_OPTS) all + endef +endif + +define Build/Compile + $(call Build/Compile/kmod) +endef + +define Build/InstallDev + mkdir -p $(1)/usr/include/mac80211 $(1)/usr/include/net/mac80211 + $(CP) $(PKG_BUILD_DIR)/net/mac80211/*.h $(PKG_BUILD_DIR)/include/* $(1)/usr/include/mac80211/ + $(CP) $(PKG_BUILD_DIR)/net/mac80211/rate.h $(1)/usr/include/net/mac80211/ +endef + +define KernelPackage/mac80211/install + $(INSTALL_DIR) $(1)/lib/wifi + $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi +endef + +define KernelPackage/rt61-pci/install + $(INSTALL_DIR) $(1)/lib/firmware + $(INSTALL_DATA) $(PKG_BUILD_DIR)/rt2?61*.bin $(1)/lib/firmware/ +endef + +define KernelPackage/rt73-usb/install + $(INSTALL_DIR) $(1)/lib/firmware + $(INSTALL_DATA) $(PKG_BUILD_DIR)/rt73.bin $(1)/lib/firmware/ +endef + +$(eval $(call KernelPackage,ath5k)) +$(eval $(call KernelPackage,net-zd1211rw)) +$(eval $(call KernelPackage,mac80211)) +$(eval $(call KernelPackage,rt2x00-lib)) +$(eval $(call KernelPackage,rt2x00-pci)) +$(eval $(call KernelPackage,rt2x00-usb)) +$(eval $(call KernelPackage,rt2400-pci)) +$(eval $(call KernelPackage,rt2500-pci)) +$(eval $(call KernelPackage,rt2500-usb)) +$(eval $(call KernelPackage,rt61-pci)) +$(eval $(call KernelPackage,rt73-usb)) diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh new file mode 100644 index 0000000000..279d1d96d6 --- /dev/null +++ b/package/mac80211/files/lib/wifi/mac80211.sh @@ -0,0 +1,192 @@ +#!/bin/sh +append DRIVERS "mac80211" + +scan_mac80211() { + local device="$1" + local adhoc sta ap + + config_get vifs "$device" vifs + for vif in $vifs; do + + config_get ifname "$vif" ifname + config_set "$vif" ifname "${ifname:-$device}" + + config_get mode "$vif" mode + case "$mode" in + adhoc|sta|ap|monitor) + append $mode "$vif" + ;; + *) echo "$device($vif): Invalid mode, ignored."; continue;; + esac + done + + config_set "$device" vifs "${ap:+$ap }${adhoc:+$adhoc }${ahdemo:+$ahdemo }${sta:+$sta }${wds:+$wds }${monitor:+$monitor}" +} + + +disable_mac80211() ( + local device="$1" + + set_wifi_down "$device" + # kill all running hostapd and wpa_supplicant processes that + # are running on atheros/mac80211 vifs + for pid in `pidof hostapd wpa_supplicant`; do + grep wlan /proc/$pid/cmdline >/dev/null && \ + kill $pid + done + + include /lib/network + cd /proc/sys/net + for dev in *; do + grep "$device" "$dev/%parent" >/dev/null 2>/dev/null && { + ifconfig "$dev" down + unbridge "$dev" + } + done + return 0 +) + +enable_mac80211() { + local device="$1" + config_get channel "$device" channel + config_get vifs "$device" vifs + config_get txpower "$device" txpower + + local first=1 + for vif in $vifs; do + ifconfig "$ifname" down 2>/dev/null + config_get ifname "$vif" ifname + config_get enc "$vif" encryption + config_get eap_type "$vif" eap_type + config_get mode "$vif" mode + + config_get ifname "$vif" ifname + [ $? -ne 0 ] && { + echo "enable_mac80211($device): Failed to set up $mode vif $ifname" >&2 + continue + } + config_set "$vif" ifname "$ifname" + + [ "$first" = 1 ] && { + # only need to change freq band and channel on the first vif + iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null + if [ "$mode" = adhoc ]; then + iwlist "$ifname" scan >/dev/null 2>/dev/null + sleep 1 + iwconfig "$ifname" mode ad-hoc >/dev/null 2>/dev/null + fi + sleep 1 + iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null + } + if [ "$mode" = sta ]; then + iwconfig "$ifname" mode managed >/dev/null 2>/dev/null + else + iwconfig "$ifname" mode $mode >/dev/null 2>/dev/null + fi + + wpa= + case "$enc" in + WEP|wep) + for idx in 1 2 3 4; do + config_get key "$vif" "key${idx}" + iwconfig "$ifname" enc "[$idx]" "${key:-off}" + done + config_get key "$vif" key + key="${key:-1}" + case "$key" in + [1234]) iwconfig "$ifname" enc "[$key]";; + *) iwconfig "$ifname" enc "$key";; + esac + ;; + PSK|psk|PSK2|psk2) + config_get key "$vif" key + ;; + esac + + case "$mode" in + adhoc) + config_get addr "$vif" bssid + [ -z "$addr" ] || { + iwconfig "$ifname" ap "$addr" + } + ;; + esac + config_get ssid "$vif" ssid + + config_get vif_txpower "$vif" txpower + # use vif_txpower (from wifi-iface) to override txpower (from + # wifi-device) if the latter doesn't exist + txpower="${txpower:-$vif_txpower}" + [ -z "$txpower" ] || iwconfig "$ifname" txpower "${txpower%%.*}" + + config_get frag "$vif" frag + if [ -n "$frag" ]; then + iwconfig "$ifname" frag "${frag%%.*}" + fi + + config_get rts "$vif" rts + if [ -n "$rts" ]; then + iwconfig "$ifname" rts "${rts%%.*}" + fi + + ifconfig "$ifname" up + iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null + + local net_cfg bridge + net_cfg="$(find_net_config "$vif")" + [ -z "$net_cfg" ] || { + bridge="$(bridge_interface "$net_cfg")" + config_set "$vif" bridge "$bridge" + start_net "$ifname" "$net_cfg" + } + iwconfig "$ifname" essid "$ssid" + set_wifi_up "$vif" "$ifname" + case "$mode" in + ap) + if eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then + hostapd_setup_vif "$vif" nl80211 || { + echo "enable_mac80211($device): Failed to set up wpa for interface $ifname" >&2 + # make sure this wifi interface won't accidentally stay open without encryption + ifconfig "$ifname" down + continue + } + fi + ;; + sta) + if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then + wpa_supplicant_setup_vif "$vif" wext || { + echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2 + # make sure this wifi interface won't accidentally stay open without encryption + ifconfig "$ifname" down + continue + } + fi + ;; + esac + first=0 + done +} + + +detect_mac80211() { + cd /sys/class/net + for dev in $(ls -d wlan* 2>&-); do + config_get type "$dev" type + [ "$type" = mac80211 ] && return + cat < /sys/bus/pci/drivers/ipw2200/*/rtap_iface +-CONFIG_IPW2200_QOS=y +- +-NEED_IEEE80211=y +- +-CONFIG_P54_PCI=m +- +-CONFIG_SSB_PCIHOST_POSSIBLE=y +-CONFIG_SSB_PCIHOST=y +-CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y +-CONFIG_SSB_DRIVER_PCICORE=y +-CONFIG_SSB_B43_PCI_BRIDGE=y +- +-CONFIG_RTL8180=m +-CONFIG_ADM8211=m +- + CONFIG_RT2X00_LIB_PCI=m + CONFIG_RT2400PCI=m + CONFIG_RT2500PCI=m +@@ -159,32 +95,6 @@ + ifneq ($(CONFIG_USB),) + CONFIG_ZD1211RW=m + +-# support for USB Wireless devices using Atmel at76c503, +-# at76c505 or at76c505a chips. +-CONFIG_USB_ATMEL=m +- +-# Stuff here things which depend on kernel versions for USB +-ifeq ($(shell test -e $(KLIB_BUILD)/Makefile && echo yes),yes) +-KERNEL_SUBLEVEL = $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') +-ifeq ($(shell test $(KERNEL_SUBLEVEL) -gt 21 && echo yes),yes) +- +-# Sorry, rndis_wlan uses cancel_work_sync which is new and can't be done in compat... +- +-# Wireless RNDIS USB support (RTL8185 802.11g) A-Link WL54PC +-# All of these devices are based on Broadcom 4320 chip which +-# is only wireless RNDIS chip known to date. +-# Note: this depends on CONFIG_USB_NET_RNDIS_HOST and CONFIG_USB_NET_CDCETHER +-# it also requires new RNDIS_HOST and CDC_ETHER modules which we add +-CONFIG_USB_NET_RNDIS_HOST=m +-CONFIG_USB_NET_RNDIS_WLAN=m +-CONFIG_USB_NET_CDCETHER=m +- +-endif +-endif +- +-CONFIG_P54_USB=m +-CONFIG_RTL8187=m +- + # RT2500USB does not require firmware + CONFIG_RT2500USB=m + CONFIG_RT2X00_LIB_USB=m +@@ -209,39 +119,6 @@ + CONFIG_RT2X00_LIB_FIRMWARE=y + endif + +-# p54 +-CONFIG_P54_COMMON=m +- +-# Sonics Silicon Backplane +-CONFIG_SSB_POSSIBLE=y +-CONFIG_SSB=m +-CONFIG_SSB_SPROM=y +- +-ifneq ($(CONFIG_PCMCIA),) +-CONFIG_SSB_PCMCIAHOST=y +-endif +- +-# These two are for mips +-CONFIG_SSB_DRIVER_MIPS=n +-CONFIG_SSB_PCICORE_HOSTMODE=n +-# CONFIG_SSB_DEBUG is not set +-# CONFIG_SSB_DRIVER_EXTIF=y +- +-ifneq ($(CONFIG_USB),) +-CONFIG_LIBERTAS_USB=m +-NEED_LIBERTAS=y +-endif +-ifneq ($(CONFIG_PCMCIA),) +-CONFIG_LIBERTAS_CS=m +-NEED_LIBERTAS=y +-endif +-ifeq ($(NEED_LIBERTAS),y) +-CONFIG_LIBERTAS=m +-# Libertas uses the old stack but not fully, it will soon +-# be cleaned. +-NEED_IEEE80211=y +-endif +- + ifeq ($(NEED_IEEE80211),y) + # Old ieee80211 "stack" + # Note: old softmac is scheduled for removal so we diff --git a/package/mac80211/patches/004-allow-ap-vlan-modes.patch b/package/mac80211/patches/004-allow-ap-vlan-modes.patch new file mode 100644 index 0000000000..a8080b20ea --- /dev/null +++ b/package/mac80211/patches/004-allow-ap-vlan-modes.patch @@ -0,0 +1,25 @@ +Subject: mac80211: allow AP and VLAN modes + +This patch allows switching interfaces into AP/VLAN modes using +cfg80211 (nl80211). Don't allow doing it with wext because then +people will just attempt to do it manually (without hostapd) and +complain that it doesn't work. + +Signed-off-by: Johannes Berg +--- + net/mac80211/cfg.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- everything.orig/net/mac80211/cfg.c 2008-08-06 21:38:13.000000000 +0200 ++++ everything/net/mac80211/cfg.c 2008-08-06 21:38:24.000000000 +0200 +@@ -33,6 +33,10 @@ nl80211_type_to_mac80211_type(enum nl802 + case NL80211_IFTYPE_MESH_POINT: + return IEEE80211_IF_TYPE_MESH_POINT; + #endif ++ case NL80211_IFTYPE_AP: ++ return IEEE80211_IF_TYPE_AP; ++ case NL80211_IFTYPE_AP_VLAN: ++ return IEEE80211_IF_TYPE_VLAN; + case NL80211_IFTYPE_WDS: + return IEEE80211_IF_TYPE_WDS; + default: -- 2.30.2