aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2017-05-12 05:19:08 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2017-05-12 05:19:08 +0000
commitbdba68304768500fb52bb5b5c94f0e7bf75d47fe (patch)
treef6798b6155fbeec661bc537e0398706572c2aac4
parenta229b00539ac080f86f984c43bf4c231762baaac (diff)
downloadsrc-bdba68304768500fb52bb5b5c94f0e7bf75d47fe.tar.gz
src-bdba68304768500fb52bb5b5c94f0e7bf75d47fe.zip
[if_iwm] Partly sync if_iwm_binding.c to Linux iwlwifi code.
* Store macid and color values in struct iwm_vap, to avoid hardcoded constants a bit. * Add iwm_mvm_binding_remove_vif() function (will be used in disconnecting from an access point without resetting the whole device). * Not adding code from Linux iwlwifi yet, to handle one PHY context to be bound to several VAPs/virtual-interfaces, it's definitely not needed in the near future. Obtained from: dragonflybsd.git f16ef74977e51e1bfc7a625dd18b98b02158e0e5
Notes
Notes: svn path=/head/; revision=318212
-rw-r--r--sys/dev/iwm/if_iwm.c11
-rw-r--r--sys/dev/iwm/if_iwm_binding.c115
-rw-r--r--sys/dev/iwm/if_iwm_binding.h4
-rw-r--r--sys/dev/iwm/if_iwm_mac_ctxt.c5
-rw-r--r--sys/dev/iwm/if_iwm_power.c5
-rw-r--r--sys/dev/iwm/if_iwm_time_event.c8
-rw-r--r--sys/dev/iwm/if_iwm_time_event.h2
-rw-r--r--sys/dev/iwm/if_iwmvar.h3
8 files changed, 100 insertions, 53 deletions
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index 9541a538423c..14ad23207254 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -4156,7 +4156,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *sc)
}
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;
@@ -4205,7 +4205,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *sc)
*/
/* 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;
@@ -4250,7 +4250,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
@@ -4299,7 +4299,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);
@@ -6303,6 +6303,9 @@ iwm_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
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. */
ieee80211_vap_attach(vap, iwm_media_change, ieee80211_media_status,
diff --git a/sys/dev/iwm/if_iwm_binding.c b/sys/dev/iwm/if_iwm_binding.c
index 0f0960f82dce..624fe9c4fdf0 100644
--- a/sys/dev/iwm/if_iwm_binding.c
+++ b/sys/dev/iwm/if_iwm_binding.c
@@ -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@linux.intel.com>
+ * Intel Linux Wireless <linuxwifi@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@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$");
@@ -161,11 +145,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;
@@ -176,41 +170,88 @@ iwm_mvm_binding_cmd(struct iwm_softc *sc, struct iwm_vap *ivp, uint32_t action)
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;
}
diff --git a/sys/dev/iwm/if_iwm_binding.h b/sys/dev/iwm/if_iwm_binding.h
index 1aa8760cfa3c..3a44492d0330 100644
--- a/sys/dev/iwm/if_iwm_binding.h
+++ b/sys/dev/iwm/if_iwm_binding.h
@@ -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__ */
diff --git a/sys/dev/iwm/if_iwm_mac_ctxt.c b/sys/dev/iwm/if_iwm_mac_ctxt.c
index 19599eadde28..ae66fc24ac1d 100644
--- a/sys/dev/iwm/if_iwm_mac_ctxt.c
+++ b/sys/dev/iwm/if_iwm_mac_ctxt.c
@@ -252,6 +252,7 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
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;
@@ -263,8 +264,8 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
* 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);
diff --git a/sys/dev/iwm/if_iwm_power.c b/sys/dev/iwm/if_iwm_power.c
index 2ddb1fb5df92..e266ce04a3fa 100644
--- a/sys/dev/iwm/if_iwm_power.c
+++ b/sys/dev/iwm/if_iwm_power.c
@@ -286,9 +286,10 @@ iwm_mvm_power_build_cmd(struct iwm_softc *sc, struct iwm_node *in,
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;
/*
diff --git a/sys/dev/iwm/if_iwm_time_event.c b/sys/dev/iwm/if_iwm_time_event.c
index ba30bce39943..db24ea986fe4 100644
--- a/sys/dev/iwm/if_iwm_time_event.c
+++ b/sys/dev/iwm/if_iwm_time_event.c
@@ -166,7 +166,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;
@@ -186,14 +186,14 @@ iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_node *in,
}
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);
@@ -209,5 +209,5 @@ iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_node *in,
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);
}
diff --git a/sys/dev/iwm/if_iwm_time_event.h b/sys/dev/iwm/if_iwm_time_event.h
index 015652ece32b..4c741428e1ea 100644
--- a/sys/dev/iwm/if_iwm_time_event.h
+++ b/sys/dev/iwm/if_iwm_time_event.h
@@ -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__ */
diff --git a/sys/dev/iwm/if_iwmvar.h b/sys/dev/iwm/if_iwmvar.h
index fa2c2c37d31e..731b10b7dc4a 100644
--- a/sys/dev/iwm/if_iwmvar.h
+++ b/sys/dev/iwm/if_iwmvar.h
@@ -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))