diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2009-07-29 20:08:07 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-04 16:44:14 -0400 |
commit | 42935ecaf4e784d0815afa9a7e5fe7e141157ca3 (patch) | |
tree | dc0a0dcfff761e98d8a2a23a7edc8f9182c2774c /include/net/mac80211.h | |
parent | 64344d78228f6346a0462ba2d5fc03494aef4e6b (diff) |
mac80211: redefine usage of the mac80211 workqueue
The mac80211 workqueue exists to enable mac80211 and drivers
to queue their own work on a single threaded workqueue. mac80211
takes care to flush the workqueue during suspend but we never
really had requirements on drivers for how they should use
the workqueue in consideration for suspend.
We extend mac80211 to document how the mac80211 workqueue should
be used, how it should not be used and finally move raw access to
the workqueue to mac80211 only. Drivers and mac80211 use helpers
to queue work onto the mac80211 workqueue:
* ieee80211_queue_work()
* ieee80211_queue_delayed_work()
These helpers will now warn if mac80211 already completed its
suspend cycle and someone is trying to queue work. mac80211
flushes the mac80211 workqueue prior to suspend a few times,
but we haven't taken the care to ensure drivers won't add more
work after suspend. To help with this we add a warning when
someone tries to add work and mac80211 already completed the
suspend cycle.
Drivers should ensure they cancel any work or delayed work
in the mac80211 stop() callback.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include/net/mac80211.h')
-rw-r--r-- | include/net/mac80211.h | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index d4e09a06b4a2..5ed93f4406a8 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -73,6 +73,21 @@ | |||
73 | */ | 73 | */ |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * DOC: mac80211 workqueue | ||
77 | * | ||
78 | * mac80211 provides its own workqueue for drivers and internal mac80211 use. | ||
79 | * The workqueue is a single threaded workqueue and can only be accessed by | ||
80 | * helpers for sanity checking. Drivers must ensure all work added onto the | ||
81 | * mac80211 workqueue should be cancelled on the driver stop() callback. | ||
82 | * | ||
83 | * mac80211 will flushed the workqueue upon interface removal and during | ||
84 | * suspend. | ||
85 | * | ||
86 | * All work performed on the mac80211 workqueue must not acquire the RTNL lock. | ||
87 | * | ||
88 | */ | ||
89 | |||
90 | /** | ||
76 | * enum ieee80211_max_queues - maximum number of queues | 91 | * enum ieee80211_max_queues - maximum number of queues |
77 | * | 92 | * |
78 | * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues. | 93 | * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues. |
@@ -913,12 +928,6 @@ enum ieee80211_hw_flags { | |||
913 | * | 928 | * |
914 | * @conf: &struct ieee80211_conf, device configuration, don't use. | 929 | * @conf: &struct ieee80211_conf, device configuration, don't use. |
915 | * | 930 | * |
916 | * @workqueue: single threaded workqueue available for driver use, | ||
917 | * allocated by mac80211 on registration and flushed when an | ||
918 | * interface is removed. | ||
919 | * NOTICE: All work performed on this workqueue must not | ||
920 | * acquire the RTNL lock. | ||
921 | * | ||
922 | * @priv: pointer to private area that was allocated for driver use | 931 | * @priv: pointer to private area that was allocated for driver use |
923 | * along with this structure. | 932 | * along with this structure. |
924 | * | 933 | * |
@@ -954,7 +963,6 @@ enum ieee80211_hw_flags { | |||
954 | struct ieee80211_hw { | 963 | struct ieee80211_hw { |
955 | struct ieee80211_conf conf; | 964 | struct ieee80211_conf conf; |
956 | struct wiphy *wiphy; | 965 | struct wiphy *wiphy; |
957 | struct workqueue_struct *workqueue; | ||
958 | const char *rate_control_algorithm; | 966 | const char *rate_control_algorithm; |
959 | void *priv; | 967 | void *priv; |
960 | u32 flags; | 968 | u32 flags; |
@@ -1301,7 +1309,8 @@ enum ieee80211_ampdu_mlme_action { | |||
1301 | * is disabled. This should turn off the hardware (at least | 1309 | * is disabled. This should turn off the hardware (at least |
1302 | * it must turn off frame reception.) | 1310 | * it must turn off frame reception.) |
1303 | * May be called right after add_interface if that rejects | 1311 | * May be called right after add_interface if that rejects |
1304 | * an interface. | 1312 | * an interface. If you added any work onto the mac80211 workqueue |
1313 | * you should ensure to cancel it on this callback. | ||
1305 | * Must be implemented. | 1314 | * Must be implemented. |
1306 | * | 1315 | * |
1307 | * @add_interface: Called when a netdevice attached to the hardware is | 1316 | * @add_interface: Called when a netdevice attached to the hardware is |
@@ -1928,6 +1937,31 @@ void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw, | |||
1928 | void *data); | 1937 | void *data); |
1929 | 1938 | ||
1930 | /** | 1939 | /** |
1940 | * ieee80211_queue_work - add work onto the mac80211 workqueue | ||
1941 | * | ||
1942 | * Drivers and mac80211 use this to add work onto the mac80211 workqueue. | ||
1943 | * This helper ensures drivers are not queueing work when they should not be. | ||
1944 | * | ||
1945 | * @hw: the hardware struct for the interface we are adding work for | ||
1946 | * @work: the work we want to add onto the mac80211 workqueue | ||
1947 | */ | ||
1948 | void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work); | ||
1949 | |||
1950 | /** | ||
1951 | * ieee80211_queue_delayed_work - add work onto the mac80211 workqueue | ||
1952 | * | ||
1953 | * Drivers and mac80211 use this to queue delayed work onto the mac80211 | ||
1954 | * workqueue. | ||
1955 | * | ||
1956 | * @hw: the hardware struct for the interface we are adding work for | ||
1957 | * @dwork: delayable work to queue onto the mac80211 workqueue | ||
1958 | * @delay: number of jiffies to wait before queueing | ||
1959 | */ | ||
1960 | void ieee80211_queue_delayed_work(struct ieee80211_hw *hw, | ||
1961 | struct delayed_work *dwork, | ||
1962 | unsigned long delay); | ||
1963 | |||
1964 | /** | ||
1931 | * ieee80211_start_tx_ba_session - Start a tx Block Ack session. | 1965 | * ieee80211_start_tx_ba_session - Start a tx Block Ack session. |
1932 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | 1966 | * @hw: pointer as obtained from ieee80211_alloc_hw(). |
1933 | * @ra: receiver address of the BA session recipient | 1967 | * @ra: receiver address of the BA session recipient |