svn commit: r330204 - stable/11/sys/dev/iwm
Eitan Adler
eadler at FreeBSD.org
Thu Mar 1 06:36:43 UTC 2018
Author: eadler
Date: Thu Mar 1 06:36:41 2018
New Revision: 330204
URL: https://svnweb.freebsd.org/changeset/base/330204
Log:
MFC r318214:
[iwm] Sanity check channel for IEEE80211_CHAN_ANYC in if_iwm_mac_ctxt.c.
* This avoids panicing in some broken vap state handling cases.
Modified:
stable/11/sys/dev/iwm/if_iwm.c
stable/11/sys/dev/iwm/if_iwm_binding.c
stable/11/sys/dev/iwm/if_iwm_binding.h
stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c
stable/11/sys/dev/iwm/if_iwm_power.c
stable/11/sys/dev/iwm/if_iwm_time_event.c
stable/11/sys/dev/iwm/if_iwm_time_event.h
stable/11/sys/dev/iwm/if_iwmvar.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/dev/iwm/if_iwm.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm.c Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwm.c Thu Mar 1 06:36:41 2018 (r330204)
@@ -3879,6 +3879,7 @@ iwm_mvm_send_add_sta_cmd_status(struct iwm_softc *sc,
static int
iwm_mvm_sta_send_to_fw(struct iwm_softc *sc, struct iwm_node *in, int update)
{
+ struct iwm_vap *ivp = IWM_VAP(in->in_ni.ni_vap);
struct iwm_mvm_add_sta_cmd add_sta_cmd;
int ret;
uint32_t status;
@@ -3887,8 +3888,7 @@ iwm_mvm_sta_send_to_fw(struct iwm_softc *sc, struct iw
add_sta_cmd.sta_id = IWM_STATION_ID;
add_sta_cmd.mac_id_n_color
- = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
+ = htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id, ivp->color));
if (!update) {
int ac;
for (ac = 0; ac < WME_NUM_AC; ac++) {
@@ -4140,7 +4140,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
}
iv->phy_ctxt = &sc->sc_phyctxt[0];
- if ((error = iwm_mvm_binding_update(sc, iv)) != 0) {
+ if ((error = iwm_mvm_binding_add_vif(sc, iv)) != 0) {
device_printf(sc->sc_dev,
"%s: binding update cmd\n", __func__);
goto out;
@@ -4189,7 +4189,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
*/
/* XXX duration is in units of TU, not MS */
duration = IWM_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS;
- iwm_mvm_protect_session(sc, in, duration, 500 /* XXX magic number */);
+ iwm_mvm_protect_session(sc, iv, duration, 500 /* XXX magic number */);
DELAY(100);
error = 0;
@@ -4234,7 +4234,7 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in)
* iwm_mvm_rm_sta(sc, in);
* iwm_mvm_update_quotas(sc, NULL);
* iwm_mvm_mac_ctxt_changed(sc, in);
- * iwm_mvm_binding_remove_vif(sc, in);
+ * iwm_mvm_binding_remove_vif(sc, IWM_VAP(in->in_ni.ni_vap));
* iwm_mvm_mac_ctxt_remove(sc, in);
*
* However, that freezes the device not matter which permutations
@@ -4283,7 +4283,7 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in)
device_printf(sc->sc_dev, "mac ctxt change fail 2 %d\n", error);
return error;
}
- iwm_mvm_binding_remove_vif(sc, in);
+ iwm_mvm_binding_remove_vif(sc, IWM_VAP(in->in_ni.ni_vap));
iwm_mvm_mac_ctxt_remove(sc, in);
@@ -6286,6 +6286,9 @@ iwm_vap_create(struct ieee80211com *ic, const char nam
/* Override with driver methods. */
ivp->iv_newstate = vap->iv_newstate;
vap->iv_newstate = iwm_newstate;
+
+ ivp->id = IWM_DEFAULT_MACID;
+ ivp->color = IWM_DEFAULT_COLOR;
ieee80211_ratectl_init(vap);
/* Complete setup. */
Modified: stable/11/sys/dev/iwm/if_iwm_binding.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_binding.c Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwm_binding.c Thu Mar 1 06:36:41 2018 (r330204)
@@ -31,7 +31,7 @@
*
* GPL LICENSE SUMMARY
*
- * Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved.
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
*
* 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
@@ -51,13 +51,12 @@
* in the file called COPYING.
*
* Contact Information:
- * Intel Linux Wireless <ilw at linux.intel.com>
+ * Intel Linux Wireless <linuxwifi at intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*
- *
* BSD LICENSE
*
- * Copyright(c) 2005 - 2013 Intel Corporation. All rights reserved.
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -87,21 +86,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*-
- * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini at free.fr>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -160,11 +144,21 @@ __FBSDID("$FreeBSD$");
* BEGIN iwlwifi/mvm/binding.c
*/
-int
-iwm_mvm_binding_cmd(struct iwm_softc *sc, struct iwm_vap *ivp, uint32_t action)
+struct iwm_mvm_iface_iterator_data {
+ int idx;
+
+ struct iwm_mvm_phy_ctxt *phyctxt;
+
+ uint16_t ids[IWM_MAX_MACS_IN_BINDING];
+ int16_t colors[IWM_MAX_MACS_IN_BINDING];
+};
+
+static int
+iwm_mvm_binding_cmd(struct iwm_softc *sc, uint32_t action,
+ struct iwm_mvm_iface_iterator_data *data)
{
struct iwm_binding_cmd cmd;
- struct iwm_mvm_phy_ctxt *phyctxt = ivp->phy_ctxt;
+ struct iwm_mvm_phy_ctxt *phyctxt = data->phyctxt;
int i, ret;
uint32_t status;
@@ -175,41 +169,88 @@ iwm_mvm_binding_cmd(struct iwm_softc *sc, struct iwm_v
cmd.action = htole32(action);
cmd.phy = htole32(IWM_FW_CMD_ID_AND_COLOR(phyctxt->id, phyctxt->color));
- cmd.macs[0] = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
- /* We use MACID 0 here.. */
- for (i = 1; i < IWM_MAX_MACS_IN_BINDING; i++)
+ for (i = 0; i < IWM_MAX_MACS_IN_BINDING; i++)
cmd.macs[i] = htole32(IWM_FW_CTXT_INVALID);
+ for (i = 0; i < data->idx; i++)
+ cmd.macs[i] = htole32(IWM_FW_CMD_ID_AND_COLOR(data->ids[i],
+ data->colors[i]));
status = 0;
ret = iwm_mvm_send_cmd_pdu_status(sc, IWM_BINDING_CONTEXT_CMD,
sizeof(cmd), &cmd, &status);
if (ret) {
- IWM_DPRINTF(sc, IWM_DEBUG_CMD | IWM_DEBUG_RESET,
- "%s: Failed to send binding (action:%d): %d\n",
- __func__, action, ret);
+ device_printf(sc->sc_dev,
+ "Failed to send binding (action:%d): %d\n", action, ret);
return ret;
}
if (status) {
- IWM_DPRINTF(sc, IWM_DEBUG_CMD | IWM_DEBUG_RESET,
- "%s: Binding command failed: %u\n",
- __func__,
- status);
+ device_printf(sc->sc_dev,
+ "Binding command failed: %u\n", status);
ret = EIO;
}
return ret;
}
-int
-iwm_mvm_binding_update(struct iwm_softc *sc, struct iwm_vap *ivp)
+static int
+iwm_mvm_binding_update(struct iwm_softc *sc, struct iwm_vap *ivp,
+ struct iwm_mvm_phy_ctxt *phyctxt, boolean_t add)
{
- return iwm_mvm_binding_cmd(sc, ivp, IWM_FW_CTXT_ACTION_MODIFY);
+ struct iwm_mvm_iface_iterator_data data = {
+ .phyctxt = phyctxt,
+ };
+ uint32_t action;
+
+ if (add)
+ action = IWM_FW_CTXT_ACTION_ADD;
+ else
+ action = IWM_FW_CTXT_ACTION_REMOVE;
+
+ if (add) {
+ data.ids[0] = ivp->id;
+ data.colors[0] = ivp->color;
+ data.idx++;
+ }
+
+ return iwm_mvm_binding_cmd(sc, action, &data);
}
int
iwm_mvm_binding_add_vif(struct iwm_softc *sc, struct iwm_vap *ivp)
{
- return iwm_mvm_binding_cmd(sc, ivp, IWM_FW_CTXT_ACTION_ADD);
+ if (!ivp->phy_ctxt)
+ return EINVAL;
+
+#ifdef notyet
+ /*
+ * Update SF - Disable if needed. if this fails, SF might still be on
+ * while many macs are bound, which is forbidden - so fail the binding.
+ */
+ if (iwm_mvm_sf_update(sc, ivp, FALSE))
+ return EINVAL;
+#endif
+
+ return iwm_mvm_binding_update(sc, ivp, ivp->phy_ctxt, TRUE);
+}
+
+int
+iwm_mvm_binding_remove_vif(struct iwm_softc *sc, struct iwm_vap *ivp)
+{
+ int ret;
+
+ if (!ivp->phy_ctxt)
+ return EINVAL;
+
+ ret = iwm_mvm_binding_update(sc, ivp, ivp->phy_ctxt, FALSE);
+
+#ifdef notyet
+ if (!ret) {
+ if (iwm_mvm_sf_update(sc, ivp, TRUE))
+ device_printf(sc->sc_dev,
+ "Failed to update SF state\n");
+ }
+#endif
+
+ return ret;
}
Modified: stable/11/sys/dev/iwm/if_iwm_binding.h
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_binding.h Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwm_binding.h Thu Mar 1 06:36:41 2018 (r330204)
@@ -105,9 +105,7 @@
#ifndef __IF_IWM_BINDING_H__
#define __IF_IWM_BINDING_H__
-extern int iwm_mvm_binding_cmd(struct iwm_softc *sc, struct iwm_vap *ivp,
- uint32_t action);
-extern int iwm_mvm_binding_update(struct iwm_softc *sc, struct iwm_vap *ivp);
extern int iwm_mvm_binding_add_vif(struct iwm_softc *sc, struct iwm_vap *ivp);
+extern int iwm_mvm_binding_remove_vif(struct iwm_softc *sc, struct iwm_vap *ivp);
#endif /* __IF_IWM_BINDING_H__ */
Modified: stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c Thu Mar 1 06:36:41 2018 (r330204)
@@ -251,6 +251,7 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, stru
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
struct ieee80211_node *ni = vap->iv_bss;
+ struct iwm_vap *ivp = IWM_VAP(vap);
int cck_ack_rates, ofdm_ack_rates;
int i;
int is2ghz;
@@ -262,8 +263,8 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, stru
* These are both functions of the vap, not of the node.
* So, for now, hard-code both to 0 (default).
*/
- cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
+ cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id,
+ ivp->color));
cmd->action = htole32(action);
cmd->mac_type = htole32(IWM_FW_MAC_TYPE_BSS_STA);
@@ -306,7 +307,7 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, stru
/*
* Default to 2ghz if no node information is given.
*/
- if (in) {
+ if (in && in->in_ni.ni_chan != IEEE80211_CHAN_ANYC) {
is2ghz = !! IEEE80211_IS_CHAN_2GHZ(in->in_ni.ni_chan);
} else {
is2ghz = 1;
Modified: stable/11/sys/dev/iwm/if_iwm_power.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_power.c Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwm_power.c Thu Mar 1 06:36:41 2018 (r330204)
@@ -285,9 +285,10 @@ iwm_mvm_power_build_cmd(struct iwm_softc *sc, struct i
int keep_alive;
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+ struct iwm_vap *ivp = IWM_VAP(vap);
- cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
+ cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id,
+ ivp->color));
dtimper = vap->iv_dtim_period ?: 1;
/*
Modified: stable/11/sys/dev/iwm/if_iwm_time_event.c
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_time_event.c Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwm_time_event.c Thu Mar 1 06:36:41 2018 (r330204)
@@ -165,7 +165,7 @@ __FBSDID("$FreeBSD$");
#define IWM_MVM_ROC_TE_TYPE_MGMT_TX IWM_TE_P2P_CLIENT_ASSOC
static int
-iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_node *in,
+iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_vap *ivp,
void *te_data, struct iwm_time_event_cmd *te_cmd)
{
int ret;
@@ -185,14 +185,14 @@ iwm_mvm_time_event_send_add(struct iwm_softc *sc, stru
}
void
-iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_node *in,
+iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp,
uint32_t duration, uint32_t max_delay)
{
struct iwm_time_event_cmd time_cmd = {};
time_cmd.action = htole32(IWM_FW_CTXT_ACTION_ADD);
time_cmd.id_and_color =
- htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID, IWM_DEFAULT_COLOR));
+ htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id, ivp->color));
time_cmd.id = htole32(IWM_TE_BSS_STA_AGGRESSIVE_ASSOC);
time_cmd.apply_time = htole32(0);
@@ -208,5 +208,5 @@ iwm_mvm_protect_session(struct iwm_softc *sc, struct i
IWM_TE_V2_NOTIF_HOST_EVENT_END |
IWM_T2_V2_START_IMMEDIATELY);
- iwm_mvm_time_event_send_add(sc, in, /*te_data*/NULL, &time_cmd);
+ iwm_mvm_time_event_send_add(sc, ivp, /*te_data*/NULL, &time_cmd);
}
Modified: stable/11/sys/dev/iwm/if_iwm_time_event.h
==============================================================================
--- stable/11/sys/dev/iwm/if_iwm_time_event.h Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwm_time_event.h Thu Mar 1 06:36:41 2018 (r330204)
@@ -107,7 +107,7 @@
#ifndef __IF_IWM_TIME_EVENT_H__
#define __IF_IWM_TIME_EVENT_H__
-extern void iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_node *in,
+extern void iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp,
uint32_t duration, uint32_t max_delay);
#endif /* __IF_IWM_TIME_EVENT_H__ */
Modified: stable/11/sys/dev/iwm/if_iwmvar.h
==============================================================================
--- stable/11/sys/dev/iwm/if_iwmvar.h Thu Mar 1 06:35:13 2018 (r330203)
+++ stable/11/sys/dev/iwm/if_iwmvar.h Thu Mar 1 06:36:41 2018 (r330204)
@@ -375,6 +375,9 @@ struct iwm_vap {
enum ieee80211_state, int);
struct iwm_mvm_phy_ctxt *phy_ctxt;
+
+ uint16_t id;
+ uint16_t color;
};
#define IWM_VAP(_vap) ((struct iwm_vap *)(_vap))
More information about the svn-src-all
mailing list