Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen
2024-02-04 15:56:19 +08:00
66 changed files with 974 additions and 4116 deletions

View File

@@ -1193,21 +1193,6 @@ config KERNEL_XDP_SOCKETS
XDP sockets allows a channel between XDP programs and
userspace applications.
config KERNEL_WIRELESS_EXT
def_bool n
config KERNEL_WEXT_CORE
def_bool KERNEL_WIRELESS_EXT
config KERNEL_WEXT_PRIV
def_bool KERNEL_WIRELESS_EXT
config KERNEL_WEXT_PROC
def_bool KERNEL_WIRELESS_EXT
config KERNEL_WEXT_SPY
def_bool KERNEL_WIRELESS_EXT
config KERNEL_PAGE_POOL
def_bool n

View File

@@ -1,192 +0,0 @@
#
# Copyright (C) 2006-2014 OpenWrt.org
#
# 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:=broadcom-wl
PKG_VERSION:=5.10.56.27.3
PKG_RELEASE:=10
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2
PKG_SOURCE_URL:=@OPENWRT
ifeq ($(ARCH),mipsel)
PKG_HASH:=26a8c370f48fc129d0731cfd751c36cae1419b0bc8ca35781126744e60eae009
endif
ifeq ($(ARCH),mips)
PKG_HASH:=ca6a86ca3e3e9c85b6dbb665b35bcbf338c37829c1b2f1994487d55664886045
endif
PKG_EXTMOD_SUBDIRS:=driver driver-mini glue
PKG_BUILD_FLAGS:=no-mips16
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
define Package/broadcom-wl/Default
SECTION:=kernel
CATEGORY:=Kernel modules
DEPENDS:=@(PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mini)
SUBMENU:=Proprietary BCM43xx WiFi driver
SUBMENUDEP:=(TARGET_bcm47xx||TARGET_bcm63xx)
endef
define KernelPackage/brcm-wl/Default
$(call Package/broadcom-wl/Default)
SECTION:=kernel
DEPENDS:=@(TARGET_bcm47xx||TARGET_bcm63xx) +wireless-tools +@KERNEL_WIRELESS_EXT
TITLE:=Kernel driver for BCM43xx chipsets
FILES:=$(PKG_BUILD_DIR)/driver$(1)/wl.ko $(PKG_BUILD_DIR)/glue/wl_glue.ko
AUTOLOAD:=$(call AutoProbe,wl)
endef
define KernelPackage/brcm-wl/Default/description
This package contains the proprietary wireless driver for the Broadcom
BCM43xx chipset.
endef
define KernelPackage/brcm-wl
$(call KernelPackage/brcm-wl/Default,)
TITLE+= (normal version)
endef
define KernelPackage/brcm-wl/description
$(call KernelPackage/brcm-wl/Default/description)
endef
define KernelPackage/brcm-wl-mini
$(call KernelPackage/brcm-wl/Default,-mini)
TITLE+= (Legacy version)
endef
define KernelPackage/brcm-wl-mini/description
$(call KernelPackage/brcm-wl/Default/description)
endef
define Package/wlc
$(call Package/broadcom-wl/Default)
TITLE:=wl driver setup utility
endef
define Package/wlc/description
This package contains an utility for initializing the proprietary Broadcom
wl driver.
endef
define Package/wl
$(call Package/broadcom-wl/Default)
TITLE:=Proprietary Broadcom wl driver config utility
endef
define Package/wl/description
This package contains the proprietary utility (wl) for configuring the
proprietary Broadcom wl driver.
endef
define Package/nas
$(call Package/broadcom-wl/Default)
TITLE:=Proprietary Broadcom WPA/WPA2 authenticator
endef
define Package/nas/description
This package contains the proprietary WPA/WPA2 authenticator (nas) for the
proprietary Broadcom wl driver.
endef
MAKE_KMOD := $(KERNEL_MAKE) \
PATH="$(TARGET_PATH)" \
M="$(PKG_BUILD_DIR)/kmod" \
define Build/Prepare
$(call Build/Prepare/Default)
# New kernel version changed the sysmbol exported from printk to _printk
# The object file provided by broadcom require modification to correctly
# modprobe and generate a .ko
$(TARGET_CROSS)objcopy $(PKG_BUILD_DIR)/driver/wl_apsta/wl_prebuilt.o \
--redefine-sym printk=_printk
$(TARGET_CROSS)objcopy $(PKG_BUILD_DIR)/driver/wl_apsta_mini/wl_prebuilt.o \
--redefine-sym printk=_printk
$(CP) $(PKG_BUILD_DIR)/driver $(PKG_BUILD_DIR)/driver-mini
$(CP) ./src/glue $(PKG_BUILD_DIR)/glue
endef
define Build/Compile
# Compile glue driver
$(MAKE_KMOD) -C "$(LINUX_DIR)" \
M="$(PKG_BUILD_DIR)/glue" \
modules
# Compile the kernel part
$(MAKE_KMOD) \
M="$(PKG_BUILD_DIR)/driver" \
MODFLAGS="-DMODULE -mlong-calls" \
KBUILD_EXTRA_SYMBOLS="$(PKG_BUILD_DIR)/glue/Module.symvers" \
modules
$(MAKE_KMOD) \
M="$(PKG_BUILD_DIR)/driver-mini" \
MODFLAGS="-DMODULE -mlong-calls" \
BUILD_TYPE="wl_apsta_mini" \
KBUILD_EXTRA_SYMBOLS="$(PKG_BUILD_DIR)/glue/Module.symvers" \
modules
# Compile libshared
$(MAKE) -C $(PKG_BUILD_DIR)/shared \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS) -I. -I$(PKG_BUILD_DIR)/driver/include" \
all
$(TARGET_CC) -o $(PKG_BUILD_DIR)/wlc \
-I$(PKG_BUILD_DIR)/shared -I$(PKG_BUILD_DIR)/driver/include \
./src/wlc.c $(PKG_BUILD_DIR)/shared/libshared.a
$(TARGET_CC) -o $(PKG_BUILD_DIR)/nas \
$(PKG_BUILD_DIR)/nas_exe.o \
$(PKG_BUILD_DIR)/shared/libshared.a
$(TARGET_CC) -o $(PKG_BUILD_DIR)/wl \
$(PKG_BUILD_DIR)/wl_exe.o \
$(PKG_BUILD_DIR)/shared/libshared.a
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/shared/libshared.a $(1)/usr/lib/
endef
define Package/wlc/install
$(CP) ./files/* $(1)/
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/wlc $(1)/sbin/
endef
define Package/wlc/postinst
#!/bin/sh
[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/wlunbind enable || true
endef
define Package/wl/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/wl $(1)/usr/sbin/
endef
define Package/nas/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/nas $(1)/usr/sbin/
$(LN) nas $(1)/usr/sbin/nas4not
$(LN) nas $(1)/usr/sbin/nas4wds
endef
$(eval $(call KernelPackage,brcm-wl))
$(eval $(call KernelPackage,brcm-wl-mini))
$(eval $(call BuildPackage,wlc))
$(eval $(call BuildPackage,wl))
$(eval $(call BuildPackage,nas))

View File

@@ -1,5 +0,0 @@
#!/bin/sh
[ "${ACTION}" = "add" ] && [ "${INTERFACE%%[0-9]}" = "wl" ] && {
/sbin/wifi config
}

View File

@@ -1,61 +0,0 @@
include /lib/wifi
setup_broadcom_wds() {
local iface="$1"
local remote="$(wlc ifname "$iface" wdsmac)"
[ -z "$remote" ] && return
config_cb() {
[ -z "$CONFIG_SECTION" ] && return
config_get type "$CONFIG_SECTION" TYPE
[ "$type" = "wifi-iface" ] || return
config_get network "$CONFIG_SECTION" network
[ -z "$network" ] && return
config_get addr "$CONFIG_SECTION" bssid
addr=$(echo "$addr" | tr 'A-F' 'a-f')
[ "$addr" = "$remote" ] && {
local cfg="$CONFIG_SECTION"
include /lib/network
scan_interfaces
for network in $network; do
setup_interface "$iface" "$network"
done
config_get encryption "$cfg" encryption
config_get key "$cfg" key
config_get ssid "$cfg" ssid
[ "$encryption" != "none" ] && {
sleep 5
case "$encryption" in
psk|PSK)
nas4not "$network" "$iface" up auto tkip psk "$key" "$ssid"
;;
psk2|PSK2)
nas4not "$network" "$iface" up auto aes psk "$key" "$ssid"
;;
psk+psk2|psk2+psk|PSK+PSK2|PSK2+PSK)
nas4not "$network" "$iface" up auto aes+tkip psk "$key" "$ssid"
;;
*)
nas4not lan "$iface" up auto aes "$encryption" "$key" "$ssid"
;;
esac
}
}
}
config_load wireless
}
case "$ACTION" in
add|register)
[ "${INTERFACE%%[0-1]-*}" = wds ] && setup_broadcom_wds "$INTERFACE"
;;
esac

View File

@@ -1,29 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2011 OpenWrt.org
START=09
unbind_driver() {
local driver="$1"
local sysfs="/sys/bus/pci/drivers/$driver"
if [ -d "$sysfs" ]; then
local lnk
for lnk in $sysfs/*; do
[ -h "$lnk" ] || continue
case "${lnk##*/}" in
*:*:*.*)
logger "Unbinding WL PCI device ${lnk##*/} from $driver"
echo -n "${lnk##*/}" > "$sysfs/unbind"
;;
esac
done
fi
}
boot() {
unbind_driver b43-pci-bridge
unbind_driver bcma-pci-bridge
}
start() { :; }
stop() { :; }

View File

