Skip to content

Commit 8ca151b

Browse files
committed
iwlwifi: add the MVM driver
Newer firmware revisions have a completely new firmware API. This is the new driver for this new API. I've listed the people who directly contributed code, but many others from various teams have contributed in other ways. Cc: Alexander Bondar <[email protected]> Cc: Amit Beka <[email protected]> Cc: Amnon Paz <[email protected]> Cc: Assaf Krauss <[email protected]> Cc: David Spinadel <[email protected]> Cc: Dor Shaish <[email protected]> Cc: Emmanuel Grumbach <[email protected]> Cc: Eytan Lifshitz <[email protected]> Cc: Ilan Peer <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent b1e1adf commit 8ca151b

37 files changed

+18263
-6
lines changed

drivers/net/wireless/iwlwifi/Kconfig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,20 @@ config IWLWIFI
4343
module will be called iwlwifi.
4444

4545
config IWLDVM
46-
tristate "Intel Wireless WiFi"
46+
tristate "Intel Wireless WiFi DVM Firmware support"
4747
depends on IWLWIFI
48+
help
49+
This is the driver supporting the DVM firmware which is
50+
currently the only firmware available for existing devices.
51+
52+
config IWLMVM
53+
tristate "Intel Wireless WiFi MVM Firmware support"
54+
depends on IWLWIFI
55+
help
56+
This is the driver supporting the MVM firmware which is
57+
currently only available for 7000 series devices.
58+
59+
Say yes if you have such a device.
4860

4961
menu "Debugging Options"
5062
depends on IWLWIFI

drivers/net/wireless/iwlwifi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ ccflags-y += -D__CHECK_ENDIAN__ -I$(src)
1717

1818

1919
obj-$(CONFIG_IWLDVM) += dvm/
20+
obj-$(CONFIG_IWLMVM) += mvm/
2021

2122
CFLAGS_iwl-devtrace.o := -I$(src)

