linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pull request: iwlwifi-next 2015-05-03
@ 2015-05-03 19:30 Grumbach, Emmanuel
  2015-05-03 19:31 ` [PATCH 01/42] iwlwifi: mvm: ROC: Reduce the aux roc max delay Emmanuel Grumbach
                   ` (42 more replies)
  0 siblings, 43 replies; 44+ messages in thread
From: Grumbach, Emmanuel @ 2015-05-03 19:30 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, Grumbach, Emmanuel

SGkgS2FsbGUsDQoNCkhlcmUgaXMgbXkgZmlyc3QgcHVsbCByZXF1ZXN0IGZvciA0LjIuIEFzIHVz
dWFsLCBkZXRhaWxzIGluIHRoZSB0YWcuDQpQbGVhc2UgcHVsbCAtIHRoYW5rcyENCg0KVGhlIGZv
bGxvd2luZyBjaGFuZ2VzIHNpbmNlIGNvbW1pdCA2YzM3M2NhODkzOTljNWEzZjdlZjIxMGFkOGY2
M2RjMzQzN2RhMzQ1Og0KDQogIE1lcmdlIGdpdDovL2dpdC5rZXJuZWwub3JnL3B1Yi9zY20vbGlu
dXgva2VybmVsL2dpdC9kYXZlbS9uZXQtbmV4dCAoMjAxNS0wNC0xNSAwOTowMDo0NyAtMDcwMCkN
Cg0KYXJlIGF2YWlsYWJsZSBpbiB0aGUgZ2l0IHJlcG9zaXRvcnkgYXQ6DQoNCiAgaHR0cHM6Ly9n
aXQua2VybmVsLm9yZy9wdWIvc2NtL2xpbnV4L2tlcm5lbC9naXQvaXdsd2lmaS9pd2x3aWZpLW5l
eHQuZ2l0IHRhZ3MvaXdsd2lmaS1uZXh0LWZvci1rYWxsZS0yMDE1LTA1LTAzDQoNCmZvciB5b3Ug
dG8gZmV0Y2ggY2hhbmdlcyB1cCB0byAwNWMzMjc0ZDU2ZWU3ODNjYjI5MWE3NzllYzJiMzY5ZTlk
MTcyNDUwOg0KDQogIGl3bHdpZmk6IG12bTogaW5jbHVkZSB3aWxkY2FyZCBTU0lEIGluIHNjYW5z
ICgyMDE1LTA1LTAzIDIyOjE4OjMzICswMzAwKQ0KDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQoqIG1ham9yIHJld29yayBv
ZiB0aGUgc2NhbiBjb2RlIChMdWNhKQ0KKiBzb21lIHdvcmsgb24gdGhlIHRoZXJtYWwgY29kZSAo
Q2hheWEgUmFjaGVsKQ0KKiBzb21lIHdvcmsgb24gdGhlIGZpcndtYXJlIGRlYnVnZ2luZyBpbmZy
YXN0cnVjdHVyZQ0KDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tDQpBbGV4YW5kZXIgQm9uZGFyICgxKToNCiAgICAgIGl3bHdp
Zmk6IG12bTogQXZvaWQgc2lnbmFsIGJhc2VkIGRlY2lzaW9ucyBpZiBhdmUgYmVhY29uIFJTU0kg
aXMgMA0KDQpBcmlrIE5lbXRzb3YgKDEpOg0KICAgICAgaXdsd2lmaTogbXZtOiBpdGVyYXRlIGFs
bCBpbnRlcmZhY2VzIGR1cmluZyBIVyByZWNvdmVyeSBjbGVhbnVwDQoNCkF2cmFoYW0gU3Rlcm4g
KDEpOg0KICAgICAgaXdsd2lmaTogbXZtOiBmaXggc2NhbiBpdGVyYXRpb24gY29tcGxldGUgbm90
aWZpY2F0aW9uIGhhbmRsaW5nDQoNCkF2cmkgQWx0bWFuICgxKToNCiAgICAgIGl3bHdpZmk6IG12
bTogZml4IFR4IFBvd2VyIGZpcm13YXJlIEFQSQ0KDQpDaGF5YSBSYWNoZWwgSXZnaSAoMSk6DQog
ICAgICBpd2x3aWZpOiBtdm06IG1ha2UgdGhlcm1hbCB0aHJvdHRsaW5nIHZhbHVlcyBjb25maWd1
cmFibGUgcGVyIE5JQyBmYW1pbHkNCg0KRGF2aWQgU3BpbmFkZWwgKDIpOg0KICAgICAgaXdsd2lm
aTogbXZtOiByZW1vdmUgZGVwcmVjYXRlZCBjb21tYW5kIElEcw0KICAgICAgaXdsd2lmaTogbXZt
OiBpbmNsdWRlIHdpbGRjYXJkIFNTSUQgaW4gc2NhbnMNCg0KRWxpYWQgUGVsbGVyICgxKToNCiAg
ICAgIGl3bHdpZmk6IG12bTogYXZvaWQgdXNlLWFmdGVyLWZyZWUgb24gaXdsX212bV9kMGkzX2Vu
YWJsZV90eCgpIFtCVUdGSVhdDQoNCkVtbWFudWVsIEdydW1iYWNoICg2KToNCiAgICAgIGl3bHdp
Zmk6IG12bTogZG9uJ3Qgc3RvcCB0aGUgRlcgbW9uaXRvciB0b28gZWFybHkNCiAgICAgIGl3bHdp
Zmk6IG12bTogZml4IHR5cG8gaW4gQ09ORklHIG9wdGlvbg0KICAgICAgTWVyZ2UgcmVtb3RlLXRy
YWNraW5nIGJyYW5jaCAnaXdsd2lmaS1maXhlcy9tYXN0ZXInIGludG8gaXdsd2lmaS1uZXh0DQog
ICAgICBpd2x3aWZpOiBtdm06IGFsbG93IHNjaGVkdWxlZCBzY2FuIGZvciBhbGwgdGhlIGZpcm13
YXJlcw0KICAgICAgaXdsd2lmaTogY2xhcmlmeSB0aGUgZGV2aWNlIC8gZmlybXdhcmUgbWFwcGlu
ZyBpbiBLY29uZmlnDQogICAgICBpd2x3aWZpOiBhbGxvdyB0byBsaW1pdCB0aGUgc2l6ZSBvZiB0
aGUgZXh0ZXJuYWwgYnVmZmVyIGZvciBmaXJtd2FyZSBkZWJ1Z2dpbmcNCg0KRXJhbiBIYXJhcnkg
KDEpOg0KICAgICAgaXdsd2lmaTogbXZtOiBkb24ndCBwb3dlciBvZmYgdGhlIGRldmljZSBiZXR3
ZWVuIElOSVQgYW5kIE9QRVIgZmlybXdhcmVzDQoNCkV5YWwgU2hhcGlyYSAoMSk6DQogICAgICBp
d2x3aWZpOiByczogY2xlYW51cCBsYXN0X3R4cmF0ZV9pZHgNCg0KSm9oYW5uZXMgQmVyZyAoMik6
DQogICAgICBpd2x3aWZpOiBtdm06IGZvcmNlIHF1b3RhIHVwZGF0ZSB1cGRhdGUgYWZ0ZXIgRlcg
cmVzdGFydA0KICAgICAgaXdsd2lmaTogbXZtOiBkb24ndCByZXNldCBrZXkgaW5kZXggb24gSFcg
cmVzdGFydA0KDQpMaWFkIEthdWZtYW4gKDQpOg0KICAgICAgaXdsd2lmaTogcGNpZTogcHJldmVu
dCB1c2luZyB1bm1hcHBlZCBtZW1vcnkgaW4gZncgbW9uaXRvcg0KICAgICAgaXdsd2lmaTogcnM6
IHJlbW92ZSBjb2RlIGR1cGxpY2F0aW9uIHdoZW4gZmlsbGluZyBscSBjbWQNCiAgICAgIGl3bHdp
Zmk6IHBjaWU6IHN1cHBvcnQgbWFyYmggZncgZGJnIG1vZGUNCiAgICAgIGl3bHdpZmk6IHJzOiBy
ZW1vdmUgdW5uZWVkZWQgY2hlY2sgb2YgYXZlcmFnZSB0cHQgaW4gd2luZG93DQoNCkx1Y2lhbm8g
Q29lbGhvICgyOCk6DQogICAgICBpd2x3aWZpOiBtdm06IGFkZCBzY2FuIHBhcmFtZXRlcnMgZGVi
dWdnaW5nIGluZm8NCiAgICAgIGl3bHdpZmk6IG12bTogZG9uJ3QgaW5jcmVhc2UgbWF4X291dF90
aW1lIHdoZW4gbG93IHByaW9yaXR5IHNjYW4gaXMgcmVxdWVzdGVkDQogICAgICBpd2x3aWZpOiBt
dm06IGNvbnZlcnQgc2Nhbl9zdGF0dXMgdG8gYSBiaXRtYXANCiAgICAgIGl3bHdpZmk6IG12bTog
ZG9uJ3Qgd2FpdCBmb3Igc2NhbiBzdG9wcGVkIHdvcmsgd2hlbiBjYW5jZWxsaW5nIHNjYW5zDQog
ICAgICBpd2x3aWZpOiBtdm06IGNoZWNrIGlmIHNjYW4gY2FuIGJlIHN0YXJ0ZWQgYmVmb3JlIGNh
bmNlbGxpbmcgb3RoZXIgc2NhbnMNCiAgICAgIGl3bHdpZmk6IG12bTogZ2VuZXJhbGl6ZSB0aGUg
b3RoZXItc2NhbiBzdG9wcGluZyBjb2RlDQogICAgICBpd2x3aWZpOiBtdm06IHJlbmFtZSB1bmlm
aWVkX3NjYW4gc3ltYm9scyB0byBqdXN0IHNjYW4NCiAgICAgIGl3bHdpZmk6IG12bTogbW92ZSBz
Y2FuIGNvZGUgZnJvbSBtYWM4MDIxMS5jIHRvIHNjYW4uYw0KICAgICAgaXdsd2lmaTogbXZtOiBk
aWZmZXJlbnRpYXRlIG5ldC1kZXRlY3QgZnJvbSBzY2hlZCBzY2FuDQogICAgICBpd2x3aWZpOiBt
dm06IHNvbWUgY2xlYW4gdXBzIGluIGZ3LWFwaS1zY2FuLmgNCiAgICAgIGl3bHdpZmk6IG12bTog
YWx3YXlzIHVzZSBpd2xfbXZtX3NjYW5fc2l6ZSB0byBjYWxjdWxhdGUgdGhlIHNjYW4gc2l6ZQ0K
ICAgICAgaXdsd2lmaTogbXZtOiBjb21iaW5lIHNjYW4gc2l6ZSBjaGVja3MgaW50byBhIGNvbW1v
biBmdW5jdGlvbg0KICAgICAgaXdsd2lmaTogbXZtOiBjb21iaW5lIHBhcnRzIG9mIFVNQUMgYW5k
IExNQUMgc2NhbnMNCiAgICAgIGl3bHdpZmk6IG12bTogY29tYmluZSBwYXJ0cyBvZiBVTUFDIGFu
ZCBMTUFDIHNjaGVkIHNjYW5zDQogICAgICBpd2x3aWZpOiBtdm06IGFkZCBjb21tb24gc2NhbiBw
YXJhbXMgdG8gdGh3IGl3bF9tdm1fc2Nhbl9wYXJhbXMgc3RydWN0DQogICAgICBpd2x3aWZpOiBt
dm06IGNvbWJpbmUgc3NpZF9iaXRtYXAgc2V0dGluZyBmb3IgcmVndWxhciBzY2Fucw0KICAgICAg
aXdsd2lmaTogbXZtOiByZXZlcnQgb3JkZXIgb2YgU1NJRHMgZm9yIHNjaGVkIHNjYW5zDQogICAg
ICBpd2x3aWZpOiBtdm06IGNvbWJpbmUgU1NJRCBmdW5jdGlvbnMgZm9yIHNjaGVkIGFuZCByZWd1
bGFyIHNjYW5zDQogICAgICBpd2x3aWZpOiBtdm06IHJlbmFtZSBzY2FuX2NhbGNfcGFyYW1zIHRv
IHNjYW5fY2FsY19kd2VsbA0KICAgICAgaXdsd2lmaTogbXZtOiBjb21iaW5lIExNQUMgYW5kIFVN
QUMgcHJlcSBnZW5lcmF0aW9uDQogICAgICBpd2x3aWZpOiBtdm06IGFkZCBudW1iZXIgb2Ygc2Nh
biBpdGVyYXRpb25zIGFuZCBtdWx0aXBsaWVyIHRvIHBhcmFtcw0KICAgICAgaXdsd2lmaTogbXZt
OiBjb21iaW5lIExNQUMgc2NhbnMgaW50byBvbmUNCiAgICAgIGl3bHdpZmk6IG12bTogdHJpbSBz
Y2hlZCBzY2FuIGRlbGF5IGRvd24gdG8gMTYtYml0IGZvciBMTUFDIGFzIHdlbGwNCiAgICAgIGl3
bHdpZmk6IG12bTogY29tYmluZSBVTUFDIHNjYW5zIGludG8gb25lDQogICAgICBpd2x3aWZpOiBt
dm06IG1vdmUgYWxsIFVNQUMgc2NhbiBmbGFncyBzZXR0aW5nIGludG8gdGhlIHJlbGV2YW50IGZ1
bmN0aW9uDQogICAgICBpd2x3aWZpOiBtdm06IG1vdmUgYWxsIExNQUMgc2NhbiBmbGFncyBpbnRv
IGEgc2luZ2xlIGZ1bnRpb24NCiAgICAgIGl3bHdpZmk6IG12bTogcmVuYW1lIGdlbmVyaWNfc2Nh
bl9jbWQgZnVuY3Rpb25zIHRvIGR3ZWxsDQogICAgICBpd2x3aWZpOiBtdm06IHJlbW92ZSBzb21l
IHVudXNlZCBzdHVmZiBmcm9tIHNjYW4uYw0KDQpNYXR0aSBHb3R0bGllYiAoMSk6DQogICAgICBp
d2x3aWZpOiBtdm06IFJPQzogUmVkdWNlIHRoZSBhdXggcm9jIG1heCBkZWxheQ0KDQogZHJpdmVy
cy9uZXQvd2lyZWxlc3MvaXdsd2lmaS9LY29uZmlnICAgICAgICAgICAgfCAgMTIgKy0NCiBkcml2
ZXJzL25ldC93aXJlbGVzcy9pd2x3aWZpL2l3bC03MDAwLmMgICAgICAgICB8ICAyMyArKysrDQog
ZHJpdmVycy9uZXQvd2lyZWxlc3MvaXdsd2lmaS9pd2wtY29uZmlnLmggICAgICAgfCAgNDQgKysr
KysrKw0KIGRyaXZlcnMvbmV0L3dpcmVsZXNzL2l3bHdpZmkvaXdsLWZ3LWZpbGUuaCAgICAgIHwg
IDEwICstDQogZHJpdmVycy9uZXQvd2lyZWxlc3MvaXdsd2lmaS9pd2wtcHJwaC5oICAgICAgICAg
fCAgIDMgKw0KIGRyaXZlcnMvbmV0L3dpcmVsZXNzL2l3bHdpZmkvaXdsLXRyYW5zLmggICAgICAg
IHwgIDQxICsrKystLS0NCiBkcml2ZXJzL25ldC93aXJlbGVzcy9pd2x3aWZpL212bS9kMy5jICAg
ICAgICAgICB8ICAgOSArLQ0KIGRyaXZlcnMvbmV0L3dpcmVsZXNzL2l3bHdpZmkvbXZtL2Z3LWFw
aS1wb3dlci5oIHwgIDM0ICsrKysrKw0KIGRyaXZlcnMvbmV0L3dpcmVsZXNzL2l3bHdpZmkvbXZt
L2Z3LWFwaS1zY2FuLmggIHwgMTAwICsrKy0tLS0tLS0tLS0tLQ0KIGRyaXZlcnMvbmV0L3dpcmVs
ZXNzL2l3bHdpZmkvbXZtL2Z3LWFwaS5oICAgICAgIHwgIDIwIC0tLQ0KIGRyaXZlcnMvbmV0L3dp
cmVsZXNzL2l3bHdpZmkvbXZtL2Z3LmMgICAgICAgICAgIHwgIDY5ICsrKystLS0tLS0tDQogZHJp
dmVycy9uZXQvd2lyZWxlc3MvaXdsd2lmaS9tdm0vbWFjODAyMTEuYyAgICAgfCAxODMgKysrKysr
KysrKystLS0tLS0tLS0tLS0tLS0tLQ0KIGRyaXZlcnMvbmV0L3dpcmVsZXNzL2l3bHdpZmkvbXZt
L212bS5oICAgICAgICAgIHwgMTEwICsrKysrKy0tLS0tLS0tLS0tDQogZHJpdmVycy9uZXQvd2ly
ZWxlc3MvaXdsd2lmaS9tdm0vb3BzLmMgICAgICAgICAgfCAgMTkgKystDQogZHJpdmVycy9uZXQv
d2lyZWxlc3MvaXdsd2lmaS9tdm0vcnMuYyAgICAgICAgICAgfCAgMjAgKy0tDQogZHJpdmVycy9u
ZXQvd2lyZWxlc3MvaXdsd2lmaS9tdm0vcnMuaCAgICAgICAgICAgfCAgIDIgLQ0KIGRyaXZlcnMv
bmV0L3dpcmVsZXNzL2l3bHdpZmkvbXZtL3J4LmMgICAgICAgICAgIHwgICA1ICsNCiBkcml2ZXJz
L25ldC93aXJlbGVzcy9pd2x3aWZpL212bS9zY2FuLmMgICAgICAgICB8IDk5MCArKysrKysrKysr
KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr
KysrKysrLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KIGRyaXZlcnMvbmV0L3dpcmVsZXNzL2l3bHdpZmkv
bXZtL3R0LmMgICAgICAgICAgIHwgIDQwICsrLS0tLQ0KIGRyaXZlcnMvbmV0L3dpcmVsZXNzL2l3
bHdpZmkvcGNpZS90cmFucy5jICAgICAgIHwgIDk0ICsrKysrKysrKysrLS0tLQ0KIDIwIGZpbGVz
IGNoYW5nZWQsIDg3OSBpbnNlcnRpb25zKCspLCA5NDkgZGVsZXRpb25zKC0pDQoNCg==

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH 01/42] iwlwifi: mvm: ROC: Reduce the aux roc max delay
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 02/42] iwlwifi: rs: remove code duplication when filling lq cmd Emmanuel Grumbach
                   ` (41 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Matti Gottlieb, Emmanuel Grumbach

From: Matti Gottlieb <matti.gottlieb@intel.com>

When user space requests mac80211 to transmit a frame off
channel, mac80211 notifies the driver, and the driver requests
a time event from the ucode, and then transmits the frame.
When the driver requests a time event, it can specify what is the allowed
max delay for starting the time event.

When the max delay is too big, this can cause a timeout in the user space,
that is waiting for the frame to be transmitted.

Currently the max delay is extremely long.

Reduce the max delay for the AUX ROC time event that is sent to the ucode.

Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 40265b9..f44bb17 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -3001,7 +3001,7 @@ static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data *notif_wait,
 	return true;
 }
 
-#define AUX_ROC_MAX_DELAY_ON_CHANNEL 5000
+#define AUX_ROC_MAX_DELAY_ON_CHANNEL 200
 static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
 				    struct ieee80211_channel *channel,
 				    struct ieee80211_vif *vif,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 02/42] iwlwifi: rs: remove code duplication when filling lq cmd
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
  2015-05-03 19:31 ` [PATCH 01/42] iwlwifi: mvm: ROC: Reduce the aux roc max delay Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 03/42] iwlwifi: rs: cleanup last_txrate_idx Emmanuel Grumbach
                   ` (40 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Liad Kaufman, Emmanuel Grumbach

From: Liad Kaufman <liad.kaufman@intel.com>

Same code appear a few lines later while the position has
no effect on the actual flow.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/rs.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
index f9928f2..a9ad644 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.c
@@ -3223,9 +3223,6 @@ static void rs_fill_lq_cmd(struct iwl_mvm *mvm,
 	if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LQ_SS_PARAMS)
 		rs_set_lq_ss_params(mvm, sta, lq_sta, initial_rate);
 
-	if (num_of_ant(initial_rate->ant) == 1)
-		lq_cmd->single_stream_ant_msk = initial_rate->ant;
-
 	mvmsta = iwl_mvm_sta_from_mac80211(sta);
 	mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 03/42] iwlwifi: rs: cleanup last_txrate_idx
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
  2015-05-03 19:31 ` [PATCH 01/42] iwlwifi: mvm: ROC: Reduce the aux roc max delay Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 02/42] iwlwifi: rs: remove code duplication when filling lq cmd Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 04/42] iwlwifi: mvm: add scan parameters debugging info Emmanuel Grumbach
                   ` (39 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Eyal Shapira, Eyal Shapira, Emmanuel Grumbach

From: Eyal Shapira <eyal@wizery.com>

last_txrate_idx isn't used anymore and can be dropped as this info
exists already somewhere else.

Signed-off-by: Eyal Shapira <eyalx.shapira@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/rs.c | 10 +++-------
 drivers/net/wireless/iwlwifi/mvm/rs.h |  2 --
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
index a9ad644..316c6e0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.c
@@ -1,7 +1,7 @@
 /******************************************************************************
  *
  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications 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
@@ -2133,7 +2133,7 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm,
 	}
 
 	/* current tx rate */
-	index = lq_sta->last_txrate_idx;
+	index = rate->index;
 
 	/* rates available for this association, and for modulation mode */
 	rate_mask = rs_get_supported_rates(lq_sta, rate);
@@ -2181,7 +2181,7 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm,
 		 * or search for a new one? */
 		rs_stay_in_table(lq_sta, false);
 
-		goto out;
+		return;
 	}
 	/* Else we have enough samples; calculate estimate of
 	 * actual average throughput */
@@ -2400,9 +2400,6 @@ lq_update:
 			rs_set_stay_in_table(mvm, 0, lq_sta);
 		}
 	}
-
-out:
-	lq_sta->last_txrate_idx = index;
 }
 
 struct rs_init_rate_info {
@@ -2545,7 +2542,6 @@ static void rs_initialize_lq(struct iwl_mvm *mvm,
 	rate = &tbl->rate;
 
 	rs_get_initial_rate(mvm, lq_sta, band, rate);
-	lq_sta->last_txrate_idx = rate->index;
 
 	WARN_ON_ONCE(rate->ant != ANT_A && rate->ant != ANT_B);
 	if (rate->ant == ANT_A)
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.h b/drivers/net/wireless/iwlwifi/mvm/rs.h
index e4aa934..2a3da31 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.h
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.h
@@ -322,8 +322,6 @@ struct iwl_lq_sta {
 	struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */
 	u8 tx_agg_tid_en;
 
-	/* used to be in sta_info */
-	int last_txrate_idx;
 	/* last tx rate_n_flags */
 	u32 last_rate_n_flags;
 	/* packets destined for this STA are aggregated */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 04/42] iwlwifi: mvm: add scan parameters debugging info
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (2 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 03/42] iwlwifi: rs: cleanup last_txrate_idx Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 05/42] iwlwifi: mvm: don't increase max_out_time when low priority scan is requested Emmanuel Grumbach
                   ` (38 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Add scan parameters information to make it easier to debug scan dwell
times and fragmentation.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Alexander Bondar <alexander.bondar@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 1075a21..9f72505 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -271,6 +271,21 @@ not_bound:
 		params->dwell[band].active = iwl_mvm_get_active_dwell(mvm, band,
 								      n_ssids);
 	}
+
+	IWL_DEBUG_SCAN(mvm,
+		       "scan parameters: max_out_time %d, suspend_time %d, passive_fragmented %d\n",
+		       params->max_out_time, params->suspend_time,
+		       params->passive_fragmented);
+	IWL_DEBUG_SCAN(mvm,
+		       "dwell[IEEE80211_BAND_2GHZ]: passive %d, active %d, fragmented %d\n",
+		       params->dwell[IEEE80211_BAND_2GHZ].passive,
+		       params->dwell[IEEE80211_BAND_2GHZ].active,
+		       params->dwell[IEEE80211_BAND_2GHZ].fragmented);
+	IWL_DEBUG_SCAN(mvm,
+		       "dwell[IEEE80211_BAND_5GHZ]: passive %d, active %d, fragmented %d\n",
+		       params->dwell[IEEE80211_BAND_5GHZ].passive,
+		       params->dwell[IEEE80211_BAND_5GHZ].active,
+		       params->dwell[IEEE80211_BAND_5GHZ].fragmented);
 }
 
 static inline bool iwl_mvm_rrm_scan_needed(struct iwl_mvm *mvm)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 05/42] iwlwifi: mvm: don't increase max_out_time when low priority scan is requested
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (3 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 04/42] iwlwifi: mvm: add scan parameters debugging info Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 06/42] iwlwifi: mvm: convert scan_status to a bitmap Emmanuel Grumbach
                   ` (37 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

In some cases, max_out_time value is smaller than 200 and having the
NL80211_SCAN_FLAG_LOW_PRIORITY flag was actually causing the
max_out_time to be increased.  To avoid that, set max_out_time to 200
only if it's greater than 200.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Alexander Bondar <alexander.bondar@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 9f72505..8a0b244 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -257,7 +257,8 @@ static void iwl_mvm_scan_calc_params(struct iwl_mvm *mvm,
 		}
 	}
 
-	if (flags & NL80211_SCAN_FLAG_LOW_PRIORITY)
+	if ((flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
+	    (params->max_out_time > 200))
 		params->max_out_time = 200;
 
 not_bound:
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 06/42] iwlwifi: mvm: convert scan_status to a bitmap
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (4 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 05/42] iwlwifi: mvm: don't increase max_out_time when low priority scan is requested Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 07/42] iwlwifi: mvm: don't wait for scan stopped work when cancelling scans Emmanuel Grumbach
                   ` (36 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

LMAC scans cannot handle more than one scan at a time, but UMAC scans
can.  To avoid confusion we should combine the states of these two
types of scans.  To do so, we need to support mutliple scans at the
same time for UMAC.

This commit changes the scan_status element from a single value to a
bitmask of running scan types for LMAC.  Later, we will modify UMAC
scans to use the same state bitmask.

Additionally, add stopping scan flags for scheduled and regular scans.
This makes it easier to differentiate and handle stop requests
triggered by the driver and spontaneous stops generated by the
firmware.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c |  24 ++---
 drivers/net/wireless/iwlwifi/mvm/mvm.h      |  22 +++--
 drivers/net/wireless/iwlwifi/mvm/scan.c     | 134 ++++++++++++++++------------
 3 files changed, 107 insertions(+), 73 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index f44bb17..aff7de7 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1227,7 +1227,7 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
 
 	iwl_trans_stop_device(mvm->trans);
 
-	mvm->scan_status = IWL_MVM_SCAN_NONE;
+	mvm->scan_status = 0;
 	mvm->ps_disabled = false;
 	mvm->calibrating = false;
 
@@ -2374,28 +2374,30 @@ static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
 }
 
 static int iwl_mvm_cancel_scan_wait_notif(struct iwl_mvm *mvm,
-					  enum iwl_scan_status scan_type)
+					  unsigned int scan_type)
 {
 	int ret;
 	bool wait_for_handlers = false;
 
 	mutex_lock(&mvm->mutex);
 
-	if (mvm->scan_status != scan_type) {
+	if (!(mvm->scan_status & scan_type)) {
 		ret = 0;
 		/* make sure there are no pending notifications */
 		wait_for_handlers = true;
 		goto out;
 	}
 
+	/* It's okay to switch on bitmask values here, because we can
+	 * only stop one scan type at a time.
+	 */
 	switch (scan_type) {
 	case IWL_MVM_SCAN_SCHED:
 		ret = iwl_mvm_scan_offload_stop(mvm, true);
 		break;
-	case IWL_MVM_SCAN_OS:
+	case IWL_MVM_SCAN_REGULAR:
 		ret = iwl_mvm_cancel_scan(mvm);
 		break;
-	case IWL_MVM_SCAN_NONE:
 	default:
 		WARN_ON_ONCE(1);
 		ret = -EINVAL;
@@ -2440,7 +2442,7 @@ static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 		goto out;
 	}
 
-	if (mvm->scan_status != IWL_MVM_SCAN_NONE) {
+	if (mvm->scan_status & IWL_MVM_SCAN_REGULAR) {
 		ret = -EBUSY;
 		goto out;
 	}
@@ -2476,7 +2478,7 @@ static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
 	/* FIXME: for now, we ignore this race for UMAC scans, since
 	 * they don't set the scan_status.
 	 */
-	if ((mvm->scan_status == IWL_MVM_SCAN_OS) ||
+	if ((mvm->scan_status & IWL_MVM_SCAN_REGULAR) ||
 	    (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN))
 		iwl_mvm_cancel_scan(mvm);
 
@@ -2797,7 +2799,7 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 	int ret;
 
 	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
-		ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_OS);
+		ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_REGULAR);
 		if (ret)
 			return ret;
 	}
@@ -2815,14 +2817,14 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 		goto out;
 	}
 