@@ -1,480 +0,0 @@
append DRIVERS "broadcom"
scan_broadcom() {
local device="$1"
local vif vifs wds
local adhoc sta apmode mon disabled
local adhoc_if sta_if ap_if mon_if
config_get vifs "$device" vifs
for vif in $vifs; do
config_get_bool disabled "$vif" disabled 0
[ $disabled -eq 0 ] || continue
local mode
config_get mode "$vif" mode
case "$mode" in
adhoc)
adhoc=1
adhoc_if="$vif"
;;
sta)
sta=1
sta_if="$vif"
;;
ap)
apmode=1
ap_if="${ap_if:+$ap_if }$vif"
;;
wds)
local addr
config_get addr "$vif" bssid
[ -z "$addr" ] || {
addr=$(echo "$addr" | tr 'A-F' 'a-f')
append wds "$addr"
}
;;
monitor)
mon=1
mon_if="$vif"
;;
*) echo "$device($vif): Invalid mode";;
esac
done
config_set "$device" wds "$wds"
local _c=
for vif in ${adhoc_if:-$sta_if $ap_if $mon_if}; do
config_set "$vif" ifname "${device}${_c:+-$_c}"
_c=$((${_c:-0} + 1))
done
config_set "$device" vifs "${adhoc_if:-$sta_if $ap_if $mon_if}"
ap=1
infra=1
if [ "$_c" -gt 1 ]; then
mssid=1
else
mssid=
fi
apsta=0
radio=1
monitor=0
case "$adhoc:$sta:$apmode:$mon" in
1*)
ap=0
mssid=
infra=0
;;
:1:1:)
apsta=1
wet=1
;;
:1::)
wet=1
ap=0
mssid=
;;
:::1)
wet=1
ap=0
mssid=
monitor=1
;;
::)
radio=0
;;
esac
}
disable_broadcom() {
local device="$1"
set_wifi_down "$device"
(
include /lib/network
local pid_file=/var/run/nas.$device.pid
[ -e $pid_file ] && start-stop-daemon -K -q -s SIGKILL -p $pid_file && rm $pid_file
# make sure the interfaces are down and removed from all bridges
local dev ifname
for dev in /sys/class/net/wds${device##wl}-* /sys/class/net/${device}-* /sys/class/net/${device}; do
if [ -e "$dev" ]; then
ifname=${dev##/sys/class/net/}
ip link set dev "$ifname" down
unbridge "$ifname"
fi
done
# make sure all of the devices are disabled in the driver
local ifdown=
local bssmax=$(wlc ifname "$device" bssmax)
local vif=$((${bssmax:-4} - 1))
append ifdown "down" "$N"
append ifdown "wds none" "$N"
while [ $vif -ge 0 ]; do
append ifdown "vif $vif" "$N"
append ifdown "enabled 0" "$N"
vif=$(($vif - 1))
done
wlc ifname "$device" stdin <<EOF
$ifdown
leddc 0xffff
EOF
)
true
}
enable_broadcom() {
local device="$1"
local channel country maxassoc wds vifs distance slottime rxantenna txantenna
local frameburst macfilter maclist macaddr txpower frag rts hwmode htmode
config_get channel "$device" channel
config_get country "$device" country
config_get maxassoc "$device" maxassoc
config_get wds "$device" wds
config_get vifs "$device" vifs
config_get distance "$device" distance
config_get slottime "$device" slottime
config_get rxantenna "$device" rxantenna
config_get txantenna "$device" txantenna
config_get_bool frameburst "$device" frameburst
config_get macfilter "$device" macfilter
config_get maclist "$device" maclist
config_get macaddr "$device" macaddr $(wlc ifname "$device" default_bssid)
config_get txpower "$device" txpower
config_get frag "$device" frag
config_get rts "$device" rts
config_get hwmode "$device" hwmode
config_get htmode "$device" htmode
local doth=0
local wmm=1
[ -z "$slottime" ] && {
[ -n "$distance" ] && {
# slottime = 9 + (distance / 150) + (distance % 150 ? 1 : 0)
slottime="$((9 + ($distance / 150) + 1 - (150 - ($distance % 150)) / 150 ))"
}
} || {
slottime="${slottime:--1}"
}
case "$macfilter" in
allow|2)
macfilter=2;
;;
deny|1)
macfilter=1;
;;
disable|none|0)
macfilter=0;
;;
esac
local gmode=2 nmode=0 nreqd=
case "$hwmode" in
*a) gmode=;;
*b) gmode=0;;
*bg) gmode=1;;
*g) gmode=2;;
*gst) gmode=4;;
*lrs) gmode=5;;
*) nmode=1; nreqd=0;;
esac
case "$hwmode" in
n|11n) nmode=1; nreqd=1;;
*n*) nmode=1; nreqd=0;;
esac
# Use 'nmode' for N-Phy only
[ "$(wlc ifname "$device" phytype)" = 4 ] || nmode=
local band chanspec
[ ${channel:-0} -ge 1 -a ${channel:-0} -le 14 ] && band=2
[ ${channel:-0} -ge 36 ] && {
band=1
gmode=
}
# Use 'chanspec' instead of 'channel' for 'N' modes (See bcmwifi.h)
[ -n "$nmode" -a -n "$band" -a -n "$channel" ] && {
case "$htmode" in
HT40)
if [ -n "$gmode" ]; then
[ $channel -lt 7 ] && htmode="HT40+" || htmode="HT40-"
else
[ $(( ($channel / 4) % 2 )) -eq 1 ] && htmode="HT40+" || htmode="HT40-"
fi
;;
esac
case "$htmode" in
HT40-) chanspec=$(printf 0x%x%x%02x $band 0xe $(($channel - 2))); nmode=1; channel=;;
HT40+) chanspec=$(printf 0x%x%x%02x $band 0xd $(($channel + 2))); nmode=1; channel=;;
HT20) chanspec=$(printf 0x%x%x%02x $band 0xb $channel); nmode=1; channel=;;
*) ;;
esac
}
local leddc=$(wlc ifname "$device" leddc)
[ $((leddc)) -eq $((0xffff)) ] && {
leddc=0x005a000a;
}
local _c=0
local nas="$(command -v nas)"
local if_pre_up if_up nas_cmd
local vif vif_pre_up vif_post_up vif_do_up vif_txpower
local bssmax=$(wlc ifname "$device" bssmax)
bssmax=${bssmax:-4}
for vif in $vifs; do
[ $_c -ge $bssmax ] && break
config_get vif_txpower "$vif" txpower
local mode
config_get mode "$vif" mode
append vif_pre_up "vif $_c" "$N"
append vif_post_up "vif $_c" "$N"
append vif_do_up "vif $_c" "$N"
config_get_bool wmm "$vif" wmm "$wmm"
config_get_bool doth "$vif" doth "$doth"
[ "$mode" = "sta" ] || {
local hidden isolate
config_get_bool hidden "$vif" hidden 0
append vif_pre_up "closed $hidden" "$N"
config_get_bool isolate "$vif" isolate 0
append vif_pre_up "ap_isolate $isolate" "$N"
}
local wsec_r=0
local eap_r=0
local wsec=0
local auth=0
local nasopts=
local enc key rekey
config_get enc "$vif" encryption
case "$enc" in
*wep*)
local def defkey k knr
wsec_r=1
wsec=1
defkey=1
config_get key "$vif" key
case "$enc" in
*shared*) append vif_do_up "wepauth 1" "$N";;
*) append vif_do_up "wepauth 0" "$N";;
esac
case "$key" in
[1234])
defkey="$key"
for knr in 1 2 3 4; do
config_get k "$vif" key$knr
[ -n "$k" ] || continue
[ "$defkey" = "$knr" ] && def="=" || def=""
append vif_do_up "wepkey $def$knr,$k" "$N"
done
;;
"");;
*) append vif_do_up "wepkey =1,$key" "$N";;
esac
;;
*psk*)
wsec_r=1
config_get key "$vif" key
# psk version + default cipher
case "$enc" in
*mixed*|*psk+psk2*) auth=132; wsec=6;;
*psk2*) auth=128; wsec=4;;
*) auth=4; wsec=2;;
esac
# cipher override
case "$enc" in
*tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;;
*aes*|*ccmp*) wsec=4;;
*tkip*) wsec=2;;
esac
# group rekey interval
config_get rekey "$vif" wpa_group_rekey
eval "${vif}_key=\"\$key\""
nasopts="-k \"\$${vif}_key\"${rekey:+ -g $rekey}"
;;
*wpa*)
local auth_port auth_secret auth_server
wsec_r=1
eap_r=1
config_get auth_server "$vif" auth_server
[ -z "$auth_server" ] && config_get auth_server "$vif" server
config_get auth_port "$vif" auth_port
[ -z "$auth_port" ] && config_get auth_port "$vif" port
config_get auth_secret "$vif" auth_secret
[ -z "$auth_secret" ] && config_get auth_secret "$vif" key
# wpa version + default cipher
case "$enc" in
*mixed*|*wpa+wpa2*) auth=66; wsec=6;;
*wpa2*) auth=64; wsec=4;;
*) auth=2; wsec=2;;
esac
# cipher override
case "$enc" in
*tkip+aes*|*tkip+ccmp*|*aes+tkip*|*ccmp+tkip*) wsec=6;;
*aes*|*ccmp*) wsec=4;;
*tkip*) wsec=2;;
esac
# group rekey interval
config_get rekey "$vif" wpa_group_rekey
eval "${vif}_key=\"\$auth_secret\""
nasopts="-r \"\$${vif}_key\" -h $auth_server -p ${auth_port:-1812}${rekey:+ -g $rekey}"
;;
esac
append vif_do_up "wsec $wsec" "$N"
append vif_do_up "wpa_auth $auth" "$N"
append vif_do_up "wsec_restrict $wsec_r" "$N"
append vif_do_up "eap_restrict $eap_r" "$N"
local ssid
config_get ssid "$vif" ssid
append vif_post_up "vlan_mode 0" "$N"
append vif_pre_up "ssid $ssid" "$N"
[ "$mode" = "monitor" ] && {
append vif_post_up "monitor $monitor" "$N"
}
[ "$mode" = "adhoc" ] && {
local bssid
config_get bssid "$vif" bssid
[ -n "$bssid" ] && {
append vif_pre_up "bssid $bssid" "$N"
append vif_pre_up "ibss_merge 0" "$N"
} || {
append vif_pre_up "ibss_merge 1" "$N"
}
}
append vif_post_up "enabled 1" "$N"
local ifname
config_get ifname "$vif" ifname
local if_cmd="if_pre_up"
[ "$ifname" != "${ifname##${device}-}" ] && if_cmd="if_up"
append $if_cmd "macaddr=\$(wlc ifname '$ifname' cur_etheraddr)" ";$N"
append $if_cmd "ip link set dev '$ifname' address \$macaddr" ";$N"
append if_up "ip link set dev '$ifname' up" ";$N"
local net_cfg="$(find_net_config "$vif")"
[ -z "$net_cfg" ] || {
ubus -t 30 wait_for network.interface."$net_cfg"
append if_up "set_wifi_up '$vif' '$ifname'" ";$N"
append if_up "start_net '$ifname' '$net_cfg'" ";$N"
}
[ -z "$nas" -o -z "$nasopts" ] || {
eval "${vif}_ssid=\"\$ssid\""
local nas_mode="-A"
[ "$mode" = "sta" ] && nas_mode="-S"
[ -z "$nas_cmd" ] && {
local pid_file=/var/run/nas.$device.pid
nas_cmd="start-stop-daemon -S -b -p $pid_file -x $nas -- -P $pid_file -H 34954"
}
append nas_cmd "-i $ifname $nas_mode -m $auth -w $wsec -s \"\$${vif}_ssid\" -g 3600 -F $nasopts"
}
_c=$(($_c + 1))
done
wlc ifname "$device" stdin <<EOF
${macaddr:+bssid $macaddr}
${macaddr:+cur_etheraddr $macaddr}
band ${band:-0}
${nmode:+nmode $nmode}
${nmode:+${nreqd:+nreqd $nreqd}}
${gmode:+gmode $gmode}
leddc $leddc
apsta $apsta
ap $ap
${mssid:+mssid $mssid}
infra $infra
${wet:+wet 1}
802.11d 0
802.11h ${doth:-0}
wme ${wmm:-1}
rxant ${rxantenna:-3}
txant ${txantenna:-3}
fragthresh ${frag:-2346}
rtsthresh ${rts:-2347}
monitor ${monitor:-0}
radio ${radio:-1}
macfilter ${macfilter:-0}
maclist ${maclist:-none}
${wds:+wds $wds}
country ${country:-US}
${channel:+channel $channel}
${chanspec:+chanspec $chanspec}
maxassoc ${maxassoc:-128}
slottime ${slottime:--1}
${frameburst:+frameburst $frameburst}
$vif_pre_up
EOF
eval "$if_pre_up"
wlc ifname "$device" stdin <<EOF
up
$vif_post_up
EOF
eval "$if_up"
wlc ifname "$device" stdin <<EOF
$vif_do_up
EOF
# use vif_txpower (from last wifi-iface) instead of txpower (from
# wifi-device) if the latter does not exist
txpower=${txpower:-$vif_txpower}
[ -z "$txpower" ] || iwconfig $device txpower ${txpower}dBm
# fd 1000 is an inherited lock file descriptor for preventing concurrent
# init script executions. Close it here to prevent the nas daemon from
# inheriting it further to avoid holding the lock indefinitely.
eval "$nas_cmd 1000>&-"
}
detect_broadcom() {
local i=-1
while grep -qs "^ *wl$((++i)):" /proc/net/dev; do
local channel type
config_get type wl${i} type
[ "$type" = broadcom ] && continue
channel=`wlc ifname wl${i} channel`
uci -q batch <<-EOF
set wireless.wl${i}=wifi-device
set wireless.wl${i}.type=broadcom
set wireless.wl${i}.channel=${channel:-11}
set wireless.wl${i}.txantenna=3
set wireless.wl${i}.rxantenna=3
set wireless.wl${i}.disabled=1
set wireless.default_wl${i}=wifi-iface
set wireless.default_wl${i}.device=wl${i}
set wireless.default_wl${i}.network=lan
set wireless.default_wl${i}.mode=ap
set wireless.default_wl${i}.ssid=OpenWrt${i#0}
set wireless.default_wl${i}.encryption=none
EOF
uci -q commit wireless
done
}

View File

@@ -1,39 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -2082,7 +2082,11 @@ static void
_wl_set_multicast_list(struct net_device *dev)
{
wl_info_t *wl;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
struct dev_mc_list *mclist;
+#else
+ struct netdev_hw_addr *ha;
+#endif
int i;
if (!dev)
@@ -2098,14 +2102,24 @@ _wl_set_multicast_list(struct net_device
wl->pub->allmulti = (dev->flags & IFF_ALLMULTI)? TRUE: FALSE;
/* copy the list of multicasts into our private table */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
for (i = 0, mclist = dev->mc_list; mclist && (i < dev->mc_count);
i++, mclist = mclist->next) {
+#else
+ i = 0;
+ netdev_for_each_mc_addr(ha, dev) {
+#endif
if (i >= MAXMULTILIST) {
wl->pub->allmulti = TRUE;
i = 0;
break;
}
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
wl->pub->multicast[i] = *((struct ether_addr*) mclist->dmi_addr);
+#else
+ wl->pub->multicast[i] = *((struct ether_addr*) ha->addr);
+ i++;
+#endif
}
wl->pub->nmulticast = i;
wlc_set(wl->wlc, WLC_SET_PROMISC, (dev->flags & IFF_PROMISC));

View File

@@ -1,22 +0,0 @@
--- a/driver/include/linuxver.h
+++ b/driver/include/linuxver.h
@@ -111,7 +111,7 @@ typedef irqreturn_t(*FN_ISR) (int irq, v
#endif /* not SANDGATE2G */
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 67) */
-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
+#if 0
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
--- a/driver/linux_osl.c
+++ b/driver/linux_osl.c
@@ -62,7 +62,7 @@ struct osl_info {
};
/* PCMCIA attribute space access macros */
-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
+#if 0
struct pcmcia_dev {
dev_link_t link; /* PCMCIA device pointer */
dev_node_t node; /* PCMCIA node structure */

View File

@@ -1,31 +0,0 @@
From: George Kashperko <george@znau.edu.ua>
Release nvram variables buffer.
Prevent block reserved by alloc_etherdev from being freed.
Signed-off-by: George Kashperko <george@znau.edu.ua>
---
---
--- a/driver/siutils.c
+++ b/driver/siutils.c
@@ -647,7 +647,10 @@ si_detach(si_t *sih)
#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS)
if (sii != &ksii)
#endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */
- MFREE(sii->osh, sii, sizeof(si_info_t));
+ do {
+ MFREE(sii->osh, sii, sizeof(si_info_t));
+ nvram_exit((void *)&(sii->pub));
+ } while (0);
}
void *
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -1477,7 +1477,6 @@ wl_free_if(wl_info_t *wl, wl_if_t *wlif)
free_netdev(wlif->dev);
#endif
}
- MFREE(wl->osh, wlif, sizeof(wl_if_t));
}
#ifdef AP

View File

@@ -1,88 +0,0 @@
From: George Kashperko <george@znau.edu.ua>
broadcom-wl driver bound to ssb device with ssb driver probe
have osh handle struct pdev pointer value initialized with
ssb_device pointer. Later on pdev is used with legacy pci
dma api as pci_dev thus causing oops sometimes.
The patch replaces legacy pci dma api and pass relevant
device struct pointer to avoid crashes.
Signed-off-by: George Kashperko <george@znau.edu.ua>
---
driver/linux_osl.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
--- a/driver/linux_osl.c
+++ b/driver/linux_osl.c
@@ -25,6 +25,9 @@
#include <asm/paccess.h>
#endif /* mips */
#include <pcicfg.h>
+#ifdef CONFIG_SSB
+#include <linux/ssb/ssb.h>
+#endif
#define PCI_CFG_RETRY 10
@@ -364,12 +367,27 @@ osl_dma_consistent_align(void)
return (PAGE_SIZE);
}
+static struct device *
+osl_get_dmadev(osl_t *osh)
+{
+#ifdef CONFIG_SSB
+ if (osh->bustype == SI_BUS) {
+ /* This can be SiliconBackplane emulated as pci with Broadcom or
+ * ssb device. Less harmful is to check for pci_bus_type and if
+ * no match then assume we got ssb */
+ if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
+ return ((struct ssb_device *)osh->pdev)->dma_dev;
+ }
+#endif
+ return &((struct pci_dev *)osh->pdev)->dev;
+}
+
void*
osl_dma_alloc_consistent(osl_t *osh, uint size, ulong *pap)
{
ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
- return (pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap));
+ return (dma_alloc_coherent(osl_get_dmadev(osh), size, (dma_addr_t*)pap, GFP_ATOMIC));
}
void
@@ -377,7 +395,7 @@ osl_dma_free_consistent(osl_t *osh, void
{
ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
- pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
+ dma_free_coherent(osl_get_dmadev(osh), size, va, (dma_addr_t)pa);
}
uint BCMFASTPATH
@@ -386,13 +404,13 @@ osl_dma_map(osl_t *osh, void *va, uint s
ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
if (direction == DMA_TX)
- return (pci_map_single(osh->pdev, va, size, PCI_DMA_TODEVICE));
+ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_TODEVICE));
else {
#ifdef mips
dma_cache_inv((uint)va, size);
return (virt_to_phys(va));
#else /* mips */
- return (pci_map_single(osh->pdev, va, size, PCI_DMA_FROMDEVICE));
+ return (dma_map_single(osl_get_dmadev(osh), va, size, PCI_DMA_FROMDEVICE));
#endif /* mips */
}
}
@@ -404,7 +422,7 @@ osl_dma_unmap(osl_t *osh, uint pa, uint
ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
- pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
+ dma_unmap_single(osl_get_dmadev(osh), (uint32)pa, size, dir);
}

View File

