1 /*- 2 * Based on BSD-licensed source modules in the Linux iwlwifi driver, 3 * which were used as the reference documentation for this implementation. 4 * 5 ****************************************************************************** 6 * 7 * This file is provided under a dual BSD/GPLv2 license. When using or 8 * redistributing this file, you may do so under either license. 9 * 10 * GPL LICENSE SUMMARY 11 * 12 * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. 13 * Copyright(c) 2015 Intel Deutschland GmbH 14 * 15 * This program is free software; you can redistribute it and/or modify 16 * it under the terms of version 2 of the GNU General Public License as 17 * published by the Free Software Foundation. 18 * 19 * This program is distributed in the hope that it will be useful, but 20 * WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, 27 * USA 28 * 29 * The full GNU General Public License is included in this distribution 30 * in the file called COPYING. 31 * 32 * Contact Information: 33 * Intel Linux Wireless <linuxwifi@intel.com> 34 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 35 * 36 * BSD LICENSE 37 * 38 * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. 39 * All rights reserved. 40 * 41 * Redistribution and use in source and binary forms, with or without 42 * modification, are permitted provided that the following conditions 43 * are met: 44 * 45 * * Redistributions of source code must retain the above copyright 46 * notice, this list of conditions and the following disclaimer. 47 * * Redistributions in binary form must reproduce the above copyright 48 * notice, this list of conditions and the following disclaimer in 49 * the documentation and/or other materials provided with the 50 * distribution. 51 * * Neither the name Intel Corporation nor the names of its 52 * contributors may be used to endorse or promote products derived 53 * from this software without specific prior written permission. 54 * 55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 56 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 57 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 58 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 59 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 60 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 61 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 62 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 63 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 64 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 65 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 66 * 67 *****************************************************************************/ 68 #ifndef __IF_IWN_NOTIF_WAIT_H__ 69 #define __IF_IWN_NOTIF_WAIT_H__ 70 71 #include <sys/queue.h> 72 73 #define IWM_MAX_NOTIF_CMDS 5 74 75 struct iwm_rx_packet; 76 struct iwm_softc; 77 78 /** 79 * struct iwm_notification_wait - notification wait entry 80 * @entry: link for global list 81 * @fn: Function called with the notification. If the function 82 * returns true, the wait is over, if it returns false then 83 * the waiter stays blocked. If no function is given, any 84 * of the listed commands will unblock the waiter. 85 * @cmds: command IDs 86 * @n_cmds: number of command IDs 87 * @triggered: waiter should be woken up 88 * @aborted: wait was aborted 89 * 90 * This structure is not used directly, to wait for a 91 * notification declare it on the stack, and call 92 * iwm_init_notification_wait() with appropriate 93 * parameters. Then do whatever will cause the ucode 94 * to notify the driver, and to wait for that then 95 * call iwm_wait_notification(). 96 * 97 * Each notification is one-shot. If at some point we 98 * need to support multi-shot notifications (which 99 * can't be allocated on the stack) we need to modify 100 * the code for them. 101 */ 102 struct iwm_notification_wait { 103 STAILQ_ENTRY(iwm_notification_wait) entry; 104 105 int (*fn)(struct iwm_softc *sc, struct iwm_rx_packet *pkt, void *data); 106 void *fn_data; 107 108 uint16_t cmds[IWM_MAX_NOTIF_CMDS]; 109 uint8_t n_cmds; 110 int triggered, aborted; 111 }; 112 113 /* caller functions */ 114 extern struct iwm_notif_wait_data *iwm_notification_wait_init( 115 struct iwm_softc *sc); 116 extern void iwm_notification_wait_free(struct iwm_notif_wait_data *notif_data); 117 extern void iwm_notification_wait_notify( 118 struct iwm_notif_wait_data *notif_data, uint16_t cmd, 119 struct iwm_rx_packet *pkt); 120 extern void iwm_abort_notification_waits( 121 struct iwm_notif_wait_data *notif_data); 122 123 /* user functions */ 124 extern void iwm_init_notification_wait(struct iwm_notif_wait_data *notif_data, 125 struct iwm_notification_wait *wait_entry, 126 const uint16_t *cmds, int n_cmds, 127 int (*fn)(struct iwm_softc *sc, 128 struct iwm_rx_packet *pkt, void *data), 129 void *fn_data); 130 extern int iwm_wait_notification(struct iwm_notif_wait_data *notif_data, 131 struct iwm_notification_wait *wait_entry, int timeout); 132 extern void iwm_remove_notification(struct iwm_notif_wait_data *notif_data, 133 struct iwm_notification_wait *wait_entry); 134 135 #endif /* __IF_IWN_NOTIF_WAIT_H__ */ 136