-	if (mvm->scan_status != IWL_MVM_SCAN_NONE) {
+	if (mvm->scan_status & IWL_MVM_SCAN_SCHED) {
 		ret = -EBUSY;
 		goto out;
 	}
 
 	ret = iwl_mvm_scan_offload_start(mvm, vif, req, ies);
 	if (ret)
-		mvm->scan_status = IWL_MVM_SCAN_NONE;
+		mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
 
 out:
 	mutex_unlock(&mvm->mutex);
@@ -2848,7 +2850,7 @@ static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw,
 	/* FIXME: for now, we ignore this race for UMAC scans, since
 	 * they don't set the scan_status.
 	 */
-	if (mvm->scan_status != IWL_MVM_SCAN_SCHED &&
+	if (!(mvm->scan_status & IWL_MVM_SCAN_SCHED) &&
 	    !(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
 		mutex_unlock(&mvm->mutex);
 		return 0;
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index cf70f68..a8648fa 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -6,7 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications 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
@@ -32,7 +32,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -446,9 +446,19 @@ iwl_mvm_vif_from_mac80211(struct ieee80211_vif *vif)
 extern const u8 tid_to_mac80211_ac[];
 
 enum iwl_scan_status {
-	IWL_MVM_SCAN_NONE,
-	IWL_MVM_SCAN_OS,
-	IWL_MVM_SCAN_SCHED,
+	IWL_MVM_SCAN_REGULAR		= BIT(0),
+	IWL_MVM_SCAN_SCHED		= BIT(1),
+
+	IWL_MVM_SCAN_STOPPING_REGULAR	= BIT(8),
+	IWL_MVM_SCAN_STOPPING_SCHED	= BIT(9),
+
+	IWL_MVM_SCAN_REGULAR_MASK	= IWL_MVM_SCAN_REGULAR |
+					  IWL_MVM_SCAN_STOPPING_REGULAR,
+	IWL_MVM_SCAN_SCHED_MASK		= IWL_MVM_SCAN_SCHED |
+					  IWL_MVM_SCAN_STOPPING_SCHED,
+
+	IWL_MVM_SCAN_STOPPING_MASK	= 0xff00,
+	IWL_MVM_SCAN_MASK		= 0x00ff,
 };
 
 /**
@@ -647,7 +657,7 @@ struct iwl_mvm {
 	u32 rts_threshold;
 
 	/* Scan status, cmd (pre-allocated) and auxiliary station */
-	enum iwl_scan_status scan_status;
+	unsigned int scan_status;
 	void *scan_cmd;
 	struct iwl_mcast_filter_cmd *mcast_filter_cmd;
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 8a0b244..833d078 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -6,7 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications 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
@@ -32,7 +32,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -358,36 +358,58 @@ int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm,
 					   struct iwl_device_cmd *cmd)
 {
 	struct iwl_rx_packet *pkt = rxb_addr(rxb);
-	struct iwl_periodic_scan_complete *scan_notif;
-
-	scan_notif = (void *)pkt->data;
+	struct iwl_periodic_scan_complete *scan_notif = (void *)pkt->data;
+	bool aborted = (scan_notif->status == IWL_SCAN_OFFLOAD_ABORTED);
+	bool ebs_successful = (scan_notif->ebs_status == IWL_SCAN_EBS_SUCCESS);
 
 	/* scan status must be locked for proper checking */
 	lockdep_assert_held(&mvm->mutex);
 
-	IWL_DEBUG_SCAN(mvm,
-		       "%s completed, status %s, EBS status %s\n",
-		       mvm->scan_status == IWL_MVM_SCAN_SCHED ?
-				"Scheduled scan" : "Scan",
-		       scan_notif->status == IWL_SCAN_OFFLOAD_COMPLETED ?
-				"completed" : "aborted",
-		       scan_notif->ebs_status == IWL_SCAN_EBS_SUCCESS ?
-				"success" : "failed");
+	/* We first check if we were stopping a scan, in which case we
+	 * just clear the stopping flag.  Then we check if it was a
+	 * firmware initiated stop, in which case we need to inform
+	 * mac80211.
+	 * Note that we can have a stopping and a running scan
+	 * simultaneously, but we can't have two different types of
+	 * scans stopping or running at the same time (since LMAC
+	 * doesn't support it).
+	 */
+
+	if (mvm->scan_status & IWL_MVM_SCAN_STOPPING_SCHED) {
+		WARN_ON_ONCE(mvm->scan_status & IWL_MVM_SCAN_STOPPING_REGULAR);
+
+		IWL_DEBUG_SCAN(mvm, "Scheduled scan %s, EBS status %s\n",
+			       aborted ? "aborted" : "completed",
+			       ebs_successful ? "successful" : "failed");
 
+		mvm->scan_status &= ~IWL_MVM_SCAN_STOPPING_SCHED;
+	} else if (mvm->scan_status & IWL_MVM_SCAN_STOPPING_REGULAR) {
+		IWL_DEBUG_SCAN(mvm, "Regular scan %s, EBS status %s\n",
+			       aborted ? "aborted" : "completed",
+			       ebs_successful ? "successful" : "failed");
 
-	/* only call mac80211 completion if the stop was initiated by FW */
-	if (mvm->scan_status == IWL_MVM_SCAN_SCHED) {
-		mvm->scan_status = IWL_MVM_SCAN_NONE;
+		mvm->scan_status &= ~IWL_MVM_SCAN_STOPPING_REGULAR;
+	} else if (mvm->scan_status & IWL_MVM_SCAN_SCHED) {
+		WARN_ON_ONCE(mvm->scan_status & IWL_MVM_SCAN_REGULAR);
+
+		IWL_DEBUG_SCAN(mvm, "Scheduled scan %s, EBS status %s (FW)\n",
+			       aborted ? "aborted" : "completed",
+			       ebs_successful ? "successful" : "failed");
+
+		mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
 		ieee80211_sched_scan_stopped(mvm->hw);
-	} else if (mvm->scan_status == IWL_MVM_SCAN_OS) {
-		mvm->scan_status = IWL_MVM_SCAN_NONE;
+	} else if (mvm->scan_status & IWL_MVM_SCAN_REGULAR) {
+		IWL_DEBUG_SCAN(mvm, "Regular scan %s, EBS status %s (FW)\n",
+			       aborted ? "aborted" : "completed",
+			       ebs_successful ? "successful" : "failed");
+
+		mvm->scan_status &= ~IWL_MVM_SCAN_REGULAR;
 		ieee80211_scan_completed(mvm->hw,
 				scan_notif->status == IWL_SCAN_OFFLOAD_ABORTED);
 		iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
 	}
 
-	if (scan_notif->ebs_status)
-		mvm->last_ebs_successful = false;
+	mvm->last_ebs_successful = ebs_successful;
 
 	return 0;
 }
@@ -544,7 +566,7 @@ int iwl_mvm_scan_offload_start(struct iwl_mvm *mvm,
 			return ret;
 		ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies);
 	} else {
-		mvm->scan_status = IWL_MVM_SCAN_SCHED;
+		mvm->scan_status |= IWL_MVM_SCAN_SCHED;
 		ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
 		if (ret)
 			return ret;
@@ -565,7 +587,7 @@ static int iwl_mvm_send_scan_offload_abort(struct iwl_mvm *mvm)
 	/* Exit instantly with error when device is not ready
 	 * to receive scan abort command or it does not perform
 	 * scheduled scan currently */
-	if (mvm->scan_status == IWL_MVM_SCAN_NONE)
+	if (!mvm->scan_status)
 		return -EIO;
 
 	ret = iwl_mvm_send_cmd_status(mvm, &cmd, &status);
@@ -592,7 +614,7 @@ int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify)
 	int ret;
 	struct iwl_notification_wait wait_scan_done;
 	static const u8 scan_done_notif[] = { SCAN_OFFLOAD_COMPLETE, };
-	bool sched = mvm->scan_status == IWL_MVM_SCAN_SCHED;
+	bool sched = !!(mvm->scan_status & IWL_MVM_SCAN_SCHED);
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -600,7 +622,11 @@ int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify)
 		return iwl_umac_scan_stop(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN,
 					  notify);
 
-	if (mvm->scan_status == IWL_MVM_SCAN_NONE)
+	/* FIXME: For now we only check if no scan is set here, since
+	 * we only support LMAC in this flow and it doesn't support
+	 * multiple scans.
+	 */
+	if (!mvm->scan_status)
 		return 0;
 
 	if (iwl_mvm_is_radio_killed(mvm)) {
@@ -622,25 +648,28 @@ int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify)
 	}
 
 	IWL_DEBUG_SCAN(mvm, "Successfully sent stop %sscan\n",
-		       sched ? "offloaded " : "");
+		       sched ? "scheduled " : "");
 
 	ret = iwl_wait_notification(&mvm->notif_wait, &wait_scan_done, 1 * HZ);
 out:
-	/*
-	 * Clear the scan status so the next scan requests will succeed. This
-	 * also ensures the Rx handler doesn't do anything, as the scan was
-	 * stopped from above. Since the rx handler won't do anything now,
-	 * we have to release the scan reference here.
+	/* Clear the scan status so the next scan requests will
+	 * succeed and mark the scan as stopping, so that the Rx
+	 * handler doesn't do anything, as the scan was stopped from
+	 * above. Since the rx handler won't do anything now, we have
+	 * to release the scan reference here.
 	 */
-	if (mvm->scan_status == IWL_MVM_SCAN_OS)
+	if (mvm->scan_status == IWL_MVM_SCAN_REGULAR)
 		iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
 
-	mvm->scan_status = IWL_MVM_SCAN_NONE;
-
-	if (notify) {
-		if (sched)
+	if (sched) {
+		mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
+		mvm->scan_status |= IWL_MVM_SCAN_STOPPING_SCHED;
+		if (notify)
 			ieee80211_sched_scan_stopped(mvm->hw);
-		else
+	} else {
+		mvm->scan_status &= ~IWL_MVM_SCAN_REGULAR;
+		mvm->scan_status |= IWL_MVM_SCAN_STOPPING_REGULAR;
+		if (notify)
 			ieee80211_scan_completed(mvm->hw, true);
 	}
 
@@ -829,7 +858,7 @@ int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
 	    req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels)
 		return -ENOBUFS;
 
-	mvm->scan_status = IWL_MVM_SCAN_OS;
+	mvm->scan_status |= IWL_MVM_SCAN_REGULAR;
 
 	iwl_mvm_scan_calc_params(mvm, vif, req->req.n_ssids, req->req.flags,
 				 &params);
@@ -906,7 +935,7 @@ int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
 		 * should try to send the command again with different params.
 		 */
 		IWL_ERR(mvm, "Scan failed! ret %d\n", ret);
-		mvm->scan_status = IWL_MVM_SCAN_NONE;
+		mvm->scan_status &= ~IWL_MVM_SCAN_REGULAR;
 		ret = -EIO;
 	}
 	return ret;
@@ -1026,7 +1055,7 @@ int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
 		 * should try to send the command again with different params.
 		 */
 		IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
-		mvm->scan_status = IWL_MVM_SCAN_NONE;
+		mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
 		ret = -EIO;
 	}
 	return ret;
@@ -1039,13 +1068,13 @@ int iwl_mvm_cancel_scan(struct iwl_mvm *mvm)
 		return iwl_umac_scan_stop(mvm, IWL_UMAC_SCAN_UID_REG_SCAN,
 					  true);
 
-	if (mvm->scan_status == IWL_MVM_SCAN_NONE)
+	if (!(mvm->scan_status & IWL_MVM_SCAN_REGULAR))
 		return 0;
 
 	if (iwl_mvm_is_radio_killed(mvm)) {
 		ieee80211_scan_completed(mvm->hw, true);
 		iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
-		mvm->scan_status = IWL_MVM_SCAN_NONE;
+		mvm->scan_status &= ~IWL_MVM_SCAN_REGULAR;
 		return 0;
 	}
 
@@ -1682,21 +1711,14 @@ void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm)
 				mvm->scan_uid[i] = 0;
 		}
 	} else {
-		switch (mvm->scan_status) {
-		case IWL_MVM_SCAN_NONE:
-			break;
-		case IWL_MVM_SCAN_OS:
+		if (mvm->scan_status & IWL_MVM_SCAN_REGULAR)
 			ieee80211_scan_completed(mvm->hw, true);
-			break;
-		case IWL_MVM_SCAN_SCHED:
-			/*
-			 * Sched scan will be restarted by mac80211 in
-			 * restart_hw, so do not report if FW is about to be
-			 * restarted.
-			 */
-			if (!mvm->restart_fw)
-				ieee80211_sched_scan_stopped(mvm->hw);
-			break;
-		}
+
+		/* Sched scan will be restarted by mac80211 in
+		 * restart_hw, so do not report if FW is about to be
+		 * restarted.
+		 */
+		if ((mvm->scan_status & IWL_MVM_SCAN_SCHED) && !mvm->restart_fw)
+			ieee80211_sched_scan_stopped(mvm->hw);
 	}
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 07/42] iwlwifi: mvm: don't wait for scan stopped work when cancelling scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (5 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 06/42] iwlwifi: mvm: convert scan_status to a bitmap Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 08/42] iwlwifi: mvm: check if scan can be started before cancelling other scans Emmanuel Grumbach
                   ` (35 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Now that we have separate flags for stopping scans, we don't need to
wait for the scan stopped work to complete before starting the new
scan.  Previously we needed it because we had no way of distinguishing
the scan that was being stopped from the scan that was currently
running.  With the new flags there won't be any confusions and we are
able to handle the stop for the correct type of scan.

Thus we can remove the iwl_mvm_cancel_scan_wait_notif() function.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c | 65 ++++++-----------------------
 1 file changed, 12 insertions(+), 53 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index aff7de7..15dc4a4 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -2373,49 +2373,6 @@ static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
 	iwl_mvm_unref(mvm, IWL_MVM_REF_BSS_CHANGED);
 }
 
-static int iwl_mvm_cancel_scan_wait_notif(struct iwl_mvm *mvm,
-					  unsigned int scan_type)
-{
-	int ret;
-	bool wait_for_handlers = false;
-
-	mutex_lock(&mvm->mutex);
-
-	if (!(mvm->scan_status & scan_type)) {
-		ret = 0;
-		/* make sure there are no pending notifications */
-		wait_for_handlers = true;
-		goto out;
-	}
-
-	/* It's okay to switch on bitmask values here, because we can
-	 * only stop one scan type at a time.
-	 */
-	switch (scan_type) {
-	case IWL_MVM_SCAN_SCHED:
-		ret = iwl_mvm_scan_offload_stop(mvm, true);
-		break;
-	case IWL_MVM_SCAN_REGULAR:
-		ret = iwl_mvm_cancel_scan(mvm);
-		break;
-	default:
-		WARN_ON_ONCE(1);
-		ret = -EINVAL;
-		break;
-	}
-	if (ret)
-		goto out;
-
-	wait_for_handlers = true;
-out:
-	mutex_unlock(&mvm->mutex);
-
-	/* make sure we consume the completion notification */
-	if (wait_for_handlers)
-		iwl_mvm_wait_for_async_handlers(mvm);
-
-	return ret;
-}
 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 			       struct ieee80211_vif *vif,
 			       struct ieee80211_scan_request *hw_req)
@@ -2428,14 +2385,15 @@ static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 	    req->n_channels > mvm->fw->ucode_capa.n_scan_channels)
 		return -EINVAL;
 
-	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
-		ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_SCHED);
+	mutex_lock(&mvm->mutex);
+
+	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
+	    (mvm->scan_status & IWL_MVM_SCAN_SCHED)) {
+		ret = iwl_mvm_scan_offload_stop(mvm, true);
 		if (ret)
-			return ret;
+			goto out;
 	}
 
-	mutex_lock(&mvm->mutex);
-
 	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
 		IWL_ERR(mvm, "scan while LAR regdomain is not set\n");
 		ret = -EBUSY;
@@ -2798,14 +2756,15 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
 	int ret;
 
-	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
-		ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_REGULAR);
+	mutex_lock(&mvm->mutex);
+
+	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
+	    (mvm->scan_status & IWL_MVM_SCAN_REGULAR)) {
+		ret = iwl_mvm_cancel_scan(mvm);
 		if (ret)
-			return ret;
+			goto out;
 	}
 
-	mutex_lock(&mvm->mutex);
-
 	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
 		IWL_ERR(mvm, "sched-scan while LAR regdomain is not set\n");
 		ret = -EBUSY;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 08/42] iwlwifi: mvm: check if scan can be started before cancelling other scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (6 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 07/42] iwlwifi: mvm: don't wait for scan stopped work when cancelling scans Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 09/42] iwlwifi: mvm: generalize the other-scan stopping code Emmanuel Grumbach
                   ` (34 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

If a new scan cannot be run for some reason, we shouldn't cancel other
ongoing scans.  Move the checks to before the code that cancels other
scans.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 15dc4a4..f57d584 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -2387,13 +2387,6 @@ static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 
 	mutex_lock(&mvm->mutex);
 
-	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
-	    (mvm->scan_status & IWL_MVM_SCAN_SCHED)) {
-		ret = iwl_mvm_scan_offload_stop(mvm, true);
-		if (ret)
-			goto out;
-	}
-
 	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
 		IWL_ERR(mvm, "scan while LAR regdomain is not set\n");
 		ret = -EBUSY;
@@ -2405,6 +2398,13 @@ static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 		goto out;
 	}
 
+	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
+	    (mvm->scan_status & IWL_MVM_SCAN_SCHED)) {
+		ret = iwl_mvm_scan_offload_stop(mvm, true);
+		if (ret)
+			goto out;
+	}
+
 	iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN);
 
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
@@ -2758,13 +2758,6 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 
 	mutex_lock(&mvm->mutex);
 
-	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
-	    (mvm->scan_status & IWL_MVM_SCAN_REGULAR)) {
-		ret = iwl_mvm_cancel_scan(mvm);
-		if (ret)
-			goto out;
-	}
-
 	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
 		IWL_ERR(mvm, "sched-scan while LAR regdomain is not set\n");
 		ret = -EBUSY;
@@ -2781,6 +2774,13 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 		goto out;
 	}
 
+	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
+	    (mvm->scan_status & IWL_MVM_SCAN_REGULAR)) {
+		ret = iwl_mvm_cancel_scan(mvm);
+		if (ret)
+			goto out;
+	}
+
 	ret = iwl_mvm_scan_offload_start(mvm, vif, req, ies);
 	if (ret)
 		mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 09/42] iwlwifi: mvm: generalize the other-scan stopping code
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (7 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 08/42] iwlwifi: mvm: check if scan can be started before cancelling other scans Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 10/42] iwlwifi: mvm: rename unified_scan symbols to just scan Emmanuel Grumbach
                   ` (33 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Instead of hardcoding the differences between UMAC scans and LMAC
scans (which in this case is the number of simultaneous scans that can
run), introduce a max_scans variable and stop scans of the other type
(i.e. stop sched scan if regular scan is being attempted and
vice-versa) if the number of running scans reached the maximum.

Add a function that checks if the maximum number of scans was reached
and stops the appropriate scan to make room for the new scan.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h | 10 ++--
 drivers/net/wireless/iwlwifi/mvm/mac80211.c    | 74 ++++++++++++++++++--------
 drivers/net/wireless/iwlwifi/mvm/mvm.h         |  5 +-
 drivers/net/wireless/iwlwifi/mvm/scan.c        | 25 +++++----
 4 files changed, 76 insertions(+), 38 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
index d6cced4..69daa4e 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
@@ -6,7 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications 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
@@ -32,7 +32,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -582,7 +582,11 @@ struct iwl_mvm_umac_cmd_hdr {
 	u8 ver;
 } __packed;
 
-#define IWL_MVM_MAX_SIMULTANEOUS_SCANS 8
+/* The maximum of either of these cannot exceed 8, because we use an
+ * 8-bit mask (see IWL_MVM_SCAN_MASK in mvm.h).
+ */
+#define IWL_MVM_MAX_UMAC_SCANS 8
+#define IWL_MVM_MAX_LMAC_SCANS 1
 
 enum scan_config_flags {
 	SCAN_CONFIG_FLAG_ACTIVATE			= BIT(0),
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index f57d584..a5fe070 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -510,6 +510,14 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 
 	hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
 
+	BUILD_BUG_ON(IWL_MVM_MAX_UMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK) ||
+		     IWL_MVM_MAX_LMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK));
+
+	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
+		mvm->max_scans = IWL_MVM_MAX_UMAC_SCANS;
+	else
+		mvm->max_scans = IWL_MVM_MAX_LMAC_SCANS;
+
 	if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels)
 		hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
 			&mvm->nvm_data->bands[IEEE80211_BAND_2GHZ];
@@ -1426,7 +1434,7 @@ void __iwl_mvm_mac_stop(struct iwl_mvm *mvm)
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
 		int i;
 
-		for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) {
+		for (i = 0; i < mvm->max_scans; i++) {
 			if (WARN_ONCE(mvm->scan_uid[i],
 				      "UMAC scan UID %d was not cleaned\n",
 				      mvm->scan_uid[i]))
@@ -2373,6 +2381,46 @@ static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
 	iwl_mvm_unref(mvm, IWL_MVM_REF_BSS_CHANGED);
 }
 
+static int iwl_mvm_num_scans(struct iwl_mvm *mvm)
+{
+	return hweight32(mvm->scan_status & IWL_MVM_SCAN_MASK);
+}
+
+static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type)
+{
+	/* This looks a bit arbitrary, but the idea is that if we run
+	 * out of possible simultaneous scans and the userspace is
+	 * trying to run a scan type that is already running, we
+	 * return -EBUSY.  But if the userspace wants to start a
+	 * different type of scan, we stop the opposite type to make
+	 * space for the new request.  The reason is backwards
+	 * compatibility with old wpa_supplicant that wouldn't stop a
+	 * scheduled scan before starting a normal scan.
+	 */
+
+	if (iwl_mvm_num_scans(mvm) < mvm->max_scans)
+		return 0;
+
+	/* Use a switch, even though this is a bitmask, so that more
+	 * than one bits set will fall in default and we will warn.
+	 */
+	switch (type) {
+	case IWL_MVM_SCAN_REGULAR:
+		if (mvm->scan_status & IWL_MVM_SCAN_REGULAR_MASK)
+			return -EBUSY;
+		return iwl_mvm_scan_offload_stop(mvm, true);
+	case IWL_MVM_SCAN_SCHED:
+		if (mvm->scan_status & IWL_MVM_SCAN_SCHED_MASK)
+			return -EBUSY;
+		return iwl_mvm_cancel_scan(mvm);
+	default:
+		WARN_ON(1);
+		break;
+	}
+
+	return -EIO;
+}
+
 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 			       struct ieee80211_vif *vif,
 			       struct ieee80211_scan_request *hw_req)
@@ -2393,17 +2441,9 @@ static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 		goto out;
 	}
 
-	if (mvm->scan_status & IWL_MVM_SCAN_REGULAR) {
-		ret = -EBUSY;
+	ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_REGULAR);
+	if (ret)
 		goto out;
-	}
-
-	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
-	    (mvm->scan_status & IWL_MVM_SCAN_SCHED)) {
-		ret = iwl_mvm_scan_offload_stop(mvm, true);
-		if (ret)
-			goto out;
-	}
 
 	iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN);
 
@@ -2769,17 +2809,9 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 		goto out;
 	}
 
-	if (mvm->scan_status & IWL_MVM_SCAN_SCHED) {
-		ret = -EBUSY;
+	ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_SCHED);
+	if (ret)
 		goto out;
-	}
-
-	if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) &&
-	    (mvm->scan_status & IWL_MVM_SCAN_REGULAR)) {
-		ret = iwl_mvm_cancel_scan(mvm);
-		if (ret)
-			goto out;
-	}
 
 	ret = iwl_mvm_scan_offload_start(mvm, vif, req, ies);
 	if (ret)
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index a8648fa..cb99eb7 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -661,8 +661,11 @@ struct iwl_mvm {
 	void *scan_cmd;
 	struct iwl_mcast_filter_cmd *mcast_filter_cmd;
 
+	/* max number of simultaneous scans the FW supports */
+	unsigned int max_scans;
+
 	/* UMAC scan tracking */
-	u32 scan_uid[IWL_MVM_MAX_SIMULTANEOUS_SCANS];
+	u32 scan_uid[IWL_MVM_MAX_UMAC_SCANS];
 	u8 scan_seq_num, sched_scan_seq_num;
 
 	/* rx chain antennas set through debugfs for the scan command */
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 833d078..3721b16 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -1200,7 +1200,7 @@ static int iwl_mvm_find_scan_uid(struct iwl_mvm *mvm, u32 uid)
 {
 	int i;
 
-	for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++)
+	for (i = 0; i < mvm->max_scans; i++)
 		if (mvm->scan_uid[i] == uid)
 			return i;
 
@@ -1217,7 +1217,7 @@ static bool iwl_mvm_find_scan_type(struct iwl_mvm *mvm,
 {
 	int i;
 
-	for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++)
+	for (i = 0; i < mvm->max_scans; i++)
 		if (mvm->scan_uid[i] & type)
 			return true;
 
@@ -1229,7 +1229,7 @@ static int iwl_mvm_find_first_scan(struct iwl_mvm *mvm,
 {
 	int i;
 
-	for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++)
+	for (i = 0; i < mvm->max_scans; i++)
 		if (mvm->scan_uid[i] & type)
 			return i;
 
@@ -1253,8 +1253,7 @@ static u32 iwl_generate_scan_uid(struct iwl_mvm *mvm,
 		uid = type | (mvm->scan_seq_num <<
 			      IWL_UMAC_SCAN_UID_SEQ_OFFSET);
 		mvm->scan_seq_num++;
-	} while (iwl_mvm_find_scan_uid(mvm, uid) <
-		 IWL_MVM_MAX_SIMULTANEOUS_SCANS);
+	} while (iwl_mvm_find_scan_uid(mvm, uid) < mvm->max_scans);
 
 	IWL_DEBUG_SCAN(mvm, "Generated scan UID %u\n", uid);
 
@@ -1338,7 +1337,7 @@ int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	lockdep_assert_held(&mvm->mutex);
 
 	uid_idx = iwl_mvm_find_free_scan_uid(mvm);
-	if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+	if (uid_idx >= mvm->max_scans)
 		return -EBUSY;
 
 	/* we should have failed registration if scan_cmd was NULL */
@@ -1435,7 +1434,7 @@ int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	lockdep_assert_held(&mvm->mutex);
 
 	uid_idx = iwl_mvm_find_free_scan_uid(mvm);
-	if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+	if (uid_idx >= mvm->max_scans)
 		return -EBUSY;
 
 	/* we should have failed registration if scan_cmd was NULL */
@@ -1536,7 +1535,7 @@ int iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
 	/*
 	 * Scan uid may be set to zero in case of scan abort request from above.
 	 */
-	if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+	if (uid_idx >= mvm->max_scans)
 		return 0;
 
 	IWL_DEBUG_SCAN(mvm,
@@ -1577,7 +1576,7 @@ static bool iwl_scan_umac_done_check(struct iwl_notif_wait_data *notif_wait,
 	if (WARN_ON(pkt->hdr.cmd != SCAN_COMPLETE_UMAC))
 		return false;
 
-	if (uid_idx >= IWL_MVM_MAX_SIMULTANEOUS_SCANS)
+	if (uid_idx >= scan_done->mvm->max_scans)
 		return false;
 
 	/*
@@ -1626,7 +1625,7 @@ static int iwl_umac_scan_stop(struct iwl_mvm *mvm,
 
 	IWL_DEBUG_SCAN(mvm, "Preparing to stop scan, type %x\n", type);
 
-	for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) {
+	for (i = 0; i < mvm->max_scans; i++) {
 		if (mvm->scan_uid[i] & type) {
 			int err;
 
@@ -1689,13 +1688,13 @@ void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm)
 		u32 uid, i;
 
 		uid = iwl_mvm_find_first_scan(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
-		if (uid < IWL_MVM_MAX_SIMULTANEOUS_SCANS) {
+		if (uid < mvm->max_scans) {
 			ieee80211_scan_completed(mvm->hw, true);
 			mvm->scan_uid[uid] = 0;
 		}
 		uid = iwl_mvm_find_first_scan(mvm,
 					      IWL_UMAC_SCAN_UID_SCHED_SCAN);
-		if (uid < IWL_MVM_MAX_SIMULTANEOUS_SCANS && !mvm->restart_fw) {
+		if (uid < mvm->max_scans && !mvm->restart_fw) {
 			ieee80211_sched_scan_stopped(mvm->hw);
 			mvm->scan_uid[uid] = 0;
 		}
@@ -1704,7 +1703,7 @@ void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm)
 		 * UIDs to make sure there's nothing left there and warn if
 		 * any is found.
 		 */
-		for (i = 0; i < IWL_MVM_MAX_SIMULTANEOUS_SCANS; i++) {
+		for (i = 0; i < mvm->max_scans; i++) {
 			if (WARN_ONCE(mvm->scan_uid[i],
 				      "UMAC scan UID %d was not cleaned\n",
 				      mvm->scan_uid[i]))
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 10/42] iwlwifi: mvm: rename unified_scan symbols to just scan
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (8 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 09/42] iwlwifi: mvm: generalize the other-scan stopping code Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 11/42] iwlwifi: mvm: move scan code from mac80211.c to scan.c Emmanuel Grumbach
                   ` (32 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

All scans are using the unified APIs now, so using "unified" in the
symbols is useless and just make them much longer and the main
difference between scans now is LMAC vs. UMAC.  Remove "unified" from
all relevant symbols.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/d3.c          |   6 +-
 drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h |   4 +-
 drivers/net/wireless/iwlwifi/mvm/mac80211.c    |   6 +-
 drivers/net/wireless/iwlwifi/mvm/mvm.h         |  20 ++---
 drivers/net/wireless/iwlwifi/mvm/scan.c        | 107 ++++++++++++-------------
 5 files changed, 68 insertions(+), 75 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c
index 1b1b2bf..e82a47b 100644
--- a/drivers/net/wireless/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/iwlwifi/mvm/d3.c
@@ -6,7 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications 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
@@ -32,7 +32,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -981,7 +981,7 @@ iwl_mvm_netdetect_config(struct iwl_mvm *mvm,
 	if (ret)
 		return ret;
 
-	ret = iwl_mvm_scan_offload_start(mvm, vif, nd_config, &mvm->nd_ies);
+	ret = iwl_mvm_sched_scan_start(mvm, vif, nd_config, &mvm->nd_ies);
 	if (ret)
 		return ret;
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
index 69daa4e..d74615f 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
@@ -464,7 +464,7 @@ enum iwl_scan_priority {
 };
 
 /**
- * iwl_scan_req_unified_lmac - SCAN_REQUEST_CMD_API_S_VER_1
+ * iwl_scan_req_lmac - SCAN_REQUEST_CMD_API_S_VER_1
  * @reserved1: for alignment and future use
  * @channel_num: num of channels to scan
  * @active-dwell: dwell time for active channels
@@ -487,7 +487,7 @@ enum iwl_scan_priority {
  * @channel_opt: channel optimization options, for full and partial scan
  * @data: channel configuration and probe request packet.
  */
-struct iwl_scan_req_unified_lmac {
+struct iwl_scan_req_lmac {
 	/* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
 	__le32 reserved1;
 	u8 n_channels;
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index a5fe070..6350ca2 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -2450,7 +2450,7 @@ static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
 		ret = iwl_mvm_scan_umac(mvm, vif, hw_req);
 	else
-		ret = iwl_mvm_unified_scan_lmac(mvm, vif, hw_req);
+		ret = iwl_mvm_scan_lmac(mvm, vif, hw_req);
 
 	if (ret)
 		iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
@@ -2813,9 +2813,7 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 	if (ret)
 		goto out;
 
-	ret = iwl_mvm_scan_offload_start(mvm, vif, req, ies);
-	if (ret)
-		mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
+	ret = iwl_mvm_sched_scan_start(mvm, vif, req, ies);
 
 out:
 	mutex_unlock(&mvm->mutex);
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index cb99eb7..be1d277 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -1173,23 +1173,19 @@ int iwl_mvm_rx_scan_offload_iter_complete_notif(struct iwl_mvm *mvm,
 						struct iwl_device_cmd *cmd);
 int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
 				       struct cfg80211_sched_scan_request *req);
-int iwl_mvm_scan_offload_start(struct iwl_mvm *mvm,
-			       struct ieee80211_vif *vif,
-			       struct cfg80211_sched_scan_request *req,
-			       struct ieee80211_scan_ies *ies);
+int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
+			     struct ieee80211_vif *vif,
+			     struct cfg80211_sched_scan_request *req,
+			     struct ieee80211_scan_ies *ies);
 int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify);
 int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm,
 				    struct iwl_rx_cmd_buffer *rxb,
 				    struct iwl_device_cmd *cmd);
 
-/* Unified scan */
-int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
-			      struct ieee80211_vif *vif,
-			      struct ieee80211_scan_request *req);
-int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
-				    struct ieee80211_vif *vif,
-				    struct cfg80211_sched_scan_request *req,
-				    struct ieee80211_scan_ies *ies);
+/* LMAC scan */
+int iwl_mvm_scan_lmac(struct iwl_mvm *mvm,
+		      struct ieee80211_vif *vif,
+		      struct ieee80211_scan_request *req);
 
 /* UMAC scan */
 int iwl_mvm_config_scan(struct iwl_mvm *mvm);
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 3721b16..62efc75 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -553,29 +553,6 @@ static bool iwl_mvm_scan_pass_all(struct iwl_mvm *mvm,
 	return true;
 }
 
-int iwl_mvm_scan_offload_start(struct iwl_mvm *mvm,
-			       struct ieee80211_vif *vif,
-			       struct cfg80211_sched_scan_request *req,
-			       struct ieee80211_scan_ies *ies)
-{
-	int ret;
-
-	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
-		ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
-		if (ret)
-			return ret;
-		ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies);
-	} else {
-		mvm->scan_status |= IWL_MVM_SCAN_SCHED;
-		ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
-		if (ret)
-			return ret;
-		ret = iwl_mvm_unified_sched_scan_lmac(mvm, vif, req, ies);
-	}
-
-	return ret;
-}
-
 static int iwl_mvm_send_scan_offload_abort(struct iwl_mvm *mvm)
 {
 	int ret;
@@ -676,9 +653,9 @@ out:
 	return ret;
 }
 