@@ -1,188 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -85,10 +85,9 @@ typedef void wlc_hw_info_t;
#include <bcmjtag.h>
#endif /* BCMJTAG */
-
-#ifdef CONFIG_SSB
-#include <linux/ssb/ssb.h>
-#endif
+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+#include <wl_glue.h>
+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
/* Linux wireless extension support */
#ifdef CONFIG_WIRELESS_EXT
@@ -997,62 +996,32 @@ static struct pci_driver wl_pci_driver =
#endif /* CONFIG_PCI */
#endif
+#ifdef BCMJTAG
+static bcmjtag_driver_t wl_jtag_driver = {
+ wl_jtag_probe,
+ wl_jtag_detach,
+ wl_jtag_poll,
+ };
+#endif /* BCMJTAG */
-static int wl_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+static void * glue_attach_cb(u16 vendor, u16 device,
+ ulong mmio, void *dev, u32 irq)
{
- wl_info_t *wl;
- void *mmio;
-
- if (dev->bus->bustype != SSB_BUSTYPE_SSB) {
- printk("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n");
- return -EINVAL;
- }
-
- mmio = (void *) 0x18000000 + dev->core_index * 0x1000;
- wl = wl_attach(id->vendor, id->coreid, (ulong) mmio, SI_BUS, dev, dev->irq);
- if (!wl) {
- printk("wl_attach failed\n");
- return -ENODEV;
- }
-
- ssb_set_drvdata(dev, wl);
-
- return 0;
+ return wl_attach(vendor, device, mmio, SI_BUS, dev, irq);
}
-static void wl_ssb_remove(struct ssb_device *dev)
+static void glue_remove_cb(void *wldev)
{
- wl_info_t *wl = (wl_info_t *) ssb_get_drvdata(dev);
+ wl_info_t *wl = (wl_info_t *)wldev;
WL_LOCK(wl);
WL_APSTA_UPDN(("wl%d (%s): wl_remove() -> wl_down()\n", wl->pub->unit, wl->dev->name));
wl_down(wl);
WL_UNLOCK(wl);
wl_free(wl);
- ssb_set_drvdata(dev, NULL);
}
-
-static const struct ssb_device_id wl_ssb_tbl[] = {
- SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV),
- SSB_DEVTABLE_END
-};
-
-#ifdef CONFIG_SSB
-static struct ssb_driver wl_ssb_driver = {
- .name = KBUILD_MODNAME,
- .id_table = wl_ssb_tbl,
- .probe = wl_ssb_probe,
- .remove = wl_ssb_remove,
-};
-#endif
-
-#ifdef BCMJTAG
-static bcmjtag_driver_t wl_jtag_driver = {
- wl_jtag_probe,
- wl_jtag_detach,
- wl_jtag_poll,
- };
-#endif /* BCMJTAG */
+#endif/* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
/**
@@ -1067,11 +1036,13 @@ wl_module_init(void)
{
int error = -ENODEV;
-#ifdef CONFIG_SSB
- error = ssb_driver_register(&wl_ssb_driver);
+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+ wl_glue_set_attach_callback(&glue_attach_cb);
+ wl_glue_set_remove_callback(&glue_remove_cb);
+ error = wl_glue_register();
if (error)
return error;
-#endif /* CONFIG_SSB */
+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
#ifdef CONFIG_PCI
error = pci_register_driver(&wl_pci_driver);
@@ -1082,7 +1053,11 @@ wl_module_init(void)
return 0;
error_pci:
- ssb_driver_unregister(&wl_ssb_driver);
+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+ wl_glue_unregister();
+ wl_glue_set_attach_callback(NULL);
+ wl_glue_set_remove_callback(NULL);
+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
return error;
}
@@ -1099,9 +1074,11 @@ wl_module_exit(void)
#ifdef CONFIG_PCI
pci_unregister_driver(&wl_pci_driver);
#endif /* CONFIG_PCI */
-#ifdef CONFIG_SSB
- ssb_driver_unregister(&wl_ssb_driver);
-#endif /* CONFIG_SSB */
+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+ wl_glue_unregister();
+ wl_glue_set_attach_callback(NULL);
+ wl_glue_set_remove_callback(NULL);
+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
}
module_init(wl_module_init);
--- a/driver/linux_osl.c
+++ b/driver/linux_osl.c
@@ -25,9 +25,9 @@
#include <asm/paccess.h>
#endif /* mips */
#include <pcicfg.h>
-#ifdef CONFIG_SSB
-#include <linux/ssb/ssb.h>
-#endif
+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
+#include <wl_glue.h>
+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
#define PCI_CFG_RETRY 10
@@ -370,15 +370,17 @@ osl_dma_consistent_align(void)
static struct device *
osl_get_dmadev(osl_t *osh)
{
-#ifdef CONFIG_SSB
+#if defined(CONFIG_SSB) || defined(CONFIG_BCMA)
if (osh->bustype == SI_BUS) {
- /* This can be SiliconBackplane emulated as pci with Broadcom or
- * ssb device. Less harmful is to check for pci_bus_type and if
- * no match then assume we got ssb */
+ /* This can be SiliconBackplane emulated as pci with Broadcom,
+ * ssb or bcma device. Less harmful is to check for pci_bus_type and if
+ * no match then assume we got either ssb or bcma */
if (((struct pci_dev *)osh->pdev)->dev.bus != &pci_bus_type)
- return ((struct ssb_device *)osh->pdev)->dma_dev;
+ {
+ return wl_glue_get_dmadev(osh->pdev);
+ }
}
-#endif
+#endif /* defined(CONFIG_SSB) || defined(CONFIG_BCMA) */
return &((struct pci_dev *)osh->pdev)->dev;
}
--- a/driver/Makefile
+++ b/driver/Makefile
@@ -1,7 +1,7 @@
BUILD_TYPE=wl_apsta
include $(src)/$(BUILD_TYPE)/buildflags.mk
-EXTRA_CFLAGS += -I$(src)/include -I$(src) -DBCMDRIVER $(WLFLAGS)
+EXTRA_CFLAGS += -I$(src)/include -I$(src) -I$(realpath $(src)/../glue) -DBCMDRIVER $(WLFLAGS)
wl-objs := $(BUILD_TYPE)/wl_prebuilt.o wl_iw.o wl_linux.o linux_osl.o siutils.o aiutils.o hndpmu.o bcmutils.o sbutils.o nicpci.o hnddma.o bcmsrom.o nvram_stub.o

View File

@@ -1,132 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -354,6 +354,7 @@ static int wl_read_proc(char *buffer, ch
static int wl_dump(wl_info_t *wl, struct bcmstrbuf *b);
#endif /* BCMDBG */
struct wl_if *wl_alloc_if(wl_info_t *wl, int iftype, uint unit, struct wlc_if* wlc_if);
+static void wl_link_if(wl_info_t *wl, wl_if_t *wlif);
static void wl_free_if(wl_info_t *wl, wl_if_t *wlif);
@@ -566,6 +567,9 @@ wl_attach(uint16 vendor, uint16 device,
wl->dev = dev;
wl_if_setup(dev);
+ /* add the interface to the interface linked list */
+ wl_link_if(wl, wlif);
+
/* map chip registers (47xx: and sprom) */
dev->base_addr = regs;
@@ -1106,10 +1110,14 @@ wl_free(wl_info_t *wl)
free_irq(wl->dev->irq, wl);
}
- if (wl->dev) {
- wl_free_if(wl, WL_DEV_IF(wl->dev));
- wl->dev = NULL;
+ /* free all interfaces */
+ while (wl->if_list) {
+ if ((wl->if_list->dev != wl->dev) || wl->if_list->next == NULL)
+ wl_free_if(wl, wl->if_list);
+ else
+ wl_free_if(wl, wl->if_list->next);
}
+ wl->dev = NULL;
#ifdef TOE
wl_toe_detach(wl->toei);
@@ -1355,10 +1363,12 @@ wl_txflowcontrol(wl_info_t *wl, bool sta
ASSERT(prio == ALLPRIO);
for (wlif = wl->if_list; wlif != NULL; wlif = wlif->next) {
- if (state == ON)
- netif_stop_queue(wlif->dev);
- else
- netif_wake_queue(wlif->dev);
+ if (wlif->dev_registed) {
+ if (state == ON)
+ netif_stop_queue(wlif->dev);
+ else
+ netif_wake_queue(wlif->dev);
+ }
}
}
@@ -1398,7 +1408,6 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
{
struct net_device *dev;
wl_if_t *wlif;
- wl_if_t *p;
dev = alloc_etherdev(sizeof(wl_if_t));
wlif = netdev_priv(dev);
@@ -1411,9 +1420,13 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
wlif->wlcif = wlcif;
wlif->subunit = subunit;
- /* match current flow control state */
- if (iftype != WL_IFTYPE_MON && wl->dev && netif_queue_stopped(wl->dev))
- netif_stop_queue(dev);
+ return wlif;
+}
+
+static void
+wl_link_if(wl_info_t *wl, wl_if_t *wlif)
+{
+ wl_if_t *p;
/* add the interface to the interface linked list */
if (wl->if_list == NULL)
@@ -1424,7 +1437,6 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
p = p->next;
p->next = wlif;
}
- return wlif;
}
static void
@@ -1504,6 +1516,9 @@ _wl_add_if(wl_task_t *task)
wl_info_t *wl = wlif->wl;
struct net_device *dev = wlif->dev;
+ /* add the interface to the interface linked list */
+ wl_link_if(wl, wlif);
+
if (wlif->type == WL_IFTYPE_WDS)
dev->netdev_ops = &wl_wds_ops;
@@ -1516,6 +1531,14 @@ _wl_add_if(wl_task_t *task)
}
wlif->dev_registed = TRUE;
+ /* match current flow control state */
+ if (wl->dev) {
+ if (netif_queue_stopped(wl->dev))
+ netif_stop_queue(dev);
+ else
+ netif_wake_queue(dev);
+ }
+
done:
MFREE(wl->osh, task, sizeof(wl_task_t));
atomic_dec(&wl->callbacks);
@@ -1545,6 +1568,8 @@ wl_add_if(wl_info_t *wl, struct wlc_if*
return NULL;
}
+ wl_if_setup(wlif->dev);
+
sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit);
if (remote)
bcopy(remote, &wlif->remote, ETHER_ADDR_LEN);
@@ -2778,6 +2803,9 @@ wl_add_monitor(wl_task_t *task)
dev = wlif->dev;
wl->monitor = dev;
+ /* add the interface to the interface linked list */
+ wl_link_if(wl, wlif);
+
/* override some fields */
sprintf(dev->name, "prism%d", wl->pub->unit);
bcopy(wl->dev->dev_addr, dev->dev_addr, ETHER_ADDR_LEN);

View File

