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