-static void iwl_mvm_unified_scan_fill_tx_cmd(struct iwl_mvm *mvm,
-					     struct iwl_scan_req_tx_cmd *tx_cmd,
-					     bool no_cck)
+static void iwl_mvm_scan_fill_tx_cmd(struct iwl_mvm *mvm,
+				     struct iwl_scan_req_tx_cmd *tx_cmd,
+				     bool no_cck)
 {
 	tx_cmd[0].tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL |
 					 TX_CMD_FLG_BT_DIS);
@@ -699,7 +676,7 @@ static void
 iwl_mvm_lmac_scan_cfg_channels(struct iwl_mvm *mvm,
 			       struct ieee80211_channel **channels,
 			       int n_channels, u32 ssid_bitmap,
-			       struct iwl_scan_req_unified_lmac *cmd)
+			       struct iwl_scan_req_lmac *cmd)
 {
 	struct iwl_scan_channel_cfg_lmac *channel_cfg = (void *)&cmd->data;
 	int i;
@@ -752,10 +729,10 @@ static u8 *iwl_mvm_copy_and_insert_ds_elem(struct iwl_mvm *mvm, const u8 *ies,
 }
 
 static void
-iwl_mvm_build_unified_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-				 struct ieee80211_scan_ies *ies,
-				 struct iwl_scan_probe_req *preq,
-				 const u8 *mac_addr, const u8 *mac_addr_mask)
+iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			 struct ieee80211_scan_ies *ies,
+			 struct iwl_scan_probe_req *preq,
+			 const u8 *mac_addr, const u8 *mac_addr_mask)
 {
 	struct ieee80211_mgmt *frame = (struct ieee80211_mgmt *)preq->buf;
 	u8 *pos, *newpos;
@@ -804,9 +781,9 @@ iwl_mvm_build_unified_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 }
 
 static void
-iwl_mvm_build_generic_unified_scan_cmd(struct iwl_mvm *mvm,
-				       struct iwl_scan_req_unified_lmac *cmd,
-				       struct iwl_mvm_scan_params *params)
+iwl_mvm_build_generic_scan_cmd(struct iwl_mvm *mvm,
+			       struct iwl_scan_req_lmac *cmd,
+			       struct iwl_mvm_scan_params *params)
 {
 	memset(cmd, 0, ksize(cmd));
 	cmd->active_dwell = params->dwell[IEEE80211_BAND_2GHZ].active;
@@ -825,20 +802,20 @@ iwl_mvm_build_generic_unified_scan_cmd(struct iwl_mvm *mvm,
 			cpu_to_le32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED);
 }
 
-int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
-			      struct ieee80211_vif *vif,
-			      struct ieee80211_scan_request *req)
+int iwl_mvm_scan_lmac(struct iwl_mvm *mvm,
+		      struct ieee80211_vif *vif,
+		      struct ieee80211_scan_request *req)
 {
 	struct iwl_host_cmd hcmd = {
 		.id = SCAN_OFFLOAD_REQUEST_CMD,
-		.len = { sizeof(struct iwl_scan_req_unified_lmac) +
+		.len = { sizeof(struct iwl_scan_req_lmac) +
 			 sizeof(struct iwl_scan_channel_cfg_lmac) *
 				mvm->fw->ucode_capa.n_scan_channels +
 			 sizeof(struct iwl_scan_probe_req), },
 		.data = { mvm->scan_cmd, },
 		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
 	};
-	struct iwl_scan_req_unified_lmac *cmd = mvm->scan_cmd;
+	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq;
 	struct iwl_mvm_scan_params params = {};
 	u32 flags;
@@ -863,7 +840,7 @@ int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
 	iwl_mvm_scan_calc_params(mvm, vif, req->req.n_ssids, req->req.flags,
 				 &params);
 
-	iwl_mvm_build_generic_unified_scan_cmd(mvm, cmd, &params);
+	iwl_mvm_build_generic_scan_cmd(mvm, cmd, &params);
 
 	cmd->n_channels = (u8)req->req.n_channels;
 
@@ -883,7 +860,7 @@ int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
 	cmd->flags = iwl_mvm_scan_rxon_flags(req->req.channels[0]->band);
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
-	iwl_mvm_unified_scan_fill_tx_cmd(mvm, cmd->tx_cmd, req->req.no_cck);
+	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, req->req.no_cck);
 	iwl_mvm_scan_fill_ssids(cmd->direct_scan, req->req.ssids,
 				req->req.n_ssids, 0);
 
@@ -920,7 +897,7 @@ int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
 	preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			mvm->fw->ucode_capa.n_scan_channels);
 
-	iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, preq,
+	iwl_mvm_build_scan_probe(mvm, vif, &req->ies, preq,
 		req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
 			req->req.mac_addr : NULL,
 		req->req.mac_addr_mask);
@@ -941,21 +918,21 @@ int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
 	return ret;
 }
 
-int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
-				    struct ieee80211_vif *vif,
-				    struct cfg80211_sched_scan_request *req,
-				    struct ieee80211_scan_ies *ies)
+static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
+				   struct ieee80211_vif *vif,
+				   struct cfg80211_sched_scan_request *req,
+				   struct ieee80211_scan_ies *ies)
 {
 	struct iwl_host_cmd hcmd = {
 		.id = SCAN_OFFLOAD_REQUEST_CMD,
-		.len = { sizeof(struct iwl_scan_req_unified_lmac) +
+		.len = { sizeof(struct iwl_scan_req_lmac) +
 			 sizeof(struct iwl_scan_channel_cfg_lmac) *
 				mvm->fw->ucode_capa.n_scan_channels +
 			 sizeof(struct iwl_scan_probe_req), },
 		.data = { mvm->scan_cmd, },
 		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
 	};
-	struct iwl_scan_req_unified_lmac *cmd = mvm->scan_cmd;
+	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq;
 	struct iwl_mvm_scan_params params = {};
 	int ret;
@@ -976,7 +953,7 @@ int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
 
 	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, 0, &params);
 
-	iwl_mvm_build_generic_unified_scan_cmd(mvm, cmd, &params);
+	iwl_mvm_build_generic_scan_cmd(mvm, cmd, &params);
 
 	cmd->n_channels = (u8)req->n_channels;
 
@@ -1006,7 +983,7 @@ int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
 	cmd->flags = iwl_mvm_scan_rxon_flags(req->channels[0]->band);
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
-	iwl_mvm_unified_scan_fill_tx_cmd(mvm, cmd->tx_cmd, false);
+	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, false);
 	iwl_scan_offload_build_ssid(req, cmd->direct_scan, &ssid_bitmap, false);
 
 	cmd->schedule[0].delay = cpu_to_le16(req->interval / MSEC_PER_SEC);
@@ -1039,7 +1016,7 @@ int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
 	preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			mvm->fw->ucode_capa.n_scan_channels);
 
-	iwl_mvm_build_unified_scan_probe(mvm, vif, ies, preq,
+	iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
 		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
 			req->mac_addr : NULL,
 		req->mac_addr_mask);
@@ -1388,7 +1365,7 @@ int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	sec_part->schedule[0].iter_count = 1;
 	sec_part->delay = 0;
 
-	iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, &sec_part->preq,
+	iwl_mvm_build_scan_probe(mvm, vif, &req->ies, &sec_part->preq,
 		req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
 			req->req.mac_addr : NULL,
 		req->req.mac_addr_mask);
@@ -1502,7 +1479,7 @@ int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 		sec_part->delay = cpu_to_le16(req->delay);
 	}
 
-	iwl_mvm_build_unified_scan_probe(mvm, vif, ies, &sec_part->preq,
+	iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq,
 		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
 			req->mac_addr : NULL,
 		req->mac_addr_mask);
@@ -1522,6 +1499,28 @@ int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	return ret;
 }
 
+int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
+			     struct ieee80211_vif *vif,
+			     struct cfg80211_sched_scan_request *req,
+			     struct ieee80211_scan_ies *ies)
+{
+	int ret;
+
+	ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
+	if (ret)
+		return ret;
+
+	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
+		ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies);
+	} else {
+		ret = iwl_mvm_sched_scan_lmac(mvm, vif, req, ies);
+		if (!ret)
+			mvm->scan_status |= IWL_MVM_SCAN_SCHED;
+	}
+
+	return ret;
+}
+
 int iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
 					struct iwl_rx_cmd_buffer *rxb,
 					struct iwl_device_cmd *cmd)
@@ -1672,7 +1671,7 @@ int iwl_mvm_scan_size(struct iwl_mvm *mvm)
 				mvm->fw->ucode_capa.n_scan_channels +
 			sizeof(struct iwl_scan_req_umac_tail);
 
-	return sizeof(struct iwl_scan_req_unified_lmac) +
+	return sizeof(struct iwl_scan_req_lmac) +
 		sizeof(struct iwl_scan_channel_cfg_lmac) *
 		mvm->fw->ucode_capa.n_scan_channels +
 		sizeof(struct iwl_scan_probe_req);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 11/42] iwlwifi: mvm: move scan code from mac80211.c to scan.c
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (9 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 10/42] iwlwifi: mvm: rename unified_scan symbols to just scan Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 12/42] iwlwifi: mvm: differentiate net-detect from sched scan Emmanuel Grumbach
                   ` (31 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Move all the scan code that was in mac80211.c to scan.c where it
belongs, leaving only the parts that are specific to mac80211 ops.

Change some function definitions slightly to improve consistency.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c |  80 +------------
 drivers/net/wireless/iwlwifi/mvm/mvm.h      |  13 +--
 drivers/net/wireless/iwlwifi/mvm/scan.c     | 173 ++++++++++++++++++++--------
 3 files changed, 136 insertions(+), 130 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 6350ca2..ff3273a 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -80,7 +80,6 @@
 #include "sta.h"
 #include "time-event.h"
 #include "iwl-eeprom-parse.h"
-#include "fw-api-scan.h"
 #include "iwl-phy-db.h"
 #include "testmode.h"
 #include "iwl-fw-error-dump.h"
@@ -2381,81 +2380,21 @@ static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
 	iwl_mvm_unref(mvm, IWL_MVM_REF_BSS_CHANGED);
 }
 
-static int iwl_mvm_num_scans(struct iwl_mvm *mvm)
-{
-	return hweight32(mvm->scan_status & IWL_MVM_SCAN_MASK);
-}
-
-static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type)
-{
-	/* This looks a bit arbitrary, but the idea is that if we run
-	 * out of possible simultaneous scans and the userspace is
-	 * trying to run a scan type that is already running, we
-	 * return -EBUSY.  But if the userspace wants to start a
-	 * different type of scan, we stop the opposite type to make
-	 * space for the new request.  The reason is backwards
-	 * compatibility with old wpa_supplicant that wouldn't stop a
-	 * scheduled scan before starting a normal scan.
-	 */
-
-	if (iwl_mvm_num_scans(mvm) < mvm->max_scans)
-		return 0;
-
-	/* Use a switch, even though this is a bitmask, so that more
-	 * than one bits set will fall in default and we will warn.
-	 */
-	switch (type) {
-	case IWL_MVM_SCAN_REGULAR:
-		if (mvm->scan_status & IWL_MVM_SCAN_REGULAR_MASK)
-			return -EBUSY;
-		return iwl_mvm_scan_offload_stop(mvm, true);
-	case IWL_MVM_SCAN_SCHED:
-		if (mvm->scan_status & IWL_MVM_SCAN_SCHED_MASK)
-			return -EBUSY;
-		return iwl_mvm_cancel_scan(mvm);
-	default:
-		WARN_ON(1);
-		break;
-	}
-
-	return -EIO;
-}
-
 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
 			       struct ieee80211_vif *vif,
 			       struct ieee80211_scan_request *hw_req)
 {
 	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
-	struct cfg80211_scan_request *req = &hw_req->req;
 	int ret;
 
-	if (req->n_channels == 0 ||
-	    req->n_channels > mvm->fw->ucode_capa.n_scan_channels)
+	if (hw_req->req.n_channels == 0 ||
+	    hw_req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels)
 		return -EINVAL;
 
 	mutex_lock(&mvm->mutex);
-
-	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
-		IWL_ERR(mvm, "scan while LAR regdomain is not set\n");
-		ret = -EBUSY;
-		goto out;
-	}
-
-	ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_REGULAR);
-	if (ret)
-		goto out;
-
-	iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN);
-
-	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
-		ret = iwl_mvm_scan_umac(mvm, vif, hw_req);
-	else
-		ret = iwl_mvm_scan_lmac(mvm, vif, hw_req);
-
-	if (ret)
-		iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
-out:
+	ret = iwl_mvm_reg_scan_start(mvm, vif, &hw_req->req, &hw_req->ies);
 	mutex_unlock(&mvm->mutex);
+
 	return ret;
 }
 
@@ -2794,25 +2733,16 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 					struct ieee80211_scan_ies *ies)
 {
 	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
+
 	int ret;
 
 	mutex_lock(&mvm->mutex);
 
-	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
-		IWL_ERR(mvm, "sched-scan while LAR regdomain is not set\n");
-		ret = -EBUSY;
-		goto out;
-	}
-
 	if (!vif->bss_conf.idle) {
 		ret = -EBUSY;
 		goto out;
 	}
 
-	ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_SCHED);
-	if (ret)
-		goto out;
-
 	ret = iwl_mvm_sched_scan_start(mvm, vif, req, ies);
 
 out:
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index be1d277..bbe4d98 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -1159,6 +1159,9 @@ int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload,
 			  struct ieee80211_vif *disabled_vif);
 
 /* Scanning */
+int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			   struct cfg80211_scan_request *req,
+			   struct ieee80211_scan_ies *ies);
 int iwl_mvm_scan_size(struct iwl_mvm *mvm);
 int iwl_mvm_cancel_scan(struct iwl_mvm *mvm);
 int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan);
@@ -1182,18 +1185,8 @@ int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm,
 				    struct iwl_rx_cmd_buffer *rxb,
 				    struct iwl_device_cmd *cmd);
 
-/* LMAC scan */
-int iwl_mvm_scan_lmac(struct iwl_mvm *mvm,
-		      struct ieee80211_vif *vif,
-		      struct ieee80211_scan_request *req);
-
 /* UMAC scan */
 int iwl_mvm_config_scan(struct iwl_mvm *mvm);
-int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-		      struct ieee80211_scan_request *req);
-int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			    struct cfg80211_sched_scan_request *req,
-			    struct ieee80211_scan_ies *ies);
 int iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
 					struct iwl_rx_cmd_buffer *rxb,
 					struct iwl_device_cmd *cmd);
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 62efc75..3fe398e 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -802,9 +802,9 @@ iwl_mvm_build_generic_scan_cmd(struct iwl_mvm *mvm,
 			cpu_to_le32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED);
 }
 
-int iwl_mvm_scan_lmac(struct iwl_mvm *mvm,
-		      struct ieee80211_vif *vif,
-		      struct ieee80211_scan_request *req)
+static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			     struct cfg80211_scan_request *req,
+			     struct ieee80211_scan_ies *ies)
 {
 	struct iwl_host_cmd hcmd = {
 		.id = SCAN_OFFLOAD_REQUEST_CMD,
@@ -828,41 +828,41 @@ int iwl_mvm_scan_lmac(struct iwl_mvm *mvm,
 	if (WARN_ON(mvm->scan_cmd == NULL))
 		return -ENOMEM;
 
-	if (req->req.n_ssids > PROBE_OPTION_MAX ||
-	    req->ies.common_ie_len + req->ies.len[NL80211_BAND_2GHZ] +
-	    req->ies.len[NL80211_BAND_5GHZ] >
+	if (req->n_ssids > PROBE_OPTION_MAX ||
+	    ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] +
+	    ies->len[NL80211_BAND_5GHZ] >
 		iwl_mvm_max_scan_ie_fw_cmd_room(mvm, false) ||
-	    req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels)
+	    req->n_channels > mvm->fw->ucode_capa.n_scan_channels)
 		return -ENOBUFS;
 
 	mvm->scan_status |= IWL_MVM_SCAN_REGULAR;
 
-	iwl_mvm_scan_calc_params(mvm, vif, req->req.n_ssids, req->req.flags,
+	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
 				 &params);
 
 	iwl_mvm_build_generic_scan_cmd(mvm, cmd, &params);
 
-	cmd->n_channels = (u8)req->req.n_channels;
+	cmd->n_channels = (u8)req->n_channels;
 
 	flags = IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;
 
-	if (req->req.n_ssids == 1 && req->req.ssids[0].ssid_len != 0)
+	if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
 
 	if (params.passive_fragmented)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
 
-	if (req->req.n_ssids == 0)
+	if (req->n_ssids == 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE;
 
 	cmd->scan_flags |= cpu_to_le32(flags);
 
-	cmd->flags = iwl_mvm_scan_rxon_flags(req->req.channels[0]->band);
+	cmd->flags = iwl_mvm_scan_rxon_flags(req->channels[0]->band);
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
-	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, req->req.no_cck);
-	iwl_mvm_scan_fill_ssids(cmd->direct_scan, req->req.ssids,
-				req->req.n_ssids, 0);
+	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, req->no_cck);
+	iwl_mvm_scan_fill_ssids(cmd->direct_scan, req->ssids,
+				req->n_ssids, 0);
 
 	cmd->schedule[0].delay = 0;
 	cmd->schedule[0].iterations = 1;
@@ -887,20 +887,20 @@ int iwl_mvm_scan_lmac(struct iwl_mvm *mvm,
 			cpu_to_le16(IWL_SPARSE_EBS_SCAN_RATIO);
 	}
 
-	for (i = 1; i <= req->req.n_ssids; i++)
+	for (i = 1; i <= req->n_ssids; i++)
 		ssid_bitmap |= BIT(i);
 
-	iwl_mvm_lmac_scan_cfg_channels(mvm, req->req.channels,
-				       req->req.n_channels, ssid_bitmap,
+	iwl_mvm_lmac_scan_cfg_channels(mvm, req->channels,
+				       req->n_channels, ssid_bitmap,
 				       cmd);
 
 	preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			mvm->fw->ucode_capa.n_scan_channels);
 
-	iwl_mvm_build_scan_probe(mvm, vif, &req->ies, preq,
-		req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			req->req.mac_addr : NULL,
-		req->req.mac_addr_mask);
+	iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
+		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
+			req->mac_addr : NULL,
+		req->mac_addr_mask);
 
 	ret = iwl_mvm_send_cmd(mvm, &hcmd);
 	if (!ret) {
@@ -1293,8 +1293,9 @@ static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids,
 	return flags;
 }
 
-int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-		      struct ieee80211_scan_request *req)
+static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			     struct cfg80211_scan_request *req,
+			     struct ieee80211_scan_ies *ies)
 {
 	struct iwl_host_cmd hcmd = {
 		.id = SCAN_REQ_UMAC,
@@ -1321,15 +1322,15 @@ int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (WARN_ON(mvm->scan_cmd == NULL))
 		return -ENOMEM;
 
-	if (WARN_ON(req->req.n_ssids > PROBE_OPTION_MAX ||
-		    req->ies.common_ie_len +
-		    req->ies.len[NL80211_BAND_2GHZ] +
-		    req->ies.len[NL80211_BAND_5GHZ] + 24 + 2 >
-		    SCAN_OFFLOAD_PROBE_REQ_SIZE || req->req.n_channels >
+	if (WARN_ON(req->n_ssids > PROBE_OPTION_MAX ||
+		    ies->common_ie_len +
+		    ies->len[NL80211_BAND_2GHZ] +
+		    ies->len[NL80211_BAND_5GHZ] + 24 + 2 >
+		    SCAN_OFFLOAD_PROBE_REQ_SIZE || req->n_channels >
 		    mvm->fw->ucode_capa.n_scan_channels))
 		return -ENOBUFS;
 
-	iwl_mvm_scan_calc_params(mvm, vif, req->req.n_ssids, req->req.flags,
+	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
 				 &params);
 
 	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, &params);
@@ -1340,8 +1341,8 @@ int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
 
-	flags = iwl_mvm_scan_umac_common_flags(mvm, req->req.n_ssids,
-					       req->req.ssids,
+	flags = iwl_mvm_scan_umac_common_flags(mvm, req->n_ssids,
+					       req->ssids,
 					       params.passive_fragmented);
 
 	flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
@@ -1354,24 +1355,24 @@ int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 				     IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
 				     IWL_SCAN_CHANNEL_FLAG_CACHE_ADD;
 
-	cmd->n_channels = req->req.n_channels;
+	cmd->n_channels = req->n_channels;
 
-	for (i = 0; i < req->req.n_ssids; i++)
+	for (i = 0; i < req->n_ssids; i++)
 		ssid_bitmap |= BIT(i);
 
-	iwl_mvm_umac_scan_cfg_channels(mvm, req->req.channels,
-				       req->req.n_channels, ssid_bitmap, cmd);
+	iwl_mvm_umac_scan_cfg_channels(mvm, req->channels,
+				       req->n_channels, ssid_bitmap, cmd);
 
 	sec_part->schedule[0].iter_count = 1;
 	sec_part->delay = 0;
 
-	iwl_mvm_build_scan_probe(mvm, vif, &req->ies, &sec_part->preq,
-		req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			req->req.mac_addr : NULL,
-		req->req.mac_addr_mask);
+	iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq,
+		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
+			req->mac_addr : NULL,
+		req->mac_addr_mask);
 
-	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, req->req.ssids,
-				req->req.n_ssids, 0);
+	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, req->ssids,
+				req->n_ssids, 0);
 
 	ret = iwl_mvm_send_cmd(mvm, &hcmd);
 	if (!ret) {
@@ -1388,9 +1389,10 @@ int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	return ret;
 }
 
-int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			    struct cfg80211_sched_scan_request *req,
-			    struct ieee80211_scan_ies *ies)
+static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
+				   struct ieee80211_vif *vif,
+				   struct cfg80211_sched_scan_request *req,
+				   struct ieee80211_scan_ies *ies)
 {
 
 	struct iwl_host_cmd hcmd = {
@@ -1499,6 +1501,76 @@ int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	return ret;
 }
 
+static int iwl_mvm_num_scans(struct iwl_mvm *mvm)
+{
+	return hweight32(mvm->scan_status & IWL_MVM_SCAN_MASK);
+}
+
+static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type)
+{
+	/* This looks a bit arbitrary, but the idea is that if we run
+	 * out of possible simultaneous scans and the userspace is
+	 * trying to run a scan type that is already running, we
+	 * return -EBUSY.  But if the userspace wants to start a
+	 * different type of scan, we stop the opposite type to make
+	 * space for the new request.  The reason is backwards
+	 * compatibility with old wpa_supplicant that wouldn't stop a
+	 * scheduled scan before starting a normal scan.
+	 */
+
+	if (iwl_mvm_num_scans(mvm) < mvm->max_scans)
+		return 0;
+
+	/* Use a switch, even though this is a bitmask, so that more
+	 * than one bits set will fall in default and we will warn.
+	 */
+	switch (type) {
+	case IWL_MVM_SCAN_REGULAR:
+		if (mvm->scan_status & IWL_MVM_SCAN_REGULAR_MASK)
+			return -EBUSY;
+		return iwl_mvm_scan_offload_stop(mvm, true);
+	case IWL_MVM_SCAN_SCHED:
+		if (mvm->scan_status & IWL_MVM_SCAN_SCHED_MASK)
+			return -EBUSY;
+		return iwl_mvm_cancel_scan(mvm);
+	default:
+		WARN_ON(1);
+		break;
+	}
+
+	return -EIO;
+}
+
+int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			   struct cfg80211_scan_request *req,
+			   struct ieee80211_scan_ies *ies)
+{
+	int ret;
+
+	lockdep_assert_held(&mvm->mutex);
+
+	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
+		IWL_ERR(mvm, "scan while LAR regdomain is not set\n");
+		return -EBUSY;
+	}
+
+	ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_REGULAR);
+	if (ret)
+		return ret;
+
+	iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN);
+
+	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
+		ret = iwl_mvm_scan_umac(mvm, vif, req, ies);
+	else
+		ret = iwl_mvm_scan_lmac(mvm, vif, req, ies);
+
+	if (ret)
+		iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
+
+	return ret;
+}
+
 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 			     struct ieee80211_vif *vif,
 			     struct cfg80211_sched_scan_request *req,
@@ -1506,6 +1578,17 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 {
 	int ret;
 
+	lockdep_assert_held(&mvm->mutex);
+
+	if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
+		IWL_ERR(mvm, "sched-scan while LAR regdomain is not set\n");
+		return -EBUSY;
+	}
+
+	ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_SCHED);
+	if (ret)
+		return ret;
+
 	ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
 	if (ret)
 		return ret;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 12/42] iwlwifi: mvm: differentiate net-detect from sched scan
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (10 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 11/42] iwlwifi: mvm: move scan code from mac80211.c to scan.c Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 13/42] iwlwifi: pcie: support marbh fw dbg mode Emmanuel Grumbach
                   ` (30 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Net-detect scans were using the same type as sched scan, which was
causing the driver to return -EBUSY and prevent the system from
suspending if there was an ongoing scheduled scan.  To avoid this, add
a new type for net-detect and don't stop anything when it is
requested, so that the existing scheduled scan will be resumed when
the system wakes up.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/d3.c       |  3 ++-
 drivers/net/wireless/iwlwifi/mvm/mac80211.c |  2 +-
 drivers/net/wireless/iwlwifi/mvm/mvm.h      |  7 ++++++-
 drivers/net/wireless/iwlwifi/mvm/scan.c     | 12 ++++++++++--
 4 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c
index e82a47b..36bf6a8 100644
--- a/drivers/net/wireless/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/iwlwifi/mvm/d3.c
@@ -981,7 +981,8 @@ iwl_mvm_netdetect_config(struct iwl_mvm *mvm,
 	if (ret)
 		return ret;
 
-	ret = iwl_mvm_sched_scan_start(mvm, vif, nd_config, &mvm->nd_ies);
+	ret = iwl_mvm_sched_scan_start(mvm, vif, nd_config, &mvm->nd_ies,
+				       IWL_MVM_SCAN_NETDETECT);
 	if (ret)
 		return ret;
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index ff3273a..c136fe0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -2743,7 +2743,7 @@ static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
 		goto out;
 	}
 
-	ret = iwl_mvm_sched_scan_start(mvm, vif, req, ies);
+	ret = iwl_mvm_sched_scan_start(mvm, vif, req, ies, IWL_MVM_SCAN_SCHED);
 
 out:
 	mutex_unlock(&mvm->mutex);
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index bbe4d98..a8f51a8 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -448,14 +448,18 @@ extern const u8 tid_to_mac80211_ac[];
 enum iwl_scan_status {
 	IWL_MVM_SCAN_REGULAR		= BIT(0),
 	IWL_MVM_SCAN_SCHED		= BIT(1),
+	IWL_MVM_SCAN_NETDETECT		= BIT(2),
 
 	IWL_MVM_SCAN_STOPPING_REGULAR	= BIT(8),
 	IWL_MVM_SCAN_STOPPING_SCHED	= BIT(9),
+	IWL_MVM_SCAN_STOPPING_NETDETECT	= BIT(10),
 
 	IWL_MVM_SCAN_REGULAR_MASK	= IWL_MVM_SCAN_REGULAR |
 					  IWL_MVM_SCAN_STOPPING_REGULAR,
 	IWL_MVM_SCAN_SCHED_MASK		= IWL_MVM_SCAN_SCHED |
 					  IWL_MVM_SCAN_STOPPING_SCHED,
+	IWL_MVM_SCAN_NETDETECT_MASK	= IWL_MVM_SCAN_NETDETECT |
+					  IWL_MVM_SCAN_STOPPING_NETDETECT,
 
 	IWL_MVM_SCAN_STOPPING_MASK	= 0xff00,
 	IWL_MVM_SCAN_MASK		= 0x00ff,
@@ -1179,7 +1183,8 @@ int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 			     struct ieee80211_vif *vif,
 			     struct cfg80211_sched_scan_request *req,
-			     struct ieee80211_scan_ies *ies);
+			     struct ieee80211_scan_ies *ies,
+			     int type);
 int iwl_mvm_scan_offload_stop(struct iwl_mvm *mvm, bool notify);
 int iwl_mvm_rx_scan_offload_results(struct iwl_mvm *mvm,
 				    struct iwl_rx_cmd_buffer *rxb,
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 3fe398e..e39f2d1 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -1533,6 +1533,13 @@ static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type)
 		if (mvm->scan_status & IWL_MVM_SCAN_SCHED_MASK)
 			return -EBUSY;
 		return iwl_mvm_cancel_scan(mvm);