@@ -1,27 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -463,6 +463,16 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
}
#endif /* DSLCPE_DELAY */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
+#define WL_DEFAULT_OPS \
+ .ndo_open = wl_open, \
+ .ndo_stop = wl_close, \
+ .ndo_start_xmit = wl_start, \
+ .ndo_get_stats = wl_get_stats, \
+ .ndo_set_mac_address = wl_set_mac_address, \
+ .ndo_set_rx_mode = wl_set_multicast_list, \
+ .ndo_do_ioctl = wl_ioctl
+#else
#define WL_DEFAULT_OPS \
.ndo_open = wl_open, \
.ndo_stop = wl_close, \
@@ -471,6 +481,7 @@ wl_schedule_fn(wl_info_t *wl, void (*fn)
.ndo_set_mac_address = wl_set_mac_address, \
.ndo_set_multicast_list = wl_set_multicast_list, \
.ndo_do_ioctl = wl_ioctl
+#endif
static const struct net_device_ops wl_ops = {
WL_DEFAULT_OPS,

View File

@@ -1,11 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -695,7 +695,7 @@ wl_attach(uint16 vendor, uint16 device,
if (wl->bustype != JTAG_BUS)
#endif /* BCMJTAG */
{
- if (request_irq(irq, wl_isr, IRQF_SHARED|IRQF_SAMPLE_RANDOM, dev->name, wl)) {
+ if (request_irq(irq, wl_isr, IRQF_SHARED, dev->name, wl)) {
WL_ERROR(("wl%d: request_irq() failed\n", unit));
goto fail;
}

View File

@@ -1,12 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -49,7 +49,9 @@
#include <linux/ieee80211.h>
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
#include <asm/system.h>
+#endif
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/pgtable.h>

View File

@@ -1,47 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -349,7 +349,7 @@ static void wl_mic_error(wl_info_t *wl,
defined(WL_MONITOR)
static int wl_schedule_task(wl_info_t *wl, void (*fn)(struct wl_task *), void *context);
#endif
-#if defined(CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
static int wl_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data);
#endif /* defined(CONFIG_PROC_FS) */
#ifdef BCMDBG
@@ -517,7 +517,7 @@ wl_attach(uint16 vendor, uint16 device,
struct net_device *dev;
wl_if_t *wlif;
wl_info_t *wl;
-#if defined(CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
char tmp[128];
#endif
osl_t *osh;
@@ -664,7 +664,7 @@ wl_attach(uint16 vendor, uint16 device,
WL_ERROR(("wl%d: Error setting MPC variable to 0\n", unit));
}
}
-#if defined(CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
/* create /proc/net/wl<unit> */
sprintf(tmp, "net/wl%d", wl->pub->unit);
create_proc_read_entry(tmp, 0, 0, wl_read_proc, (void*)wl);
@@ -810,7 +810,7 @@ wl_dbus_disconnect_cb(void *arg)
}
#endif /* BCMDBUS */
-#if defined(CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
static int
wl_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
{
@@ -1149,7 +1149,7 @@ wl_free(wl_info_t *wl)
/* free common resources */
if (wl->wlc) {
-#if defined(CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
char tmp[128];
/* remove /proc/net/wl<unit> */
sprintf(tmp, "net/wl%d", wl->pub->unit);

View File

@@ -1,11 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -1583,7 +1583,7 @@ wl_add_if(wl_info_t *wl, struct wlc_if*
wl_if_setup(wlif->dev);
- sprintf(wlif->dev->name, "%s%d.%d", devname, wl->pub->unit, wlif->subunit);
+ sprintf(wlif->dev->name, "%s%d-%d", devname, wl->pub->unit, wlif->subunit);
if (remote)
bcopy(remote, &wlif->remote, ETHER_ADDR_LEN);

View File

@@ -1,41 +0,0 @@
--- a/driver/wl_iw.c
+++ b/driver/wl_iw.c
@@ -314,7 +314,7 @@ wl_iw_get_name(
)
{
int phytype, err;
- uint band[3];
+ uint i, band[3], bands;
char cap[5];
WL_TRACE(("%s: SIOCGIWNAME\n", dev->name));
@@ -335,16 +335,20 @@ wl_iw_get_name(
break;
case WLC_PHY_TYPE_LP:
case WLC_PHY_TYPE_G:
- if (band[0] >= 2)
- strcpy(cap, "abg");
- else
- strcpy(cap, "bg");
- break;
case WLC_PHY_TYPE_N:
- if (band[0] >= 2)
- strcpy(cap, "abgn");
- else
- strcpy(cap, "bgn");
+ bands = 0;
+ for (i = 1; i <= band[0]; i++) {
+ bands |= dtoh32(band[i]);
+ }
+ strcpy(cap, "");
+ if (bands & WLC_BAND_5G)
+ strcat(cap, "a");
+ if (bands & WLC_BAND_2G)
+ strcat(cap, "bg");
+ if (phytype == WLC_PHY_TYPE_N)
+ strcat(cap, "n");
+ break;
+ default:
break;
}
done:

View File

@@ -1,11 +0,0 @@
--- a/shared/wl.c
+++ b/shared/wl.c
@@ -27,7 +27,7 @@ wl_probe(char *name)
{
int ret, val;
- if ((name[0] != 'w') || (name[1] != 'l'))
+ if ((name[0] != 'w') || ((name[1] != 'l') && ((name[1] != 'd') || (name[2] != 's'))))
return -1;
/* Check interface */

View File

@@ -1,75 +0,0 @@
--- a/shared/wl_linux.c
+++ b/shared/wl_linux.c
@@ -13,6 +13,7 @@
*/
#include <stdio.h>
+#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -20,10 +21,10 @@
#include <net/if.h>
#include <linux/types.h>
-typedef u_int64_t u64;
-typedef u_int32_t u32;
-typedef u_int16_t u16;
-typedef u_int8_t u8;
+typedef uint64_t u64;
+typedef uint32_t u32;
+typedef uint16_t u16;
+typedef uint8_t u8;
#include <linux/sockios.h>
#include <linux/ethtool.h>
--- a/shared/linux_timer.c
+++ b/shared/linux_timer.c
@@ -125,7 +125,7 @@ void unblock_timer();
static struct event *event_queue = NULL;
static struct event *event_freelist;
-static uint g_granularity;
+static unsigned int g_granularity;
static int g_maxevents = 0;
uclock_t uclock()
--- a/shared/wl.c
+++ b/shared/wl.c
@@ -14,6 +14,7 @@
#include <typedefs.h>
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -263,3 +264,28 @@ wl_printlasterror(char *name)
fprintf(stderr, err_buf);
}
*/
+
+static int in_assert; /* bss inits to 0. */
+
+void __assert(const char *assertion, const char * filename,
+ unsigned int linenumber, register const char * function)
+{
+ if (!in_assert) {
+ in_assert = 1;
+
+ fprintf(stderr,
+#ifdef ASSERT_SHOW_PROGNAME
+ "%s: %s: %d: %s: Assertion `%s' failed.\n", __uclibc_progname,
+#else
+ "%s: %d: %s: Assertion `%s' failed.\n",
+#endif
+ filename,
+ linenumber,
+ /* Function name isn't available with some compilers. */
+ ((function == NULL) ? "?function?" : function),
+ assertion
+ );
+ }
+ /* shouldn't we? fflush(stderr); */
+ abort();
+}

View File

@@ -1,74 +0,0 @@
--- a/driver/include/linuxver.h
+++ b/driver/include/linuxver.h
@@ -139,22 +139,6 @@ typedef struct pcmcia_device dev_link_t;
#endif /* CONFIG_PCMCIA */
-#ifndef __exit
-#define __exit
-#endif
-#ifndef __devexit
-#define __devexit
-#endif
-#ifndef __devinit
-#define __devinit __init
-#endif
-#ifndef __devinitdata
-#define __devinitdata
-#endif
-#ifndef __devexit_p
-#define __devexit_p(x) x
-#endif
-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0))
#define pci_get_drvdata(dev) (dev)->sysdata
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -854,7 +854,7 @@ wl_read_proc(char *buffer, char **start,
*/
#if !defined(BCMJTAG)
#ifdef CONFIG_PCI
-static void __devexit wl_remove(struct pci_dev *pdev);
+static void wl_remove(struct pci_dev *pdev);
/**
* determines if a device is a WL device, and if so, attaches it.
*
@@ -862,7 +862,7 @@ static void __devexit wl_remove(struct p
* and if so, performs a wl_attach() on it.
*
*/
-int __devinit
+int
wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
int rc;
@@ -976,7 +976,7 @@ wl_resume(struct pci_dev *pdev)
}
#endif /* LINUXSTA_PS */
-static void __devexit
+static void
wl_remove(struct pci_dev *pdev)
{
wl_info_t *wl = (wl_info_t *) pci_get_drvdata(pdev);
@@ -1007,7 +1007,7 @@ static struct pci_driver wl_pci_driver =
suspend: wl_suspend,
resume: wl_resume,
#endif /* LINUXSTA_PS */
- remove: __devexit_p(wl_remove),
+ remove: wl_remove,
id_table: wl_id_table,
};
#endif /* CONFIG_PCI */
--- a/driver/wl_linux.h
+++ b/driver/wl_linux.h
@@ -33,7 +33,7 @@ extern irqreturn_t wl_isr(int irq, void
extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
#endif
-extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+extern int wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
extern void wl_free(wl_info_t *wl);
extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
extern struct net_device * wl_netdev_get(wl_info_t *wl);

View File

@@ -1,10 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -2762,7 +2762,6 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rx
bcopy(oskb->data + D11_PHY_HDR_LEN, pdata, oskb->len - D11_PHY_HDR_LEN);
skb->dev = wl->monitor;
- skb->dev->last_rx = jiffies;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
skb_reset_mac_header(skb);
#else

View File

@@ -1,32 +0,0 @@
--- a/driver/nvram_stub.c
+++ b/driver/nvram_stub.c
@@ -22,6 +22,7 @@ typedef struct _vars {
#define VARS_T_OH sizeof(vars_t)
static vars_t *vars = NULL;
+static int nvram_init_done = 0;
extern char *nvram_buf[];
int
@@ -33,6 +34,10 @@ BCMATTACHFN(nvram_init)(void *si)
uint nvs, bufsz;
vars_t *new;
+ nvram_init_done++;
+ if (nvram_init_done != 1)
+ return 0;
+
osh = si_osh(sih);
nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header);
@@ -79,6 +84,10 @@ BCMATTACHFN(nvram_exit)(void *si)
vars_t *this, *next;
si_t *sih;
+ nvram_init_done--;
+ if (nvram_init_done != 0)
+ return;
+
sih = (si_t *)si;
this = vars;
while (this) {

View File

@@ -1,15 +0,0 @@
--- a/driver/wl_iw.c
+++ a/driver/wl_iw.c
@@ -381,9 +381,9 @@ wl_iw_set_freq(
while (fwrq->e++ < 6)
fwrq->m /= 10;
}
- /* handle 4.9GHz frequencies as Japan 4 GHz based channelization */
- if (fwrq->m > 4000 && fwrq->m < 5000)
- sf = WF_CHAN_FACTOR_4_G; /* start factor for 4 GHz */
+ /* handle 4.9GHz frequencies as Japan 4 GHz based channelization */
+ if (fwrq->m > 4000 && fwrq->m < 5000)
+ sf = WF_CHAN_FACTOR_4_G; /* start factor for 4 GHz */
chan = wf_mhz2channel(fwrq->m, sf);
}

View File

@@ -1,11 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -1425,7 +1425,7 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
dev = alloc_etherdev(sizeof(wl_if_t));
wlif = netdev_priv(dev);
bzero(wlif, sizeof(wl_if_t));
- strncpy(dev->name, name, IFNAMSIZ);
+ snprintf(dev->name, IFNAMSIZ, name, subunit);
wlif->type = iftype;
wlif->dev = dev;

View File

@@ -1,93 +0,0 @@
--- a/driver/nvram_stub.c
+++ b/driver/nvram_stub.c
@@ -5,6 +5,8 @@
#include <siutils.h>
#include <bcmendian.h>
#include <bcmnvram.h>
+#include <proto/ethernet.h>
+#include <linux/errno.h>
#ifdef BCMDBG_ERR
#define NVR_MSG(x) printf x
@@ -24,6 +26,7 @@ typedef struct _vars {
static vars_t *vars = NULL;
static int nvram_init_done = 0;
extern char *nvram_buf[];
+static void fixup_mac_addr(vars_t *new);
int
BCMATTACHFN(nvram_init)(void *si)
@@ -55,6 +58,7 @@ BCMATTACHFN(nvram_init)(void *si)
vars = new;
bcopy((char *)(&nvh[1]), new->vars, nvs);
+ fixup_mac_addr(new);
return 0;
}
@@ -164,3 +168,65 @@ nvram_getall(char *buf, int count)
*buf = '\0';
return 0;
}
+
+static bool nvram_is_valid_mac(struct ether_addr *mac)
+{
+ return mac && !(mac->octet[0] == 0x00 && mac->octet[1] == 0x90 && mac->octet[2] == 0x4c);
+}
+
+static int nvram_increase_mac_addr(struct ether_addr *mac, u8 num)
+{
+ u8 *oui = mac->octet + ETHER_ADDR_LEN/2 - 1;
+ u8 *p = mac->octet + ETHER_ADDR_LEN - 1;
+
+ do {
+ (*p) += num;
+ if (*p > num)
+ break;
+ p--;
+ num = 1;
+ } while (p != oui);
+
+ if (p == oui) {
+ pr_err("unable to fetch mac address\n");
+ return -ENOENT;
+ }
+ return 0;
+}
+
+static void nvram_change_mac_addr(vars_t *new, struct ether_addr *valid, const char *name)
+{
+ char *macaddr_c;
+ struct ether_addr macaddr;
+
+ macaddr_c = findvar(new->vars, new->vars + new->size, name);
+ if (!macaddr_c)
+ return;
+
+ bcm_ether_atoe(macaddr_c, &macaddr);
+ if (nvram_is_valid_mac(&macaddr))
+ return;
+ nvram_increase_mac_addr(valid, 1);
+ bcm_ether_ntoa(valid, macaddr_c);
+}
+
+static void fixup_mac_addr(vars_t *new)
+{
+ char *macaddr_base_c;
+ struct ether_addr macaddr_base;
+
+ macaddr_base_c = findvar(new->vars, new->vars + new->size, "et0macaddr");
+ if (!macaddr_base_c)
+ return;
+
+ bcm_ether_atoe(macaddr_base_c, &macaddr_base);
+ if (!nvram_is_valid_mac(&macaddr_base))
+ return;
+
+ /* jump over the first free address so it can be used for wan */
+ nvram_increase_mac_addr(&macaddr_base, 1);
+ nvram_change_mac_addr(new, &macaddr_base, "sb/1/macaddr");
+ nvram_change_mac_addr(new, &macaddr_base, "pci/1/1/macaddr");
+ nvram_change_mac_addr(new, &macaddr_base, "pci/1/2/macaddr");
+ nvram_change_mac_addr(new, &macaddr_base, "pci/2/1/macaddr");
+}

View File

@@ -1,12 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -876,7 +876,8 @@ wl_pci_probe(struct pci_dev *pdev, const
if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) ||
(((pdev->device & 0xff00) != 0x4300) &&
- ((pdev->device & 0xff00) != 0x4700)))
+ ((pdev->device & 0xff00) != 0x4700) &&
+ ((pdev->device & 0xff00) != 0xa800)))
return (-ENODEV);
rc = pci_enable_device(pdev);

View File

@@ -1,78 +0,0 @@
--- a/driver/bcmsrom.c
+++ b/driver/bcmsrom.c
@@ -39,6 +39,11 @@
#include <sbsdpcmdev.h>
#endif
+#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
+#include <linux/ssb/ssb.h>
+extern int bcm63xx_get_fallback_sprom(uint pci_bus, uint pci_slot, struct ssb_sprom *out);
+#endif
+
#ifdef WLTEST
#include <sbsprom.h>
#endif /* WLTEST */
@@ -2120,6 +2125,63 @@ BCMATTACHFN(initvars_srom_pci)(si_t *sih
goto varscont;
}
+#if defined(CONFIG_SSB_PCIHOST) && defined(CONFIG_BOARD_BCM963XX)
+ base = vp = MALLOC(osh, MAXSZ_NVRAM_VARS);
+
+ if( base != NULL )
+ {
+ char eabuf[18];
+ struct ssb_sprom bcm63xx_sprom;
+ uint pci_bus = osl_pci_bus(osh), pci_slot = osl_pci_slot(osh);
+
+ bcm63xx_get_fallback_sprom(pci_bus, pci_slot, &bcm63xx_sprom);
+ printk("BCM%X(%02x:%02x) using sprom version %i\n", sih->chip, pci_bus, pci_slot, bcm63xx_sprom.revision);
+
+ varbuf_init(&b, base, MAXSZ_NVRAM_VARS);
+
+ varbuf_append(&b, vstr_sromrev, bcm63xx_sprom.revision);
+ varbuf_append(&b, vstr_boardrev, bcm63xx_sprom.board_rev);
+
+ /* ToDo: map bcm63xx_sprom.country_code */
+ varbuf_append(&b, vstr_noccode);
+
+ varbuf_append(&b, vstr_aa2g, bcm63xx_sprom.ant_available_bg);
+
+ varbuf_append(&b, vstr_pa0b[0], bcm63xx_sprom.pa0b0);
+ varbuf_append(&b, vstr_pa1b[0], bcm63xx_sprom.pa1b0);
+ varbuf_append(&b, vstr_pa0b[1], bcm63xx_sprom.pa0b1);
+ varbuf_append(&b, vstr_pa1b[1], bcm63xx_sprom.pa1b1);
+ varbuf_append(&b, vstr_pa0b[2], bcm63xx_sprom.pa0b2);
+ varbuf_append(&b, vstr_pa1b[2], bcm63xx_sprom.pa1b2);
+
+ varbuf_append(&b, vstr_pa0maxpwr, bcm63xx_sprom.maxpwr_bg);
+ varbuf_append(&b, vstr_pa0itssit, bcm63xx_sprom.itssi_bg);
+
+ varbuf_append(&b, vstr_boardflags, (bcm63xx_sprom.boardflags_hi << 16) | bcm63xx_sprom.boardflags_lo);
+ varbuf_append(&b, vstr_boardflags2, (bcm63xx_sprom.boardflags2_hi << 16) | bcm63xx_sprom.boardflags2_lo);
+
+ snprintf(eabuf, sizeof(eabuf), "%02x:%02x:%02x:%02x:%02x:%02x",
+ bcm63xx_sprom.il0mac[0], bcm63xx_sprom.il0mac[1], bcm63xx_sprom.il0mac[2],
+ bcm63xx_sprom.il0mac[3], bcm63xx_sprom.il0mac[4], bcm63xx_sprom.il0mac[5]
+ );
+
+ varbuf_append(&b, vstr_macaddr, eabuf);
+
+ /* final nullbyte terminator */
+ ASSERT(b.size >= 1);
+ vp = b.buf;
+ *vp++ = '\0';
+
+ ASSERT((vp - base) <= MAXSZ_NVRAM_VARS);
+ goto varsdone;
+ }
+ else
+ {
+ err = -2;
+ goto errout;
+ }
+#endif
+
BS_ERROR(("SROM CRC Error\n"));
#if defined(WLTEST)

View File

@@ -1,11 +0,0 @@
--- a/driver/siutils.c
+++ b/driver/siutils.c
@@ -1859,7 +1859,7 @@ BCMINITFN(si_devpath)(si_t *sih, char *p
case PCI_BUS:
ASSERT((SI_INFO(sih))->osh != NULL);
slen = snprintf(path, (size_t)size, "pci/%u/%u/",
- OSL_PCI_BUS((SI_INFO(sih))->osh),
+ OSL_PCI_BUS((SI_INFO(sih))->osh) + 1,
OSL_PCI_SLOT((SI_INFO(sih))->osh));
break;
case PCMCIA_BUS:

View File

@@ -1,12 +0,0 @@
--- a/driver/linux_osl.c
+++ b/driver/linux_osl.c
@@ -723,6 +723,9 @@ osl_readl(volatile uint32 *r)
uint16
osl_readw(volatile uint16 *r)
{
+ uint32 addr = (uintptr)r & 0xffff3fff;
+ if (addr == 0xa8000688) /* ifs_ctl */
+ readl(r);
return (readw(r));
}

View File

@@ -1,21 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -762,7 +762,7 @@ wl_attach(uint16 vendor, uint16 device,
dev->name, device);
#ifdef BCMDBG
- printf(" (Compiled in " SRCBASE " at " __TIME__ " on " __DATE__ ")");
+ printf(" (Compiled in " SRCBASE ")");
#endif /* BCMDBG */
printf("\n");
@@ -2298,8 +2298,7 @@ wl_sendup(wl_info_t *wl, wl_if_t *wlif,
void
wl_dump_ver(wl_info_t *wl, struct bcmstrbuf *b)
{
- bcm_bprintf(b, "wl%d: %s %s version %s\n", wl->pub->unit,
- __DATE__, __TIME__, EPI_VERSION_STR);
+ bcm_bprintf(b, "wl%d: version %s\n", wl->pub->unit, EPI_VERSION_STR);
}
#ifdef BCMDBG

View File

@@ -1,55 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -235,7 +235,11 @@ struct wl_info {
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
+static void wl_timer(struct timer_list *tl);
+#else
static void wl_timer(ulong data);
+#endif
static void _wl_timer(wl_timer_t *t);
#ifdef WLC_HIGH_ONLY
@@ -2512,6 +2516,18 @@ wl_timer_task(wl_task_t *task)
}
#endif /* WLC_HIGH_ONLY */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
+static void
+wl_timer(struct timer_list *tl)
+{
+ wl_timer_t *t = from_timer(t, tl, timer);
+#ifndef WLC_HIGH_ONLY
+ _wl_timer(t);
+#else
+ wl_schedule_task(t->wl, wl_timer_task, t);
+#endif /* WLC_HIGH_ONLY */
+}
+#else
static void
wl_timer(ulong data)
{
@@ -2522,6 +2538,7 @@ wl_timer(ulong data)
wl_schedule_task(t->wl, wl_timer_task, t);
#endif /* WLC_HIGH_ONLY */
}
+#endif /* linux >= 4.15.0 */
static void
_wl_timer(wl_timer_t *t)
@@ -2573,9 +2590,13 @@ wl_init_timer(wl_info_t *wl, void (*fn)(
bzero(t, sizeof(wl_timer_t));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
+ timer_setup(&t->timer, wl_timer, 0);
+#else
init_timer(&t->timer);
t->timer.data = (ulong) t;
t->timer.function = wl_timer;
+#endif
t->wl = wl;
t->fn = fn;
t->arg = arg;

View File

@@ -1,18 +0,0 @@
--- a/driver/wl_iw.c
+++ b/driver/wl_iw.c
@@ -112,10 +112,14 @@ dev_wlc_ioctl(
ifr.ifr_data = (caddr_t) &ioc;
/* Must be up for virtually all useful ioctls */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
+ dev_open(dev, NULL);
+#else
dev_open(dev);
+#endif
fs = get_fs();
- set_fs(get_ds());
+ set_fs(KERNEL_DS);
ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
set_fs(fs);

View File

@@ -1,42 +0,0 @@
Index: broadcom-wl-5.10.56.27.3/driver/wl_linux.c
===================================================================
--- broadcom-wl-5.10.56.27.3.orig/driver/wl_linux.c
+++ broadcom-wl-5.10.56.27.3/driver/wl_linux.c
@@ -74,6 +74,10 @@
#error "No support for Kernel Rev <= 2.4.5, As the older kernel revs doesn't support Tasklets"
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+#define ioremap_nocache ioremap
+#endif
+
typedef void wlc_info_t;
typedef void wlc_hw_info_t;
#include <wlc_pub.h>
@@ -1915,7 +1919,11 @@ wl_ioctl(struct net_device *dev, struct
}
/* optimization for direct ioctl calls from kernel */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)
if (segment_eq(get_fs(), KERNEL_DS))
+#else
+ if (uaccess_kernel())
+#endif
buf = ioc.buf;
else if (ioc.buf) {
Index: broadcom-wl-5.10.56.27.3/driver/linux_osl.c
===================================================================
--- broadcom-wl-5.10.56.27.3.orig/driver/linux_osl.c
+++ broadcom-wl-5.10.56.27.3/driver/linux_osl.c
@@ -34,6 +34,10 @@
#define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognise osh */
#define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+#define ioremap_nocache ioremap
+#endif
+
typedef struct bcm_mem_link {
struct bcm_mem_link *prev;
struct bcm_mem_link *next;

View File

@@ -1,27 +0,0 @@
--- a/driver/wl_iw.c
+++ a/driver/wl_iw.c
@@ -100,7 +100,9 @@ dev_wlc_ioctl(
{
struct ifreq ifr;
wl_ioctl_t ioc;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0)
mm_segment_t fs;
+#endif
int ret;
memset(&ioc, 0, sizeof(ioc));
@@ -118,10 +120,14 @@ dev_wlc_ioctl(
dev_open(dev);
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0)
fs = get_fs();
set_fs(KERNEL_DS);
+#endif
ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0)
set_fs(fs);
+#endif
return ret;
}

View File

@@ -1,297 +0,0 @@
--- a/driver/wl_iw.c
+++ b/driver/wl_iw.c
@@ -495,9 +495,9 @@ wl_iw_get_range(
)
{
struct iw_range *range = (struct iw_range *) extra;
- int channels[MAXCHANNEL+1];
- wl_uint32_list_t *list = (wl_uint32_list_t *) channels;
- wl_rateset_t rateset;
+ int *channels;
+ wl_uint32_list_t *list;
+ wl_rateset_t *rateset;
int error, i;
uint sf, ch;
@@ -506,6 +506,17 @@ wl_iw_get_range(
if (!extra)
return -EINVAL;
+ channels = kcalloc(MAXCHANNEL+1, sizeof(*channels), GFP_KERNEL);
+ if (!channels)
+ return -ENOMEM;
+ list = (wl_uint32_list_t *) channels;
+
+ rateset = kzalloc(sizeof(*rateset), GFP_KERNEL);
+ if (!rateset) {
+ error = -ENOMEM;
+ goto free_channels;
+ }
+
dwrq->length = sizeof(struct iw_range);
memset(range, 0, sizeof(range));
@@ -514,8 +525,9 @@ wl_iw_get_range(
/* Set available channels/frequencies */
list->count = htod32(MAXCHANNEL);
- if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, sizeof(channels))))
- return error;
+ if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels,
+ (MAXCHANNEL+1) * sizeof(*channels))))
+ goto free_rateset;
for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) {
range->freq[i].i = dtoh32(list->element[i]);
@@ -549,19 +561,19 @@ wl_iw_get_range(
#endif /* WIRELESS_EXT > 11 */
/* Set available bitrates */
- if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset))))
- return error;
- rateset.count = dtoh32(rateset.count);
- range->num_bitrates = rateset.count;
- for (i = 0; i < rateset.count && i < IW_MAX_BITRATES; i++)
- range->bitrate[i] = (rateset.rates[i] & 0x7f) * 500000; /* convert to bps */
+ if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, rateset, sizeof(*rateset))))
+ goto free_rateset;
+ rateset->count = dtoh32(rateset->count);
+ range->num_bitrates = rateset->count;
+ for (i = 0; i < rateset->count && i < IW_MAX_BITRATES; i++)
+ range->bitrate[i] = (rateset->rates[i] & 0x7f) * 500000; /* convert to bps */
/* Set an indication of the max TCP throughput
* in bit/s that we can expect using this interface.
* May be use for QoS stuff... Jean II
*/
if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i))))
- return error;
+ goto free_rateset;
i = dtoh32(i);
if (i == WLC_PHY_TYPE_A)
range->throughput = 24000000; /* 24 Mbits/s */
@@ -624,7 +636,12 @@ wl_iw_get_range(
#endif
#endif /* WIRELESS_EXT > 17 */
- return 0;
+free_rateset:
+ kfree(rateset);
+free_channels:
+ kfree(channels);
+
+ return error;
}
static int
--- a/driver/bcmsrom.c
+++ b/driver/bcmsrom.c
@@ -437,20 +437,37 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
uint byteoff, uint nbytes, uint16 *buf)
{
uint i, nw, crc_range;
- uint16 old[SROM_MAXW], new[SROM_MAXW];
+ uint16 *old, *new;
uint8 crc;
volatile uint32 val32;
+ int rc = 0;
ASSERT(bustype == BUSTYPE(bustype));
+ old = MALLOC(osh, SROM_MAXW);
+ ASSERT(old != NULL);
+ if (!old)
+ return -2;
+
+ new = MALLOC(osh, SROM_MAXW);
+ ASSERT(new != NULL);
+ if (!new) {
+ rc = -2;
+ goto free_old;
+ }
+
/* check input - 16-bit access only. use byteoff 0x55aa to indicate
* srclear
*/
- if ((byteoff != 0x55aa) && ((byteoff & 1) || (nbytes & 1)))
- return 1;
+ if ((byteoff != 0x55aa) && ((byteoff & 1) || (nbytes & 1))) {
+ rc = 1;
+ goto free_new;
+ }
- if ((byteoff != 0x55aa) && ((byteoff + nbytes) > SROM_MAX))
- return 1;
+ if ((byteoff != 0x55aa) && ((byteoff + nbytes) > SROM_MAX)) {
+ rc = 1;
+ goto free_new;
+ }
if (BUSTYPE(bustype) == PCMCIA_BUS) {
crc_range = SROM_MAX;
@@ -467,8 +484,10 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
nw = crc_range / 2;
/* read first small number words from srom, then adjust the length, read all */
- if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE))
- return 1;
+ if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) {
+ rc = 1;
+ goto free_new;
+ }
BS_ERROR(("%s: old[SROM4_SIGN] 0x%x, old[SROM8_SIGN] 0x%x\n",
__FUNCTION__, old[SROM4_SIGN], old[SROM8_SIGN]));
@@ -481,10 +500,13 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
__FUNCTION__, buf[SROM4_SIGN], buf[SROM8_SIGN]));
/* block invalid buffer size */
- if (nbytes < SROM4_WORDS * 2)
- return BCME_BUFTOOSHORT;
- else if (nbytes > SROM4_WORDS * 2)
- return BCME_BUFTOOLONG;
+ if (nbytes < SROM4_WORDS * 2) {
+ rc = BCME_BUFTOOSHORT;
+ goto free_new;
+ } else if (nbytes > SROM4_WORDS * 2) {
+ rc = BCME_BUFTOOLONG;
+ goto free_new;
+ }
nw = SROM4_WORDS;
} else if (nbytes == SROM_WORDS * 2){ /* the other possible SROM format */
@@ -493,17 +515,22 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
nw = SROM_WORDS;
} else {
BS_ERROR(("%s: Invalid input file signature\n", __FUNCTION__));
- return BCME_BADARG;
+ rc = BCME_BADARG;
+ goto free_new;
}
crc_range = nw * 2;
- if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE))
- return 1;
+ if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) {
+ rc = 1;
+ goto free_new;
+ }
} else if ((old[SROM4_SIGN] == SROM4_SIGNATURE) ||
(old[SROM8_SIGN] == SROM4_SIGNATURE)) {
nw = SROM4_WORDS;
crc_range = nw * 2;
- if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE))
- return 1;
+ if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) {
+ rc = 1;
+ goto free_new;
+ }
} else {
/* Assert that we have already read enough for sromrev 2 */
ASSERT(crc_range >= SROM_WORDS * 2);
@@ -562,8 +589,10 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
}
} else if (BUSTYPE(bustype) == PCMCIA_BUS) {
/* enable writes to the SPROM */
- if (sprom_cmd_pcmcia(osh, SROM_WEN))
- return 1;
+ if (sprom_cmd_pcmcia(osh, SROM_WEN)) {
+ rc = 1;
+ goto free_new;
+ }
bcm_mdelay(WRITE_ENABLE_DELAY);
/* write srom */
for (i = 0; i < nw; i++) {
@@ -573,14 +602,15 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
}
}
/* disable writes to the SPROM */
- if (sprom_cmd_pcmcia(osh, SROM_WDS))
- return 1;
+ if (sprom_cmd_pcmcia(osh, SROM_WDS)) {
+ rc = 1;
+ goto free_new;
+ }
} else if (BUSTYPE(bustype) == SI_BUS) {
#if defined(BCMUSBDEV)
if (SPROMBUS == PCMCIA_BUS) {
uint origidx;
void *regs;
- int rc;
bool wasup;
origidx = si_coreidx(sih);
@@ -596,16 +626,24 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
si_core_disable(sih, 0);
si_setcoreidx(sih, origidx);
- return rc;
+ goto free_new;
}
#endif
- return 1;
+ rc = 1;
+ goto free_new;
} else {
- return 1;
+ rc = 1;
+ goto free_new;
}
bcm_mdelay(WRITE_ENABLE_DELAY);
- return 0;
+ rc = 0;
+
+free_new:
+ MFREE(osh, new, SROM_MAXW);
+free_old:
+ MFREE(osh, old, SROM_MAXW);
+ return rc;
}
#if defined(BCMUSBDEV)
--- a/driver/linux_osl.c
+++ b/driver/linux_osl.c
@@ -600,20 +600,29 @@ int
osl_printf(const char *format, ...)
{
va_list args;
- char buf[1024];
+ char *buf;
int len;
+ buf = kcalloc(1024, sizeof(*buf), GFP_KERNEL);
+ if (!buf)
+ return (-ENOMEM);
+
/* sprintf into a local buffer because there *is* no "vprintk()".. */
va_start(args, format);
len = vsnprintf(buf, 1024, format, args);
va_end(args);
- if (len > sizeof(buf)) {
+ if (len > (sizeof(*buf) * 1024)) {
printk("osl_printf: buffer overrun\n");
- return (0);
+ goto exit;
}
- return (printk(buf));
+ printk(buf);
+
+exit:
+ kfree(buf);
+
+ return (0);
}
int
--- a/driver/bcmutils.c
+++ b/driver/bcmutils.c
@@ -13,6 +13,7 @@
#include <typedefs.h>
#include <bcmdefs.h>
+#define __need___va_list
#include <stdarg.h>
#include <bcmutils.h>
#ifdef BCMDRIVER

View File

@@ -1,14 +0,0 @@
--- a/driver/aiutils.c
+++ b/driver/aiutils.c
@@ -228,9 +228,10 @@ ai_scan(si_t *sih, void *regs, uint devid)
do {
asd = get_asd(sih, &eromptr, 0, j, AD_ST_SLAVE, &addrl, &addrh,
&sizel, &sizeh);
- if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE))
+ if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE)) {
sii->coresba2[idx] = addrl;
sii->coresba2_size[idx] = sizel;
+ }
j++;
} while (asd != 0);