drivers/net/wireless/iwlwifi/iwl-debug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ do { \
116116
#define IWL_DL_HCMD 0x00000004
117117
#define IWL_DL_STATE 0x00000008
118118
/* 0x000000F0 - 0x00000010 */
119+
#define IWL_DL_TE 0x00000020
119120
#define IWL_DL_EEPROM 0x00000040
120121
#define IWL_DL_RADIO 0x00000080
121122
/* 0x00000F00 - 0x00000100 */
@@ -156,6 +157,7 @@ do { \
156157
#define IWL_DEBUG_LED(p, f, a...) IWL_DEBUG(p, IWL_DL_LED, f, ## a)
157158
#define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a)
158159
#define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a)
160+
#define IWL_DEBUG_TE(p, f, a...) IWL_DEBUG(p, IWL_DL_TE, f, ## a)
159161
#define IWL_DEBUG_EEPROM(d, f, a...) IWL_DEBUG_DEV(d, IWL_DL_EEPROM, f, ## a)
160162
#define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a)
161163
#define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a)

drivers/net/wireless/iwlwifi/iwl-drv.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ struct iwl_drv {
139139
#endif
140140
};
141141

142-
#define DVM_OP_MODE 0
143-
#define MVM_OP_MODE 1
142+
enum {
143+
DVM_OP_MODE = 0,
144+
MVM_OP_MODE = 1,
145+
};
144146

145147
/* Protects the table contents, i.e. the ops pointer & drv list */
146148
static struct mutex iwlwifi_opmode_table_mtx;
@@ -149,8 +151,8 @@ static struct iwlwifi_opmode_table {
149151
const struct iwl_op_mode_ops *ops; /* pointer to op_mode ops */
150152
struct list_head drv; /* list of devices using this op_mode */
151153
} iwlwifi_opmode_table[] = { /* ops set when driver is initialized */
152-
{ .name = "iwldvm", .ops = NULL },
153-
{ .name = "iwlmvm", .ops = NULL },
154+
[DVM_OP_MODE] = { .name = "iwldvm", .ops = NULL },
155+
[MVM_OP_MODE] = { .name = "iwlmvm", .ops = NULL },
154156
};
155157

156158
/*
@@ -963,7 +965,10 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
963965
release_firmware(ucode_raw);
964966

965967
mutex_lock(&iwlwifi_opmode_table_mtx);
966-
op = &iwlwifi_opmode_table[DVM_OP_MODE];
968+
if (fw->mvm_fw)
969+
op = &iwlwifi_opmode_table[MVM_OP_MODE];
970+
else
971+
op = &iwlwifi_opmode_table[DVM_OP_MODE];
967972

968973
/* add this device to the list of devices using this op_mode */
969974
list_add_tail(&drv->list, &op->drv);

drivers/net/wireless/iwlwifi/iwl-fw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ struct iwl_tlv_calib_ctrl {
166166
* @inst_evtlog_ptr: event log offset for runtime ucode.
167167
* @inst_evtlog_size: event log size for runtime ucode.
168168
* @inst_errlog_ptr: error log offfset for runtime ucode.
169+
* @mvm_fw: indicates this is MVM firmware
169170
*/
170171
struct iwl_fw {
171172
u32 ucode_ver;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
obj-$(CONFIG_IWLMVM) += iwlmvm.o
2+
iwlmvm-y += fw.o mac80211.o nvm.o ops.o phy-ctxt.o mac-ctxt.o
3+
iwlmvm-y += utils.o rx.o tx.o binding.o quota.o sta.o
4+
iwlmvm-y += scan.o time-event.o rs.o
5+
iwlmvm-y += power.o
6+
iwlmvm-y += led.o
7+
iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o
8+
iwlmvm-$(CONFIG_PM_SLEEP) += d3.o
9+
10+
ccflags-y += -D__CHECK_ENDIAN__ -I$(src)/../
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
/******************************************************************************
2+
*
3+
* This file is provided under a dual BSD/GPLv2 license. When using or
4+
* redistributing this file, you may do so under either license.
5+
*
6+
* GPL LICENSE SUMMARY
7+
*
8+
* Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
9+
*
10+
* This program is free software; you can redistribute it and/or modify
11+
* it under the terms of version 2 of the GNU General Public License as
12+
* published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful, but
15+
* WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22+
* USA
23+
*
24+
* The full GNU General Public License is included in this distribution
25+
* in the file called LICENSE.GPL.
26+
*
27+
* Contact Information:
28+
* Intel Linux Wireless <[email protected]>
29+
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30+
*
31+
* BSD LICENSE
32+
*
33+
* Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
34+
* All rights reserved.
35+
*
36+
* Redistribution and use in source and binary forms, with or without
37+
* modification, are permitted provided that the following conditions
38+
* are met:
39+
*
40+
* * Redistributions of source code must retain the above copyright
41+
* notice, this list of conditions and the following disclaimer.
42+
* * Redistributions in binary form must reproduce the above copyright
43+
* notice, this list of conditions and the following disclaimer in
44+
* the documentation and/or other materials provided with the
45+
* distribution.
46+
* * Neither the name Intel Corporation nor the names of its
47+
* contributors may be used to endorse or promote products derived
48+
* from this software without specific prior written permission.
49+
*
50+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61+
*
62+
*****************************************************************************/
63+
64+
#include <net/mac80211.h>
65+
#include "fw-api.h"
66+
#include "mvm.h"
67+
68+
struct iwl_mvm_iface_iterator_data {
69+
struct ieee80211_vif *ignore_vif;
70+
int idx;
71+
72+
struct iwl_mvm_phy_ctxt *phyctxt;
73+
74+
u16 ids[MAX_MACS_IN_BINDING];
75+
u16 colors[MAX_MACS_IN_BINDING];
76+
};
77+
78+
static int iwl_mvm_binding_cmd(struct iwl_mvm *mvm, u32 action,
79+
struct iwl_mvm_iface_iterator_data *data)
80+
{
81+
struct iwl_binding_cmd cmd;
82+
struct iwl_mvm_phy_ctxt *phyctxt = data->phyctxt;
83+
int i, ret;
84+
u32 status;
85+
86+
memset(&cmd, 0, sizeof(cmd));
87+
88+
cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(phyctxt->id,
89+
phyctxt->color));
90+
cmd.action = cpu_to_le32(action);
91+
cmd.phy = cpu_to_le32(FW_CMD_ID_AND_COLOR(phyctxt->id,
92+
phyctxt->color));
93+
94+
for (i = 0; i < MAX_MACS_IN_BINDING; i++)
95+
cmd.macs[i] = cpu_to_le32(FW_CTXT_INVALID);
96+
for (i = 0; i < data->idx; i++)
97+
cmd.macs[i] = cpu_to_le32(FW_CMD_ID_AND_COLOR(data->ids[i],
98+
data->colors[i]));
99+
100+
status = 0;
101+
ret = iwl_mvm_send_cmd_pdu_status(mvm, BINDING_CONTEXT_CMD,
102+
sizeof(cmd), &cmd, &status);
103+
if (ret) {
104+
IWL_ERR(mvm, "Failed to send binding (action:%d): %d\n",
105+
action, ret);
106+
return ret;
107+
}
108+
109+
if (status) {
110+
IWL_ERR(mvm, "Binding command failed: %u\n", status);
111+
ret = -EIO;
112+
}
113+
114+
return ret;
115+
}
116+
117+
static void iwl_mvm_iface_iterator(void *_data, u8 *mac,
118+
struct ieee80211_vif *vif)
119+
{
120+
struct iwl_mvm_iface_iterator_data *data = _data;
121+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
122+
123+
if (vif == data->ignore_vif)
124+
return;
125+
126+
if (mvmvif->phy_ctxt != data->phyctxt)
127+
return;
128+
129+
if (WARN_ON_ONCE(data->idx >= MAX_MACS_IN_BINDING))
130+
return;
131+
132+
data->ids[data->idx] = mvmvif->id;
133+
data->colors[data->idx] = mvmvif->color;
134+
data->idx++;
135+
}
136+
137+
static int iwl_mvm_binding_update(struct iwl_mvm *mvm,
138+
struct ieee80211_vif *vif,
139+
struct iwl_mvm_phy_ctxt *phyctxt,
140+
bool add)
141+
{
142+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
143+
struct iwl_mvm_iface_iterator_data data = {
144+
.ignore_vif = vif,
145+
.phyctxt = phyctxt,
146+
};
147+
u32 action = FW_CTXT_ACTION_MODIFY;
148+
149+
lockdep_assert_held(&mvm->mutex);
150+
151+
ieee80211_iterate_active_interfaces_atomic(mvm->hw,
152+
IEEE80211_IFACE_ITER_NORMAL,
153+
iwl_mvm_iface_iterator,
154+
&data);
155+
156+
/*
157+
* If there are no other interfaces yet we
158+
* need to create a new binding.
159+
*/
160+
if (data.idx == 0) {
161+
if (add)
162+
action = FW_CTXT_ACTION_ADD;
163+
else
164+
action = FW_CTXT_ACTION_REMOVE;
165+
}
166+
167+
if (add) {
168+
if (WARN_ON_ONCE(data.idx >= MAX_MACS_IN_BINDING))
169+
return -EINVAL;
170+
171+
data.ids[data.idx] = mvmvif->id;
172+
data.colors[data.idx] = mvmvif->color;
173+
data.idx++;
174+
}
175+
176+
return iwl_mvm_binding_cmd(mvm, action, &data);
177+
}
178+
179+
int iwl_mvm_binding_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
180+
{
181+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
182+
183+
if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
184+
return -EINVAL;
185+
186+
return iwl_mvm_binding_update(mvm, vif, mvmvif->phy_ctxt, true);
187+
}
188+
189+
int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
190+
{
191+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
192+
193+
if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
194+
return -EINVAL;
195+
196+
return iwl_mvm_binding_update(mvm, vif, mvmvif->phy_ctxt, false);
197+
}

0 commit comments

Comments
 (0)