+	case IWL_MVM_SCAN_NETDETECT:
+		/* No need to stop anything for net-detect since the
+		 * firmware is restarted anyway.  This way, any sched
+		 * scans that were running will be restarted when we
+		 * resume.
+		*/
+		return 0;
 	default:
 		WARN_ON(1);
 		break;
@@ -1574,7 +1581,8 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 			     struct ieee80211_vif *vif,
 			     struct cfg80211_sched_scan_request *req,
-			     struct ieee80211_scan_ies *ies)
+			     struct ieee80211_scan_ies *ies,
+			     int type)
 {
 	int ret;
 
@@ -1585,7 +1593,7 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 		return -EBUSY;
 	}
 
-	ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_SCHED);
+	ret = iwl_mvm_check_running_scans(mvm, type);
 	if (ret)
 		return ret;
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 13/42] iwlwifi: pcie: support marbh fw dbg mode
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (11 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 12/42] iwlwifi: mvm: differentiate net-detect from sched scan Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 14/42] iwlwifi: rs: remove unneeded check of average tpt in window Emmanuel Grumbach
                   ` (29 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Liad Kaufman, Emmanuel Grumbach

From: Liad Kaufman <liad.kaufman@intel.com>

This adds support for configuring and retrieving the FW
monitor in MARBH mode.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-prph.h   |  3 ++
 drivers/net/wireless/iwlwifi/pcie/trans.c | 49 ++++++++++++++++++++++++-------
 2 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index 88a57e6..5af1c77 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -348,6 +348,9 @@ enum secure_load_status_reg {
 #define MON_BUFF_WRPTR			(0xa03c44)
 #define MON_BUFF_CYCLE_CNT		(0xa03c48)
 
+#define MON_DMARB_RD_CTL_ADDR		(0xa03c60)
+#define MON_DMARB_RD_DATA_ADDR		(0xa03c5c)
+
 #define DBGC_IN_SAMPLE			(0xa03c00)
 
 /* enable the ID buf for read */
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 47bbf57..d108e5b 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -2198,6 +2198,29 @@ static u32 iwl_trans_pcie_fh_regs_dump(struct iwl_trans *trans,
 	return sizeof(**data) + fh_regs_len;
 }
 
+static u32
+iwl_trans_pci_dump_marbh_monitor(struct iwl_trans *trans,
+				 struct iwl_fw_error_dump_fw_mon *fw_mon_data,
+				 u32 monitor_len)
+{
+	u32 buf_size_in_dwords = (monitor_len >> 2);
+	u32 *buffer = (u32 *)fw_mon_data->data;
+	unsigned long flags;
+	u32 i;
+
+	if (!iwl_trans_grab_nic_access(trans, false, &flags))
+		return 0;
+
+	__iwl_write_prph(trans, MON_DMARB_RD_CTL_ADDR, 0x1);
+	for (i = 0; i < buf_size_in_dwords; i++)
+		buffer[i] = __iwl_read_prph(trans, MON_DMARB_RD_DATA_ADDR);
+	__iwl_write_prph(trans, MON_DMARB_RD_CTL_ADDR, 0x0);
+
+	iwl_trans_release_nic_access(trans, &flags);
+
+	return monitor_len;
+}
+
 static
 struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 {
@@ -2250,7 +2273,8 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 		      trans->dbg_dest_tlv->end_shift;
 
 		/* Make "end" point to the actual end */
-		if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000)
+		if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000 ||
+		    trans->dbg_dest_tlv->monitor_mode == MARBH_MODE)
 			end += (1 << trans->dbg_dest_tlv->end_shift);
 		monitor_len = end - base;
 		len += sizeof(*data) + sizeof(struct iwl_fw_error_dump_fw_mon) +
@@ -2326,9 +2350,6 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 
 		len += sizeof(*data) + sizeof(*fw_mon_data);
 		if (trans_pcie->fw_mon_page) {
-			data->len = cpu_to_le32(trans_pcie->fw_mon_size +
-						sizeof(*fw_mon_data));
-
 			/*
 			 * The firmware is now asserted, it won't write anything
 			 * to the buffer. CPU can take ownership to fetch the
@@ -2343,10 +2364,8 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 			       page_address(trans_pcie->fw_mon_page),
 			       trans_pcie->fw_mon_size);
 
-			len += trans_pcie->fw_mon_size;
-		} else {
-			/* If we are here then the buffer is internal */
-
+			monitor_len = trans_pcie->fw_mon_size;
+		} else if (trans->dbg_dest_tlv->monitor_mode == SMEM_MODE) {
 			/*
 			 * Update pointers to reflect actual values after
 			 * shifting
@@ -2355,10 +2374,18 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans)
 			       trans->dbg_dest_tlv->base_shift;
 			iwl_trans_read_mem(trans, base, fw_mon_data->data,
 					   monitor_len / sizeof(u32));
-			data->len = cpu_to_le32(sizeof(*fw_mon_data) +
-						monitor_len);
-			len += monitor_len;
+		} else if (trans->dbg_dest_tlv->monitor_mode == MARBH_MODE) {
+			monitor_len =
+				iwl_trans_pci_dump_marbh_monitor(trans,
+								 fw_mon_data,
+								 monitor_len);
+		} else {
+			/* Didn't match anything - output no monitor data */
+			monitor_len = 0;
 		}
+
+		len += monitor_len;
+		data->len = cpu_to_le32(monitor_len + sizeof(*fw_mon_data));
 	}
 
 	dump_data->len = len;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 14/42] iwlwifi: rs: remove unneeded check of average tpt in window
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (12 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 13/42] iwlwifi: pcie: support marbh fw dbg mode Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 15/42] iwlwifi: mvm: some clean ups in fw-api-scan.h Emmanuel Grumbach
                   ` (28 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Liad Kaufman, Emmanuel Grumbach

From: Liad Kaufman <liad.kaufman@intel.com>

Previously there was a check that compared window->average_tpt
to some value, and if it was different - it set it to that
value. However, this value was already calculated and set in
_rs_collect_tx_data(), so the entire check is unneeded.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/rs.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
index 316c6e0..0440142 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.c
@@ -2183,13 +2183,6 @@ static void rs_rate_scale_perform(struct iwl_mvm *mvm,
 
 		return;
 	}
-	/* Else we have enough samples; calculate estimate of
-	 * actual average throughput */
-	if (window->average_tpt != ((window->success_ratio *
-			tbl->expected_tpt[index] + 64) / 128)) {
-		window->average_tpt = ((window->success_ratio *
-					tbl->expected_tpt[index] + 64) / 128);
-	}
 
 	/* If we are searching for better modulation mode, check success. */
 	if (lq_sta->search_better_tbl) {
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 15/42] iwlwifi: mvm: some clean ups in fw-api-scan.h
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (13 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 14/42] iwlwifi: rs: remove unneeded check of average tpt in window Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 16/42] iwlwifi: mvm: allow scheduled scan for all the firmwares Emmanuel Grumbach
                   ` (27 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Remove unused struct iwl_scan_offload_req and enum
iwl_scan_offload_flags which are not used anymore.  Rename
iwl_scan_offload_schedule to iwl_scan_schedule_lmac to make it clear
that this is for LMAC only.  And fix a small typo.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h | 42 +++-----------------------
 1 file changed, 5 insertions(+), 37 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
index d74615f..be1a0a1 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
@@ -274,50 +274,18 @@ struct iwl_scan_offload_profile_cfg {
 } __packed;
 
 /**
- * iwl_scan_offload_schedule - schedule of scan offload
+ * iwl_scan_schedule_lmac - schedule of scan offload
  * @delay:		delay between iterations, in seconds.
  * @iterations:		num of scan iterations
  * @full_scan_mul:	number of partial scans before each full scan
  */
-struct iwl_scan_offload_schedule {
+struct iwl_scan_schedule_lmac {
 	__le16 delay;
 	u8 iterations;
 	u8 full_scan_mul;
-} __packed;
-
-/*
- * iwl_scan_offload_flags
- *
- * IWL_SCAN_OFFLOAD_FLAG_PASS_ALL: pass all results - no filtering.
- * IWL_SCAN_OFFLOAD_FLAG_CACHED_CHANNEL: add cached channels to partial scan.
- * IWL_SCAN_OFFLOAD_FLAG_EBS_QUICK_MODE: EBS duration is 100mSec - typical
- *	beacon period. Finding channel activity in this mode is not guaranteed.
- * IWL_SCAN_OFFLOAD_FLAG_EBS_ACCURATE_MODE: EBS duration is 200mSec.
- *	Assuming beacon period is 100ms finding channel activity is guaranteed.
- */
-enum iwl_scan_offload_flags {
-	IWL_SCAN_OFFLOAD_FLAG_PASS_ALL		= BIT(0),
-	IWL_SCAN_OFFLOAD_FLAG_CACHED_CHANNEL	= BIT(2),
-	IWL_SCAN_OFFLOAD_FLAG_EBS_QUICK_MODE	= BIT(5),
-	IWL_SCAN_OFFLOAD_FLAG_EBS_ACCURATE_MODE	= BIT(6),
-};
-
-/**
- * iwl_scan_offload_req - scan offload request command
- * @flags:		bitmap - enum iwl_scan_offload_flags.
- * @watchdog:		maximum scan duration in TU.
- * @delay:		delay in seconds before first iteration.
- * @schedule_line:	scan offload schedule, for fast and regular scan.
- */
-struct iwl_scan_offload_req {
-	__le16 flags;
-	__le16 watchdog;
-	__le16 delay;
-	__le16 reserved;
-	struct iwl_scan_offload_schedule schedule_line[2];
-} __packed;
+} __packed; /* SCAN_SCHEDULE_API_S */
 
-enum iwl_scan_offload_compleate_status {
+enum iwl_scan_offload_complete_status {
 	IWL_SCAN_OFFLOAD_COMPLETED	= 1,
 	IWL_SCAN_OFFLOAD_ABORTED	= 2,
 };
@@ -508,7 +476,7 @@ struct iwl_scan_req_lmac {
 	/* SCAN_REQ_PERIODIC_PARAMS_API_S */
 	__le32 iter_num;
 	__le32 delay;
-	struct iwl_scan_offload_schedule schedule[2];
+	struct iwl_scan_schedule_lmac schedule[2];
 	struct iwl_scan_channel_opt channel_opt[2];
 	u8 data[];
 } __packed;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 16/42] iwlwifi: mvm: allow scheduled scan for all the firmwares
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (14 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 15/42] iwlwifi: mvm: some clean ups in fw-api-scan.h Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 17/42] iwlwifi: mvm: always use iwl_mvm_scan_size to calculate the scan size Emmanuel Grumbach
                   ` (26 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Emmanuel Grumbach

We don't support -9.ucode so, all the released firmwares
support scheduled scan properly.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index c136fe0..249d020 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -539,14 +539,12 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 	else
 		hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
 
-	if (IWL_UCODE_API(mvm->fw->ucode_ver) >= 10) {
-		hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
-		hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX;
-		hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES;
-		/* we create the 802.11 header and zero length SSID IE. */
-		hw->wiphy->max_sched_scan_ie_len =
-			SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2;
-	}
+	hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
+	hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX;
+	hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES;
+	/* we create the 802.11 header and zero length SSID IE. */
+	hw->wiphy->max_sched_scan_ie_len =
+		SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2;
 
 	hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN |
 			       NL80211_FEATURE_LOW_PRIORITY_SCAN |
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 17/42] iwlwifi: mvm: always use iwl_mvm_scan_size to calculate the scan size
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (15 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 16/42] iwlwifi: mvm: allow scheduled scan for all the firmwares Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 18/42] iwlwifi: mvm: combine scan size checks into a common function Emmanuel Grumbach
                   ` (25 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

We have a function (iwl_mvm_scan_size()) that can calculate the scan
size for both UMAC and LMAC scans.  Use that function instead of
calculating manually for LMAC scan and sched scan.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index e39f2d1..cbed9f3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -808,10 +808,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 {
 	struct iwl_host_cmd hcmd = {
 		.id = SCAN_OFFLOAD_REQUEST_CMD,
-		.len = { sizeof(struct iwl_scan_req_lmac) +
-			 sizeof(struct iwl_scan_channel_cfg_lmac) *
-				mvm->fw->ucode_capa.n_scan_channels +
-			 sizeof(struct iwl_scan_probe_req), },
+		.len = { iwl_mvm_scan_size(mvm), },
 		.data = { mvm->scan_cmd, },
 		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
 	};
@@ -925,10 +922,7 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 {
 	struct iwl_host_cmd hcmd = {
 		.id = SCAN_OFFLOAD_REQUEST_CMD,
-		.len = { sizeof(struct iwl_scan_req_lmac) +
-			 sizeof(struct iwl_scan_channel_cfg_lmac) *
-				mvm->fw->ucode_capa.n_scan_channels +
-			 sizeof(struct iwl_scan_probe_req), },
+		.len = { iwl_mvm_scan_size(mvm), },
 		.data = { mvm->scan_cmd, },
 		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
 	};
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 18/42] iwlwifi: mvm: combine scan size checks into a common function
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (16 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 17/42] iwlwifi: mvm: always use iwl_mvm_scan_size to calculate the scan size Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 19/42] iwlwifi: mvm: iterate all interfaces during HW recovery cleanup Emmanuel Grumbach
                   ` (24 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Instead of repeating the same code in 4 different places, combine the
comparisons into a new function.  Additionally, this change fixes UMAC
scans where the RRM IEs were not taken into consideration when
calculating the IE length.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c |  2 +-
 drivers/net/wireless/iwlwifi/mvm/mvm.h      |  2 +-
 drivers/net/wireless/iwlwifi/mvm/scan.c     | 44 +++++++++++++----------------
 3 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 249d020..8d9e5da 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -505,7 +505,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 
 	iwl_mvm_reset_phy_ctxts(mvm);
 
-	hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm, false);
+	hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm);
 
 	hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index a8f51a8..7679ad6 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -1168,7 +1168,7 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			   struct ieee80211_scan_ies *ies);
 int iwl_mvm_scan_size(struct iwl_mvm *mvm);
 int iwl_mvm_cancel_scan(struct iwl_mvm *mvm);
-int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan);
+int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm);
 void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm);
 
 /* Scheduled scan */
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index cbed9f3..95b9862 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -296,8 +296,7 @@ static inline bool iwl_mvm_rrm_scan_needed(struct iwl_mvm *mvm)
 	       IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT;
 }
 
-static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm,
-					   bool is_sched_scan)
+static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm)
 {
 	int max_probe_len;
 
@@ -313,9 +312,9 @@ static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm,
 	return max_probe_len;
 }
 
-int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm, bool is_sched_scan)
+int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm)
 {
-	int max_ie_len = iwl_mvm_max_scan_ie_fw_cmd_room(mvm, is_sched_scan);
+	int max_ie_len = iwl_mvm_max_scan_ie_fw_cmd_room(mvm);
 
 	/* TODO: [BUG] This function should return the maximum allowed size of
 	 * scan IEs, however the LMAC scan api contains both 2GHZ and 5GHZ IEs
@@ -802,6 +801,18 @@ iwl_mvm_build_generic_scan_cmd(struct iwl_mvm *mvm,
 			cpu_to_le32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED);
 }
 
+static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
+				     struct ieee80211_scan_ies *ies,
+				     int n_channels)
+{
+	return ((n_ssids <= PROBE_OPTION_MAX) &&
+		(n_channels <= mvm->fw->ucode_capa.n_scan_channels) &
+		(ies->common_ie_len +
+		 ies->len[NL80211_BAND_2GHZ] +
+		 ies->len[NL80211_BAND_5GHZ] <=
+		 iwl_mvm_max_scan_ie_fw_cmd_room(mvm)));
+}
+
 static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			     struct cfg80211_scan_request *req,
 			     struct ieee80211_scan_ies *ies)
@@ -825,11 +836,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (WARN_ON(mvm->scan_cmd == NULL))
 		return -ENOMEM;
 
-	if (req->n_ssids > PROBE_OPTION_MAX ||
-	    ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] +
-	    ies->len[NL80211_BAND_5GHZ] >
-		iwl_mvm_max_scan_ie_fw_cmd_room(mvm, false) ||
-	    req->n_channels > mvm->fw->ucode_capa.n_scan_channels)
+	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
 	mvm->scan_status |= IWL_MVM_SCAN_REGULAR;
@@ -938,11 +945,7 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 	if (WARN_ON(mvm->scan_cmd == NULL))
 		return -ENOMEM;
 
-	if (req->n_ssids > PROBE_OPTION_MAX ||
-	    ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] +
-	    ies->len[NL80211_BAND_5GHZ] >
-		iwl_mvm_max_scan_ie_fw_cmd_room(mvm, true) ||
-	    req->n_channels > mvm->fw->ucode_capa.n_scan_channels)
+	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
 	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, 0, &params);
@@ -1316,12 +1319,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (WARN_ON(mvm->scan_cmd == NULL))
 		return -ENOMEM;
 
-	if (WARN_ON(req->n_ssids > PROBE_OPTION_MAX ||
-		    ies->common_ie_len +
-		    ies->len[NL80211_BAND_2GHZ] +
-		    ies->len[NL80211_BAND_5GHZ] + 24 + 2 >
-		    SCAN_OFFLOAD_PROBE_REQ_SIZE || req->n_channels >
-		    mvm->fw->ucode_capa.n_scan_channels))
+	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
 	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
@@ -1414,11 +1412,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 	if (WARN_ON(mvm->scan_cmd == NULL))
 		return -ENOMEM;
 
-	if (WARN_ON(req->n_ssids > PROBE_OPTION_MAX ||
-		    ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] +
-		    ies->len[NL80211_BAND_5GHZ] + 24 + 2 >
-		    SCAN_OFFLOAD_PROBE_REQ_SIZE || req->n_channels >
-		    mvm->fw->ucode_capa.n_scan_channels))
+	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
 	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 19/42] iwlwifi: mvm: iterate all interfaces during HW recovery cleanup
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (17 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 18/42] iwlwifi: mvm: combine scan size checks into a common function Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 20/42] iwlwifi: clarify the device / firmware mapping in Kconfig Emmanuel Grumbach
                   ` (23 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Arik Nemtsov, Arik Nemtsov, Emmanuel Grumbach

From: Arik Nemtsov <arik@wizery.com>

Usually during HW recovery the state of all active interfaces is cleaned
up during drv_start(). There's a special case where a HW restart is
requested when an interface is going down. In this case the iface-iterator
won't see this interface and we won't clean it. This has bad consequences
once the interface is legitimately brought up again.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 8d9e5da..eca1666 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1239,9 +1239,11 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
 	/* just in case one was running */
 	ieee80211_remain_on_channel_expired(mvm->hw);
 
-	ieee80211_iterate_active_interfaces_atomic(
-		mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
-		iwl_mvm_cleanup_iterator, mvm);
+	/*
+	 * cleanup all interfaces, even inactive ones, as some might have
+	 * gone down during the HW restart
+	 */
+	ieee80211_iterate_interfaces(mvm->hw, 0, iwl_mvm_cleanup_iterator, mvm);
 
 	mvm->p2p_device_vif = NULL;
 	mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 20/42] iwlwifi: clarify the device / firmware mapping in Kconfig
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (18 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 19/42] iwlwifi: mvm: iterate all interfaces during HW recovery cleanup Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 21/42] iwlwifi: mvm: combine parts of UMAC and LMAC scans Emmanuel Grumbach
                   ` (22 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Emmanuel Grumbach

The lists of the devices supported by either MVM or DVM
firmwares was incomplete. Point to
https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#firmware
instead of maintaining the lists.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/Kconfig | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index ab019b4..99f9760 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -21,6 +21,7 @@ config IWLWIFI
 		Intel 7260 Wi-Fi Adapter
 		Intel 3160 Wi-Fi Adapter
 		Intel 7265 Wi-Fi Adapter
+		Intel 8260 Wi-Fi Adapter
 
 
 	  This driver uses the kernel's mac80211 subsystem.
@@ -53,16 +54,17 @@ config IWLDVM
 	tristate "Intel Wireless WiFi DVM Firmware support"
 	default IWLWIFI
 	help
-	  This is the driver that supports the DVM firmware which is
-	  used by most existing devices (with the exception of 7260
-	  and 3160).
+	  This is the driver that supports the DVM firmware. The list
+	  of the devices that use this firmware is available here:
+	  https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#firmware
 
 config IWLMVM
 	tristate "Intel Wireless WiFi MVM Firmware support"
 	select WANT_DEV_COREDUMP
 	help
-	  This is the driver that supports the MVM firmware which is
-	  currently only available for 7260 and 3160 devices.
+	  This is the driver that supports the MVM firmware. The list
+	  of the devices that use this firmware is available here:
+	  https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#firmware
 
 # don't call it _MODULE -- will confuse Kconfig/fixdep/...
 config IWLWIFI_OPMODE_MODULAR
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 21/42] iwlwifi: mvm: combine parts of UMAC and LMAC scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (19 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 20/42] iwlwifi: clarify the device / firmware mapping in Kconfig Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 22/42] iwlwifi: mvm: combine parts of UMAC and LMAC sched scans Emmanuel Grumbach
                   ` (21 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

A lot of the UMAC and LMAC scan code is almost identical.  Grab the
low hanging fruits by combining the obvious parts.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 125 +++++++++++++-------------------
 1 file changed, 50 insertions(+), 75 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 95b9862..0aa0857 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -815,36 +815,18 @@ static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
 
 static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			     struct cfg80211_scan_request *req,
-			     struct ieee80211_scan_ies *ies)
+			     struct ieee80211_scan_ies *ies,
+			     struct iwl_mvm_scan_params *params)
 {
-	struct iwl_host_cmd hcmd = {
-		.id = SCAN_OFFLOAD_REQUEST_CMD,
-		.len = { iwl_mvm_scan_size(mvm), },
-		.data = { mvm->scan_cmd, },
-		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
-	};
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq;
-	struct iwl_mvm_scan_params params = {};
 	u32 flags;
 	u32 ssid_bitmap = 0;
-	int ret, i;
+	int i;
 
 	lockdep_assert_held(&mvm->mutex);
 
-	/* we should have failed registration if scan_cmd was NULL */
-	if (WARN_ON(mvm->scan_cmd == NULL))
-		return -ENOMEM;
-
-	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
-		return -ENOBUFS;
-
-	mvm->scan_status |= IWL_MVM_SCAN_REGULAR;
-
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
-				 &params);
-
-	iwl_mvm_build_generic_scan_cmd(mvm, cmd, &params);
+	iwl_mvm_build_generic_scan_cmd(mvm, cmd, params);
 
 	cmd->n_channels = (u8)req->n_channels;
 