View File

@@ -1,63 +0,0 @@
--- a/driver/hnddma.c
+++ b/driver/hnddma.c
@@ -1896,7 +1896,8 @@ dma64_txfast(dma_info_t *di, void *p0, bool commit)
if (!(flags & D64_CTRL1_EOF)) {
#if defined(linux) && defined(__mips__)
if (CHIPID(di->sih->chip) == BCM5356_CHIP_ID && di->sih->chiprev == 0) {
- uint32 ctrl1, ctrl2, addrlow, addrhigh;
+ uint32 ctrl2, addrlow, addrhigh;
+ // uint32 ctrl1;
addrlow = R_SM((volatile uint32 *)&di->txd64[PREVTXD(txout)].addrlow);
addrhigh = R_SM((volatile uint32 *)&di->txd64[PREVTXD(txout)].addrhigh);
--- a/driver/include/linux_osl.h
+++ b/driver/include/linux_osl.h
@@ -580,9 +580,9 @@ extern void osl_writew(uint16 v, volatile uint16 *r);
extern void osl_writel(uint32 v, volatile uint32 *r);
/* uncached/cached virtual address */
-#define OSL_UNCACHED(va) osl_uncached((va))
+#define OSL_UNCACHED(va) osl_uncached((void *)(va))
extern void *osl_uncached(void *va);
-#define OSL_CACHED(va) osl_cached((va))
+#define OSL_CACHED(va) osl_cached((void *)(va))
extern void *osl_cached(void *va);
/* get processor cycle count */
--- a/driver/siutils.c
+++ b/driver/siutils.c
@@ -495,11 +495,13 @@ BCMATTACHFN(si_doattach)(si_info_t *sii, uint devid, osl_t *osh, void *regs,
}
sih->bustype = bustype;
+#ifdef BCMBUSTYPE
if (bustype != BUSTYPE(bustype)) {
SI_ERROR(("si_doattach: bus type %d does not match configured bus type %d\n",
bustype, BUSTYPE(bustype)));
return NULL;
}
+#endif
/* bus/core/clk setup for register access */
if (!si_buscore_prep(sii, bustype, devid, sdh)) {
@@ -1716,6 +1718,9 @@ si_clkctl_xtal(si_t *sih, uint what, bool on)
outen);
}
+ return (0);
+
+
default:
return (-1);
}
--- a/driver/bcmsrom.c
+++ b/driver/bcmsrom.c
@@ -1005,6 +1043,7 @@ BCMNMIATTACHFN(srom_parsecis)(osl_t *osh, uint8 *pcis[], uint ciscnt, char **var
break;
}
+ fallthrough;
case CISTPL_MANFID: FROMHOST();
varbuf_append(&b, vstr_manfid, (cis[i + 1] << 8) + cis[i]);
varbuf_append(&b, vstr_prodid, (cis[i + 3] << 8) + cis[i + 2]);

View File

