Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146120821
D7340.1779254114.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
13 KB
Referenced Files
None
Subscribers
None
D7340.1779254114.diff
View Options
Index: sys/conf/files
===================================================================
--- sys/conf/files
+++ sys/conf/files
@@ -1718,6 +1718,7 @@
dev/iwm/if_iwm_binding.c optional iwm
dev/iwm/if_iwm_led.c optional iwm
dev/iwm/if_iwm_mac_ctxt.c optional iwm
+dev/iwm/if_iwm_notif_wait.c optional iwm
dev/iwm/if_iwm_pcie_trans.c optional iwm
dev/iwm/if_iwm_phy_ctxt.c optional iwm
dev/iwm/if_iwm_phy_db.c optional iwm
Index: sys/dev/iwm/if_iwm.c
===================================================================
--- sys/dev/iwm/if_iwm.c
+++ sys/dev/iwm/if_iwm.c
@@ -154,6 +154,7 @@
#include <dev/iwm/if_iwmvar.h>
#include <dev/iwm/if_iwm_debug.h>
#include <dev/iwm/if_iwm_util.h>
+#include <dev/iwm/if_iwm_notif_wait.h>
#include <dev/iwm/if_iwm_binding.h>
#include <dev/iwm/if_iwm_phy_db.h>
#include <dev/iwm/if_iwm_mac_ctxt.h>
@@ -5049,6 +5050,8 @@
continue;
}
+ iwm_notification_wait_notify(sc->sc_notif_wait, code);
+
switch (code) {
case IWM_REPLY_RX_PHY_CMD:
iwm_mvm_rx_rx_phy_cmd(sc, pkt, data);
@@ -5685,6 +5688,12 @@
callout_init_mtx(&sc->sc_led_blink_to, &sc->sc_mtx, 0);
TASK_INIT(&sc->sc_es_task, 0, iwm_endscan_cb, sc);
+ sc->sc_notif_wait = iwm_notification_wait_init();
+ if (sc->sc_notif_wait == NULL) {
+ device_printf(dev, "failed to init notification wait struct\n");
+ goto fail;
+ }
+
/* PCI attach */
error = iwm_pci_attach(dev);
if (error != 0)
@@ -6150,6 +6159,11 @@
/* Finished with the hardware - detach things */
iwm_pci_detach(dev);
+ if (sc->sc_notif_wait != NULL) {
+ iwm_notification_wait_free(sc->sc_notif_wait);
+ sc->sc_notif_wait = NULL;
+ }
+
mbufq_drain(&sc->sc_snd);
IWM_LOCK_DESTROY(sc);
Index: sys/dev/iwm/if_iwm_notif_wait.h
===================================================================
--- /dev/null
+++ sys/dev/iwm/if_iwm_notif_wait.h
@@ -0,0 +1,120 @@
+/*-
+ * Based on BSD-licensed source modules in the Linux iwlwifi driver,
+ * which were used as the reference documentation for this implementation.
+ *
+ ******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2015 Intel Deutschland GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ * Intel Linux Wireless <linuxwifi@intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+#ifndef __IF_IWN_NOTIF_WAIT_H__
+#define __IF_IWN_NOTIF_WAIT_H__
+
+#include <sys/queue.h>
+
+#define IWM_MAX_NOTIF_CMDS 5
+
+/**
+ * struct iwl_notification_wait - notification wait entry
+ * @entry: link for global list
+ * @cmds: command IDs
+ * @n_cmds: number of command IDs
+ * @triggered: waiter should be woken up
+ * @aborted: wait was aborted
+ *
+ * This structure is not used directly, to wait for a
+ * notification declare it on the stack, and call
+ * iwm_init_notification_wait() with appropriate
+ * parameters. Then do whatever will cause the ucode
+ * to notify the driver, and to wait for that then
+ * call iwm_wait_notification().
+ *
+ * Each notification is one-shot. If at some point we
+ * need to support multi-shot notifications (which
+ * can't be allocated on the stack) we need to modify
+ * the code for them.
+ */
+struct iwm_notification_wait {
+ STAILQ_ENTRY(iwm_notification_wait) entry;
+
+ uint16_t cmds[IWM_MAX_NOTIF_CMDS];
+ uint8_t n_cmds;
+ int triggered, aborted;
+};
+
+/* caller functions */
+extern struct iwm_notif_wait_data *iwm_notification_wait_init(void);
+extern void iwm_notification_wait_free(struct iwm_notif_wait_data *notif_data);
+extern void iwm_notification_wait_notify(
+ struct iwm_notif_wait_data *notif_data, uint16_t cmd);
+extern void iwm_abort_notification_waits(
+ struct iwm_notif_wait_data *notif_data);
+
+/* user functions */
+extern void iwm_init_notification_wait(struct iwm_notif_wait_data *notif_data,
+ struct iwm_notification_wait *wait_entry, const uint16_t *cmds,
+ int n_cmds);
+extern int iwm_wait_notification(struct iwm_notif_wait_data *notif_data,
+ struct iwm_notification_wait *wait_entry, int timeout);
+extern void iwm_remove_notification(struct iwm_notif_wait_data *notif_data,
+ struct iwm_notification_wait *wait_entry);
+
+#endif /* __IF_IWN_NOTIF_WAIT_H__ */
Index: sys/dev/iwm/if_iwm_notif_wait.c
===================================================================
--- /dev/null
+++ sys/dev/iwm/if_iwm_notif_wait.c
@@ -0,0 +1,182 @@
+/*-
+ * Based on BSD-licensed source modules in the Linux iwlwifi driver,
+ * which were used as the reference documentation for this implementation.
+ *
+ ******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2015 Intel Deutschland GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ * Intel Linux Wireless <linuxwifi@intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/queue.h>
+
+#include "if_iwm_notif_wait.h"
+
+struct iwm_notif_wait_data {
+ struct mtx mtx;
+ STAILQ_HEAD(, iwm_notification_wait) list;
+};
+
+struct iwm_notif_wait_data *
+iwm_notification_wait_init(void)
+{
+ struct iwm_notif_wait_data *data;
+
+ data = malloc(sizeof(*data), M_DEVBUF, M_WAITOK | M_ZERO);
+ if (data != NULL) {
+ mtx_init(&data->mtx, "iwm_notif", NULL, MTX_DEF);
+ STAILQ_INIT(&data->list);
+ }
+
+ return data;
+}
+
+void
+iwm_notification_wait_free(struct iwm_notif_wait_data *notif_data)
+{
+ KASSERT(STAILQ_EMPTY(¬if_data->list), ("notif queue not empty"));
+ mtx_destroy(¬if_data->mtx);
+ free(notif_data, M_DEVBUF);
+}
+
+void
+iwm_notification_wait_notify(struct iwm_notif_wait_data *notif_data,
+ uint16_t cmd)
+{
+ struct iwm_notification_wait *wait_entry;
+ int i;
+
+ mtx_lock(¬if_data->mtx);
+ STAILQ_FOREACH(wait_entry, ¬if_data->list, entry) {
+ for (i = 0; i < wait_entry->n_cmds; i++) {
+ if (cmd == wait_entry->cmds[i] &&
+ !wait_entry->triggered && !wait_entry->aborted) {
+ wait_entry->triggered = 1;
+ wakeup(wait_entry);
+ }
+ }
+ }
+ mtx_unlock(¬if_data->mtx);
+}
+
+void
+iwm_abort_notification_waits(struct iwm_notif_wait_data *notif_data)
+{
+ struct iwm_notification_wait *wait_entry;
+
+ mtx_lock(¬if_data->mtx);
+ STAILQ_FOREACH(wait_entry, ¬if_data->list, entry) {
+ wait_entry->aborted = 1;
+ wakeup(wait_entry);
+ }
+ mtx_unlock(¬if_data->mtx);
+}
+
+void
+iwm_init_notification_wait(struct iwm_notif_wait_data *notif_data,
+ struct iwm_notification_wait *wait_entry, const uint16_t *cmds, int n_cmds)
+{
+ int i;
+
+ KASSERT(n_cmds <= IWM_MAX_NOTIF_CMDS, ("too many notif values"));
+ for (i = 0; i < n_cmds; i++)
+ wait_entry->cmds[i] = cmds[i];
+ wait_entry->n_cmds = n_cmds;
+ wait_entry->triggered = 0;
+ wait_entry->aborted = 0;
+
+ mtx_lock(¬if_data->mtx);
+ STAILQ_INSERT_TAIL(¬if_data->list, wait_entry, entry);
+ mtx_unlock(¬if_data->mtx);
+}
+
+int
+iwm_wait_notification(struct iwm_notif_wait_data *notif_data,
+ struct iwm_notification_wait *wait_entry, int timeout)
+{
+ int ret = 0;
+
+ mtx_lock(¬if_data->mtx);
+ if (!wait_entry->triggered && !wait_entry->aborted) {
+ ret = msleep(wait_entry, ¬if_data->mtx, 0, "iwm_notif",
+ timeout);
+ }
+ STAILQ_REMOVE(¬if_data->list, wait_entry, iwm_notification_wait,
+ entry);
+ mtx_unlock(¬if_data->mtx);
+
+ return ret;
+}
+
+void
+iwm_remove_notification(struct iwm_notif_wait_data *notif_data,
+ struct iwm_notification_wait *wait_entry)
+{
+ mtx_lock(¬if_data->mtx);
+ STAILQ_REMOVE(¬if_data->list, wait_entry, iwm_notification_wait,
+ entry);
+ mtx_unlock(¬if_data->mtx);
+}
Index: sys/dev/iwm/if_iwmvar.h
===================================================================
--- sys/dev/iwm/if_iwmvar.h
+++ sys/dev/iwm/if_iwmvar.h
@@ -524,6 +524,8 @@
struct iwm_tx_radiotap_header sc_txtap;
int sc_max_rssi;
+
+ struct iwm_notif_wait_data *sc_notif_wait;
};
#define IWM_LOCK_INIT(_sc) \
Index: sys/modules/iwm/Makefile
===================================================================
--- sys/modules/iwm/Makefile
+++ sys/modules/iwm/Makefile
@@ -6,7 +6,7 @@
# Main driver
SRCS= if_iwm.c if_iwm_binding.c if_iwm_util.c if_iwm_phy_db.c
SRCS+= if_iwm_mac_ctxt.c if_iwm_phy_ctxt.c if_iwm_time_event.c
-SRCS+= if_iwm_power.c if_iwm_scan.c if_iwm_led.c
+SRCS+= if_iwm_power.c if_iwm_scan.c if_iwm_led.c if_iwm_notif_wait.c
# bus layer
SRCS+= if_iwm_pcie_trans.c
SRCS+= device_if.h bus_if.h pci_if.h opt_wlan.h
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 20, 5:15 AM (7 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28752217
Default Alt Text
D7340.1779254114.diff (13 KB)
Attached To
Mode
D7340: [iwm] Add partial implementation of notification wait api from iwlwifi.
Attached
Detach File
Event Timeline
Log In to Comment