@@ -853,7 +835,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
 
-	if (params.passive_fragmented)
+	if (params->passive_fragmented)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
 
 	if (req->n_ssids == 0)
@@ -906,20 +888,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			req->mac_addr : NULL,
 		req->mac_addr_mask);
 
-	ret = iwl_mvm_send_cmd(mvm, &hcmd);
-	if (!ret) {
-		IWL_DEBUG_SCAN(mvm, "Scan request was sent successfully\n");
-	} else {
-		/*
-		 * If the scan failed, it usually means that the FW was unable
-		 * to allocate the time events. Warn on it, but maybe we
-		 * should try to send the command again with different params.
-		 */
-		IWL_ERR(mvm, "Scan failed! ret %d\n", ret);
-		mvm->scan_status &= ~IWL_MVM_SCAN_REGULAR;
-		ret = -EIO;
-	}
-	return ret;
+	return 0;
 }
 
 static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
@@ -1292,22 +1261,16 @@ static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids,
 
 static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			     struct cfg80211_scan_request *req,
-			     struct ieee80211_scan_ies *ies)
+			     struct ieee80211_scan_ies *ies,
+			     struct iwl_mvm_scan_params *params)
 {
-	struct iwl_host_cmd hcmd = {
-		.id = SCAN_REQ_UMAC,
-		.len = { iwl_mvm_scan_size(mvm), },
-		.data = { mvm->scan_cmd, },
-		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
-	};
 	struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
 	struct iwl_scan_req_umac_tail *sec_part = (void *)&cmd->data +
 		sizeof(struct iwl_scan_channel_cfg_umac) *
 			mvm->fw->ucode_capa.n_scan_channels;
-	struct iwl_mvm_scan_params params = {};
 	u32 uid, flags;
 	u32 ssid_bitmap = 0;
-	int ret, i, uid_idx;
+	int i, uid_idx;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -1315,17 +1278,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (uid_idx >= mvm->max_scans)
 		return -EBUSY;
 
-	/* we should have failed registration if scan_cmd was NULL */
-	if (WARN_ON(mvm->scan_cmd == NULL))
-		return -ENOMEM;
-
-	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
-		return -ENOBUFS;
-
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
-				 &params);
-
-	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, &params);
+	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);
 
 	uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
 	mvm->scan_uid[uid_idx] = uid;
@@ -1335,7 +1288,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	flags = iwl_mvm_scan_umac_common_flags(mvm, req->n_ssids,
 					       req->ssids,
-					       params.passive_fragmented);
+					       params->passive_fragmented);
 
 	flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
 
@@ -1366,19 +1319,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, req->ssids,
 				req->n_ssids, 0);
 
-	ret = iwl_mvm_send_cmd(mvm, &hcmd);
-	if (!ret) {
-		IWL_DEBUG_SCAN(mvm,
-			       "Scan request was sent successfully\n");
-	} else {
-		/*
-		 * If the scan failed, it usually means that the FW was unable
-		 * to allocate the time events. Warn on it, but maybe we
-		 * should try to send the command again with different params.
-		 */
-		IWL_ERR(mvm, "Scan failed! ret %d\n", ret);
-	}
-	return ret;
+	return 0;
 }
 
 static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
@@ -1540,6 +1481,12 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			   struct cfg80211_scan_request *req,
 			   struct ieee80211_scan_ies *ies)
 {
+	struct iwl_host_cmd hcmd = {
+		.len = { iwl_mvm_scan_size(mvm), },
+		.data = { mvm->scan_cmd, },
+		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
+	};
+	struct iwl_mvm_scan_params params = {};
 	int ret;
 
 	lockdep_assert_held(&mvm->mutex);
@@ -1555,10 +1502,38 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN);
 
-	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
-		ret = iwl_mvm_scan_umac(mvm, vif, req, ies);
-	else
-		ret = iwl_mvm_scan_lmac(mvm, vif, req, ies);
+	/* we should have failed registration if scan_cmd was NULL */
+	if (WARN_ON(!mvm->scan_cmd))
+		return -ENOMEM;
+
+	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
+		return -ENOBUFS;
+
+	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
+				 &params);
+
+	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
+		hcmd.id = SCAN_REQ_UMAC;
+		ret = iwl_mvm_scan_umac(mvm, vif, req, ies, &params);
+	} else {
+		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
+		ret = iwl_mvm_scan_lmac(mvm, vif, req, ies, &params);
+	}
+
+	if (ret)
+		return ret;
+
+	ret = iwl_mvm_send_cmd(mvm, &hcmd);
+	if (!ret) {
+		IWL_DEBUG_SCAN(mvm, "Scan request was sent successfully\n");
+		mvm->scan_status |= IWL_MVM_SCAN_REGULAR;
+	} else {
+		/* If the scan failed, it usually means that the FW was unable
+		 * to allocate the time events. Warn on it, but maybe we
+		 * should try to send the command again with different params.
+		 */
+		IWL_ERR(mvm, "Scan failed! ret %d\n", ret);
+	}
 
 	if (ret)
 		iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 22/42] iwlwifi: mvm: combine parts of UMAC and LMAC sched scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (20 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 21/42] iwlwifi: mvm: combine parts of UMAC and LMAC scans Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 23/42] iwlwifi: mvm: add common scan params to thw iwl_mvm_scan_params struct Emmanuel Grumbach
                   ` (20 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Similarly to the regular scan patch, a lot of the UMAC and LMAC sched
scan code is also almost identical.  Grab the low hanging fruits by
combining the obvious parts.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 121 +++++++++++++-------------------
 1 file changed, 47 insertions(+), 74 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 0aa0857..7db3bf3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -894,32 +894,16 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 				   struct ieee80211_vif *vif,
 				   struct cfg80211_sched_scan_request *req,
-				   struct ieee80211_scan_ies *ies)
+				   struct ieee80211_scan_ies *ies,
+				   struct iwl_mvm_scan_params *params)
 {
-	struct iwl_host_cmd hcmd = {
-		.id = SCAN_OFFLOAD_REQUEST_CMD,
-		.len = { iwl_mvm_scan_size(mvm), },
-		.data = { mvm->scan_cmd, },
-		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
-	};
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq;
-	struct iwl_mvm_scan_params params = {};
-	int ret;
 	u32 flags = 0, ssid_bitmap = 0;
 
 	lockdep_assert_held(&mvm->mutex);
 
-	/* we should have failed registration if scan_cmd was NULL */
-	if (WARN_ON(mvm->scan_cmd == NULL))
-		return -ENOMEM;
-
-	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
-		return -ENOBUFS;
-
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, 0, &params);
-
-	iwl_mvm_build_generic_scan_cmd(mvm, cmd, &params);
+	iwl_mvm_build_generic_scan_cmd(mvm, cmd, params);
 
 	cmd->n_channels = (u8)req->n_channels;
 
@@ -933,7 +917,7 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 	if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
 
-	if (params.passive_fragmented)
+	if (params->passive_fragmented)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
 
 	if (req->n_ssids == 0)
@@ -987,21 +971,7 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 			req->mac_addr : NULL,
 		req->mac_addr_mask);
 
-	ret = iwl_mvm_send_cmd(mvm, &hcmd);
-	if (!ret) {
-		IWL_DEBUG_SCAN(mvm,
-			       "Sched scan request was sent successfully\n");
-	} else {
-		/*
-		 * If the scan failed, it usually means that the FW was unable
-		 * to allocate the time events. Warn on it, but maybe we
-		 * should try to send the command again with different params.
-		 */
-		IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
-		mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
-		ret = -EIO;
-	}
-	return ret;
+	return 0;
 }
 
 
@@ -1325,23 +1295,16 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 				   struct ieee80211_vif *vif,
 				   struct cfg80211_sched_scan_request *req,
-				   struct ieee80211_scan_ies *ies)
+				   struct ieee80211_scan_ies *ies,
+				   struct iwl_mvm_scan_params *params)
 {
-
-	struct iwl_host_cmd hcmd = {
-		.id = SCAN_REQ_UMAC,
-		.len = { iwl_mvm_scan_size(mvm), },
-		.data = { mvm->scan_cmd, },
-		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
-	};
 	struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
 	struct iwl_scan_req_umac_tail *sec_part = (void *)&cmd->data +
 		sizeof(struct iwl_scan_channel_cfg_umac) *
 			mvm->fw->ucode_capa.n_scan_channels;
-	struct iwl_mvm_scan_params params = {};
 	u32 uid, flags;
 	u32 ssid_bitmap = 0;
-	int ret, uid_idx;
+	int uid_idx;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -1349,17 +1312,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 	if (uid_idx >= mvm->max_scans)
 		return -EBUSY;
 
-	/* we should have failed registration if scan_cmd was NULL */
-	if (WARN_ON(mvm->scan_cmd == NULL))
-		return -ENOMEM;
-
-	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
-		return -ENOBUFS;
-
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
-					 &params);
-
-	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, &params);
+	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);
 
 	cmd->flags = cpu_to_le32(IWL_UMAC_SCAN_FLAG_PREEMPTIVE);
 
@@ -1370,7 +1323,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 	cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
 
 	flags = iwl_mvm_scan_umac_common_flags(mvm, req->n_ssids, req->ssids,
-					       params.passive_fragmented);
+					       params->passive_fragmented);
 
 	flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
 
@@ -1415,19 +1368,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 			req->mac_addr : NULL,
 		req->mac_addr_mask);
 
-	ret = iwl_mvm_send_cmd(mvm, &hcmd);
-	if (!ret) {
-		IWL_DEBUG_SCAN(mvm,
-			       "Sched scan request was sent successfully\n");
-	} else {
-		/*
-		 * If the scan failed, it usually means that the FW was unable
-		 * to allocate the time events. Warn on it, but maybe we
-		 * should try to send the command again with different params.
-		 */
-		IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
-	}
-	return ret;
+	return 0;
 }
 
 static int iwl_mvm_num_scans(struct iwl_mvm *mvm)
@@ -1547,6 +1488,12 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 			     struct ieee80211_scan_ies *ies,
 			     int type)
 {
+	struct iwl_host_cmd hcmd = {
+		.len = { iwl_mvm_scan_size(mvm), },
+		.data = { mvm->scan_cmd, },
+		.dataflags = { IWL_HCMD_DFL_NOCOPY, },
+	};
+	struct iwl_mvm_scan_params params = {};
 	int ret;
 
 	lockdep_assert_held(&mvm->mutex);
@@ -1560,16 +1507,42 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 	if (ret)
 		return ret;
 
+	/* we should have failed registration if scan_cmd was NULL */
+	if (WARN_ON(!mvm->scan_cmd))
+		return -ENOMEM;
+
+	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
+		return -ENOBUFS;
+
+	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
+				 &params);
+
 	ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
 	if (ret)
 		return ret;
 
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
-		ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies);
+		hcmd.id = SCAN_REQ_UMAC;
+		ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies, &params);
 	} else {
-		ret = iwl_mvm_sched_scan_lmac(mvm, vif, req, ies);
-		if (!ret)
-			mvm->scan_status |= IWL_MVM_SCAN_SCHED;
+		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
+		ret = iwl_mvm_sched_scan_lmac(mvm, vif, req, ies, &params);
+	}
+
+	if (ret)
+		return ret;
+
+	ret = iwl_mvm_send_cmd(mvm, &hcmd);
+	if (!ret) {
+		IWL_DEBUG_SCAN(mvm,
+			       "Sched scan request was sent successfully\n");
+		mvm->scan_status |= type;
+	} else {
+		/* If the scan failed, it usually means that the FW was unable
+		 * to allocate the time events. Warn on it, but maybe we
+		 * should try to send the command again with different params.
+		 */
+		IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
 	}
 
 	return ret;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 23/42] iwlwifi: mvm: add common scan params to thw iwl_mvm_scan_params struct
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (21 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 22/42] iwlwifi: mvm: combine parts of UMAC and LMAC sched scans Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 24/42] iwlwifi: mvm: combine ssid_bitmap setting for regular scans Emmanuel Grumbach
                   ` (19 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Many parameters are common for all scans.  Instead of parsing the
cfg80211 scan and sched scan requests differently in each flow, move
the parsing outside of the API/scan-type specific functions.  In this
way, we only need to differentiate between scan types once.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 239 +++++++++++++++++++-------------
 1 file changed, 145 insertions(+), 94 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 7db3bf3..2836792 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -79,6 +79,19 @@ struct iwl_mvm_scan_params {
 	u32 max_out_time;
 	u32 suspend_time;
 	bool passive_fragmented;
+	u32 n_channels;
+	u32 delay;
+	int n_ssids;
+	struct cfg80211_ssid *ssids;
+	struct ieee80211_channel **channels;
+	u16 interval; /* interval between scans (in secs) */
+	u32 flags;
+	u8 *mac_addr;
+	u8 *mac_addr_mask;
+	bool no_cck;
+	bool pass_all;
+	int n_match_sets;
+	struct cfg80211_match_set *match_sets;
 	struct _dwell {
 		u16 passive;
 		u16 active;
@@ -149,18 +162,17 @@ iwl_mvm_scan_rate_n_flags(struct iwl_mvm *mvm, enum ieee80211_band band,
  * request.
  */
 static void iwl_mvm_scan_fill_ssids(struct iwl_ssid_ie *cmd_ssid,
-				    struct cfg80211_ssid *ssids,
-				    int n_ssids, int first)
+				    struct iwl_mvm_scan_params *params)
 {
 	int fw_idx, req_idx;
 
-	for (req_idx = n_ssids - 1, fw_idx = 0; req_idx >= first;
+	for (req_idx = params->n_ssids - 1, fw_idx = 0; req_idx >= 0;
 	     req_idx--, fw_idx++) {
 		cmd_ssid[fw_idx].id = WLAN_EID_SSID;
-		cmd_ssid[fw_idx].len = ssids[req_idx].ssid_len;
+		cmd_ssid[fw_idx].len = params->ssids[req_idx].ssid_len;
 		memcpy(cmd_ssid[fw_idx].ssid,
-		       ssids[req_idx].ssid,
-		       ssids[req_idx].ssid_len);
+		       params->ssids[req_idx].ssid,
+		       params->ssids[req_idx].ssid_len);
 	}
 }
 
@@ -216,6 +228,8 @@ static void iwl_mvm_scan_calc_params(struct iwl_mvm *mvm,
 					    IEEE80211_IFACE_ITER_NORMAL,
 					    iwl_mvm_scan_condition_iterator,
 					    &global_cnt);
+	params->n_ssids = n_ssids;
+	params->flags = flags;
 
 	if (!global_cnt)
 		goto not_bound;
@@ -427,9 +441,9 @@ static int iwl_ssid_exist(u8 *ssid, u8 ssid_len, struct iwl_ssid_ie *ssid_list)
 	return -1;
 }
 
-static void iwl_scan_offload_build_ssid(struct cfg80211_sched_scan_request *req,
+static void iwl_scan_offload_build_ssid(struct iwl_mvm_scan_params *params,
 					struct iwl_ssid_ie *direct_scan,
-					u32 *ssid_bitmap, bool basic_ssid)
+					u32 *ssid_bitmap)
 {
 	int i, j;
 	int index;
@@ -439,28 +453,28 @@ static void iwl_scan_offload_build_ssid(struct cfg80211_sched_scan_request *req,
 	 * iwl_config_sched_scan_profiles() uses the order of these ssids to
 	 * config match list.
 	 */
-	for (i = 0; i < req->n_match_sets && i < PROBE_OPTION_MAX; i++) {
+	for (i = 0; i < params->n_match_sets && i < PROBE_OPTION_MAX; i++) {
 		/* skip empty SSID matchsets */
-		if (!req->match_sets[i].ssid.ssid_len)
+		if (!params->match_sets[i].ssid.ssid_len)
 			continue;
 		direct_scan[i].id = WLAN_EID_SSID;
-		direct_scan[i].len = req->match_sets[i].ssid.ssid_len;
-		memcpy(direct_scan[i].ssid, req->match_sets[i].ssid.ssid,
+		direct_scan[i].len = params->match_sets[i].ssid.ssid_len;
+		memcpy(direct_scan[i].ssid, params->match_sets[i].ssid.ssid,
 		       direct_scan[i].len);
 	}
 
 	/* add SSIDs from scan SSID list */
 	*ssid_bitmap = 0;
-	for (j = 0; j < req->n_ssids && i < PROBE_OPTION_MAX; j++) {
-		index = iwl_ssid_exist(req->ssids[j].ssid,
-				       req->ssids[j].ssid_len,
+	for (j = 0; j < params->n_ssids && i < PROBE_OPTION_MAX; j++) {
+		index = iwl_ssid_exist(params->ssids[j].ssid,
+				       params->ssids[j].ssid_len,
 				       direct_scan);
 		if (index < 0) {
-			if (!req->ssids[j].ssid_len && basic_ssid)
+			if (!params->ssids[j].ssid_len)
 				continue;
 			direct_scan[i].id = WLAN_EID_SSID;
-			direct_scan[i].len = req->ssids[j].ssid_len;
-			memcpy(direct_scan[i].ssid, req->ssids[j].ssid,
+			direct_scan[i].len = params->ssids[j].ssid_len;
+			memcpy(direct_scan[i].ssid, params->ssids[j].ssid,
 			       direct_scan[i].len);
 			*ssid_bitmap |= BIT(i + 1);
 			i++;
@@ -814,46 +828,54 @@ static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
 }
 
 static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			     struct cfg80211_scan_request *req,
 			     struct ieee80211_scan_ies *ies,
 			     struct iwl_mvm_scan_params *params)
 {
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq;
-	u32 flags;
-	u32 ssid_bitmap = 0;
+	u32 flags = 0, ssid_bitmap = 0;
 	int i;
 
 	lockdep_assert_held(&mvm->mutex);
 
 	iwl_mvm_build_generic_scan_cmd(mvm, cmd, params);
 
-	cmd->n_channels = (u8)req->n_channels;
+	cmd->n_channels = (u8)params->n_channels;
+
+	cmd->delay = cpu_to_le32(params->delay);
 
-	flags = IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;
+	if (params->pass_all)
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;
+	else
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_MATCH;
 
-	if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0)
+	if (params->n_ssids == 1 && params->ssids[0].ssid_len != 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
 
 	if (params->passive_fragmented)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
 
-	if (req->n_ssids == 0)
+	if (params->n_ssids == 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE;
 
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+	/* TODO: Check if it's okay to have this in regular scans */
+	if (mvm->scan_iter_notif_enabled)
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE;
+#endif
+
 	cmd->scan_flags |= cpu_to_le32(flags);
 
-	cmd->flags = iwl_mvm_scan_rxon_flags(req->channels[0]->band);
+	cmd->flags = iwl_mvm_scan_rxon_flags(params->channels[0]->band);
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
-	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, req->no_cck);
-	iwl_mvm_scan_fill_ssids(cmd->direct_scan, req->ssids,
-				req->n_ssids, 0);
+	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck);
+	iwl_mvm_scan_fill_ssids(cmd->direct_scan, params);
 
-	cmd->schedule[0].delay = 0;
+	cmd->schedule[0].delay = cpu_to_le16(params->interval);
 	cmd->schedule[0].iterations = 1;
 	cmd->schedule[0].full_scan_mul = 0;
-	cmd->schedule[1].delay = 0;
+	cmd->schedule[1].delay = cpu_to_le16(params->interval);
 	cmd->schedule[1].iterations = 0;
 	cmd->schedule[1].full_scan_mul = 0;
 
@@ -873,29 +895,27 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			cpu_to_le16(IWL_SPARSE_EBS_SCAN_RATIO);
 	}
 
-	for (i = 1; i <= req->n_ssids; i++)
+	for (i = 1; i <= params->n_ssids; i++)
 		ssid_bitmap |= BIT(i);
 
-	iwl_mvm_lmac_scan_cfg_channels(mvm, req->channels,
-				       req->n_channels, ssid_bitmap,
-				       cmd);
+	iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
+				       params->n_channels, ssid_bitmap, cmd);
 
 	preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			mvm->fw->ucode_capa.n_scan_channels);
 
 	iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
-		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			req->mac_addr : NULL,
-		req->mac_addr_mask);
+		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
+			params->mac_addr : NULL,
+		params->mac_addr_mask);
 
 	return 0;
 }
 
-static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
-				   struct ieee80211_vif *vif,
-				   struct cfg80211_sched_scan_request *req,
-				   struct ieee80211_scan_ies *ies,
-				   struct iwl_mvm_scan_params *params)
+static int
+iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			struct ieee80211_scan_ies *ies,
+			struct iwl_mvm_scan_params *params)
 {
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq;
@@ -905,22 +925,22 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 
 	iwl_mvm_build_generic_scan_cmd(mvm, cmd, params);
 
-	cmd->n_channels = (u8)req->n_channels;
+	cmd->n_channels = (u8)params->n_channels;
 
-	cmd->delay = cpu_to_le32(req->delay);
+	cmd->delay = cpu_to_le32(params->delay);
 
-	if (iwl_mvm_scan_pass_all(mvm, req))
+	if (params->pass_all)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;
 	else
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_MATCH;
 
-	if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0)
+	if (params->n_ssids == 1 && params->ssids[0].ssid_len != 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
 
 	if (params->passive_fragmented)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
 
-	if (req->n_ssids == 0)
+	if (params->n_ssids == 0)
 		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE;
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
@@ -930,17 +950,18 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 
 	cmd->scan_flags |= cpu_to_le32(flags);
 
-	cmd->flags = iwl_mvm_scan_rxon_flags(req->channels[0]->band);
+	cmd->flags = iwl_mvm_scan_rxon_flags(params->channels[0]->band);
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
-	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, false);
-	iwl_scan_offload_build_ssid(req, cmd->direct_scan, &ssid_bitmap, false);
+	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck);
+
+	iwl_scan_offload_build_ssid(params, cmd->direct_scan, &ssid_bitmap);
 
-	cmd->schedule[0].delay = cpu_to_le16(req->interval / MSEC_PER_SEC);
+	cmd->schedule[0].delay = cpu_to_le16(params->interval);
 	cmd->schedule[0].iterations = IWL_FAST_SCHED_SCAN_ITERATIONS;
 	cmd->schedule[0].full_scan_mul = 1;
 
-	cmd->schedule[1].delay = cpu_to_le16(req->interval / MSEC_PER_SEC);
+	cmd->schedule[1].delay = cpu_to_le16(params->interval);
 	cmd->schedule[1].iterations = 0xff;
 	cmd->schedule[1].full_scan_mul = IWL_FULL_SCAN_MULTIPLIER;
 
@@ -960,16 +981,16 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
 			cpu_to_le16(IWL_SPARSE_EBS_SCAN_RATIO);
 	}
 
-	iwl_mvm_lmac_scan_cfg_channels(mvm, req->channels, req->n_channels,
-				       ssid_bitmap, cmd);
+	iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
+				       params->n_channels, ssid_bitmap, cmd);
 
 	preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			mvm->fw->ucode_capa.n_scan_channels);
 
 	iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
-		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			req->mac_addr : NULL,
-		req->mac_addr_mask);
+		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
+			params->mac_addr : NULL,
+		params->mac_addr_mask);
 
 	return 0;
 }
@@ -1230,7 +1251,6 @@ static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids,
 }
 
 static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			     struct cfg80211_scan_request *req,
 			     struct ieee80211_scan_ies *ies,
 			     struct iwl_mvm_scan_params *params)
 {
@@ -1240,7 +1260,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			mvm->fw->ucode_capa.n_scan_channels;
 	u32 uid, flags;
 	u32 ssid_bitmap = 0;
-	int i, uid_idx;
+	int uid_idx, i;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -1256,11 +1276,14 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
 
-	flags = iwl_mvm_scan_umac_common_flags(mvm, req->n_ssids,
-					       req->ssids,
+	flags = iwl_mvm_scan_umac_common_flags(mvm, params->n_ssids,
+					       params->ssids,
 					       params->passive_fragmented);
 
-	flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
+	if (params->pass_all)
+		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
+	else
+		flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH;
 
 	cmd->general_flags = cpu_to_le32(flags);
 
@@ -1270,31 +1293,29 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 				     IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
 				     IWL_SCAN_CHANNEL_FLAG_CACHE_ADD;
 
-	cmd->n_channels = req->n_channels;
+	cmd->n_channels = params->n_channels;
 
-	for (i = 0; i < req->n_ssids; i++)
+	for (i = 0; i < params->n_ssids; i++)
 		ssid_bitmap |= BIT(i);
 
-	iwl_mvm_umac_scan_cfg_channels(mvm, req->channels,
-				       req->n_channels, ssid_bitmap, cmd);
+	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
+				       params->n_channels, ssid_bitmap, cmd);
 
 	sec_part->schedule[0].iter_count = 1;
 	sec_part->delay = 0;
 
 	iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq,
-		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			req->mac_addr : NULL,
-		req->mac_addr_mask);
+		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
+			params->mac_addr : NULL,
+		params->mac_addr_mask);
 
-	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, req->ssids,
-				req->n_ssids, 0);
+	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, params);
 
 	return 0;
 }
 
 static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 				   struct ieee80211_vif *vif,
-				   struct cfg80211_sched_scan_request *req,
 				   struct ieee80211_scan_ies *ies,
 				   struct iwl_mvm_scan_params *params)
 {
@@ -1322,12 +1343,13 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 
 	cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
 
-	flags = iwl_mvm_scan_umac_common_flags(mvm, req->n_ssids, req->ssids,
+	flags = iwl_mvm_scan_umac_common_flags(mvm, params->n_ssids,
+					       params->ssids,
 					       params->passive_fragmented);
 
 	flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
 
-	if (iwl_mvm_scan_pass_all(mvm, req))
+	if (params->pass_all)
 		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
 	else
 		flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH;
@@ -1340,33 +1362,33 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 				     IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
 				     IWL_SCAN_CHANNEL_FLAG_CACHE_ADD;
 
-	cmd->n_channels = req->n_channels;
+	cmd->n_channels = params->n_channels;
 
-	iwl_scan_offload_build_ssid(req, sec_part->direct_scan, &ssid_bitmap,
-				    false);
+	iwl_scan_offload_build_ssid(params, sec_part->direct_scan,
+				    &ssid_bitmap);
 
 	/* This API uses bits 0-19 instead of 1-20. */
 	ssid_bitmap = ssid_bitmap >> 1;
 
-	iwl_mvm_umac_scan_cfg_channels(mvm, req->channels, req->n_channels,
-				       ssid_bitmap, cmd);
+	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
+				       params->n_channels, ssid_bitmap, cmd);
 
 	sec_part->schedule[0].interval =
-				cpu_to_le16(req->interval / MSEC_PER_SEC);
+				cpu_to_le16(params->interval / MSEC_PER_SEC);
 	sec_part->schedule[0].iter_count = 0xff;
 
-	if (req->delay > U16_MAX) {
+	if (params->delay > U16_MAX) {
 		IWL_DEBUG_SCAN(mvm,
 			       "delay value is > 16-bits, set to max possible\n");
 		sec_part->delay = cpu_to_le16(U16_MAX);
 	} else {
-		sec_part->delay = cpu_to_le16(req->delay);
+		sec_part->delay = cpu_to_le16(params->delay);
 	}
 
 	iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq,
-		req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			req->mac_addr : NULL,
-		req->mac_addr_mask);
+		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
+			params->mac_addr : NULL,
+		params->mac_addr_mask);
 
 	return 0;
 }
@@ -1450,15 +1472,26 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
-				 &params);
+	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, &params);
+
+	params.n_channels = req->n_channels;
+	params.delay = 0;
+	params.interval = 0;
+	params.ssids = req->ssids;
+	params.channels = req->channels;
+	params.mac_addr = req->mac_addr;
+	params.mac_addr_mask = req->mac_addr_mask;
+	params.no_cck = req->no_cck;
+	params.pass_all = true;
+	params.n_match_sets = 0;
+	params.match_sets = NULL;
 
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
 		hcmd.id = SCAN_REQ_UMAC;
-		ret = iwl_mvm_scan_umac(mvm, vif, req, ies, &params);
+		ret = iwl_mvm_scan_umac(mvm, vif, ies, &params);
 	} else {
 		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
-		ret = iwl_mvm_scan_lmac(mvm, vif, req, ies, &params);
+		ret = iwl_mvm_scan_lmac(mvm, vif, ies, &params);
 	}
 
 	if (ret)