@@ -1,10 +0,0 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -1109,6 +1109,7 @@ wl_module_exit(void)
module_init(wl_module_init);
module_exit(wl_module_exit);
+MODULE_LICENSE("Proprietary");
/**
* This function frees the WL per-device resources.

View File

@@ -1,17 +0,0 @@
#
# Makefile for wl_glue driver
#
# Copyright (C) 2011 Jo-Philipp Wich <jo@mein.io>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version
# 2 of the License, or (at your option) any later version.
#
obj-m := wl_glue.o
ifeq ($(MAKING_MODULES),1)
-include $(TOPDIR)/Rules.make
endif

View File

@@ -1,315 +0,0 @@
/*
* wl_glue.c: Broadcom WL support module providing a unified SSB/BCMA handling.
* Copyright (C) 2011 Jo-Philipp Wich <jo@mein.io>
*/
#include "wl_glue.h"
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#ifdef CONFIG_BCM47XX
#include <bcm47xx.h>
#endif
#ifdef CONFIG_SSB
#include <linux/ssb/ssb.h>
#endif
#ifdef CONFIG_BCMA
#include <linux/bcma/bcma.h>
#endif
MODULE_AUTHOR("Jo-Philipp Wich (jo@mein.io)");
MODULE_DESCRIPTION("Broadcom WL SSB/BCMA compatibility layer");
MODULE_LICENSE("GPL");
static wl_glue_attach_cb_t attach_cb = NULL;
static wl_glue_remove_cb_t remove_cb = NULL;
static enum wl_glue_bus_type active_bus_type = WL_GLUE_BUS_TYPE_UNSPEC;
static int wl_glue_attached = 0;
#ifdef CONFIG_SSB
static int wl_glue_ssb_probe(struct ssb_device *dev, const struct ssb_device_id *id)
{
void *mmio;
void *wldev;
if (!attach_cb)
{
pr_err("No attach callback registered\n");
return -ENOSYS;
}
if (dev->bus->bustype != SSB_BUSTYPE_SSB)
{
pr_err("Attaching to SSB behind PCI is not supported. Please remove the b43 ssb bridge\n");
return -EINVAL;
}
mmio = (void *) 0x18000000 + dev->core_index * 0x1000;
wldev = attach_cb(id->vendor, id->coreid, (ulong)mmio, dev, dev->irq);
if (!wldev)
{
pr_err("The attach callback failed, SSB probe aborted\n");
return -ENODEV;
}
ssb_set_drvdata(dev, wldev);
return 0;
}
static void wl_glue_ssb_remove(struct ssb_device *dev)
{
void *wldev = ssb_get_drvdata(dev);
if (remove_cb)
remove_cb(wldev);
ssb_set_drvdata(dev, NULL);
}
static const struct ssb_device_id wl_glue_ssb_tbl[] = {
SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, SSB_ANY_REV),
{},
};
static struct ssb_driver wl_glue_ssb_driver = {
.name = KBUILD_MODNAME,
.id_table = wl_glue_ssb_tbl,
.probe = wl_glue_ssb_probe,
.remove = wl_glue_ssb_remove,
};
#endif /* CONFIG_SSB */
#ifdef CONFIG_BCMA
static int wl_glue_bcma_probe(struct bcma_device *dev)
{
void *wldev;
if (!attach_cb)
{
pr_err("No attach callback registered\n");
return -ENOSYS;
}
if (dev->bus->hosttype != BCMA_HOSTTYPE_SOC)
{
pr_err("Unsupported BCMA bus type %d\n", dev->bus->hosttype);
return -EINVAL;
}
/*
* NB:
* 0x18000000 = BCMA_ADDR_BASE
* 0x1000 = BCMA_CORE_SIZE
*/
wldev = attach_cb(dev->id.manuf, dev->id.id, (ulong)dev->addr, dev, dev->irq);
if (!wldev)
{
pr_err("The attach callback failed, BCMA probe aborted\n");
return -ENODEV;
}
bcma_set_drvdata(dev, wldev);
return 0;
}
static void wl_glue_bcma_remove(struct bcma_device *dev)
{
void *wldev = bcma_get_drvdata(dev);
if (remove_cb)
remove_cb(wldev);
bcma_set_drvdata(dev, NULL);
}
static const struct bcma_device_id wl_glue_bcma_tbl[] = {
BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, BCMA_ANY_REV, BCMA_ANY_CLASS),
{},
};
static struct bcma_driver wl_glue_bcma_driver = {
.name = KBUILD_MODNAME,
.id_table = wl_glue_bcma_tbl,
.probe = wl_glue_bcma_probe,
.remove = wl_glue_bcma_remove,
};
#endif /* CONFIG_BCMA */
void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb)
{
attach_cb = cb;
}
EXPORT_SYMBOL(wl_glue_set_attach_callback);
void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb)
{
remove_cb = cb;
}
EXPORT_SYMBOL(wl_glue_set_remove_callback);
int wl_glue_register(void)
{
int err;
switch(active_bus_type)
{
#ifdef CONFIG_SSB
case WL_GLUE_BUS_TYPE_SSB:
err = ssb_driver_register(&wl_glue_ssb_driver);
break;
#endif /* CONFIG_SSB */
#ifdef CONFIG_BCMA
case WL_GLUE_BUS_TYPE_BCMA:
err = bcma_driver_register(&wl_glue_bcma_driver);
break;
#endif /* CONFIG_BCMA */
default:
pr_err("Not attaching through glue driver due to unsupported bus\n");
err = -ENOSYS;
break;
}
if (!err)
{
pr_info("SSB/BCMA glue driver successfully attached\n");
wl_glue_attached = 1;
}
return err;
}
EXPORT_SYMBOL(wl_glue_register);
int wl_glue_unregister(void)
{
int err;
if (!wl_glue_attached)
return -ENOSYS;
switch (active_bus_type)
{
#ifdef CONFIG_SSB
case WL_GLUE_BUS_TYPE_SSB:
ssb_driver_unregister(&wl_glue_ssb_driver);
err = 0;
break;
#endif /* CONFIG_SSB */
#ifdef CONFIG_BCMA
case WL_GLUE_BUS_TYPE_BCMA:
bcma_driver_unregister(&wl_glue_bcma_driver);
err = 0;
break;
#endif /* CONFIG_BCMA */
default:
pr_err("Not removing glue driver due to unsupported bus\n");
err = -ENOSYS;
break;
}
if (!err)
{
pr_info("SSB/BCMA glue driver successfully detached\n");
wl_glue_attached = 0;
}
return err;
}
EXPORT_SYMBOL(wl_glue_unregister);
struct device * wl_glue_get_dmadev(void *dev)
{
struct device *dma_dev;
switch (active_bus_type)
{
#ifdef CONFIG_SSB
case WL_GLUE_BUS_TYPE_SSB:
dma_dev = ((struct ssb_device *)dev)->dma_dev;
break;
#endif /* CONFIG_SSB */
#ifdef CONFIG_BCMA
case WL_GLUE_BUS_TYPE_BCMA:
dma_dev = ((struct bcma_device *)dev)->dma_dev;
break;
#endif /* CONFIG_BCMA */
default:
BUG();
dma_dev = NULL;
break;
}
return dma_dev;
}
EXPORT_SYMBOL(wl_glue_get_dmadev);
static int __init wl_glue_init(void)
{
#ifdef CONFIG_BCM47XX
/*
* BCM47xx currently supports either SSB or BCMA bus,
* determine the used one from the info set by the
* platform setup code.
*/
switch (bcm47xx_bus_type)
{
#ifdef CONFIG_BCM47XX_SSB
case BCM47XX_BUS_TYPE_SSB:
active_bus_type = WL_GLUE_BUS_TYPE_SSB;
break;
#endif /* CONFIG_BCM47XX_SSB */
#ifdef CONFIG_BCM47XX_BCMA
case BCM47XX_BUS_TYPE_BCMA:
active_bus_type = WL_GLUE_BUS_TYPE_BCMA;
break;
#endif /* CONFIG_BCM47XX_BCMA */
}
#endif /* CONFIG_BCM47XX */
#ifdef CONFIG_BCM63XX
#ifdef CONFIG_SSB
/*
* BCM63xx currently only uses SSB, so assume that.
*/
active_bus_type = WL_GLUE_BUS_TYPE_SSB;
#endif /* CONFIG_SSB */
#endif /* CONFIG_BCM63XX */
/* do not fail here, let wl_glue_register() return -ENOSYS later */
if (active_bus_type == WL_GLUE_BUS_TYPE_UNSPEC)
pr_err("Unable to determine used system bus type\n");
return 0;
}
static void __exit wl_glue_exit(void)
{
if (wl_glue_attached)
{
if (wl_glue_unregister())
pr_err("Failed to unregister glue driver\n");
wl_glue_attached = 0;
}
return;
}
module_init(wl_glue_init);
module_exit(wl_glue_exit);

View File

@@ -1,22 +0,0 @@
/*
* wl_glue.h: Broadcom WL support module providing a unified SSB/BCMA handling.
* Copyright (C) 2011 Jo-Philipp Wich <jo@mein.io>
*/
#include <linux/types.h>
typedef void * (*wl_glue_attach_cb_t)(u16, u16, ulong, void *, u32);
typedef void (*wl_glue_remove_cb_t)(void *);
enum wl_glue_bus_type {
WL_GLUE_BUS_TYPE_UNSPEC,
WL_GLUE_BUS_TYPE_SSB,
WL_GLUE_BUS_TYPE_BCMA
};
extern void wl_glue_set_attach_callback(wl_glue_attach_cb_t cb);
extern void wl_glue_set_remove_callback(wl_glue_remove_cb_t cb);
extern int wl_glue_register(void);
extern int wl_glue_unregister(void);
extern struct device * wl_glue_get_dmadev(void *);

File diff suppressed because it is too large Load Diff

View File

