From: Johannes Berg <johannes@sipsolutions.net>
To: netdev@vger.kernel.org
Cc: Jouni Malinen <jkm@devicescape.com>,
"John W. Linville" <linville@tuxdriver.com>,
Jiri Benc <jbenc@suse.cz>,
Johannes Berg <johannes@sipsolutions.net>
Subject: [PATCH 01/18] d80211: LED triggers
Date: Mon, 21 Aug 2006 09:41:08 +0200 [thread overview]
Message-ID: <20060821075158.728615077@sipsolutions.net> (raw)
In-Reply-To: 20060821074107.648561364@sipsolutions.net
[-- Attachment #1: d80211-led.patch --]
[-- Type: text/plain, Size: 10883 bytes --]
This patch makes d80211 export LED triggers for rx/tx and introduces
functions to allow device drivers to query the trigger names for setting
default triggers. It also cleans up the Makefile LED related stuff.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
--- wireless-dev.orig/include/net/d80211.h 2006-08-20 14:56:10.708192788 +0200
+++ wireless-dev/include/net/d80211.h 2006-08-20 16:27:03.988192788 +0200
@@ -695,6 +695,36 @@ struct net_device *ieee80211_alloc_hw(si
* function. */
int ieee80211_register_hw(struct net_device *dev, struct ieee80211_hw *hw);
+/* driver can use this and ieee80211_get_rx_led_name to get the
+ * name of the registered LEDs after ieee80211_register_hw
+ * was called.
+ * This is useful to set the default trigger on the LED class
+ * device that your driver should export for each LED the device
+ * has, that way the default behaviour will be as expected but
+ * the user can still change it/turn off the LED etc.
+ */
+#ifdef CONFIG_D80211_LEDS
+extern char *__ieee80211_get_tx_led_name(struct net_device *dev);
+extern char *__ieee80211_get_rx_led_name(struct net_device *dev);
+#endif
+static inline char *ieee80211_get_tx_led_name(struct net_device *dev)
+{
+#ifdef CONFIG_D80211_LEDS
+ return __ieee80211_get_tx_led_name(dev);
+#else
+ return NULL;
+#endif
+}
+
+static inline char *ieee80211_get_rx_led_name(struct net_device *dev)
+{
+#ifdef CONFIG_D80211_LEDS
+ return __ieee80211_get_rx_led_name(dev);
+#else
+ return NULL;
+#endif
+}
+
/* This function is allowed to update hardware configuration (e.g., list of
* supported operation modes and rates). */
int ieee80211_update_hw(struct net_device *dev, struct ieee80211_hw *hw);
@@ -884,16 +914,6 @@ enum {
IEEE80211_TEST_PARAM_TX_ANT_SEL_RAW = 5,
};
-/* ieee80211_tx_led called with state == 1 when the first frame is queued
- * with state == 0 when the last frame is transmitted and tx queue is empty
- */
-void ieee80211_tx_led(int state, struct net_device *dev);
-/* ieee80211_rx_led is called each time frame is received, state is not used
- * (== 2)
- */
-void ieee80211_rx_led(int state, struct net_device *dev);
-
-
/* IEEE 802.11 defines */
#define FCS_LEN 4
--- wireless-dev.orig/net/d80211/Kconfig 2006-08-20 14:56:10.728192788 +0200
+++ wireless-dev/net/d80211/Kconfig 2006-08-20 16:27:27.578192788 +0200
@@ -7,6 +7,14 @@ config D80211
This option enables the hardware independent IEEE 802.11
networking stack.
+config D80211_LEDS
+ bool "Enable LED triggers"
+ depends on D80211
+ select LEDS_TRIGGERS
+ ---help---
+ This option enables a few LED triggers for different
+ packet receive/transmit events.
+
config D80211_DEBUG
bool "Enable debugging output"
depends on D80211
--- wireless-dev.orig/net/d80211/ieee80211.c 2006-08-20 14:56:10.768192788 +0200
+++ wireless-dev/net/d80211/ieee80211.c 2006-08-20 16:27:08.548192788 +0200
@@ -31,7 +31,7 @@
#include "tkip.h"
#include "wme.h"
#include "aes_ccm.h"
-
+#include "ieee80211_led.h"
/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
@@ -1181,11 +1181,7 @@ static int __ieee80211_tx(struct ieee802
ret = local->hw->tx(local->mdev, skb, control);
if (ret)
return IEEE80211_TX_AGAIN;
-#ifdef IEEE80211_LEDS
- if (local->tx_led_counter++ == 0) {
- ieee80211_tx_led(1, local->mdev);
- }
-#endif /* IEEE80211_LEDS */
+ ieee80211_led_tx(local, 1);
}
if (tx->u.tx.extra_frag) {
control->use_rts_cts = 0;
@@ -1210,11 +1206,7 @@ static int __ieee80211_tx(struct ieee802
control);
if (ret)
return IEEE80211_TX_FRAG_AGAIN;
-#ifdef IEEE80211_LEDS
- if (local->tx_led_counter++ == 0) {
- ieee80211_tx_led(1, local->mdev);
- }
-#endif /* IEEE80211_LEDS */
+ ieee80211_led_tx(local, 1);
tx->u.tx.extra_frag[i] = NULL;
}
kfree(tx->u.tx.extra_frag);
@@ -2998,10 +2990,8 @@ ieee80211_rx_h_defragment(struct ieee802
rx->sta->rx_packets++;
if (is_multicast_ether_addr(hdr->addr1))
rx->local->dot11MulticastReceivedFrameCount++;
-#ifdef IEEE80211_LEDS
else
- ieee80211_rx_led(2, rx->dev);
-#endif /* IEEE80211_LEDS */
+ ieee80211_led_rx(rx->local);
return TXRX_CONTINUE;
}
@@ -4104,11 +4094,8 @@ void ieee80211_tx_status(struct net_devi
rate_control_tx_status(dev, skb, status);
}
-#ifdef IEEE80211_LEDS
- if (local->tx_led_counter && (local->tx_led_counter-- == 1)) {
- ieee80211_tx_led(0, dev);
- }
-#endif /* IEEE80211_LEDS */
+ ieee80211_led_tx(local, 0);
+
/* SNMP counters
* Fragments are passed to low-level drivers as separate skbs, so these
* are actually fragments, not frames. Update frame counters only for
@@ -4500,6 +4487,8 @@ int ieee80211_register_hw(struct net_dev
local->reg_state = IEEE80211_DEV_REGISTERED;
rtnl_unlock();
+ ieee80211_led_init(local);
+
return 0;
fail_rate_attrs:
@@ -4603,6 +4592,7 @@ void ieee80211_unregister_hw(struct net_
skb_queue_purge(&local->skb_queue_unreliable);
ieee80211_dev_free_index(local);
+ ieee80211_led_exit(local);
}
void ieee80211_free_hw(struct net_device *dev)
--- wireless-dev.orig/net/d80211/ieee80211_dev.c 2006-08-20 14:56:10.818192788 +0200
+++ wireless-dev/net/d80211/ieee80211_dev.c 2006-08-20 14:56:15.978192788 +0200
@@ -13,6 +13,7 @@
#include <linux/netdevice.h>
#include <net/d80211.h>
#include "ieee80211_i.h"
+#include "ieee80211_led.h"
struct ieee80211_dev_list {
struct list_head list;
--- wireless-dev.orig/net/d80211/ieee80211_i.h 2006-08-20 14:56:10.838192788 +0200
+++ wireless-dev/net/d80211/ieee80211_i.h 2006-08-20 16:27:06.458192788 +0200
@@ -460,7 +460,11 @@ struct ieee80211_local {
u32 dot11TransmittedFrameCount;
u32 dot11WEPUndecryptableCount;
- int tx_led_counter;
+#ifdef CONFIG_D80211_LEDS
+ int tx_led_counter, rx_led_counter;
+ struct led_trigger *tx_led, *rx_led;
+ char tx_led_name[32], rx_led_name[32];
+#endif
u32 channel_use;
u32 channel_use_raw;
--- wireless-dev.orig/net/d80211/ieee80211_led.c 2006-08-20 14:56:10.878192788 +0200
+++ wireless-dev/net/d80211/ieee80211_led.c 2006-08-20 14:56:15.978192788 +0200
@@ -1,32 +1,91 @@
/*
- * Copyright 2002-2004, Instant802 Networks, Inc.
+ * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
-#include <linux/config.h>
-#include <linux/netdevice.h>
-#include <linux/types.h>
-
-#ifdef CONFIG_OAP_LEDS_WLAN
-extern void leds_wlan_set(int unit, int tx, int state);
-#endif
-
-void ieee80211_rx_led(int state, struct net_device *dev) {
-#ifdef CONFIG_OAP_LEDS_WLAN
- static unsigned int count = 0;
+/* just for IFNAMSIZ */
+#include <linux/if.h>
+#include "ieee80211_led.h"
+
+void ieee80211_led_rx(struct ieee80211_local *local)
+{
+ if (unlikely(!local->rx_led))
+ return;
+ if (local->rx_led_counter++ % 2 == 0)
+ led_trigger_event(local->rx_led, LED_OFF);
+ else
+ led_trigger_event(local->rx_led, LED_FULL);
+}
+
+/* q is 1 if a packet was enqueued, 0 if it has been transmitted */
+void ieee80211_led_tx(struct ieee80211_local *local, int q)
+{
+ if (unlikely(!local->tx_led))
+ return;
+ /* not sure how this is supposed to work ... */
+ local->tx_led_counter += 2*q-1;
+ if (local->tx_led_counter % 2 == 0)
+ led_trigger_event(local->tx_led, LED_OFF);
+ else
+ led_trigger_event(local->tx_led, LED_FULL);
+}
+
+void ieee80211_led_init(struct ieee80211_local *local)
+{
+ local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (!local->rx_led)
+ return;
+ snprintf(local->rx_led_name, sizeof(local->rx_led_name),
+ "wiphy%drx", local->dev_index);
+ local->rx_led->name = local->rx_led_name;
+ if (led_trigger_register(local->rx_led)) {
+ kfree(local->rx_led);
+ local->rx_led = NULL;
+ }
- if (state == 2) {
- leds_wlan_set(0, 0, (++count) & 1);
+ local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (!local->tx_led)
+ return;
+ snprintf(local->tx_led_name, sizeof(local->tx_led_name),
+ "wiphy%dtx", local->dev_index);
+ local->tx_led->name = local->tx_led_name;
+ if (led_trigger_register(local->tx_led)) {
+ kfree(local->tx_led);
+ local->tx_led = NULL;
}
-#endif
}
-void ieee80211_tx_led(int state, struct net_device *dev) {
-#ifdef CONFIG_OAP_LEDS_WLAN
- leds_wlan_set(0, 1, state);
-#endif
+void ieee80211_led_exit(struct ieee80211_local *local)
+{
+ if (local->tx_led) {
+ led_trigger_unregister(local->tx_led);
+ kfree(local->tx_led);
+ }
+ if (local->rx_led) {
+ led_trigger_unregister(local->rx_led);
+ kfree(local->rx_led);
+ }
}
+char *__ieee80211_get_tx_led_name(struct net_device *dev)
+{
+ struct ieee80211_local *local = dev->ieee80211_ptr;
+
+ if (local->tx_led)
+ return local->tx_led_name;
+ return NULL;
+}
+EXPORT_SYMBOL(__ieee80211_get_tx_led_name);
+
+char *__ieee80211_get_rx_led_name(struct net_device *dev)
+{
+ struct ieee80211_local *local = dev->ieee80211_ptr;
+
+ if (local->rx_led)
+ return local->rx_led_name;
+ return NULL;
+}
+EXPORT_SYMBOL(__ieee80211_get_rx_led_name);
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/d80211/ieee80211_led.h 2006-08-20 14:56:15.978192788 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/leds.h>
+#include "ieee80211_i.h"
+
+#ifdef CONFIG_D80211_LEDS
+extern void ieee80211_led_rx(struct ieee80211_local *local);
+extern void ieee80211_led_tx(struct ieee80211_local *local, int q);
+extern void ieee80211_led_init(struct ieee80211_local *local);
+extern void ieee80211_led_exit(struct ieee80211_local *local);
+#else
+static inline void ieee80211_led_rx(struct ieee80211_local *local)
+{
+}
+static inline void ieee80211_led_tx(struct ieee80211_local *local, int q)
+{
+}
+static inline void ieee80211_led_init(struct ieee80211_local *local)
+{
+}
+static inline void ieee80211_led_exit(struct ieee80211_local *local)
+{
+}
+#endif
--- wireless-dev.orig/net/d80211/Makefile 2006-08-20 14:56:10.958192788 +0200
+++ wireless-dev/net/d80211/Makefile 2006-08-20 16:27:06.898192788 +0200
@@ -1,5 +1,7 @@
obj-$(CONFIG_D80211) += 80211.o rate_control.o
+80211-objs-$(CONFIG_D80211_LEDS) += ieee80211_led.o
+
80211-objs := \
ieee80211.o \
ieee80211_ioctl.o \
@@ -15,13 +17,9 @@ obj-$(CONFIG_D80211) += 80211.o rate_con
michael.o \
tkip.o \
aes_ccm.o \
- wme.o
+ wme.o \
+ $(80211-objs-y)
ifeq ($(CONFIG_NET_SCHED),)
80211-objs += fifo_qdisc.o
endif
-
-ifeq ($(CONFIG_D80211_LEDS),y)
- 80211-objs += ieee80211_led.o
-endif
-
--
next prev parent reply other threads:[~2006-08-21 8:02 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-21 7:41 [PATCH 00/18] d80211: various cleanups/fixes/changes Johannes Berg
2006-08-21 7:41 ` Johannes Berg [this message]
2006-08-22 0:30 ` [PATCH 01/3] d80211: add support for SIOCSIWRATE, SIOCSIWTXPOW and SIOCSIWPOWER Mohamed Abbas
2006-08-22 0:36 ` [PATCH 02/3] d80211: iwlist scan Mohamed Abbas
2006-08-23 15:46 ` Jiri Benc
2006-08-28 20:37 ` [PATCH 0/7] d80211: support more wireless command mabbas
2006-08-22 0:38 ` [PATCH 03/3] d80211: adhoc Mohamed Abbas
2006-08-23 15:51 ` Jiri Benc
2006-08-23 15:19 ` [PATCH 01/3] d80211: add support for SIOCSIWRATE, SIOCSIWTXPOW and SIOCSIWPOWER Jiri Benc
2006-08-25 18:37 ` Jouni Malinen
2006-08-25 18:46 ` Mohamed Abbas
2006-08-22 16:54 ` [PATCH 01/18] d80211: LED triggers Jouni Malinen
2006-08-22 18:38 ` Jiri Benc
2006-08-23 7:02 ` Johannes Berg
2006-08-23 18:16 ` Jiri Benc
2006-08-24 7:03 ` Johannes Berg
2006-09-22 11:59 ` Jiri Benc
2006-08-21 7:41 ` [PATCH 02/18] d80211: master link Johannes Berg
2006-08-21 8:13 ` Johannes Berg
2006-08-21 19:08 ` Jiri Benc
2006-08-22 7:49 ` Johannes Berg
2006-08-21 7:41 ` [PATCH 03/18] d80211: pointers as extended booleans Johannes Berg
2006-08-22 6:43 ` Bill Fink
2006-08-22 8:39 ` Johannes Berg
2006-08-21 7:41 ` [PATCH 04/18] d80211: use kzalloc() Johannes Berg
2006-08-21 7:41 ` [PATCH 05/18] d80211: get rid of WME bitfield Johannes Berg
2006-08-21 7:41 ` [PATCH 06/18] d80211: rework rate control registration Johannes Berg
2006-08-21 19:19 ` Jiri Benc
2006-08-22 8:33 ` Johannes Berg
2006-08-21 7:41 ` [PATCH 07/18] d80211: get rid of sta_aid in favour of keeping track of TIM Johannes Berg
2006-08-22 18:36 ` Jiri Benc
2006-08-23 7:04 ` Johannes Berg
2006-08-23 10:04 ` [PATCH] " Johannes Berg
2006-08-23 10:05 ` Johannes Berg
2006-08-23 10:16 ` [PATCH ] " Johannes Berg
2006-08-21 7:41 ` [PATCH 08/18] d80211: clean up exports Johannes Berg
2006-08-22 16:44 ` Jouni Malinen
2006-08-23 7:01 ` Johannes Berg
2006-08-23 10:03 ` [PATCH] " Johannes Berg
2006-08-21 7:41 ` [PATCH 09/18] d80211: move out rate control registration code Johannes Berg
2006-08-21 7:41 ` [PATCH 10/18] d80211: clean up includes Johannes Berg
2006-08-21 7:41 ` [PATCH 11/18] d80211: clean up qdisc requeue Johannes Berg
2006-08-21 19:31 ` Jiri Benc
2006-08-22 7:48 ` Johannes Berg
2006-08-21 7:41 ` [PATCH 12/18] d80211: fix some sparse warnings Johannes Berg
2006-08-22 18:55 ` Jiri Benc
2006-08-21 7:41 ` [PATCH 13/18] d80211: clean up some coding style issues Johannes Berg
2006-08-21 19:35 ` Jiri Benc
2006-08-22 8:27 ` Johannes Berg
2006-08-21 7:41 ` [PATCH 14/18] d80211: make lowlevel TX framedump option visible Johannes Berg
2006-08-21 7:41 ` [PATCH 15/18] d80211: surface IBSS debug Johannes Berg
2006-08-21 7:41 ` [PATCH 16/18] d80211: get rid of MICHAEL_MIC_HWACCEL define Johannes Berg
2006-08-22 19:00 ` Jiri Benc
2006-08-23 7:05 ` Johannes Berg
2006-08-23 9:46 ` Jiri Benc
2006-08-21 7:41 ` [PATCH 17/18] d80211: surface powersave debug switch Johannes Berg
2006-08-21 7:41 ` [PATCH 18/18] d80211: fix some documentation Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060821075158.728615077@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=jbenc@suse.cz \
--cc=jkm@devicescape.com \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.