@@ -1514,8 +1547,26 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
-				 &params);
+	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, &params);
+
+	params.n_channels = req->n_channels;
+	params.delay = req->delay;
+	params.ssids = req->ssids;
+	params.channels = req->channels;
+	params.mac_addr = req->mac_addr;
+	params.mac_addr_mask = req->mac_addr_mask;
+	params.no_cck = false;
+	params.pass_all =  iwl_mvm_scan_pass_all(mvm, req);
+	params.n_match_sets = req->n_match_sets;
+	params.match_sets = req->match_sets;
+
+	if (req->interval > U16_MAX) {
+		IWL_DEBUG_SCAN(mvm,
+			       "interval value is > 16-bits, set to max possible\n");
+		params.interval = U16_MAX;
+	} else {
+		params.interval = req->interval / MSEC_PER_SEC;
+	}
 
 	ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
 	if (ret)
@@ -1523,10 +1574,10 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
 		hcmd.id = SCAN_REQ_UMAC;
-		ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies, &params);
+		ret = iwl_mvm_sched_scan_umac(mvm, vif, ies, &params);
 	} else {
 		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
-		ret = iwl_mvm_sched_scan_lmac(mvm, vif, req, ies, &params);
+		ret = iwl_mvm_sched_scan_lmac(mvm, vif, ies, &params);
 	}
 
 	if (ret)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 24/42] iwlwifi: mvm: combine ssid_bitmap setting for regular scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (22 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 23/42] iwlwifi: mvm: add common scan params to thw iwl_mvm_scan_params struct Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 25/42] iwlwifi: mvm: revert order of SSIDs for sched scans Emmanuel Grumbach
                   ` (18 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

The only difference in the ssid_bitmap between LMAC and UMAC scans is
that in LMAC bits 1 to 20 are used, while in UMAC bits 0 to 19 are
used (*sigh*).  So we can combine the bitmap creation into a single
function and simply shift left if LMAC is used.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 2836792..551f66d 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -162,9 +162,10 @@ iwl_mvm_scan_rate_n_flags(struct iwl_mvm *mvm, enum ieee80211_band band,
  * request.
  */
 static void iwl_mvm_scan_fill_ssids(struct iwl_ssid_ie *cmd_ssid,
-				    struct iwl_mvm_scan_params *params)
+				    struct iwl_mvm_scan_params *params,
+				    u32 *ssid_bitmap)
 {
-	int fw_idx, req_idx;
+	int fw_idx, req_idx, i;
 
 	for (req_idx = params->n_ssids - 1, fw_idx = 0; req_idx >= 0;
 	     req_idx--, fw_idx++) {
@@ -174,6 +175,9 @@ static void iwl_mvm_scan_fill_ssids(struct iwl_ssid_ie *cmd_ssid,
 		       params->ssids[req_idx].ssid,
 		       params->ssids[req_idx].ssid_len);
 	}
+
+	for (i = 0; i < params->n_ssids; i++)
+		*ssid_bitmap |= BIT(i);
 }
 
 /*
@@ -834,7 +838,6 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq;
 	u32 flags = 0, ssid_bitmap = 0;
-	int i;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -870,7 +873,10 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
 	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck);
-	iwl_mvm_scan_fill_ssids(cmd->direct_scan, params);
+	iwl_mvm_scan_fill_ssids(cmd->direct_scan, params, &ssid_bitmap);
+
+	/* this API uses bits 1-20 instead of 0-19 */
+	ssid_bitmap <<= 1;
 
 	cmd->schedule[0].delay = cpu_to_le16(params->interval);
 	cmd->schedule[0].iterations = 1;
@@ -895,9 +901,6 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			cpu_to_le16(IWL_SPARSE_EBS_SCAN_RATIO);
 	}
 
-	for (i = 1; i <= params->n_ssids; i++)
-		ssid_bitmap |= BIT(i);
-
 	iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
 
@@ -1260,7 +1263,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			mvm->fw->ucode_capa.n_scan_channels;
 	u32 uid, flags;
 	u32 ssid_bitmap = 0;
-	int uid_idx, i;
+	int uid_idx;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -1295,8 +1298,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	cmd->n_channels = params->n_channels;
 
-	for (i = 0; i < params->n_ssids; i++)
-		ssid_bitmap |= BIT(i);
+	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, params, &ssid_bitmap);
 
 	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
@@ -1309,8 +1311,6 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			params->mac_addr : NULL,
 		params->mac_addr_mask);
 
-	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, params);
-
 	return 0;
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 25/42] iwlwifi: mvm: revert order of SSIDs for sched scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (23 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 24/42] iwlwifi: mvm: combine ssid_bitmap setting for regular scans Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 26/42] iwlwifi: mvm: combine SSID functions for sched and regular scans Emmanuel Grumbach
                   ` (17 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

The firmware inverts the order of the SSIDs sent out in probe requests
(for some reason).  For regular scans, we've been passing the SSIDs in
the opposite order so they go out in the order we want.  With
scheduled scans, we were not doing that, so they were sent out in
reverse order of priority.  Fix that by using the reverse order when
populating the SSIDs array for scheduled scans as well.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 551f66d..785e99c 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -446,7 +446,7 @@ static int iwl_ssid_exist(u8 *ssid, u8 ssid_len, struct iwl_ssid_ie *ssid_list)
 }
 
 static void iwl_scan_offload_build_ssid(struct iwl_mvm_scan_params *params,
-					struct iwl_ssid_ie *direct_scan,
+					struct iwl_ssid_ie *ssid,
 					u32 *ssid_bitmap)
 {
 	int i, j;
@@ -457,31 +457,34 @@ static void iwl_scan_offload_build_ssid(struct iwl_mvm_scan_params *params,
 	 * iwl_config_sched_scan_profiles() uses the order of these ssids to
 	 * config match list.
 	 */
-	for (i = 0; i < params->n_match_sets && i < PROBE_OPTION_MAX; i++) {
+	for (i = 0, j = params->n_match_sets - 1;
+	     j >= 0 && i < PROBE_OPTION_MAX;
+	     i++, j--) {
 		/* skip empty SSID matchsets */
-		if (!params->match_sets[i].ssid.ssid_len)
+		if (!params->match_sets[j].ssid.ssid_len)
 			continue;
-		direct_scan[i].id = WLAN_EID_SSID;
-		direct_scan[i].len = params->match_sets[i].ssid.ssid_len;
-		memcpy(direct_scan[i].ssid, params->match_sets[i].ssid.ssid,
-		       direct_scan[i].len);
+		ssid[i].id = WLAN_EID_SSID;
+		ssid[i].len = params->match_sets[j].ssid.ssid_len;
+		memcpy(ssid[i].ssid, params->match_sets[j].ssid.ssid,
+		       ssid[i].len);
 	}
 
 	/* add SSIDs from scan SSID list */
 	*ssid_bitmap = 0;
-	for (j = 0; j < params->n_ssids && i < PROBE_OPTION_MAX; j++) {
+	for (j = params->n_ssids - 1;
+	     j >= 0 && i < PROBE_OPTION_MAX;
+	     i++, j--) {
 		index = iwl_ssid_exist(params->ssids[j].ssid,
 				       params->ssids[j].ssid_len,
-				       direct_scan);
+				       ssid);
 		if (index < 0) {
 			if (!params->ssids[j].ssid_len)
 				continue;
-			direct_scan[i].id = WLAN_EID_SSID;
-			direct_scan[i].len = params->ssids[j].ssid_len;
-			memcpy(direct_scan[i].ssid, params->ssids[j].ssid,
-			       direct_scan[i].len);
+			ssid[i].id = WLAN_EID_SSID;
+			ssid[i].len = params->ssids[j].ssid_len;
+			memcpy(ssid[i].ssid, params->ssids[j].ssid,
+			       ssid[i].len);
 			*ssid_bitmap |= BIT(i + 1);
-			i++;
 		} else {
 			*ssid_bitmap |= BIT(index + 1);
 		}
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 26/42] iwlwifi: mvm: combine SSID functions for sched and regular scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (24 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 25/42] iwlwifi: mvm: revert order of SSIDs for sched scans Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 27/42] iwlwifi: mvm: rename scan_calc_params to scan_calc_dwell Emmanuel Grumbach
                   ` (16 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Now that both scheduled scan and regular scan SSID populating
functions do the same thing, they can be combined into a single
function.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 71 +++++++++++----------------------
 1 file changed, 24 insertions(+), 47 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 785e99c..36254c5 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -156,31 +156,6 @@ iwl_mvm_scan_rate_n_flags(struct iwl_mvm *mvm, enum ieee80211_band band,
 }
 
 /*
- * We insert the SSIDs in an inverted order, because the FW will
- * invert it back. The most prioritized SSID, which is first in the
- * request list, is not copied here, but inserted directly to the probe
- * request.
- */
-static void iwl_mvm_scan_fill_ssids(struct iwl_ssid_ie *cmd_ssid,
-				    struct iwl_mvm_scan_params *params,
-				    u32 *ssid_bitmap)
-{
-	int fw_idx, req_idx, i;
-
-	for (req_idx = params->n_ssids - 1, fw_idx = 0; req_idx >= 0;
-	     req_idx--, fw_idx++) {
-		cmd_ssid[fw_idx].id = WLAN_EID_SSID;
-		cmd_ssid[fw_idx].len = params->ssids[req_idx].ssid_len;
-		memcpy(cmd_ssid[fw_idx].ssid,
-		       params->ssids[req_idx].ssid,
-		       params->ssids[req_idx].ssid_len);
-	}
-
-	for (i = 0; i < params->n_ssids; i++)
-		*ssid_bitmap |= BIT(i);
-}
-
-/*
  * If req->n_ssids > 0, it means we should do an active scan.
  * In case of active scan w/o directed scan, we receive a zero-length SSID
  * just to notify that this scan is active and not passive.
@@ -445,9 +420,12 @@ static int iwl_ssid_exist(u8 *ssid, u8 ssid_len, struct iwl_ssid_ie *ssid_list)
 	return -1;
 }
 
-static void iwl_scan_offload_build_ssid(struct iwl_mvm_scan_params *params,
-					struct iwl_ssid_ie *ssid,
-					u32 *ssid_bitmap)
+/* We insert the SSIDs in an inverted order, because the FW will
+ * invert it back.
+ */
+static void iwl_scan_build_ssids(struct iwl_mvm_scan_params *params,
+				 struct iwl_ssid_ie *ssids,
+				 u32 *ssid_bitmap)
 {
 	int i, j;
 	int index;
@@ -463,10 +441,10 @@ static void iwl_scan_offload_build_ssid(struct iwl_mvm_scan_params *params,
 		/* skip empty SSID matchsets */
 		if (!params->match_sets[j].ssid.ssid_len)
 			continue;
-		ssid[i].id = WLAN_EID_SSID;
-		ssid[i].len = params->match_sets[j].ssid.ssid_len;
-		memcpy(ssid[i].ssid, params->match_sets[j].ssid.ssid,
-		       ssid[i].len);
+		ssids[i].id = WLAN_EID_SSID;
+		ssids[i].len = params->match_sets[j].ssid.ssid_len;
+		memcpy(ssids[i].ssid, params->match_sets[j].ssid.ssid,
+		       ssids[i].len);
 	}
 
 	/* add SSIDs from scan SSID list */
@@ -476,17 +454,17 @@ static void iwl_scan_offload_build_ssid(struct iwl_mvm_scan_params *params,
 	     i++, j--) {
 		index = iwl_ssid_exist(params->ssids[j].ssid,
 				       params->ssids[j].ssid_len,
-				       ssid);
+				       ssids);
 		if (index < 0) {
 			if (!params->ssids[j].ssid_len)
 				continue;
-			ssid[i].id = WLAN_EID_SSID;
-			ssid[i].len = params->ssids[j].ssid_len;
-			memcpy(ssid[i].ssid, params->ssids[j].ssid,
-			       ssid[i].len);
-			*ssid_bitmap |= BIT(i + 1);
+			ssids[i].id = WLAN_EID_SSID;
+			ssids[i].len = params->ssids[j].ssid_len;
+			memcpy(ssids[i].ssid, params->ssids[j].ssid,
+			       ssids[i].len);
+			*ssid_bitmap |= BIT(i);
 		} else {
-			*ssid_bitmap |= BIT(index + 1);
+			*ssid_bitmap |= BIT(index);
 		}
 	}
 }
@@ -876,7 +854,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
 	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck);
-	iwl_mvm_scan_fill_ssids(cmd->direct_scan, params, &ssid_bitmap);
+	iwl_scan_build_ssids(params, cmd->direct_scan, &ssid_bitmap);
 
 	/* this API uses bits 1-20 instead of 0-19 */
 	ssid_bitmap <<= 1;
@@ -961,7 +939,10 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 					MAC_FILTER_IN_BEACON);
 	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck);
 
-	iwl_scan_offload_build_ssid(params, cmd->direct_scan, &ssid_bitmap);
+	iwl_scan_build_ssids(params, cmd->direct_scan, &ssid_bitmap);
+
+	/* this API uses bits 1-20 instead of 0-19 */
+	ssid_bitmap <<= 1;
 
 	cmd->schedule[0].delay = cpu_to_le16(params->interval);
 	cmd->schedule[0].iterations = IWL_FAST_SCHED_SCAN_ITERATIONS;
@@ -1301,7 +1282,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	cmd->n_channels = params->n_channels;
 
-	iwl_mvm_scan_fill_ssids(sec_part->direct_scan, params, &ssid_bitmap);
+	iwl_scan_build_ssids(params, sec_part->direct_scan, &ssid_bitmap);
 
 	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
@@ -1367,11 +1348,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 
 	cmd->n_channels = params->n_channels;
 
-	iwl_scan_offload_build_ssid(params, sec_part->direct_scan,
-				    &ssid_bitmap);
-
-	/* This API uses bits 0-19 instead of 1-20. */
-	ssid_bitmap = ssid_bitmap >> 1;
+	iwl_scan_build_ssids(params, sec_part->direct_scan, &ssid_bitmap);
 
 	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 27/42] iwlwifi: mvm: rename scan_calc_params to scan_calc_dwell
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (25 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 26/42] iwlwifi: mvm: combine SSID functions for sched and regular scans Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 28/42] iwlwifi: mvm: combine LMAC and UMAC preq generation Emmanuel Grumbach
                   ` (15 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

To make things clearer, rename the iwl_mvm_scan_calc_params() function
to iwl_mvm_calc_dwell() and make it calculate and fill in only
dwell-related parameters.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 36254c5..e8ec6e2 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -194,10 +194,9 @@ static void iwl_mvm_scan_condition_iterator(void *data, u8 *mac,
 		*global_cnt += 1;
 }
 
-static void iwl_mvm_scan_calc_params(struct iwl_mvm *mvm,
-				     struct ieee80211_vif *vif,
-				     int n_ssids, u32 flags,
-				     struct iwl_mvm_scan_params *params)
+static void iwl_mvm_scan_calc_dwell(struct iwl_mvm *mvm,
+				    struct ieee80211_vif *vif,
+				    struct iwl_mvm_scan_params *params)
 {
 	int global_cnt = 0;
 	enum ieee80211_band band;
@@ -207,9 +206,6 @@ static void iwl_mvm_scan_calc_params(struct iwl_mvm *mvm,
 					    IEEE80211_IFACE_ITER_NORMAL,
 					    iwl_mvm_scan_condition_iterator,
 					    &global_cnt);
-	params->n_ssids = n_ssids;
-	params->flags = flags;
-
 	if (!global_cnt)
 		goto not_bound;
 
@@ -250,7 +246,7 @@ static void iwl_mvm_scan_calc_params(struct iwl_mvm *mvm,
 		}
 	}
 
-	if ((flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
+	if ((params->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
 	    (params->max_out_time > 200))
 		params->max_out_time = 200;
 
@@ -262,8 +258,8 @@ not_bound:
 
 		params->dwell[band].passive = iwl_mvm_get_passive_dwell(mvm,
 									band);
-		params->dwell[band].active = iwl_mvm_get_active_dwell(mvm, band,
-								      n_ssids);
+		params->dwell[band].active =
+			iwl_mvm_get_active_dwell(mvm, band, params->n_ssids);
 	}
 
 	IWL_DEBUG_SCAN(mvm,
@@ -1452,8 +1448,8 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, &params);
-
+	params.n_ssids = req->n_ssids;
+	params.flags = req->flags;
 	params.n_channels = req->n_channels;
 	params.delay = 0;
 	params.interval = 0;
@@ -1466,6 +1462,8 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	params.n_match_sets = 0;
 	params.match_sets = NULL;
 
+	iwl_mvm_scan_calc_dwell(mvm, vif, &params);
+
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
 		hcmd.id = SCAN_REQ_UMAC;
 		ret = iwl_mvm_scan_umac(mvm, vif, ies, &params);
@@ -1527,8 +1525,8 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 	if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
 		return -ENOBUFS;
 
-	iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags, &params);
-
+	params.n_ssids = req->n_ssids;
+	params.flags = req->flags;
 	params.n_channels = req->n_channels;
 	params.delay = req->delay;
 	params.ssids = req->ssids;
@@ -1548,6 +1546,8 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 		params.interval = req->interval / MSEC_PER_SEC;
 	}
 
+	iwl_mvm_scan_calc_dwell(mvm, vif, &params);
+
 	ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
 	if (ret)
 		return ret;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 28/42] iwlwifi: mvm: combine LMAC and UMAC preq generation
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (26 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 27/42] iwlwifi: mvm: rename scan_calc_params to scan_calc_dwell Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 29/42] iwlwifi: mvm: add number of scan iterations and multiplier to params Emmanuel Grumbach
                   ` (14 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

The probe request to be added to both LMAC and UMAC scan commands are
identical, so move the generation out of the LMAC/UMAC-specific code.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 81 ++++++++++++++-------------------
 1 file changed, 35 insertions(+), 46 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index e8ec6e2..acff2e7 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -91,6 +91,7 @@ struct iwl_mvm_scan_params {
 	bool no_cck;
 	bool pass_all;
 	int n_match_sets;
+	struct iwl_scan_probe_req preq;
 	struct cfg80211_match_set *match_sets;
 	struct _dwell {
 		u16 passive;
@@ -725,11 +726,12 @@ static u8 *iwl_mvm_copy_and_insert_ds_elem(struct iwl_mvm *mvm, const u8 *ies,
 static void
 iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			 struct ieee80211_scan_ies *ies,
-			 struct iwl_scan_probe_req *preq,
-			 const u8 *mac_addr, const u8 *mac_addr_mask)
+			 struct iwl_mvm_scan_params *params)
 {
-	struct ieee80211_mgmt *frame = (struct ieee80211_mgmt *)preq->buf;
+	struct ieee80211_mgmt *frame = (void *)params->preq.buf;
 	u8 *pos, *newpos;
+	const u8 *mac_addr = params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
+		params->mac_addr : NULL;
 
 	/*
 	 * Unfortunately, right now the offload scan doesn't support randomising
@@ -738,7 +740,8 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	 * random, only when it's restarted, but at least that helps a bit.
 	 */
 	if (mac_addr)
-		get_random_mask_addr(frame->sa, mac_addr, mac_addr_mask);
+		get_random_mask_addr(frame->sa, mac_addr,
+				     params->mac_addr_mask);
 	else
 		memcpy(frame->sa, vif->addr, ETH_ALEN);
 
@@ -751,27 +754,28 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	*pos++ = WLAN_EID_SSID;
 	*pos++ = 0;
 
-	preq->mac_header.offset = 0;
-	preq->mac_header.len = cpu_to_le16(24 + 2);
+	params->preq.mac_header.offset = 0;
+	params->preq.mac_header.len = cpu_to_le16(24 + 2);
 
 	/* Insert ds parameter set element on 2.4 GHz band */
 	newpos = iwl_mvm_copy_and_insert_ds_elem(mvm,
 						 ies->ies[IEEE80211_BAND_2GHZ],
 						 ies->len[IEEE80211_BAND_2GHZ],
 						 pos);
-	preq->band_data[0].offset = cpu_to_le16(pos - preq->buf);
-	preq->band_data[0].len = cpu_to_le16(newpos - pos);
+	params->preq.band_data[0].offset = cpu_to_le16(pos - params->preq.buf);
+	params->preq.band_data[0].len = cpu_to_le16(newpos - pos);
 	pos = newpos;
 
 	memcpy(pos, ies->ies[IEEE80211_BAND_5GHZ],
 	       ies->len[IEEE80211_BAND_5GHZ]);
-	preq->band_data[1].offset = cpu_to_le16(pos - preq->buf);
-	preq->band_data[1].len = cpu_to_le16(ies->len[IEEE80211_BAND_5GHZ]);
+	params->preq.band_data[1].offset = cpu_to_le16(pos - params->preq.buf);
+	params->preq.band_data[1].len =
+		cpu_to_le16(ies->len[IEEE80211_BAND_5GHZ]);
 	pos += ies->len[IEEE80211_BAND_5GHZ];
 
 	memcpy(pos, ies->common_ies, ies->common_ie_len);
-	preq->common_data.offset = cpu_to_le16(pos - preq->buf);
-	preq->common_data.len = cpu_to_le16(ies->common_ie_len);
+	params->preq.common_data.offset = cpu_to_le16(pos - params->preq.buf);
+	params->preq.common_data.len = cpu_to_le16(ies->common_ie_len);
 }
 
 static void
@@ -809,11 +813,12 @@ static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
 }
 
 static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			     struct ieee80211_scan_ies *ies,
 			     struct iwl_mvm_scan_params *params)
 {
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
-	struct iwl_scan_probe_req *preq;
+	struct iwl_scan_probe_req *preq =
+		(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
+			 mvm->fw->ucode_capa.n_scan_channels);
 	u32 flags = 0, ssid_bitmap = 0;
 
 	lockdep_assert_held(&mvm->mutex);
@@ -881,24 +886,19 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
 
-	preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
-			mvm->fw->ucode_capa.n_scan_channels);
-
-	iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
-		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			params->mac_addr : NULL,
-		params->mac_addr_mask);
+	*preq = params->preq;
 
 	return 0;
 }
 
 static int
 iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			struct ieee80211_scan_ies *ies,
-			struct iwl_mvm_scan_params *params)
+				   struct iwl_mvm_scan_params *params)
 {
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
-	struct iwl_scan_probe_req *preq;
+	struct iwl_scan_probe_req *preq =
+		(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
+			 mvm->fw->ucode_capa.n_scan_channels);
 	u32 flags = 0, ssid_bitmap = 0;
 
 	lockdep_assert_held(&mvm->mutex);
@@ -967,13 +967,7 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
 
-	preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
-			mvm->fw->ucode_capa.n_scan_channels);
-
-	iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
-		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			params->mac_addr : NULL,
-		params->mac_addr_mask);
+	*preq = params->preq;
 
 	return 0;
 }
@@ -1234,7 +1228,6 @@ static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids,
 }
 
 static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			     struct ieee80211_scan_ies *ies,
 			     struct iwl_mvm_scan_params *params)
 {
 	struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
@@ -1285,18 +1278,13 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	sec_part->schedule[0].iter_count = 1;
 	sec_part->delay = 0;
-
-	iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq,
-		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			params->mac_addr : NULL,
-		params->mac_addr_mask);
+	sec_part->preq = params->preq;
 
 	return 0;
 }
 
 static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 				   struct ieee80211_vif *vif,
-				   struct ieee80211_scan_ies *ies,
 				   struct iwl_mvm_scan_params *params)
 {
 	struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
@@ -1361,10 +1349,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 		sec_part->delay = cpu_to_le16(params->delay);
 	}
 
-	iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq,
-		params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
-			params->mac_addr : NULL,
-		params->mac_addr_mask);
+	sec_part->preq = params->preq;
 
 	return 0;
 }
@@ -1464,12 +1449,14 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	iwl_mvm_scan_calc_dwell(mvm, vif, &params);
 
+	iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
+
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
 		hcmd.id = SCAN_REQ_UMAC;
-		ret = iwl_mvm_scan_umac(mvm, vif, ies, &params);
+		ret = iwl_mvm_scan_umac(mvm, vif, &params);
 	} else {
 		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
-		ret = iwl_mvm_scan_lmac(mvm, vif, ies, &params);
+		ret = iwl_mvm_scan_lmac(mvm, vif, &params);
 	}
 
 	if (ret)
@@ -1552,12 +1539,14 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 	if (ret)
 		return ret;
 
+	iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
+
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
 		hcmd.id = SCAN_REQ_UMAC;
-		ret = iwl_mvm_sched_scan_umac(mvm, vif, ies, &params);
+		ret = iwl_mvm_sched_scan_umac(mvm, vif, &params);
 	} else {
 		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
-		ret = iwl_mvm_sched_scan_lmac(mvm, vif, ies, &params);
+		ret = iwl_mvm_sched_scan_lmac(mvm, vif, &params);
 	}
 
 	if (ret)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 29/42] iwlwifi: mvm: add number of scan iterations and multiplier to params
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (27 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 28/42] iwlwifi: mvm: combine LMAC and UMAC preq generation Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 30/42] iwlwifi: mvm: combine LMAC scans into one Emmanuel Grumbach
                   ` (13 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

As another step towards combining the scan and sched scan functions,
add parameters that tell the scan function how many iterations we want
(i.e. 1 for normal scan, more for scheduled scan) and that set the
full scan multiplier (only meaningful for LMAC).

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 42 ++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index acff2e7..5576152 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -98,6 +98,10 @@ struct iwl_mvm_scan_params {
 		u16 active;
 		u16 fragmented;
 	} dwell[IEEE80211_NUM_BANDS];
+	struct {
+		u8 iterations;
+		u8 full_scan_mul; /* not used for UMAC */
+	} schedule[2];
 };
 
 enum iwl_umac_scan_uid_type {
@@ -861,11 +865,11 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	ssid_bitmap <<= 1;
 
 	cmd->schedule[0].delay = cpu_to_le16(params->interval);
-	cmd->schedule[0].iterations = 1;
-	cmd->schedule[0].full_scan_mul = 0;
+	cmd->schedule[0].iterations = params->schedule[0].iterations;
+	cmd->schedule[0].full_scan_mul = params->schedule[0].full_scan_mul;
 	cmd->schedule[1].delay = cpu_to_le16(params->interval);
-	cmd->schedule[1].iterations = 0;
-	cmd->schedule[1].full_scan_mul = 0;
+	cmd->schedule[1].iterations = params->schedule[1].iterations;
+	cmd->schedule[1].full_scan_mul = params->schedule[1].iterations;
 
 	if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS &&
 	    mvm->last_ebs_successful) {
@@ -941,12 +945,11 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	ssid_bitmap <<= 1;
 
 	cmd->schedule[0].delay = cpu_to_le16(params->interval);
-	cmd->schedule[0].iterations = IWL_FAST_SCHED_SCAN_ITERATIONS;
-	cmd->schedule[0].full_scan_mul = 1;
-
+	cmd->schedule[0].iterations = params->schedule[0].iterations;
+	cmd->schedule[0].full_scan_mul = params->schedule[0].full_scan_mul;
 	cmd->schedule[1].delay = cpu_to_le16(params->interval);
-	cmd->schedule[1].iterations = 0xff;
-	cmd->schedule[1].full_scan_mul = IWL_FULL_SCAN_MULTIPLIER;
+	cmd->schedule[1].iterations = params->schedule[1].iterations;
+	cmd->schedule[1].full_scan_mul = params->schedule[1].iterations;
 
 	if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_EBS_SUPPORT &&
 	    mvm->last_ebs_successful) {
@@ -1276,8 +1279,8 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
 
-	sec_part->schedule[0].iter_count = 1;
-	sec_part->delay = 0;
+	sec_part->schedule[0].iter_count = params->schedule[0].iterations;
+	sec_part->delay = cpu_to_le16(params->delay);
 	sec_part->preq = params->preq;
 
 	return 0;
@@ -1337,9 +1340,10 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
 
-	sec_part->schedule[0].interval =
-				cpu_to_le16(params->interval / MSEC_PER_SEC);
-	sec_part->schedule[0].iter_count = 0xff;
+	sec_part->schedule[0].interval = cpu_to_le16(params->interval);
+
+	/* With UMAC we use only one schedule, so take the final one only */
+	sec_part->schedule[0].iter_count = params->schedule[1].iterations;
 
 	if (params->delay > U16_MAX) {
 		IWL_DEBUG_SCAN(mvm,
@@ -1447,6 +1451,11 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	params.n_match_sets = 0;
 	params.match_sets = NULL;
 
+	params.schedule[0].iterations = 1;
+	params.schedule[0].full_scan_mul = 0;
+	params.schedule[1].iterations = 0;
+	params.schedule[1].full_scan_mul = 0;
+
 	iwl_mvm_scan_calc_dwell(mvm, vif, &params);
 
 	iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
@@ -1525,6 +1534,11 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 	params.n_match_sets = req->n_match_sets;
 	params.match_sets = req->match_sets;
 
+	params.schedule[0].iterations = IWL_FAST_SCHED_SCAN_ITERATIONS;
+	params.schedule[0].full_scan_mul = 1;
+	params.schedule[1].iterations = 0xff;
+	params.schedule[1].full_scan_mul = IWL_FULL_SCAN_MULTIPLIER;
+
 	if (req->interval > U16_MAX) {
 		IWL_DEBUG_SCAN(mvm,
 			       "interval value is > 16-bits, set to max possible\n");
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 30/42] iwlwifi: mvm: combine LMAC scans into one
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (28 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 29/42] iwlwifi: mvm: add number of scan iterations and multiplier to params Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 31/42] iwlwifi: mvm: trim sched scan delay down to 16-bit for LMAC as well Emmanuel Grumbach
                   ` (12 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

The last remaining difference between the regular scan and scheduled
scan flows for LMAC is the FW capabilities check for EBS scans.

Merge these checks into a new function and then combine the LMAC scan
functions into a single one.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 100 ++++++--------------------------
 1 file changed, 17 insertions(+), 83 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 5576152..f4d38f5 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -816,94 +816,31 @@ static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
 		 iwl_mvm_max_scan_ie_fw_cmd_room(mvm)));
 }
 
-static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-			     struct iwl_mvm_scan_params *params)
+static inline bool iwl_mvm_scan_use_ebs(struct iwl_mvm *mvm, int n_iterations)
 {
-	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
-	struct iwl_scan_probe_req *preq =
-		(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
-			 mvm->fw->ucode_capa.n_scan_channels);
-	u32 flags = 0, ssid_bitmap = 0;
-
-	lockdep_assert_held(&mvm->mutex);
-
-	iwl_mvm_build_generic_scan_cmd(mvm, cmd, params);
+	const struct iwl_ucode_capabilities *capa = &mvm->fw->ucode_capa;
 
-	cmd->n_channels = (u8)params->n_channels;
-
-	cmd->delay = cpu_to_le32(params->delay);
-
-	if (params->pass_all)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;
-	else
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_MATCH;
-
-	if (params->n_ssids == 1 && params->ssids[0].ssid_len != 0)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
-
-	if (params->passive_fragmented)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
-
-	if (params->n_ssids == 0)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE;
-
-#ifdef CONFIG_IWLWIFI_DEBUGFS
-	/* TODO: Check if it's okay to have this in regular scans */
-	if (mvm->scan_iter_notif_enabled)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE;
-#endif
-
-	cmd->scan_flags |= cpu_to_le32(flags);
-
-	cmd->flags = iwl_mvm_scan_rxon_flags(params->channels[0]->band);
-	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
-					MAC_FILTER_IN_BEACON);
-	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck);
-	iwl_scan_build_ssids(params, cmd->direct_scan, &ssid_bitmap);
-
-	/* this API uses bits 1-20 instead of 0-19 */
-	ssid_bitmap <<= 1;
-
-	cmd->schedule[0].delay = cpu_to_le16(params->interval);
-	cmd->schedule[0].iterations = params->schedule[0].iterations;
-	cmd->schedule[0].full_scan_mul = params->schedule[0].full_scan_mul;
-	cmd->schedule[1].delay = cpu_to_le16(params->interval);
-	cmd->schedule[1].iterations = params->schedule[1].iterations;
-	cmd->schedule[1].full_scan_mul = params->schedule[1].iterations;
-
-	if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS &&
-	    mvm->last_ebs_successful) {
-		cmd->channel_opt[0].flags =
-			cpu_to_le16(IWL_SCAN_CHANNEL_FLAG_EBS |
-				    IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
-				    IWL_SCAN_CHANNEL_FLAG_CACHE_ADD);
-		cmd->channel_opt[0].non_ebs_ratio =
-			cpu_to_le16(IWL_DENSE_EBS_SCAN_RATIO);
-		cmd->channel_opt[1].flags =
-			cpu_to_le16(IWL_SCAN_CHANNEL_FLAG_EBS |
-				    IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
-				    IWL_SCAN_CHANNEL_FLAG_CACHE_ADD);
-		cmd->channel_opt[1].non_ebs_ratio =
-			cpu_to_le16(IWL_SPARSE_EBS_SCAN_RATIO);
-	}
-
-	iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
-				       params->n_channels, ssid_bitmap, cmd);
-
-	*preq = params->preq;
-
-	return 0;
+	/* We can only use EBS if:
+	 *	1. the feature is supported;
+	 *	2. the last EBS was successful;
+	 *	3. if only single scan, the single scan EBS API is supported.
+	 */
+	return ((capa->flags & IWL_UCODE_TLV_FLAGS_EBS_SUPPORT) &&
+		mvm->last_ebs_successful &&
+		(n_iterations > 1 ||
+		 (capa->api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS)));
 }
 
-static int
-iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-				   struct iwl_mvm_scan_params *params)
+static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			     struct iwl_mvm_scan_params *params)
 {
 	struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
 	struct iwl_scan_probe_req *preq =
 		(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			 mvm->fw->ucode_capa.n_scan_channels);
 	u32 flags = 0, ssid_bitmap = 0;
+	int n_iterations = params->schedule[0].iterations +
+		params->schedule[1].iterations;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -938,7 +875,6 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
 					MAC_FILTER_IN_BEACON);
 	iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck);
-
 	iwl_scan_build_ssids(params, cmd->direct_scan, &ssid_bitmap);
 
 	/* this API uses bits 1-20 instead of 0-19 */
@@ -951,8 +887,7 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	cmd->schedule[1].iterations = params->schedule[1].iterations;
 	cmd->schedule[1].full_scan_mul = params->schedule[1].iterations;
 
-	if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_EBS_SUPPORT &&
-	    mvm->last_ebs_successful) {
+	if (iwl_mvm_scan_use_ebs(mvm, n_iterations)) {
 		cmd->channel_opt[0].flags =
 			cpu_to_le16(IWL_SCAN_CHANNEL_FLAG_EBS |
 				    IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
@@ -975,7 +910,6 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	return 0;
 }
 
-
 int iwl_mvm_cancel_scan(struct iwl_mvm *mvm)
 {
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
@@ -1560,7 +1494,7 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 		ret = iwl_mvm_sched_scan_umac(mvm, vif, &params);
 	} else {
 		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
-		ret = iwl_mvm_sched_scan_lmac(mvm, vif, &params);
+		ret = iwl_mvm_scan_lmac(mvm, vif, &params);
 	}
 
 	if (ret)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 31/42] iwlwifi: mvm: trim sched scan delay down to 16-bit for LMAC as well
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (29 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 30/42] iwlwifi: mvm: combine LMAC scans into one Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 32/42] iwlwifi: mvm: combine UMAC scans into one Emmanuel Grumbach
                   ` (11 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

In theory, LMAC scans can handle a 32-bit delay, but since waiting for
over 18 hours to start the scan is a bit silly and to keep it aligned
with UMAC scans (which only support 16-bit delays), trim it down to
16-bits.

This makes the LMAC vs. UMAC and the UMAC reg scan vs. UMAC sched scan
code more similar.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index f4d38f5..1abbc66 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -80,7 +80,7 @@ struct iwl_mvm_scan_params {
 	u32 suspend_time;
 	bool passive_fragmented;
 	u32 n_channels;
-	u32 delay;
+	u16 delay;
 	int n_ssids;
 	struct cfg80211_ssid *ssids;
 	struct ieee80211_channel **channels;
@@ -1279,14 +1279,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 	/* With UMAC we use only one schedule, so take the final one only */
 	sec_part->schedule[0].iter_count = params->schedule[1].iterations;
 
-	if (params->delay > U16_MAX) {
-		IWL_DEBUG_SCAN(mvm,
-			       "delay value is > 16-bits, set to max possible\n");
-		sec_part->delay = cpu_to_le16(U16_MAX);
-	} else {
-		sec_part->delay = cpu_to_le16(params->delay);
-	}
-
+	sec_part->delay = cpu_to_le16(params->delay);
 	sec_part->preq = params->preq;
 
 	return 0;
@@ -1458,7 +1451,6 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 	params.n_ssids = req->n_ssids;
 	params.flags = req->flags;
 	params.n_channels = req->n_channels;
-	params.delay = req->delay;
 	params.ssids = req->ssids;
 	params.channels = req->channels;
 	params.mac_addr = req->mac_addr;
@@ -1481,6 +1473,19 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 		params.interval = req->interval / MSEC_PER_SEC;
 	}
 
+	/* In theory, LMAC scans can handle a 32-bit delay, but since
+	 * waiting for over 18 hours to start the scan is a bit silly
+	 * and to keep it aligned with UMAC scans (which only support
+	 * 16-bit delays), trim it down to 16-bits.
+	 */
+	if (req->delay > U16_MAX) {
+		IWL_DEBUG_SCAN(mvm,
+			       "delay value is > 16-bits, set to max possible\n");
+		params.delay = U16_MAX;
+	} else {
+		params.delay = req->delay;
+	}
+
 	iwl_mvm_scan_calc_dwell(mvm, vif, &params);
 
 	ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 32/42] iwlwifi: mvm: combine UMAC scans into one
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (30 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 31/42] iwlwifi: mvm: trim sched scan delay down to 16-bit for LMAC as well Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 33/42] iwlwifi: mvm: avoid use-after-free on iwl_mvm_d0i3_enable_tx() [BUGFIX] Emmanuel Grumbach
                   ` (10 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

With just a few differences left in the UMAC scan functions now, we
can merge them into one, taking care of the small difference according
to the total number of iterations required.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 86 +++++++--------------------------
 1 file changed, 17 insertions(+), 69 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 1abbc66..cecc5a3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -1173,6 +1173,8 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			mvm->fw->ucode_capa.n_scan_channels;
 	u32 uid, flags;
 	u32 ssid_bitmap = 0;
+	int n_iterations = params->schedule[0].iterations +
+		params->schedule[1].iterations;
 	int uid_idx;
 
 	lockdep_assert_held(&mvm->mutex);
@@ -1183,77 +1185,22 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);
 
-	uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
-	mvm->scan_uid[uid_idx] = uid;
-	cmd->uid = cpu_to_le32(uid);
-
-	cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
-
 	flags = iwl_mvm_scan_umac_common_flags(mvm, params->n_ssids,
 					       params->ssids,
 					       params->passive_fragmented);
 
-	if (params->pass_all)
-		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
-	else
-		flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH;
-
-	cmd->general_flags = cpu_to_le32(flags);
-
-	if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS &&
-	    mvm->last_ebs_successful)
-		cmd->channel_flags = IWL_SCAN_CHANNEL_FLAG_EBS |
-				     IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
-				     IWL_SCAN_CHANNEL_FLAG_CACHE_ADD;
-
-	cmd->n_channels = params->n_channels;
-
-	iwl_scan_build_ssids(params, sec_part->direct_scan, &ssid_bitmap);
-
-	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
-				       params->n_channels, ssid_bitmap, cmd);
-
-	sec_part->schedule[0].iter_count = params->schedule[0].iterations;
-	sec_part->delay = cpu_to_le16(params->delay);
-	sec_part->preq = params->preq;
-
-	return 0;
-}
-
-static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
-				   struct ieee80211_vif *vif,
-				   struct iwl_mvm_scan_params *params)
-{
-	struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
-	struct iwl_scan_req_umac_tail *sec_part = (void *)&cmd->data +
-		sizeof(struct iwl_scan_channel_cfg_umac) *
-			mvm->fw->ucode_capa.n_scan_channels;
-	u32 uid, flags;
-	u32 ssid_bitmap = 0;
-	int uid_idx;
-
-	lockdep_assert_held(&mvm->mutex);
-
-	uid_idx = iwl_mvm_find_free_scan_uid(mvm);
-	if (uid_idx >= mvm->max_scans)
-		return -EBUSY;
-
-	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);
-
-	cmd->flags = cpu_to_le32(IWL_UMAC_SCAN_FLAG_PREEMPTIVE);
+	if (n_iterations == 1) {
+		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
+		uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
+	} else {
+		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
+		uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN);
+		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
+	}
 
-	uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN);
 	mvm->scan_uid[uid_idx] = uid;
 	cmd->uid = cpu_to_le32(uid);
 
-	cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
-
-	flags = iwl_mvm_scan_umac_common_flags(mvm, params->n_ssids,
-					       params->ssids,
-					       params->passive_fragmented);
-
-	flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
-
 	if (params->pass_all)
 		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
 	else
@@ -1261,8 +1208,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 
 	cmd->general_flags = cpu_to_le32(flags);
 
-	if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_EBS_SUPPORT &&
-	    mvm->last_ebs_successful)
+	if (iwl_mvm_scan_use_ebs(mvm, n_iterations))
 		cmd->channel_flags = IWL_SCAN_CHANNEL_FLAG_EBS |
 				     IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE |
 				     IWL_SCAN_CHANNEL_FLAG_CACHE_ADD;
@@ -1274,11 +1220,13 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
 	iwl_mvm_umac_scan_cfg_channels(mvm, params->channels,
 				       params->n_channels, ssid_bitmap, cmd);
 
+	/* With UMAC we can have only one schedule, so use the sum of
+	 * the iterations (with a a maximum of 255).
+	 */
+	sec_part->schedule[0].iter_count =
+		(n_iterations > 255) ? 255 : n_iterations;
 	sec_part->schedule[0].interval = cpu_to_le16(params->interval);
 
-	/* With UMAC we use only one schedule, so take the final one only */
-	sec_part->schedule[0].iter_count = params->schedule[1].iterations;
-
 	sec_part->delay = cpu_to_le16(params->delay);
 	sec_part->preq = params->preq;
 
@@ -1496,7 +1444,7 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 
 	if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
 		hcmd.id = SCAN_REQ_UMAC;
-		ret = iwl_mvm_sched_scan_umac(mvm, vif, &params);
+		ret = iwl_mvm_scan_umac(mvm, vif, &params);
 	} else {
 		hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
 		ret = iwl_mvm_scan_lmac(mvm, vif, &params);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 33/42] iwlwifi: mvm: avoid use-after-free on iwl_mvm_d0i3_enable_tx() [BUGFIX]
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (31 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 32/42] iwlwifi: mvm: combine UMAC scans into one Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 34/42] iwlwifi: allow to limit the size of the external buffer for firmware debugging Emmanuel Grumbach
                   ` (9 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Eliad Peller, Eliad Peller, Emmanuel Grumbach

From: Eliad Peller <eliad@wizery.com>

qos_seq points (to a struct) inside the command response data.

Make sure to free the response only after qos_seq is not
needed anymore.

type=bugfix
bug=not-tracked
fixes=I78c07110b59dcd389207bd2b168b0a2760839fe0

Change-Id: I619ce2c17e064dc98c7be9abc1e23175fdc8fb9a
Reported-by: Heng Luo <heng.luo@intel.com>
Signed-off-by: Eliad Peller <eliadx.peller@intel.com>
Reviewed-on: https://gerrit.rds.intel.com/r/55381
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Tested-by: IWL Jenkins
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/ops.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index 1c66297..2ea0123 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -1263,11 +1263,13 @@ static void iwl_mvm_d0i3_exit_work(struct work_struct *wk)
 		ieee80211_iterate_active_interfaces(
 			mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
 			iwl_mvm_d0i3_disconnect_iter, mvm);
-
-	iwl_free_resp(&get_status_cmd);
 out:
 	iwl_mvm_d0i3_enable_tx(mvm, qos_seq);
 
+	/* qos_seq might point inside resp_pkt, so free it only now */
+	if (get_status_cmd.resp_pkt)
+		iwl_free_resp(&get_status_cmd);
+
 	/* the FW might have updated the regdomain */
 	iwl_mvm_update_changed_regdom(mvm);
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 34/42] iwlwifi: allow to limit the size of the external buffer for firmware debugging
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (32 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 33/42] iwlwifi: mvm: avoid use-after-free on iwl_mvm_d0i3_enable_tx() [BUGFIX] Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 35/42] iwlwifi: mvm: remove deprecated command IDs Emmanuel Grumbach
                   ` (8 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Emmanuel Grumbach

When we use an external buffer, it is allocated from the
t DRAM and can be as big as 64MB. This buffer is huge and
might not be needed for the specific issue being chased.
Especially if lots of dumps are going to be created.
Allow to limit the size of the buffer in the configuration.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-fw-file.h |  8 +++++---
 drivers/net/wireless/iwlwifi/pcie/trans.c  | 28 +++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-fw-file.h b/drivers/net/wireless/iwlwifi/iwl-fw-file.h
index 62db2e5..c7cfc38 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fw-file.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fw-file.h
@@ -6,7 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications 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
@@ -32,7 +32,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -436,6 +436,7 @@ enum iwl_fw_dbg_monitor_mode {
  *
  * @version: version of the TLV - currently 0
  * @monitor_mode: %enum iwl_fw_dbg_monitor_mode
+ * @size_power: buffer size will be 2^(size_power + 11)
  * @base_reg: addr of the base addr register (PRPH)
  * @end_reg:  addr of the end addr register (PRPH)
  * @write_ptr_reg: the addr of the reg of the write pointer
@@ -449,7 +450,8 @@ enum iwl_fw_dbg_monitor_mode {
 struct iwl_fw_dbg_dest_tlv {
 	u8 version;
 	u8 monitor_mode;
-	u8 reserved[2];
+	u8 size_power;
+	u8 reserved;
 	__le32 base_reg;
 	__le32 end_reg;
 	__le32 write_ptr_reg;
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index d108e5b..4526336 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -101,14 +101,26 @@ static void iwl_pcie_free_fw_monitor(struct iwl_trans *trans)
 	trans_pcie->fw_mon_size = 0;
 }
 
-static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
+static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans, u8 max_power)
 {
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 	struct page *page = NULL;
 	dma_addr_t phys;
-	u32 size;
+	u32 size = 0;
 	u8 power;
 
+	if (!max_power) {
+		/* default max_power is maximum */
+		max_power = 26;
+	} else {
+		max_power += 11;
+	}
+
+	if (WARN(max_power > 26,
+		 "External buffer size for monitor is too big %d, check the FW TLV\n",
+		 max_power))
+		return;
+
 	if (trans_pcie->fw_mon_page) {
 		dma_sync_single_for_device(trans->dev, trans_pcie->fw_mon_phys,
 					   trans_pcie->fw_mon_size,
@@ -117,7 +129,7 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
 	}
 
 	phys = 0;
-	for (power = 26; power >= 11; power--) {
+	for (power = max_power; power >= 11; power--) {
 		int order;
 
 		size = BIT(power);
@@ -143,6 +155,12 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)
 	if (WARN_ON_ONCE(!page))
 		return;
 
+	if (power != max_power)
+		IWL_ERR(trans,
+			"Sorry - debug buffer is only %luK while you requested %luK\n",
+			(unsigned long)BIT(power - 10),
+			(unsigned long)BIT(max_power - 10));
+
 	trans_pcie->fw_mon_page = page;
 	trans_pcie->fw_mon_phys = phys;
 	trans_pcie->fw_mon_size = size;
@@ -834,7 +852,7 @@ static void iwl_pcie_apply_destination(struct iwl_trans *trans)
 		 get_fw_dbg_mode_string(dest->monitor_mode));
 
 	if (dest->monitor_mode == EXTERNAL_MODE)
-		iwl_pcie_alloc_fw_monitor(trans);
+		iwl_pcie_alloc_fw_monitor(trans, dest->size_power);
 	else
 		IWL_WARN(trans, "PCI should have external buffer debug\n");
 
@@ -908,7 +926,7 @@ static int iwl_pcie_load_given_ucode(struct iwl_trans *trans,
 	/* supported for 7000 only for the moment */
 	if (iwlwifi_mod_params.fw_monitor &&
 	    trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
-		iwl_pcie_alloc_fw_monitor(trans);
+		iwl_pcie_alloc_fw_monitor(trans, 0);
 
 		if (trans_pcie->fw_mon_size) {
 			iwl_write_prph(trans, MON_BUFF_BASE_ADDR,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 35/42] iwlwifi: mvm: remove deprecated command IDs
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (33 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 34/42] iwlwifi: allow to limit the size of the external buffer for firmware debugging Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 36/42] iwlwifi: mvm: move all UMAC scan flags setting into the relevant function Emmanuel Grumbach
                   ` (7 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: David Spinadel, Emmanuel Grumbach

From: David Spinadel <david.spinadel@intel.com>

Signed-off-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/fw-api.h |  7 -------
 drivers/net/wireless/iwlwifi/mvm/fw.c     | 15 ---------------
 drivers/net/wireless/iwlwifi/mvm/mvm.h    |  4 ----
 drivers/net/wireless/iwlwifi/mvm/ops.c    |  3 ---
 4 files changed, 29 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
index 01b1da6..56db2ba 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
@@ -147,13 +147,6 @@ enum {
 
 	LQ_CMD = 0x4e,
 
-	/* Calibration */
-	TEMPERATURE_NOTIFICATION = 0x62,
-	CALIBRATION_CFG_CMD = 0x65,
-	CALIBRATION_RES_NOTIFICATION = 0x66,
-	CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
-	RADIO_VERSION_NOTIFICATION = 0x68,
-
 	/* Scan offload */
 	SCAN_OFFLOAD_REQUEST_CMD = 0x51,
 	SCAN_OFFLOAD_ABORT_CMD = 0x52,
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c
index df86963..0601445 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/iwlwifi/mvm/fw.c
@@ -832,21 +832,6 @@ int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
 	return 0;
 }
 
-int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
-			 struct iwl_device_cmd *cmd)
-{
-	struct iwl_rx_packet *pkt = rxb_addr(rxb);
-	struct iwl_radio_version_notif *radio_version = (void *)pkt->data;
-
-	/* TODO: what to do with that? */
-	IWL_DEBUG_INFO(mvm,
-		       "Radio version: flavor: 0x%08x, step 0x%08x, dash 0x%08x\n",
-		       le32_to_cpu(radio_version->radio_flavor),
-		       le32_to_cpu(radio_version->radio_step),
-		       le32_to_cpu(radio_version->radio_dash));
-	return 0;
-}
-
 int iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
 			    struct iwl_rx_cmd_buffer *rxb,
 			    struct iwl_device_cmd *cmd)
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index 7679ad6..e6169c6 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -1100,8 +1100,6 @@ int iwl_mvm_rx_tx_cmd(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
 		      struct iwl_device_cmd *cmd);
 int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
 			struct iwl_device_cmd *cmd);