@@ -92,7 +92,7 @@ PKG_CONFIG_DEPENDS += \
define KernelPackage/cfg80211
$(call KernelPackage/mac80211/Default)
TITLE:=cfg80211 - wireless configuration API
DEPENDS+= +iw +iwinfo +wireless-regdb +USE_RFKILL:kmod-rfkill
DEPENDS+= +iw +iwinfo +wifi-scripts +wireless-regdb +USE_RFKILL:kmod-rfkill
ABI_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
FILES:= \
$(PKG_BUILD_DIR)/compat/compat.ko \
@@ -384,14 +384,6 @@ define Build/InstallDev
endef
define KernelPackage/cfg80211/install
$(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless
$(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi
$(INSTALL_BIN) ./files/lib/netifd/wireless/mac80211.sh $(1)/lib/netifd/wireless
$(INSTALL_DIR) $(1)/etc/hotplug.d/ieee80211
$(INSTALL_DATA) ./files/mac80211.hotplug $(1)/etc/hotplug.d/ieee80211/10-wifi-detect
endef
$(eval $(foreach drv,$(PKG_DRIVERS),$(call KernelPackage,$(drv))))
$(eval $(call KernelPackage,cfg80211))
$(eval $(call KernelPackage,mac80211))

View File

@@ -8,9 +8,9 @@ PKG_LICENSE_FILES:=
PKG_SOURCE_URL:=https://github.com/openwrt/mt76
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2024-01-18
PKG_SOURCE_VERSION:=f77188160441d5f77f08dd517632ae3f60c653b0
PKG_MIRROR_HASH:=133a5e44624fe1933c893ee0b8ac75a847753f3490c26518c2ed9798f9ef53e0
PKG_SOURCE_DATE:=2024-02-03
PKG_SOURCE_VERSION:=6124ea9135ed512671933f5520c46842906c78bc
PKG_MIRROR_HASH:=acc326d7b15c9c72b494ed601300be329553f896e65c7f045e6a09327304c34a
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_USE_NINJA:=0
@@ -326,6 +326,12 @@ define KernelPackage/mt7996e
AUTOLOAD:=$(call AutoProbe,mt7996e)
endef
define KernelPackage/mt7996-firmware
$(KernelPackage/mt76-default)
TITLE:=MediaTek MT7996 firmware
DEPENDS+=+kmod-mt7996e
endef
define KernelPackage/mt7925-common
$(KernelPackage/mt76-default)
TITLE:=MediaTek MT7925 wireless driver common code
@@ -613,6 +619,17 @@ define KernelPackage/mt7922-firmware/install
$(1)/lib/firmware/mediatek
endef
define KernelPackage/mt7996-firmware/install
$(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7996
cp \
$(PKG_BUILD_DIR)/firmware/mt7996/mt7996_dsp.bin \
$(PKG_BUILD_DIR)/firmware/mt7996/mt7996_eeprom.bin \
$(PKG_BUILD_DIR)/firmware/mt7996/mt7996_rom_patch.bin \
$(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wa.bin \
$(PKG_BUILD_DIR)/firmware/mt7996/mt7996_wm.bin \
$(1)/lib/firmware/mediatek/mt7996
endef
define Package/mt76-test/install
mkdir -p $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mt76-test $(1)/usr/sbin
@@ -657,5 +674,6 @@ $(eval $(call KernelPackage,mt7921e))
$(eval $(call KernelPackage,mt7925u))
$(eval $(call KernelPackage,mt7925e))
$(eval $(call KernelPackage,mt7996e))
$(eval $(call KernelPackage,mt7996-firmware))
$(eval $(call KernelPackage,mt76))
$(eval $(call BuildPackage,mt76-test))

View File

@@ -43,7 +43,10 @@ define Package/netifd/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/netifd $(1)/sbin/
$(CP) ./files/* $(1)/
$(INSTALL_DIR) $(1)/etc/udhcpc.user.d/
$(CP) $(PKG_BUILD_DIR)/scripts/* $(1)/lib/netifd/
$(CP) \
$(PKG_BUILD_DIR)/scripts/utils.sh \
$(PKG_BUILD_DIR)/scripts/netifd-proto.sh \
$(1)/lib/netifd/
endef
$(eval $(call BuildPackage,netifd))

View File

@@ -0,0 +1,45 @@
#
# Copyright (C) 2024 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=wifi-scripts
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
include $(INCLUDE_DIR)/package.mk
define Package/wifi-scripts
SECTION:=utils
CATEGORY:=Base system
DEPENDS:=+netifd +ucode +ucode-mod-nl80211 +ucode-mod-ubus
TITLE:=Wi-Fi configuration scripts
PKGARCH:=all
endef
define Package/qos-scripts/description
A set of scripts that handle setup and configuration of Wi-Fi devices.
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/wifi-scripts/install
$(INSTALL_DIR) $(1)
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,wifi-scripts))

View File

@@ -0,0 +1,439 @@
NETIFD_MAIN_DIR="${NETIFD_MAIN_DIR:-/lib/netifd}"
. /usr/share/libubox/jshn.sh
. $NETIFD_MAIN_DIR/utils.sh
CMD_UP=0
CMD_SET_DATA=1
CMD_PROCESS_ADD=2
CMD_PROCESS_KILL_ALL=3
CMD_SET_RETRY=4
add_driver() {
return
}
wireless_setup_vif_failed() {
local error="$1"
echo "Interface $_w_iface setup failed: $error"
}
wireless_setup_failed() {
local error="$1"
echo "Device setup failed: $error"
wireless_set_retry 0
}
prepare_key_wep() {
local key="$1"
local hex=1
echo -n "$key" | grep -qE "[^a-fA-F0-9]" && hex=0
[ "${#key}" -eq 10 -a $hex -eq 1 ] || \
[ "${#key}" -eq 26 -a $hex -eq 1 ] || {
[ "${key:0:2}" = "s:" ] && key="${key#s:}"
key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')"
}
echo "$key"
}
_wdev_prepare_channel() {
json_get_vars channel band hwmode
auto_channel=0
enable_ht=0
htmode=
hwmode="${hwmode##11}"
case "$channel" in
""|0|auto)
channel=0
auto_channel=1
;;
[0-9]*) ;;
*)
wireless_setup_failed "INVALID_CHANNEL"
;;
esac
case "$hwmode" in
a|b|g|ad) ;;
*)
if [ "$channel" -gt 14 ]; then
hwmode=a
else
hwmode=g
fi
;;
esac
case "$band" in
2g) hwmode=g;;
5g|6g) hwmode=a;;
60g) hwmode=ad;;
*)
case "$hwmode" in
*a) band=5g;;
*ad) band=60g;;
*b|*g) band=2g;;
esac
;;
esac
}
_wdev_handler() {
json_load "$data"
json_select config
_wdev_prepare_channel
json_select ..
eval "drv_$1_$2 \"$interface\""
}
_wdev_msg_call() {
local old_cb
json_set_namespace wdev old_cb
"$@"
json_set_namespace $old_cb
}
_wdev_wrapper() {
while [ -n "$1" ]; do
eval "$1() { _wdev_msg_call _$1 \"\$@\"; }"
shift
done
}
_wdev_notify_init() {
local command="$1"; shift;
json_init
json_add_int "command" "$command"
json_add_string "device" "$__netifd_device"
while [ -n "$1" ]; do
local name="$1"; shift
local value="$1"; shift
json_add_string "$name" "$value"
done
json_add_object "data"
}
_wdev_notify() {
local options="$1"
json_close_object
ubus $options call network.wireless notify "$(json_dump)"
}
_wdev_add_variables() {
while [ -n "$1" ]; do
local var="${1%%=*}"
local val="$1"
shift
[[ "$var" = "$val" ]] && continue
val="${val#*=}"
json_add_string "$var" "$val"
done
}
_wireless_add_vif() {
local name="$1"; shift
local ifname="$1"; shift
_wdev_notify_init $CMD_SET_DATA "interface" "$name"
json_add_string "ifname" "$ifname"
_wdev_add_variables "$@"
_wdev_notify
}
_wireless_add_vlan() {
local name="$1"; shift
local ifname="$1"; shift
_wdev_notify_init $CMD_SET_DATA interface "$__cur_interface" "vlan" "$name"
json_add_string "ifname" "$ifname"
_wdev_add_variables "$@"
_wdev_notify
}
_wireless_set_up() {
_wdev_notify_init $CMD_UP
_wdev_notify
}
_wireless_set_data() {
_wdev_notify_init $CMD_SET_DATA
_wdev_add_variables "$@"
_wdev_notify
}
_wireless_add_process() {
_wdev_notify_init $CMD_PROCESS_ADD
local exe="$2"
[ -L "$exe" ] && exe="$(readlink -f "$exe")"
json_add_int pid "$1"
json_add_string exe "$exe"
[ -n "$3" ] && json_add_boolean required 1
[ -n "$4" ] && json_add_boolean keep 1
exe2="$(readlink -f /proc/$1/exe)"
[ "$exe" != "$exe2" ] && echo "WARNING (wireless_add_process): executable path $exe does not match process $1 path ($exe2)"
_wdev_notify
}
_wireless_process_kill_all() {
_wdev_notify_init $CMD_PROCESS_KILL_ALL
[ -n "$1" ] && json_add_int signal "$1"
_wdev_notify
}
_wireless_set_retry() {
_wdev_notify_init $CMD_SET_RETRY
json_add_int retry "$1"
_wdev_notify
}
_wdev_wrapper \
wireless_add_vif \
wireless_add_vlan \
wireless_set_up \
wireless_set_data \
wireless_add_process \
wireless_process_kill_all \
wireless_set_retry \
wireless_vif_parse_encryption() {
json_get_vars encryption
set_default encryption none
auth_mode_open=1
auth_mode_shared=0
auth_type=none
if [ "$hwmode" = "ad" ]; then
wpa_cipher="GCMP"
else
wpa_cipher="CCMP"
fi
case "$encryption" in
*tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip) wpa_cipher="CCMP TKIP";;
*ccmp256) wpa_cipher="CCMP-256";;
*aes|*ccmp) wpa_cipher="CCMP";;
*tkip) wpa_cipher="TKIP";;
*gcmp256) wpa_cipher="GCMP-256";;
*gcmp) wpa_cipher="GCMP";;
wpa3-192*) wpa_cipher="GCMP-256";;
esac
# 802.11n requires CCMP for WPA
[ "$enable_ht:$wpa_cipher" = "1:TKIP" ] && wpa_cipher="CCMP TKIP"
# Examples:
# psk-mixed/tkip => WPA1+2 PSK, TKIP
# wpa-psk2/tkip+aes => WPA2 PSK, CCMP+TKIP
# wpa2/tkip+aes => WPA2 RADIUS, CCMP+TKIP
case "$encryption" in
wpa2*|wpa3*|*psk2*|psk3*|sae*|owe*)
wpa=2
;;
wpa*mixed*|*psk*mixed*)
wpa=3
;;
wpa*|*psk*)
wpa=1
;;
*)
wpa=0
wpa_cipher=
;;
esac
wpa_pairwise="$wpa_cipher"
case "$encryption" in
owe*)
auth_type=owe
;;
wpa3-192*)
auth_type=eap192
;;
wpa3-mixed*)
auth_type=eap-eap2
;;
wpa3*)
auth_type=eap2
;;
psk3-mixed*|sae-mixed*)
auth_type=psk-sae
;;
psk3*|sae*)
auth_type=sae
;;
*psk*)
auth_type=psk
;;
*wpa*|*8021x*)
auth_type=eap
;;
*wep*)
auth_type=wep
case "$encryption" in
*shared*)
auth_mode_open=0
auth_mode_shared=1
;;
*mixed*)
auth_mode_shared=1
;;
esac
;;
esac
case "$encryption" in
*osen*)
auth_osen=1
;;
esac
}
_wireless_set_brsnoop_isolation() {
local multicast_to_unicast="$1"
local isolate
json_get_vars isolate proxy_arp
[ ${isolate:-0} -gt 0 -o -z "$network_bridge" ] && return
[ ${multicast_to_unicast:-1} -gt 0 -o ${proxy_arp:-0} -gt 0 ] && json_add_boolean isolate 1
}
for_each_interface() {
local _w_types="$1"; shift
local _w_ifaces _w_iface
local _w_type
local _w_found
local multicast_to_unicast
json_get_keys _w_ifaces interfaces
json_select interfaces
for _w_iface in $_w_ifaces; do
json_select "$_w_iface"
if [ -n "$_w_types" ]; then
json_get_var network_bridge bridge
json_get_var network_ifname bridge-ifname
json_get_var multicast_to_unicast multicast_to_unicast
json_select config
_wireless_set_brsnoop_isolation "$multicast_to_unicast"
json_get_var _w_type mode
json_select ..
_w_types=" $_w_types "
[[ "${_w_types%$_w_type*}" = "$_w_types" ]] && {
json_select ..
continue
}
fi
__cur_interface="$_w_iface"
"$@" "$_w_iface"
json_select ..
done
json_select ..
}
for_each_vlan() {
local _w_vlans _w_vlan
json_get_keys _w_vlans vlans
json_select vlans
for _w_vlan in $_w_vlans; do
json_select "$_w_vlan"
json_select config
"$@" "$_w_vlan"
json_select ..
json_select ..
done
json_select ..
}
for_each_station() {
local _w_stas _w_sta
json_get_keys _w_stas stas
json_select stas
for _w_sta in $_w_stas; do
json_select "$_w_sta"
json_select config
"$@" "$_w_sta"
json_select ..
json_select ..
done
json_select ..
}
_wdev_common_device_config() {
config_add_string channel hwmode band htmode noscan
}
_wdev_common_iface_config() {
config_add_string mode ssid encryption 'key:wpakey'
config_add_boolean bridge_isolate
}
_wdev_common_vlan_config() {
config_add_string name vid iface
config_add_boolean bridge_isolate
}
_wdev_common_station_config() {
config_add_string mac key vid iface
}
init_wireless_driver() {
name="$1"; shift
cmd="$1"; shift
case "$cmd" in
dump)
add_driver() {
eval "drv_$1_cleanup"
json_init
json_add_string name "$1"
json_add_array device
_wdev_common_device_config
eval "drv_$1_init_device_config"
json_close_array
json_add_array iface
_wdev_common_iface_config
eval "drv_$1_init_iface_config"
json_close_array
json_add_array vlan
_wdev_common_vlan_config
eval "drv_$1_init_vlan_config"
json_close_array
json_add_array station
_wdev_common_station_config
eval "drv_$1_init_station_config"
json_close_array
json_dump
}
;;
setup|teardown)
interface="$1"; shift
data="$1"; shift
export __netifd_device="$interface"
add_driver() {
[[ "$name" == "$1" ]] || return 0
_wdev_handler "$1" "$cmd"
}
;;
esac
}

View File

@@ -176,6 +176,7 @@ wifi_detect_notice() {
wifi_config() {
[ -e /tmp/.config_pending ] && return
ucode /usr/share/hostap/wifi-detect.uc
[ ! -f /etc/config/wireless ] && touch /etc/config/wireless
for driver in $DRIVERS; do (

View File

@@ -0,0 +1,154 @@
#!/usr/bin/env ucode
'use strict';
import { readfile, writefile, realpath, glob, basename, unlink, open, rename } from "fs";
import { is_equal } from "/usr/share/hostap/common.uc";
let nl = require("nl80211");
let board_file = "/etc/board.json";
let prev_board_data = json(readfile(board_file));
let board_data = json(readfile(board_file));
function phy_idx(name) {
return +rtrim(readfile(`/sys/class/ieee80211/${name}/index`));
}
function phy_path(name) {
let devpath = realpath(`/sys/class/ieee80211/${name}/device`);
devpath = replace(devpath, /^\/sys\/devices\//, "");
if (match(devpath, /^platform\/.*\/pci/))
devpath = replace(devpath, /^platform\//, "");
let dev_phys = map(glob(`/sys/class/ieee80211/${name}/device/ieee80211/*`), basename);
sort(dev_phys, (a, b) => phy_idx(a) - phy_idx(b));
let ofs = index(dev_phys, name);
if (ofs > 0)
devpath += `+${ofs}`;
return devpath;
}
function cleanup() {
let wlan = board_data.wlan;
for (let name in wlan)
if (substr(name, 0, 3) == "phy")
delete wlan[name];
else
delete wlan[name].info;
}
function wiphy_get_entry(phy, path) {
let wlan = board_data.wlan;
for (let name in wlan)
if (wlan[name].path == path)
return wlan[name];
wlan[phy] = {
path: path
};
return wlan[phy];
}
function wiphy_detect() {
let phys = nl.request(nl.const.NL80211_CMD_GET_WIPHY, nl.const.NLM_F_DUMP, { split_wiphy_dump: true });
if (!phys)
return;
for (let phy in phys) {
let name = phy.wiphy_name;
let path = phy_path(name);
let info = {
antenna_rx: phy.wiphy_antenna_avail_rx,
antenna_tx: phy.wiphy_antenna_avail_tx,
bands: {},
};
let bands = info.bands;
for (let band in phy.wiphy_bands) {
if (!band || !band.freqs)
continue;
let freq = band.freqs[0].freq;
let band_info = {};
let band_name;
if (freq > 50000)
band_name = "60G";
else if (freq > 5900)
band_name = "6G";
else if (freq > 4000)
band_name = "5G";
else
band_name = "2G";
bands[band_name] = band_info;
if (band.ht_capa > 0)
band_info.ht = true;
if (band.vht_capa > 0)
band_info.vht = true;
let he_phy_cap = 0;
for (let ift in band.iftype_data) {
if (!ift.he_cap_phy)
continue;
band_info.he = true;
he_phy_cap |= ift.he_cap_phy[0];
/* TODO: EHT */
}
if (band_name != "2G" &&
(he_phy_cap & 0x18) || ((band.vht_capa >> 2) & 0x3))
band_info.max_width = 160;
else if (band_name != "2G" &&
(he_phy_cap & 4) || band.vht_capa > 0)
band_info.max_width = 80;
else if ((band.ht_capa & 0x2) || (he_phy_cap & 0x2))
band_info.max_width = 40;
else
band_info.max_width = 20;
let modes = band_info.modes = [ "NOHT" ];
if (band_info.ht)
push(modes, "HT20");
if (band_info.vht)
push(modes, "VHT20");
if (band_info.he)
push(modes, "HE20");
if (band.ht_capa & 0x2) {
push(modes, "HT40");
if (band_info.vht)
push(modes, "VHT40")
}
if (he_phy_cap & 0x2)
push(modes, "HE40");
if (band_name == "2G")
continue;
if (band_info.vht)
push(modes, "VHT80");
if (he_phy_cap & 4)
push(modes, "HE80");
if ((band.vht_capa >> 2) & 0x3)
push(modes, "VHT160");
if (he_phy_cap & 0x18)
push(modes, "HE160");
}
let entry = wiphy_get_entry(name, path);
entry.info = info;
}
}
cleanup();
wiphy_detect();
if (!is_equal(prev_board_data, board_data)) {
let new_file = board_file + ".new";
unlink(new_file);
let f = open(new_file, "wx");
if (!f)
exit(1);
f.write(sprintf("%.J\n", board_data));
f.close();
rename(new_file, board_file);
}

View File

@@ -712,13 +712,10 @@ endef
define Package/hostapd-common/install
$(INSTALL_DIR) $(1)/etc/capabilities $(1)/etc/rc.button $(1)/etc/hotplug.d/ieee80211 $(1)/etc/init.d $(1)/lib/netifd $(1)/usr/share/acl.d $(1)/usr/share/hostap
$(INSTALL_BIN) ./files/dhcp-get-server.sh $(1)/lib/netifd/dhcp-get-server.sh
$(INSTALL_DATA) ./files/hostapd.sh $(1)/lib/netifd/hostapd.sh
$(INSTALL_BIN) ./files/wpad.init $(1)/etc/init.d/wpad
$(INSTALL_BIN) ./files/wps-hotplug.sh $(1)/etc/rc.button/wps
$(INSTALL_DATA) ./files/wpad_acl.json $(1)/usr/share/acl.d
$(INSTALL_DATA) ./files/wpad.json $(1)/etc/capabilities
$(INSTALL_DATA) ./files/common.uc $(1)/usr/share/hostap/
$(INSTALL_DATA) ./files/wdev.uc $(1)/usr/share/hostap/
endef
define Package/hostapd/install

View File

