From 6cc530cefe97eb22b079c54ecff575a62d87882b Mon Sep 17 00:00:00 2001 From: Daniel Ehlers Date: Fri, 4 Jul 2014 00:15:41 +0200 Subject: [PATCH 1/2] gluon-ath9k-workaround: Workaround for the ath9k wifi bug. Cron script which restarts wifi iff queues are marked stopped. This script also outputs some debug information to nail down the problem. --- gluon/gluon-ath9k-workaround/Makefile | 35 +++++++++++ .../files/lib/gluon/cron/ath9k-workaround | 1 + .../files/usr/sbin/ath9k-workaround | 61 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 gluon/gluon-ath9k-workaround/Makefile create mode 100644 gluon/gluon-ath9k-workaround/files/lib/gluon/cron/ath9k-workaround create mode 100755 gluon/gluon-ath9k-workaround/files/usr/sbin/ath9k-workaround diff --git a/gluon/gluon-ath9k-workaround/Makefile b/gluon/gluon-ath9k-workaround/Makefile new file mode 100644 index 0000000..bc809df --- /dev/null +++ b/gluon/gluon-ath9k-workaround/Makefile @@ -0,0 +1,35 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-ath9k-workaround +PKG_VERSION:=1 +PKG_RELEASE:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/gluon-ath9k-workaround + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=ATH9K Workaround + DEPENDS:=+gluon-cron +endef + +define Package/gluon-ath9k-workaround/description + Gluon community wifi mesh firmware framework: ath9k wifi bug workaround +endef + +define Build/Prepare +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/gluon-ath9k-workaround/install + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,gluon-ath9k-workaround)) diff --git a/gluon/gluon-ath9k-workaround/files/lib/gluon/cron/ath9k-workaround b/gluon/gluon-ath9k-workaround/files/lib/gluon/cron/ath9k-workaround new file mode 100644 index 0000000..73552f9 --- /dev/null +++ b/gluon/gluon-ath9k-workaround/files/lib/gluon/cron/ath9k-workaround @@ -0,0 +1 @@ +* * * * * /usr/sbin/ath9k-workaround diff --git a/gluon/gluon-ath9k-workaround/files/usr/sbin/ath9k-workaround b/gluon/gluon-ath9k-workaround/files/usr/sbin/ath9k-workaround new file mode 100755 index 0000000..fccd218 --- /dev/null +++ b/gluon/gluon-ath9k-workaround/files/usr/sbin/ath9k-workaround @@ -0,0 +1,61 @@ +#!/bin/sh + +check_stopped_queue(){ + local device=$1 + grep -q -E 'stopped: 1$' "${device}/queues" +} + +get_tx_pkts() { + local device=$1 + grep 'TX-Pkts-All' "${device}/xmit" \ + | sed -e 's/^TX-Pkts-All: *\([0-9]*\) .*$/\1/' +} + +inc_fatal() { + local qs=$(cat /tmp/ath9k_workaround_trigger 2>/dev/null || echo 0) + expr ${qs} + 1 > /tmp/ath9k_workaround_trigger +} + +check_ath9k_bug() { + local device=$1 + check_stopped_queue $device && { + local tx_first=$(get_tx_pkts $device) + sleep 5 + check_stopped_queue $device && { + local tx_second=$(get_tx_pkts $device) + test $tx_first == $tx_second && { + local hostname=$(uci get -q system.@system[0].hostname) + echo "Hostname: ${hostname}" + echo "------------ Trigger workaround: ${tx_first} -> ${tx_second} ----------------" + echo "Model:" + cat /tmp/sysinfo/model + echo "Release:" + cat /lib/gluon/release + echo "Uptime:" + uptime + echo "Batctl Neighbours:" + batctl o | grep wlan0-1 + echo "Queues:" + cat $device/queues + echo "Reset:" + cat $device/reset + echo "------------ Interupts #1 ---------------------------------------------------" + cat $device/interrupt + sleep 10 + echo "------------ Interupts #2 ---------------------------------------------------" + cat $device/interrupt + echo "Batctl Neighbours:" + batctl o | grep wlan0-1 + + #BE queue hangs + inc_fatal + wifi + exit 1; + } + } + } +} + +for device in /sys/kernel/debug/ieee80211/phy*/ath9k ; do + check_ath9k_bug $device +done From 91b43d0df48d835cb4cdf782d3023022a8c9f0f7 Mon Sep 17 00:00:00 2001 From: Daniel Ehlers Date: Mon, 7 Jul 2014 01:36:31 +0200 Subject: [PATCH 2/2] gluon-ath9k-workaround: bug reporting support If the `monitor` attribute in the site.conf is defined, the cron script is modifed to send debug informations, generated on bug detection, to given remote host and port, e.g.: "fda1:384a:74de:4242::2 8090" --- .../upgrade/ath9k-workaround/invariant/010-monitor | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 gluon/gluon-ath9k-workaround/files/lib/gluon/upgrade/ath9k-workaround/invariant/010-monitor diff --git a/gluon/gluon-ath9k-workaround/files/lib/gluon/upgrade/ath9k-workaround/invariant/010-monitor b/gluon/gluon-ath9k-workaround/files/lib/gluon/upgrade/ath9k-workaround/invariant/010-monitor new file mode 100755 index 0000000..ac69624 --- /dev/null +++ b/gluon/gluon-ath9k-workaround/files/lib/gluon/upgrade/ath9k-workaround/invariant/010-monitor @@ -0,0 +1,12 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' + +local c = uci.cursor() + +local f = io.open('/lib/gluon/cron/ath9k-workaround','w') +if f and site.monitor ~= nil then + f:write('* * * * * /usr/sbin/ath9k-workaround | nc ' .. site.monitor) + f:close() +end