-int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
-			 struct iwl_device_cmd *cmd);
 int iwl_mvm_rx_ant_coupling_notif(struct iwl_mvm *mvm,
 				  struct iwl_rx_cmd_buffer *rxb,
 				  struct iwl_device_cmd *cmd);
@@ -1110,8 +1108,6 @@ int iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
 int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
 				struct iwl_rx_cmd_buffer *rxb,
 				struct iwl_device_cmd *cmd);
-int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
-			 struct iwl_device_cmd *cmd);
 int iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
 			    struct iwl_device_cmd *cmd);
 int iwl_mvm_rx_shared_mem_cfg_notif(struct iwl_mvm *mvm,
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index 2ea0123..02028bc 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -246,7 +246,6 @@ static const struct iwl_rx_handlers iwl_mvm_rx_handlers[] = {
 	RX_HANDLER(SCAN_COMPLETE_UMAC, iwl_mvm_rx_umac_scan_complete_notif,
 		   true),
 
-	RX_HANDLER(RADIO_VERSION_NOTIFICATION, iwl_mvm_rx_radio_ver, false),
 	RX_HANDLER(CARD_STATE_NOTIFICATION, iwl_mvm_rx_card_state_notif, false),
 
 	RX_HANDLER(MISSED_BEACONS_NOTIFICATION, iwl_mvm_rx_missed_beacons_notif,
@@ -280,7 +279,6 @@ static const char *const iwl_mvm_cmd_strings[REPLY_MAX] = {
 	CMD(BINDING_CONTEXT_CMD),
 	CMD(TIME_QUOTA_CMD),
 	CMD(NON_QOS_TX_COUNTER_CMD),
-	CMD(RADIO_VERSION_NOTIFICATION),
 	CMD(SCAN_REQUEST_CMD),
 	CMD(SCAN_ABORT_CMD),
 	CMD(SCAN_START_NOTIFICATION),
@@ -290,7 +288,6 @@ static const char *const iwl_mvm_cmd_strings[REPLY_MAX] = {
 	CMD(PHY_CONFIGURATION_CMD),
 	CMD(CALIB_RES_NOTIF_PHY_DB),
 	CMD(SET_CALIB_DEFAULT_CMD),
-	CMD(CALIBRATION_COMPLETE_NOTIFICATION),
 	CMD(ADD_STA_KEY),
 	CMD(ADD_STA),
 	CMD(REMOVE_STA),
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 36/42] iwlwifi: mvm: move all UMAC scan flags setting into the relevant function
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (34 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 35/42] iwlwifi: mvm: remove deprecated command IDs Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 37/42] iwlwifi: mvm: move all LMAC scan flags into a single funtion Emmanuel Grumbach
                   ` (6 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Clean the code a little by moving all the flags into the right
function.  Additionally, rename the function, since "common" is now
irrelevant.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 44 ++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index cecc5a3..437adc3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -831,6 +831,11 @@ static inline bool iwl_mvm_scan_use_ebs(struct iwl_mvm *mvm, int n_iterations)
 		 (capa->api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS)));
 }
 
+static int iwl_mvm_scan_total_iterations(struct iwl_mvm_scan_params *params)
+{
+	return params->schedule[0].iterations + params->schedule[1].iterations;
+}
+
 static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			     struct iwl_mvm_scan_params *params)
 {
@@ -839,8 +844,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 		(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			 mvm->fw->ucode_capa.n_scan_channels);
 	u32 flags = 0, ssid_bitmap = 0;
-	int n_iterations = params->schedule[0].iterations +
-		params->schedule[1].iterations;
+	int n_iterations = iwl_mvm_scan_total_iterations(params);
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -1143,24 +1147,31 @@ iwl_mvm_umac_scan_cfg_channels(struct iwl_mvm *mvm,
 	}
 }
 
-static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids,
-					  struct cfg80211_ssid *ssids,
-					  int fragmented)
+static u32 iwl_mvm_scan_umac_flags(struct iwl_mvm *mvm,
+				   struct iwl_mvm_scan_params *params)
 {
 	int flags = 0;
 
-	if (n_ssids == 0)
+	if (params->n_ssids == 0)
 		flags = IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE;
 
-	if (n_ssids == 1 && ssids[0].ssid_len != 0)
+	if (params->n_ssids == 1 && params->ssids[0].ssid_len != 0)
 		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT;
 
-	if (fragmented)
+	if (params->passive_fragmented)
 		flags |= IWL_UMAC_SCAN_GEN_FLAGS_FRAGMENTED;
 
 	if (iwl_mvm_rrm_scan_needed(mvm))
 		flags |= IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED;
 
+	if (params->pass_all)
+		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
+	else
+		flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH;
+
+	if (iwl_mvm_scan_total_iterations(params) > 1)
+		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
+
 	return flags;
 }
 
@@ -1171,10 +1182,9 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	struct iwl_scan_req_umac_tail *sec_part = (void *)&cmd->data +
 		sizeof(struct iwl_scan_channel_cfg_umac) *
 			mvm->fw->ucode_capa.n_scan_channels;
-	u32 uid, flags;
+	u32 uid;
 	u32 ssid_bitmap = 0;
-	int n_iterations = params->schedule[0].iterations +
-		params->schedule[1].iterations;
+	int n_iterations = iwl_mvm_scan_total_iterations(params);
 	int uid_idx;
 
 	lockdep_assert_held(&mvm->mutex);
@@ -1185,28 +1195,18 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);
 
-	flags = iwl_mvm_scan_umac_common_flags(mvm, params->n_ssids,
-					       params->ssids,
-					       params->passive_fragmented);
-
 	if (n_iterations == 1) {
 		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
 		uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
 	} else {
 		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
 		uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN);
-		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
 	}
 
 	mvm->scan_uid[uid_idx] = uid;
 	cmd->uid = cpu_to_le32(uid);
 
-	if (params->pass_all)
-		flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
-	else
-		flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH;
-
-	cmd->general_flags = cpu_to_le32(flags);
+	cmd->general_flags = cpu_to_le32(iwl_mvm_scan_umac_flags(mvm, params));
 
 	if (iwl_mvm_scan_use_ebs(mvm, n_iterations))
 		cmd->channel_flags = IWL_SCAN_CHANNEL_FLAG_EBS |
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 37/42] iwlwifi: mvm: move all LMAC scan flags into a single funtion
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (35 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 36/42] iwlwifi: mvm: move all UMAC scan flags setting into the relevant function Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 38/42] iwlwifi: mvm: rename generic_scan_cmd functions to dwell Emmanuel Grumbach
                   ` (5 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Having an LMAC counterpart for the existing UMAC flags function makes
things more consistent and easy to compare and spot the differences.
The flags are the same, but are in different bits, so unfortunately we
can't use a single function for both APIs.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 57 ++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 437adc3..277fe79 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -798,10 +798,6 @@ iwl_mvm_build_generic_scan_cmd(struct iwl_mvm *mvm,
 	cmd->suspend_time = cpu_to_le32(params->suspend_time);
 	cmd->scan_prio = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
 	cmd->iter_num = cpu_to_le32(1);
-
-	if (iwl_mvm_rrm_scan_needed(mvm))
-		cmd->scan_flags |=
-			cpu_to_le32(IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED);
 }
 
 static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
@@ -836,6 +832,36 @@ static int iwl_mvm_scan_total_iterations(struct iwl_mvm_scan_params *params)
 	return params->schedule[0].iterations + params->schedule[1].iterations;
 }
 
+static int iwl_mvm_scan_lmac_flags(struct iwl_mvm *mvm,
+				   struct iwl_mvm_scan_params *params)
+{
+	int flags = 0;
+
+	if (params->n_ssids == 0)
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE;
+
+	if (params->n_ssids == 1 && params->ssids[0].ssid_len != 0)
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
+
+	if (params->passive_fragmented)
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
+
+	if (iwl_mvm_rrm_scan_needed(mvm))
+		flags |= IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED;
+
+	if (params->pass_all)
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;
+	else
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_MATCH;
+
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+	if (mvm->scan_iter_notif_enabled)
+		flags |= IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE;
+#endif
+
+	return flags;
+}
+
 static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			     struct iwl_mvm_scan_params *params)
 {
@@ -843,7 +869,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	struct iwl_scan_probe_req *preq =
 		(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
 			 mvm->fw->ucode_capa.n_scan_channels);
-	u32 flags = 0, ssid_bitmap = 0;
+	u32 ssid_bitmap = 0;
 	int n_iterations = iwl_mvm_scan_total_iterations(params);
 
 	lockdep_assert_held(&mvm->mutex);
@@ -854,26 +880,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	cmd->delay = cpu_to_le32(params->delay);
 
-	if (params->pass_all)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;
-	else
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_MATCH;
-
-	if (params->n_ssids == 1 && params->ssids[0].ssid_len != 0)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
-
-	if (params->passive_fragmented)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;
-
-	if (params->n_ssids == 0)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_PASSIVE;
-
-#ifdef CONFIG_IWLWIFI_DEBUGFS
-	if (mvm->scan_iter_notif_enabled)
-		flags |= IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE;
-#endif
-
-	cmd->scan_flags |= cpu_to_le32(flags);
+	cmd->scan_flags = cpu_to_le32(iwl_mvm_scan_lmac_flags(mvm, params));
 
 	cmd->flags = iwl_mvm_scan_rxon_flags(params->channels[0]->band);
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP |
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 38/42] iwlwifi: mvm: rename generic_scan_cmd functions to dwell
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (36 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 37/42] iwlwifi: mvm: move all LMAC scan flags into a single funtion Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 39/42] iwlwifi: mvm: don't reset key index on HW restart Emmanuel Grumbach
                   ` (4 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

The generic scan command functions are now irrelevant, since both
sched and regular scans are in the same code.  So rename this
functions to dwell and isolate all the dwell-related setting to them.
Keeping the dwell code separate makes it easier to compare the LMAC
and UMAC versions.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 40 +++++++++++++++++----------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 277fe79..8646887 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -782,22 +782,18 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	params->preq.common_data.len = cpu_to_le16(ies->common_ie_len);
 }
 
-static void
-iwl_mvm_build_generic_scan_cmd(struct iwl_mvm *mvm,
-			       struct iwl_scan_req_lmac *cmd,
-			       struct iwl_mvm_scan_params *params)
+static void iwl_mvm_scan_lmac_dwell(struct iwl_mvm *mvm,
+				    struct iwl_scan_req_lmac *cmd,
+				    struct iwl_mvm_scan_params *params)
 {
-	memset(cmd, 0, ksize(cmd));
 	cmd->active_dwell = params->dwell[IEEE80211_BAND_2GHZ].active;
 	cmd->passive_dwell = params->dwell[IEEE80211_BAND_2GHZ].passive;
 	if (params->passive_fragmented)
 		cmd->fragmented_dwell =
 				params->dwell[IEEE80211_BAND_2GHZ].fragmented;
-	cmd->rx_chain_select = iwl_mvm_scan_rx_chain(mvm);
 	cmd->max_out_time = cpu_to_le32(params->max_out_time);
 	cmd->suspend_time = cpu_to_le32(params->suspend_time);
 	cmd->scan_prio = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
-	cmd->iter_num = cpu_to_le32(1);
 }
 
 static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
@@ -874,8 +870,12 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 
 	lockdep_assert_held(&mvm->mutex);
 
-	iwl_mvm_build_generic_scan_cmd(mvm, cmd, params);
+	memset(cmd, 0, ksize(cmd));
+
+	iwl_mvm_scan_lmac_dwell(mvm, cmd, params);
 
+	cmd->rx_chain_select = iwl_mvm_scan_rx_chain(mvm);
+	cmd->iter_num = cpu_to_le32(1);
 	cmd->n_channels = (u8)params->n_channels;
 
 	cmd->delay = cpu_to_le32(params->delay);
@@ -1119,14 +1119,10 @@ static u32 iwl_generate_scan_uid(struct iwl_mvm *mvm,
 	return uid;
 }
 
-static void
-iwl_mvm_build_generic_umac_scan_cmd(struct iwl_mvm *mvm,
+static void iwl_mvm_scan_umac_dwell(struct iwl_mvm *mvm,
 				    struct iwl_scan_req_umac *cmd,
 				    struct iwl_mvm_scan_params *params)
 {
-	memset(cmd, 0, ksize(cmd));
-	cmd->hdr.size = cpu_to_le16(iwl_mvm_scan_size(mvm) -
-				    sizeof(struct iwl_mvm_umac_cmd_hdr));
 	cmd->active_dwell = params->dwell[IEEE80211_BAND_2GHZ].active;
 	cmd->passive_dwell = params->dwell[IEEE80211_BAND_2GHZ].passive;
 	if (params->passive_fragmented)
@@ -1135,6 +1131,11 @@ iwl_mvm_build_generic_umac_scan_cmd(struct iwl_mvm *mvm,
 	cmd->max_out_time = cpu_to_le32(params->max_out_time);
 	cmd->suspend_time = cpu_to_le32(params->suspend_time);
 	cmd->scan_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
+
+	if (iwl_mvm_scan_total_iterations(params) == 0)
+		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
+	else
+		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
 }
 
 static void
@@ -1200,15 +1201,16 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (uid_idx >= mvm->max_scans)
 		return -EBUSY;
 
-	iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);
+	memset(cmd, 0, ksize(cmd));
+	cmd->hdr.size = cpu_to_le16(iwl_mvm_scan_size(mvm) -
+				    sizeof(struct iwl_mvm_umac_cmd_hdr));
 
-	if (n_iterations == 1) {
-		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
+	iwl_mvm_scan_umac_dwell(mvm, cmd, params);
+
+	if (n_iterations == 1)
 		uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
-	} else {
-		cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
+	else
 		uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN);
-	}
 
 	mvm->scan_uid[uid_idx] = uid;
 	cmd->uid = cpu_to_le32(uid);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 39/42] iwlwifi: mvm: don't reset key index on HW restart
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (37 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 38/42] iwlwifi: mvm: rename generic_scan_cmd functions to dwell Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 40/42] iwlwifi: mvm: make thermal throttling values configurable per NIC family Emmanuel Grumbach
                   ` (3 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Johannes Berg, Emmanuel Grumbach

From: Johannes Berg <johannes.berg@intel.com>

When a firmware restart is done, don't try to reprogram the keys to new
slots but rather just keep the old key index, while skipping keys that
weren't programmed before.

Not only does this restore the state more faithfully, but it will also
allow using the HW key index for internal purposes as an array index.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index eca1666..b56a445 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1249,7 +1249,6 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
 	mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT;
 
 	iwl_mvm_reset_phy_ctxts(mvm);
-	memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
 	memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained));
 	memset(mvm->tfd_drained, 0, sizeof(mvm->tfd_drained));
 	memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif));
