Path: blob/main/sys/contrib/dev/iwlwifi/fw/notif-wait.h
48287 views
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */1/*2* Copyright (C) 2005-2014, 2023 Intel Corporation3* Copyright (C) 2015-2017 Intel Deutschland GmbH4*/5#ifndef __iwl_notif_wait_h__6#define __iwl_notif_wait_h__78#include <linux/wait.h>910#include "iwl-trans.h"1112struct iwl_notif_wait_data {13struct list_head notif_waits;14spinlock_t notif_wait_lock;15wait_queue_head_t notif_waitq;16};1718#define MAX_NOTIF_CMDS 51920/**21* struct iwl_notification_wait - notification wait entry22* @list: list head for global list23* @fn: Function called with the notification. If the function24* returns true, the wait is over, if it returns false then25* the waiter stays blocked. If no function is given, any26* of the listed commands will unblock the waiter.27* @fn_data: pointer to pass to the @fn's data argument28* @cmds: command IDs29* @n_cmds: number of command IDs30* @triggered: waiter should be woken up31* @aborted: wait was aborted32*33* This structure is not used directly, to wait for a34* notification declare it on the stack, and call35* iwl_init_notification_wait() with appropriate36* parameters. Then do whatever will cause the ucode37* to notify the driver, and to wait for that then38* call iwl_wait_notification().39*40* Each notification is one-shot. If at some point we41* need to support multi-shot notifications (which42* can't be allocated on the stack) we need to modify43* the code for them.44*/45struct iwl_notification_wait {46struct list_head list;4748bool (*fn)(struct iwl_notif_wait_data *notif_data,49struct iwl_rx_packet *pkt, void *data);50void *fn_data;5152u16 cmds[MAX_NOTIF_CMDS];53u8 n_cmds;54bool triggered, aborted;55};565758/* caller functions */59void iwl_notification_wait_init(struct iwl_notif_wait_data *notif_data);60bool iwl_notification_wait(struct iwl_notif_wait_data *notif_data,61struct iwl_rx_packet *pkt);62void iwl_abort_notification_waits(struct iwl_notif_wait_data *notif_data);6364static inline void65iwl_notification_notify(struct iwl_notif_wait_data *notif_data)66{67wake_up_all(¬if_data->notif_waitq);68}6970static inline void71iwl_notification_wait_notify(struct iwl_notif_wait_data *notif_data,72struct iwl_rx_packet *pkt)73{74if (iwl_notification_wait(notif_data, pkt))75iwl_notification_notify(notif_data);76}7778/* user functions */79void __acquires(wait_entry)80iwl_init_notification_wait(struct iwl_notif_wait_data *notif_data,81struct iwl_notification_wait *wait_entry,82const u16 *cmds, int n_cmds,83bool (*fn)(struct iwl_notif_wait_data *notif_data,84struct iwl_rx_packet *pkt, void *data),85void *fn_data);8687int __must_check __releases(wait_entry)88iwl_wait_notification(struct iwl_notif_wait_data *notif_data,89struct iwl_notification_wait *wait_entry,90unsigned long timeout);9192void __releases(wait_entry)93iwl_remove_notification(struct iwl_notif_wait_data *notif_data,94struct iwl_notification_wait *wait_entry);9596#endif /* __iwl_notif_wait_h__ */979899