1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * The full GNU General Public License is included in this distribution
21 * in the file called COPYING.
23 * Contact Information:
24 * Intel Linux Wireless <linuxwifi@intel.com>
25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
29 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
30 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
31 * All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
37 * * Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in
42 * * Neither the name Intel Corporation nor the names of its
43 * contributors may be used to endorse or promote products derived
44 * from this software without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
48 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
49 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
50 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 *****************************************************************************/
59 #ifndef __iwl_notif_wait_h__
60 #define __iwl_notif_wait_h__
62 #include <linux/wait.h>
64 #include "iwl-trans.h"
66 struct iwl_notif_wait_data
{
67 struct list_head notif_waits
;
68 spinlock_t notif_wait_lock
;
69 wait_queue_head_t notif_waitq
;
72 #define MAX_NOTIF_CMDS 5
75 * struct iwl_notification_wait - notification wait entry
76 * @list: list head for global list
77 * @fn: Function called with the notification. If the function
78 * returns true, the wait is over, if it returns false then
79 * the waiter stays blocked. If no function is given, any
80 * of the listed commands will unblock the waiter.
82 * @n_cmds: number of command IDs
83 * @triggered: waiter should be woken up
84 * @aborted: wait was aborted
86 * This structure is not used directly, to wait for a
87 * notification declare it on the stack, and call
88 * iwl_init_notification_wait() with appropriate
89 * parameters. Then do whatever will cause the ucode
90 * to notify the driver, and to wait for that then
91 * call iwl_wait_notification().
93 * Each notification is one-shot. If at some point we
94 * need to support multi-shot notifications (which
95 * can't be allocated on the stack) we need to modify
98 struct iwl_notification_wait
{
99 struct list_head list
;
101 bool (*fn
)(struct iwl_notif_wait_data
*notif_data
,
102 struct iwl_rx_packet
*pkt
, void *data
);
105 u16 cmds
[MAX_NOTIF_CMDS
];
107 bool triggered
, aborted
;
111 /* caller functions */
112 void iwl_notification_wait_init(struct iwl_notif_wait_data
*notif_data
);
113 bool iwl_notification_wait(struct iwl_notif_wait_data
*notif_data
,
114 struct iwl_rx_packet
*pkt
);
115 void iwl_abort_notification_waits(struct iwl_notif_wait_data
*notif_data
);
118 iwl_notification_notify(struct iwl_notif_wait_data
*notif_data
)
120 wake_up_all(¬if_data
->notif_waitq
);
124 iwl_notification_wait_notify(struct iwl_notif_wait_data
*notif_data
,
125 struct iwl_rx_packet
*pkt
)
127 if (iwl_notification_wait(notif_data
, pkt
))
128 iwl_notification_notify(notif_data
);
132 void __acquires(wait_entry
)
133 iwl_init_notification_wait(struct iwl_notif_wait_data
*notif_data
,
134 struct iwl_notification_wait
*wait_entry
,
135 const u16
*cmds
, int n_cmds
,
136 bool (*fn
)(struct iwl_notif_wait_data
*notif_data
,
137 struct iwl_rx_packet
*pkt
, void *data
),
140 int __must_check
__releases(wait_entry
)
141 iwl_wait_notification(struct iwl_notif_wait_data
*notif_data
,
142 struct iwl_notification_wait
*wait_entry
,
143 unsigned long timeout
);
145 void __releases(wait_entry
)
146 iwl_remove_notification(struct iwl_notif_wait_data
*notif_data
,
147 struct iwl_notification_wait
*wait_entry
);
149 #endif /* __iwl_notif_wait_h__ */