@@ -2843,8 +2842,21 @@ static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
 			break;
 		}
 
+		/* During FW restart, in order to restore the state as it was,
+		 * don't try to reprogram keys we previously failed for.
+		 */
+		if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
+		    key->hw_key_idx == STA_KEY_IDX_INVALID) {
+			IWL_DEBUG_MAC80211(mvm,
+					   "skip invalid idx key programming during restart\n");
+			ret = 0;
+			break;
+		}
+
 		IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n");
-		ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false);
+		ret = iwl_mvm_set_sta_key(mvm, vif, sta, key,
+					  test_bit(IWL_MVM_STATUS_IN_HW_RESTART,
+						   &mvm->status));
 		if (ret) {
 			IWL_WARN(mvm, "set key failed\n");
 			/*
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 40/42] iwlwifi: mvm: make thermal throttling values configurable per NIC family
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (38 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 39/42] iwlwifi: mvm: don't reset key index on HW restart Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 41/42] iwlwifi: mvm: remove some unused stuff from scan.c Emmanuel Grumbach
                   ` (2 subsequent siblings)
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Chaya Rachel Ivgi, Emmanuel Grumbach

From: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>

The thermal throttling parameters were constant and hardcoded, not allowing
changes for different NIC families.
Change this so that the values are part of the NIC family configuration and
are not constant (so they can be changed dynamically in the future).

Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-7000.c   | 23 ++++++++++++++++
 drivers/net/wireless/iwlwifi/iwl-config.h | 44 +++++++++++++++++++++++++++++
 drivers/net/wireless/iwlwifi/mvm/mvm.h    | 46 ++-----------------------------
 drivers/net/wireless/iwlwifi/mvm/tt.c     | 40 ++++++---------------------
 4 files changed, 78 insertions(+), 75 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-7000.c b/drivers/net/wireless/iwlwifi/iwl-7000.c
index 36e786f..69b2c0b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-7000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-7000.c
@@ -128,6 +128,28 @@ static const struct iwl_base_params iwl7000_base_params = {
 	.apmg_wake_up_wa = true,
 };
 
+static const struct iwl_tt_params iwl7000_high_temp_tt_params = {
+	.ct_kill_entry = 118,
+	.ct_kill_exit = 96,
+	.ct_kill_duration = 5,
+	.dynamic_smps_entry = 114,
+	.dynamic_smps_exit = 110,
+	.tx_protection_entry = 114,
+	.tx_protection_exit = 108,
+	.tx_backoff = {
+		{.temperature = 112, .backoff = 300},
+		{.temperature = 113, .backoff = 800},
+		{.temperature = 114, .backoff = 1500},
+		{.temperature = 115, .backoff = 3000},
+		{.temperature = 116, .backoff = 5000},
+		{.temperature = 117, .backoff = 10000},
+	},
+	.support_ct_kill = true,
+	.support_dynamic_smps = true,
+	.support_tx_protection = true,
+	.support_tx_backoff = true,
+};
+
 static const struct iwl_ht_params iwl7000_ht_params = {
 	.stbc = true,
 	.ht40_bands = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ),
@@ -170,6 +192,7 @@ const struct iwl_cfg iwl7260_2ac_cfg_high_temp = {
 	.host_interrupt_operation_mode = true,
 	.lp_xtal_workaround = true,
 	.dccm_len = IWL7260_DCCM_LEN,
+	.thermal_params = &iwl7000_high_temp_tt_params,
 };
 
 const struct iwl_cfg iwl7260_2n_cfg = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-config.h b/drivers/net/wireless/iwlwifi/iwl-config.h
index 3f33f75..225b6d6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/iwlwifi/iwl-config.h
@@ -195,6 +195,49 @@ struct iwl_ht_params {
 };
 
 /*
+ * Tx-backoff threshold
+ * @temperature: The threshold in Celsius
+ * @backoff: The tx-backoff in uSec
+ */
+struct iwl_tt_tx_backoff {
+	s32 temperature;
+	u32 backoff;
+};
+
+#define TT_TX_BACKOFF_SIZE 6
+
+/**
+ * struct iwl_tt_params - thermal throttling parameters
+ * @ct_kill_entry: CT Kill entry threshold
+ * @ct_kill_exit: CT Kill exit threshold
+ * @ct_kill_duration: The time  intervals (in uSec) in which the driver needs
+ *	to checks whether to exit CT Kill.
+ * @dynamic_smps_entry: Dynamic SMPS entry threshold
+ * @dynamic_smps_exit: Dynamic SMPS exit threshold
+ * @tx_protection_entry: TX protection entry threshold
+ * @tx_protection_exit: TX protection exit threshold
+ * @tx_backoff: Array of thresholds for tx-backoff , in ascending order.
+ * @support_ct_kill: Support CT Kill?
+ * @support_dynamic_smps: Support dynamic SMPS?
+ * @support_tx_protection: Support tx protection?
+ * @support_tx_backoff: Support tx-backoff?
+ */
+struct iwl_tt_params {
+	s32 ct_kill_entry;
+	s32 ct_kill_exit;
+	u32 ct_kill_duration;
+	s32 dynamic_smps_entry;
+	s32 dynamic_smps_exit;
+	s32 tx_protection_entry;
+	s32 tx_protection_exit;
+	struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE];
+	bool support_ct_kill;
+	bool support_dynamic_smps;
+	bool support_tx_protection;
+	bool support_tx_backoff;
+};
+
+/*
  * information on how to parse the EEPROM
  */
 #define EEPROM_REG_BAND_1_CHANNELS		0x08
@@ -316,6 +359,7 @@ struct iwl_cfg {
 	const u32 dccm2_len;
 	const u32 smem_offset;
 	const u32 smem_len;
+	const struct iwl_tt_params *thermal_params;
 };
 
 /*
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index e6169c6..6d33234 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -76,6 +76,7 @@
 #include "iwl-notif-wait.h"
 #include "iwl-eeprom-parse.h"
 #include "iwl-fw-file.h"
+#include "iwl-config.h"
 #include "sta.h"
 #include "fw-api.h"
 #include "constants.h"
@@ -477,49 +478,6 @@ struct iwl_nvm_section {
 	const u8 *data;
 };
 
-/*
- * Tx-backoff threshold
- * @temperature: The threshold in Celsius
- * @backoff: The tx-backoff in uSec
- */
-struct iwl_tt_tx_backoff {
-	s32 temperature;
-	u32 backoff;
-};
-
-#define TT_TX_BACKOFF_SIZE 6
-
-/**
- * struct iwl_tt_params - thermal throttling parameters
- * @ct_kill_entry: CT Kill entry threshold
- * @ct_kill_exit: CT Kill exit threshold
- * @ct_kill_duration: The time  intervals (in uSec) in which the driver needs
- *	to checks whether to exit CT Kill.
- * @dynamic_smps_entry: Dynamic SMPS entry threshold
- * @dynamic_smps_exit: Dynamic SMPS exit threshold
- * @tx_protection_entry: TX protection entry threshold
- * @tx_protection_exit: TX protection exit threshold
- * @tx_backoff: Array of thresholds for tx-backoff , in ascending order.
- * @support_ct_kill: Support CT Kill?
- * @support_dynamic_smps: Support dynamic SMPS?
- * @support_tx_protection: Support tx protection?
- * @support_tx_backoff: Support tx-backoff?
- */
-struct iwl_tt_params {
-	s32 ct_kill_entry;
-	s32 ct_kill_exit;
-	u32 ct_kill_duration;
-	s32 dynamic_smps_entry;
-	s32 dynamic_smps_exit;
-	s32 tx_protection_entry;
-	s32 tx_protection_exit;
-	struct iwl_tt_tx_backoff tx_backoff[TT_TX_BACKOFF_SIZE];
-	bool support_ct_kill;
-	bool support_dynamic_smps;
-	bool support_tx_protection;
-	bool support_tx_backoff;
-};
-
 /**
  * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure
  * @ct_kill_exit: worker to exit thermal kill
@@ -534,7 +492,7 @@ struct iwl_mvm_tt_mgmt {
 	bool dynamic_smps;
 	u32 tx_backoff;
 	u32 min_backoff;
-	const struct iwl_tt_params *params;
+	struct iwl_tt_params params;
 	bool throttle;
 };
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/tt.c b/drivers/net/wireless/iwlwifi/mvm/tt.c
index ba615ad..80d07db 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tt.c
@@ -70,7 +70,7 @@
 static void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm)
 {
 	struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
-	u32 duration = mvm->thermal_throttle.params->ct_kill_duration;
+	u32 duration = tt->params.ct_kill_duration;
 
 	if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
 		return;
@@ -223,7 +223,7 @@ static void check_exit_ctkill(struct work_struct *work)
 	tt = container_of(work, struct iwl_mvm_tt_mgmt, ct_kill_exit.work);
 	mvm = container_of(tt, struct iwl_mvm, thermal_throttle);
 
-	duration = tt->params->ct_kill_duration;
+	duration = tt->params.ct_kill_duration;
 
 	mutex_lock(&mvm->mutex);
 
@@ -247,7 +247,7 @@ static void check_exit_ctkill(struct work_struct *work)
 
 	IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", temp);
 
-	if (temp <= tt->params->ct_kill_exit) {
+	if (temp <= tt->params.ct_kill_exit) {
 		mutex_unlock(&mvm->mutex);
 		iwl_mvm_exit_ctkill(mvm);
 		return;
@@ -325,7 +325,7 @@ void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff)
 
 void iwl_mvm_tt_handler(struct iwl_mvm *mvm)
 {
-	const struct iwl_tt_params *params = mvm->thermal_throttle.params;
+	struct iwl_tt_params *params = &mvm->thermal_throttle.params;
 	struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
 	s32 temperature = mvm->temperature;
 	bool throttle_enable = false;
@@ -340,7 +340,7 @@ void iwl_mvm_tt_handler(struct iwl_mvm *mvm)
 	}
 
 	if (params->support_ct_kill &&
-	    temperature <= tt->params->ct_kill_exit) {
+	    temperature <= params->ct_kill_exit) {
 		iwl_mvm_exit_ctkill(mvm);
 		return;
 	}
@@ -400,7 +400,7 @@ void iwl_mvm_tt_handler(struct iwl_mvm *mvm)
 	}
 }
 
-static const struct iwl_tt_params iwl7000_tt_params = {
+static const struct iwl_tt_params iwl_mvm_default_tt_params = {
 	.ct_kill_entry = 118,
 	.ct_kill_exit = 96,
 	.ct_kill_duration = 5,
@@ -422,38 +422,16 @@ static const struct iwl_tt_params iwl7000_tt_params = {
 	.support_tx_backoff = true,
 };
 
-static const struct iwl_tt_params iwl7000_high_temp_tt_params = {
-	.ct_kill_entry = 118,
-	.ct_kill_exit = 96,
-	.ct_kill_duration = 5,
-	.dynamic_smps_entry = 114,
-	.dynamic_smps_exit = 110,
-	.tx_protection_entry = 114,
-	.tx_protection_exit = 108,
-	.tx_backoff = {
-		{.temperature = 112, .backoff = 300},
-		{.temperature = 113, .backoff = 800},
-		{.temperature = 114, .backoff = 1500},
-		{.temperature = 115, .backoff = 3000},
-		{.temperature = 116, .backoff = 5000},
-		{.temperature = 117, .backoff = 10000},
-	},
-	.support_ct_kill = true,
-	.support_dynamic_smps = true,
-	.support_tx_protection = true,
-	.support_tx_backoff = true,
-};
-
 void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff)
 {
 	struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
 
 	IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n");
 
-	if (mvm->cfg->high_temp)
-		tt->params = &iwl7000_high_temp_tt_params;
+	if (mvm->cfg->thermal_params)
+		tt->params = *mvm->cfg->thermal_params;
 	else
-		tt->params = &iwl7000_tt_params;
+		tt->params = iwl_mvm_default_tt_params;
 
 	tt->throttle = false;
 	tt->dynamic_smps = false;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 41/42] iwlwifi: mvm: remove some unused stuff from scan.c
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (39 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 40/42] iwlwifi: mvm: make thermal throttling values configurable per NIC family Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-03 19:31 ` [PATCH 42/42] iwlwifi: mvm: include wildcard SSID in scans Emmanuel Grumbach
  2015-05-09 13:24 ` pull request: iwlwifi-next 2015-05-03 Kalle Valo
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luciano Coelho, Emmanuel Grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Some more tidbits left over from the legacy scan removal.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 8646887..3c33d61 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -67,11 +67,8 @@
 #include <net/mac80211.h>
 
 #include "mvm.h"
-#include "iwl-eeprom-parse.h"
 #include "fw-api-scan.h"
 
-#define IWL_PLCP_QUIET_THRESH 1
-#define IWL_ACTIVE_QUIET_TIME 10
 #define IWL_DENSE_EBS_SCAN_RATIO 5
 #define IWL_SPARSE_EBS_SCAN_RATIO 1
 
@@ -107,8 +104,6 @@ struct iwl_mvm_scan_params {
 enum iwl_umac_scan_uid_type {
 	IWL_UMAC_SCAN_UID_REG_SCAN	= BIT(0),
 	IWL_UMAC_SCAN_UID_SCHED_SCAN	= BIT(1),
-	IWL_UMAC_SCAN_UID_ALL		= IWL_UMAC_SCAN_UID_REG_SCAN |
-					  IWL_UMAC_SCAN_UID_SCHED_SCAN,
 };
 
 static int iwl_umac_scan_stop(struct iwl_mvm *mvm,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 42/42] iwlwifi: mvm: include wildcard SSID in scans
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (40 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 41/42] iwlwifi: mvm: remove some unused stuff from scan.c Emmanuel Grumbach
@ 2015-05-03 19:31 ` Emmanuel Grumbach
  2015-05-09 13:24 ` pull request: iwlwifi-next 2015-05-03 Kalle Valo
  42 siblings, 0 replies; 44+ messages in thread
From: Emmanuel Grumbach @ 2015-05-03 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: David Spinadel, Emmanuel Grumbach

From: David Spinadel <david.spinadel@intel.com>

Fix a copy paste bug that didn't copy wildcard SSIDs to
scan requests. This bug causes scan with only wildcard
SSID to be passive, and scans with more than one SSID to
send only the direct probes.

Fixes: 2a28ac14c518 ("iwlwifi: mvm: add common scan params to thw iwl_mvm_scan_params struct")
Signed-off-by: David Spinadel <david.spinadel@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/scan.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 3c33d61..e50fd3f 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -452,8 +452,6 @@ static void iwl_scan_build_ssids(struct iwl_mvm_scan_params *params,
 				       params->ssids[j].ssid_len,
 				       ssids);
 		if (index < 0) {
-			if (!params->ssids[j].ssid_len)
-				continue;
 			ssids[i].id = WLAN_EID_SSID;
 			ssids[i].len = params->ssids[j].ssid_len;
 			memcpy(ssids[i].ssid, params->ssids[j].ssid,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: pull request: iwlwifi-next 2015-05-03
  2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
                   ` (41 preceding siblings ...)
  2015-05-03 19:31 ` [PATCH 42/42] iwlwifi: mvm: include wildcard SSID in scans Emmanuel Grumbach
@ 2015-05-09 13:24 ` Kalle Valo
  42 siblings, 0 replies; 44+ messages in thread
From: Kalle Valo @ 2015-05-09 13:24 UTC (permalink / raw)
  To: Grumbach, Emmanuel; +Cc: linux-wireless

"Grumbach, Emmanuel" <emmanuel.grumbach@intel.com> writes:

> Hi Kalle,
>
> Here is my first pull request for 4.2. As usual, details in the tag.
> Please pull - thanks!
>
> The following changes since commit 6c373ca89399c5a3f7ef210ad8f63dc3437da345:
>
>   Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next (2015-04-15 09:00:47 -0700)
>
> are available in the git repository at:
>
>   https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next.git tags/iwlwifi-next-for-kalle-2015-05-03
>
> for you to fetch changes up to 05c3274d56ee783cb291a779ec2b369e9d172450:
>
>   iwlwifi: mvm: include wildcard SSID in scans (2015-05-03 22:18:33 +0300)
>
> ----------------------------------------------------------------
> * major rework of the scan code (Luca)
> * some work on the thermal code (Chaya Rachel)
> * some work on the firwmare debugging infrastructure
>
> ----------------------------------------------------------------

Thanks, pulled.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2015-05-09 13:24 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03 19:30 pull request: iwlwifi-next 2015-05-03 Grumbach, Emmanuel
2015-05-03 19:31 ` [PATCH 01/42] iwlwifi: mvm: ROC: Reduce the aux roc max delay Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 02/42] iwlwifi: rs: remove code duplication when filling lq cmd Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 03/42] iwlwifi: rs: cleanup last_txrate_idx Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 04/42] iwlwifi: mvm: add scan parameters debugging info Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 05/42] iwlwifi: mvm: don't increase max_out_time when low priority scan is requested Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 06/42] iwlwifi: mvm: convert scan_status to a bitmap Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 07/42] iwlwifi: mvm: don't wait for scan stopped work when cancelling scans Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 08/42] iwlwifi: mvm: check if scan can be started before cancelling other scans Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 09/42] iwlwifi: mvm: generalize the other-scan stopping code Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 10/42] iwlwifi: mvm: rename unified_scan symbols to just scan Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 11/42] iwlwifi: mvm: move scan code from mac80211.c to scan.c Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 12/42] iwlwifi: mvm: differentiate net-detect from sched scan Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 13/42] iwlwifi: pcie: support marbh fw dbg mode Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 14/42] iwlwifi: rs: remove unneeded check of average tpt in window Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 15/42] iwlwifi: mvm: some clean ups in fw-api-scan.h Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 16/42] iwlwifi: mvm: allow scheduled scan for all the firmwares Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 17/42] iwlwifi: mvm: always use iwl_mvm_scan_size to calculate the scan size Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 18/42] iwlwifi: mvm: combine scan size checks into a common function Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 19/42] iwlwifi: mvm: iterate all interfaces during HW recovery cleanup Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 20/42] iwlwifi: clarify the device / firmware mapping in Kconfig Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 21/42] iwlwifi: mvm: combine parts of UMAC and LMAC scans Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 22/42] iwlwifi: mvm: combine parts of UMAC and LMAC sched scans Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 23/42] iwlwifi: mvm: add common scan params to thw iwl_mvm_scan_params struct Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 24/42] iwlwifi: mvm: combine ssid_bitmap setting for regular scans Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 25/42] iwlwifi: mvm: revert order of SSIDs for sched scans Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 26/42] iwlwifi: mvm: combine SSID functions for sched and regular scans Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 27/42] iwlwifi: mvm: rename scan_calc_params to scan_calc_dwell Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 28/42] iwlwifi: mvm: combine LMAC and UMAC preq generation Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 29/42] iwlwifi: mvm: add number of scan iterations and multiplier to params Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 30/42] iwlwifi: mvm: combine LMAC scans into one Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 31/42] iwlwifi: mvm: trim sched scan delay down to 16-bit for LMAC as well Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 32/42] iwlwifi: mvm: combine UMAC scans into one Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 33/42] iwlwifi: mvm: avoid use-after-free on iwl_mvm_d0i3_enable_tx() [BUGFIX] Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 34/42] iwlwifi: allow to limit the size of the external buffer for firmware debugging Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 35/42] iwlwifi: mvm: remove deprecated command IDs Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 36/42] iwlwifi: mvm: move all UMAC scan flags setting into the relevant function Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 37/42] iwlwifi: mvm: move all LMAC scan flags into a single funtion Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 38/42] iwlwifi: mvm: rename generic_scan_cmd functions to dwell Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 39/42] iwlwifi: mvm: don't reset key index on HW restart Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 40/42] iwlwifi: mvm: make thermal throttling values configurable per NIC family Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 41/42] iwlwifi: mvm: remove some unused stuff from scan.c Emmanuel Grumbach
2015-05-03 19:31 ` [PATCH 42/42] iwlwifi: mvm: include wildcard SSID in scans Emmanuel Grumbach
2015-05-09 13:24 ` pull request: iwlwifi-next 2015-05-03 Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).