@@ -0,0 +1,36 @@
From f2ec98566775dd4341ec1dcf93aa5859c60de826 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Thu, 1 Feb 2024 14:46:00 +0100
Subject: [PATCH 1/2] net: phy: qcom: qca808x: fix logic error in LED
brightness set
In switching to using phy_modify_mmd and a more short version of the
LED ON/OFF condition in later revision, it was made a logic error where
value ? QCA808X_LED_FORCE_ON : QCA808X_LED_FORCE_OFF is always true as
value is always OR with QCA808X_LED_FORCE_EN due to missing ()
resulting in the testing condition being QCA808X_LED_FORCE_EN | value.
Add the () to apply the correct condition and restore correct
functionality of the brightness ON/OFF.
Fixes: 7196062b64ee ("net: phy: at803x: add LED support for qca808x")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/phy/qcom/qca808x.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/net/phy/qcom/qca808x.c
+++ b/drivers/net/phy/qcom/qca808x.c
@@ -820,8 +820,8 @@ static int qca808x_led_brightness_set(st
return phy_modify_mmd(phydev, MDIO_MMD_AN, reg,
QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_MODE_MASK,
- QCA808X_LED_FORCE_EN | value ? QCA808X_LED_FORCE_ON :
- QCA808X_LED_FORCE_OFF);
+ QCA808X_LED_FORCE_EN | (value ? QCA808X_LED_FORCE_ON :
+ QCA808X_LED_FORCE_OFF));
}
static int qca808x_led_blink_set(struct phy_device *phydev, u8 index,

View File

@@ -0,0 +1,41 @@
From f203c8c77c7616c099647636f4c67d59a45fe8a2 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Thu, 1 Feb 2024 14:46:01 +0100
Subject: [PATCH 2/2] net: phy: qcom: qca808x: default to LED active High if
not set
qca808x PHY provide support for the led_polarity_set OP to configure
and apply the active-low property but on PHY reset, the Active High bit
is not set resulting in the LED driven as active-low.
To fix this, check if active-low is not set in DT and enable Active High
polarity by default to restore correct funcionality of the LED.
Fixes: 7196062b64ee ("net: phy: at803x: add LED support for qca808x")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/phy/qcom/qca808x.c | 10 ++++++++++
1 file changed, 10 insertions(+)
--- a/drivers/net/phy/qcom/qca808x.c
+++ b/drivers/net/phy/qcom/qca808x.c
@@ -290,8 +290,18 @@ static int qca808x_probe(struct phy_devi
static int qca808x_config_init(struct phy_device *phydev)
{
+ struct qca808x_priv *priv = phydev->priv;
int ret;
+ /* Default to LED Active High if active-low not in DT */
+ if (priv->led_polarity_mode == -1) {
+ ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN,
+ QCA808X_MMD7_LED_POLARITY_CTRL,
+ QCA808X_LED_ACTIVE_HIGH);
+ if (ret)
+ return ret;
+ }
+
/* Active adc&vga on 802.3az for the link 1000M and 100M */
ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, QCA808X_PHY_MMD3_ADDR_CLD_CTRL7,
QCA808X_8023AZ_AFE_CTRL_MASK, QCA808X_8023AZ_AFE_EN);

View File

@@ -1,8 +1,7 @@
From eacf1d2505dfecd3599d558cdade1a2da47fe06d Mon Sep 17 00:00:00 2001
From bdce82e960d1205d118662f575cec39379984e34 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Wed, 24 Jan 2024 18:52:33 +0100
Subject: [PATCH 2/3] net: mdio: ipq4019: add support for clock-frequency
property
Date: Wed, 31 Jan 2024 03:26:04 +0100
Subject: [PATCH] net: mdio: ipq4019: add support for clock-frequency property
The IPQ4019 MDIO internally divide the clock feed by AHB based on the
MDIO_MODE reg. On reset or power up, the default value for the
@@ -44,6 +43,8 @@ Documentation of some BITs is skipped as they are marked as reserved and
their usage is not clear (RES 11:9 GENPHY 16:13 RES1 19:17)
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/mdio/mdio-ipq4019.c | 109 ++++++++++++++++++++++++++++++--
1 file changed, 103 insertions(+), 6 deletions(-)
@@ -167,7 +168,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+
+ /* div is not set to the default value of /256
+ * Probably someone changed that (bootloader, other drivers)
+ * Keep this and doesn't overwrite it.
+ * Keep this and don't overwrite it.
+ */
+ if (div != MDIO_MODE_DIV_256) {
+ priv->mdc_rate = DIV_ROUND_UP(ahb_rate, div + 1);

View File

@@ -0,0 +1,170 @@
From fe2b1226656afae56702d1d84c6900f6b67df297 Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Fri, 1 Dec 2023 11:23:22 +0100
Subject: [PATCH] leds: trigger: netdev: fix RTNL handling to prevent potential
deadlock
When working on LED support for r8169 I got the following lockdep
warning. Easiest way to prevent this scenario seems to be to take
the RTNL lock before the trigger_data lock in set_device_name().
======================================================
WARNING: possible circular locking dependency detected
6.7.0-rc2-next-20231124+ #2 Not tainted
------------------------------------------------------
bash/383 is trying to acquire lock:
ffff888103aa1c68 (&trigger_data->lock){+.+.}-{3:3}, at: netdev_trig_notify+0xec/0x190 [ledtrig_netdev]
but task is already holding lock:
ffffffff8cddf808 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock+0x12/0x20
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (rtnl_mutex){+.+.}-{3:3}:
__mutex_lock+0x9b/0xb50
mutex_lock_nested+0x16/0x20
rtnl_lock+0x12/0x20
set_device_name+0xa9/0x120 [ledtrig_netdev]
netdev_trig_activate+0x1a1/0x230 [ledtrig_netdev]
led_trigger_set+0x172/0x2c0
led_trigger_write+0xf1/0x140
sysfs_kf_bin_write+0x5d/0x80
kernfs_fop_write_iter+0x15d/0x210
vfs_write+0x1f0/0x510
ksys_write+0x6c/0xf0
__x64_sys_write+0x14/0x20
do_syscall_64+0x3f/0xf0
entry_SYSCALL_64_after_hwframe+0x6c/0x74
-> #0 (&trigger_data->lock){+.+.}-{3:3}:
__lock_acquire+0x1459/0x25a0
lock_acquire+0xc8/0x2d0
__mutex_lock+0x9b/0xb50
mutex_lock_nested+0x16/0x20
netdev_trig_notify+0xec/0x190 [ledtrig_netdev]
call_netdevice_register_net_notifiers+0x5a/0x100
register_netdevice_notifier+0x85/0x120
netdev_trig_activate+0x1d4/0x230 [ledtrig_netdev]
led_trigger_set+0x172/0x2c0
led_trigger_write+0xf1/0x140
sysfs_kf_bin_write+0x5d/0x80
kernfs_fop_write_iter+0x15d/0x210
vfs_write+0x1f0/0x510
ksys_write+0x6c/0xf0
__x64_sys_write+0x14/0x20
do_syscall_64+0x3f/0xf0
entry_SYSCALL_64_after_hwframe+0x6c/0x74
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(rtnl_mutex);
lock(&trigger_data->lock);
lock(rtnl_mutex);
lock(&trigger_data->lock);
*** DEADLOCK ***
8 locks held by bash/383:
#0: ffff888103ff33f0 (sb_writers#3){.+.+}-{0:0}, at: ksys_write+0x6c/0xf0
#1: ffff888103aa1e88 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x114/0x210
#2: ffff8881036f1890 (kn->active#82){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x11d/0x210
#3: ffff888108e2c358 (&led_cdev->led_access){+.+.}-{3:3}, at: led_trigger_write+0x30/0x140
#4: ffffffff8cdd9e10 (triggers_list_lock){++++}-{3:3}, at: led_trigger_write+0x75/0x140
#5: ffff888108e2c270 (&led_cdev->trigger_lock){++++}-{3:3}, at: led_trigger_write+0xe3/0x140
#6: ffffffff8cdde3d0 (pernet_ops_rwsem){++++}-{3:3}, at: register_netdevice_notifier+0x1c/0x120
#7: ffffffff8cddf808 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock+0x12/0x20
stack backtrace:
CPU: 0 PID: 383 Comm: bash Not tainted 6.7.0-rc2-next-20231124+ #2
Hardware name: Default string Default string/Default string, BIOS ADLN.M6.SODIMM.ZB.CY.015 08/08/2023
Call Trace:
<TASK>
dump_stack_lvl+0x5c/0xd0
dump_stack+0x10/0x20
print_circular_bug+0x2dd/0x410
check_noncircular+0x131/0x150
__lock_acquire+0x1459/0x25a0
lock_acquire+0xc8/0x2d0
? netdev_trig_notify+0xec/0x190 [ledtrig_netdev]
__mutex_lock+0x9b/0xb50
? netdev_trig_notify+0xec/0x190 [ledtrig_netdev]
? __this_cpu_preempt_check+0x13/0x20
? netdev_trig_notify+0xec/0x190 [ledtrig_netdev]
? __cancel_work_timer+0x11c/0x1b0
? __mutex_lock+0x123/0xb50
mutex_lock_nested+0x16/0x20
? mutex_lock_nested+0x16/0x20
netdev_trig_notify+0xec/0x190 [ledtrig_netdev]
call_netdevice_register_net_notifiers+0x5a/0x100
register_netdevice_notifier+0x85/0x120
netdev_trig_activate+0x1d4/0x230 [ledtrig_netdev]
led_trigger_set+0x172/0x2c0
? preempt_count_add+0x49/0xc0
led_trigger_write+0xf1/0x140
sysfs_kf_bin_write+0x5d/0x80
kernfs_fop_write_iter+0x15d/0x210
vfs_write+0x1f0/0x510
ksys_write+0x6c/0xf0
__x64_sys_write+0x14/0x20
do_syscall_64+0x3f/0xf0
entry_SYSCALL_64_after_hwframe+0x6c/0x74
RIP: 0033:0x7f269055d034
Code: c7 00 16 00 00 00 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 80 3d 35 c3 0d 00 00 74 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 48 83 ec 28 48 89 54 24 18 48
RSP: 002b:00007ffddb7ef748 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000007 RCX: 00007f269055d034
RDX: 0000000000000007 RSI: 000055bf5f4af3c0 RDI: 0000000000000001
RBP: 000055bf5f4af3c0 R08: 0000000000000073 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000007
R13: 00007f26906325c0 R14: 00007f269062ff20 R15: 0000000000000000
</TASK>
Fixes: d5e01266e7f5 ("leds: trigger: netdev: add additional specific link speed mode")
Cc: stable@vger.kernel.org
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/fb5c8294-2a10-4bf5-8f10-3d2b77d2757e@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/leds/trigger/ledtrig-netdev.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -235,6 +235,11 @@ static int set_device_name(struct led_ne
{
cancel_delayed_work_sync(&trigger_data->work);
+ /*
+ * Take RTNL lock before trigger_data lock to prevent potential
+ * deadlock with netdev notifier registration.
+ */
+ rtnl_lock();
mutex_lock(&trigger_data->lock);
if (trigger_data->net_dev) {
@@ -254,16 +259,14 @@ static int set_device_name(struct led_ne
trigger_data->carrier_link_up = false;
trigger_data->link_speed = SPEED_UNKNOWN;
trigger_data->duplex = DUPLEX_UNKNOWN;
- if (trigger_data->net_dev != NULL) {
- rtnl_lock();
+ if (trigger_data->net_dev)
get_device_state(trigger_data);
- rtnl_unlock();
- }
trigger_data->last_activity = 0;
set_baseline_state(trigger_data);
mutex_unlock(&trigger_data->lock);
+ rtnl_unlock();
return 0;
}

View File

@@ -7665,6 +7665,9 @@ CONFIG_VHOST_MENU=y
# CONFIG_VIDEO_OV9734 is not set
# CONFIG_VIDEO_PVRUSB2 is not set
# CONFIG_VIDEO_RASPBERRYPI_PISP_BE is not set
# CONFIG_VIDEO_RCAR_CSI2 is not set
# CONFIG_VIDEO_RCAR_ISP is not set
# CONFIG_VIDEO_RCAR_VIN is not set
# CONFIG_VIDEO_RDACM20 is not set
# CONFIG_VIDEO_RDACM21 is not set
# CONFIG_VIDEO_RJ54N1 is not set
@@ -7688,6 +7691,7 @@ CONFIG_VHOST_MENU=y
# CONFIG_VIDEO_SMIAPP is not set
# CONFIG_VIDEO_SOLO6X10 is not set
# CONFIG_VIDEO_SONY_BTF_MPX is not set
# CONFIG_VIDEO_SUN4I_CSI is not set
# CONFIG_VIDEO_SUN6I_CSI is not set
# CONFIG_VIDEO_SUN8I_A83T_MIPI_CSI2 is not set
# CONFIG_VIDEO_SR030PC30 is not set

View File

@@ -124,59 +124,6 @@ Signed-off-by: John Crispin <john@phrozen.org>
config NETFILTER_FAMILY_BRIDGE
bool
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
config WIRELESS_EXT
- bool
+ bool "Wireless extensions"
config WEXT_CORE
def_bool y
@@ -12,10 +12,10 @@ config WEXT_PROC
depends on WEXT_CORE
config WEXT_SPY
- bool
+ bool "WEXT_SPY"
config WEXT_PRIV
- bool
+ bool "WEXT_PRIV"
config CFG80211
tristate "cfg80211 - wireless configuration API"
@@ -204,7 +204,7 @@ config CFG80211_WEXT_EXPORT
endif # CFG80211
config LIB80211
- tristate
+ tristate "LIB80211"
default n
help
This options enables a library of common routines used
@@ -213,17 +213,17 @@ config LIB80211
Drivers should select this themselves if needed.
config LIB80211_CRYPT_WEP
- tristate
+ tristate "LIB80211_CRYPT_WEP"
select CRYPTO_LIB_ARC4
config LIB80211_CRYPT_CCMP
- tristate
+ tristate "LIB80211_CRYPT_CCMP"
select CRYPTO
select CRYPTO_AES
select CRYPTO_CCM
config LIB80211_CRYPT_TKIP
- tristate
+ tristate "LIB80211_CRYPT_TKIP"
select CRYPTO_LIB_ARC4
config LIB80211_DEBUG
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -17,7 +17,7 @@ config SND_DMAENGINE_PCM

View File

@@ -124,59 +124,6 @@ Signed-off-by: John Crispin <john@phrozen.org>
config NETFILTER_FAMILY_BRIDGE
bool
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
config WIRELESS_EXT
- bool
+ bool "Wireless extensions"
config WEXT_CORE
def_bool y
@@ -12,10 +12,10 @@ config WEXT_PROC
depends on WEXT_CORE
config WEXT_SPY
- bool
+ bool "WEXT_SPY"
config WEXT_PRIV
- bool
+ bool "WEXT_PRIV"
config CFG80211
tristate "cfg80211 - wireless configuration API"
@@ -208,7 +208,7 @@ config CFG80211_WEXT_EXPORT
endif # CFG80211
config LIB80211
- tristate
+ tristate "LIB80211"
default n
help
This options enables a library of common routines used
@@ -217,17 +217,17 @@ config LIB80211
Drivers should select this themselves if needed.
config LIB80211_CRYPT_WEP
- tristate
+ tristate "LIB80211_CRYPT_WEP"
select CRYPTO_LIB_ARC4
config LIB80211_CRYPT_CCMP
- tristate
+ tristate "LIB80211_CRYPT_CCMP"
select CRYPTO
select CRYPTO_AES
select CRYPTO_CCM
config LIB80211_CRYPT_TKIP
- tristate
+ tristate "LIB80211_CRYPT_TKIP"
select CRYPTO_LIB_ARC4
config LIB80211_DEBUG
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -17,7 +17,7 @@ config SND_DMAENGINE_PCM

View File

@@ -1,42 +0,0 @@
From 85e2038891989e41bc62f6a4625fd5865da8a1a2 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Wed, 24 Jan 2024 19:17:02 +0100
Subject: [PATCH 1/3] dt-bindings: net: ipq4019-mdio: document now supported
clock-frequency
Document support for clock-frequency and add details on why this
property is needed and what values are supported.
From internal documentation, while other values are supported, the
correct function of the MDIO bus is not assured hence add only the
suggested supported values to the property enum.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
.../bindings/net/qcom,ipq4019-mdio.yaml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
--- a/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
+++ b/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
@@ -38,6 +38,21 @@ properties:
MDIO clock source frequency fixed to 100MHZ, this clock should be specified
by the platform IPQ807x, IPQ60xx and IPQ50xx.
+ clock-frequency:
+ description:
+ The MDIO bus clock that must be output by the MDIO bus hardware, if
+ absent, the default hardware values are used.
+
+ MDC rate is feed by an external clock (fixed 100MHz) and is divider
+ internally. The default divider is /256 resulting in the default rate
+ applied of 390KHz.
+
+ To follow 802.3 standard that instruct up to 2.5MHz by default, if
+ this property is not declared and the divider is set to /256, by
+ default 1.5625Mhz is select.
+ enum: [ 390625, 781250, 1562500, 3125000, 6250000, 12500000 ]
+ default: 1562500
+
required:
- compatible
- reg

View File

@@ -0,0 +1,52 @@
From 9e2a0a8bd7a392b5af6bf2cfa0b07d96d1fb6719 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 4 Feb 2024 00:32:04 +0100
Subject: [PATCH] leds: trigger: netdev: Fix kernel panic on interface rename
trig notify
Commit d5e01266e7f5 ("leds: trigger: netdev: add additional specific link
speed mode") in the various changes, reworked the way to set the LINKUP
mode in commit cee4bd16c319 ("leds: trigger: netdev: Recheck
NETDEV_LED_MODE_LINKUP on dev rename") and moved it to a generic function.
This changed the logic where, in the previous implementation the dev
from the trigger event was used to check if the carrier was ok, but in
the new implementation with the generic function, the dev in
trigger_data is used instead.
This is problematic and cause a possible kernel panic due to the fact
that the dev in the trigger_data still reference the old one as the
new one (passed from the trigger event) still has to be hold and saved
in the trigger_data struct (done in the NETDEV_REGISTER case).
On calling of get_device_state(), an invalid net_dev is used and this
cause a kernel panic.
To handle this correctly, move the call to get_device_state() after the
new net_dev is correctly set in trigger_data (in the NETDEV_REGISTER
case) and correctly parse the new dev.
Fixes: d5e01266e7f5 ("leds: trigger: netdev: add additional specific link speed mode")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/leds/trigger/ledtrig-netdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -489,12 +489,12 @@ static int netdev_trig_notify(struct not
trigger_data->duplex = DUPLEX_UNKNOWN;
switch (evt) {
case NETDEV_CHANGENAME:
- get_device_state(trigger_data);
- fallthrough;
case NETDEV_REGISTER:
dev_put(trigger_data->net_dev);
dev_hold(dev);
trigger_data->net_dev = dev;
+ if (evt == NETDEV_CHANGENAME)
+ get_device_state(trigger_data);
break;
case NETDEV_UNREGISTER:
dev_put(trigger_data->net_dev);