mac80211: count started vifs

count the started roles by simply counting the non-idle vifs.

this method also takes care of counting non-associated
stations (when device role is started)

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
wl12xx: delay fw switch to start/stop_role_sta/ap

do the fw switch only when the role was started/stopped

Signed-off-by: Eliad Peller <eliad@wizery.com>
wl12xx: add grace period when changing MR -> SR fw

This improves user experience when performing p2p_find for instance.

[Changed grace period to 30 seconds]

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
wl12xx: change recovery on start/stop device role

since the recovery itself will usually stop the offchannel
operation, on fw boot we will use SR fw again, which will
result in endless recoveries... avoid it by forcing MR fw
for some grace period after it was needed.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
wl12xx: increase WL12XX_MAX_ROLES

when working with AP + 2*STA we have more than
4 active roles. increase WL12XX_MAX_ROLES to 6.

Signed-off-by: Eliad Peller <eliad@wizery.com>
mac80211: check sdata_running on ieee80211_set_bitrate_mask

Otherwise, we might call the driver callback before
the interface was uploaded.

Solves the following warning:
WARNING: at net/mac80211/driver-ops.h:12 ieee80211_set_bitrate_mask+0xbc/0x18c [mac80211]()
wlan0:  Failed check-sdata-in-driver check, flags: 0x0
Modules linked in: wlcore_sdio wl12xx wl18xx wlcore mac80211 cfg80211 [last unloaded: cfg80211]
[<c001b964>] (unwind_backtrace+0x0/0x12c) from [<c0495550>] (dump_stack+0x20/0x24)
[<c0495550>] (dump_stack+0x20/0x24) from [<c003ee28>] (warn_slowpath_common+0x5c/0x74)
[<c003ee28>] (warn_slowpath_common+0x5c/0x74) from [<c003eefc>] (warn_slowpath_fmt+0x40/0x48)
[<c003eefc>] (warn_slowpath_fmt+0x40/0x48) from [<bf5c1ad0>] (ieee80211_set_bitrate_mask+0xbc/0x18c [mac80211])
[<bf5c1ad0>] (ieee80211_set_bitrate_mask+0xbc/0x18c [mac80211]) from [<bf575960>] (nl80211_set_tx_bitrate_mask+0x350/0x358 [cfg80211])
[<bf575960>] (nl80211_set_tx_bitrate_mask+0x350/0x358 [cfg80211]) from [<c03e9e94>] (genl_rcv_msg+0x1a8/0x1e8)
[<c03e9e94>] (genl_rcv_msg+0x1a8/0x1e8) from [<c03e9164>] (netlink_rcv_skb+0x5c/0xc0)
[<c03e9164>] (netlink_rcv_skb+0x5c/0xc0) from [<c03e9ce0>] (genl_rcv+0x28/0x34)
[<c03e9ce0>] (genl_rcv+0x28/0x34) from [<c03e8e74>] (netlink_unicast+0x158/0x234)
[<c03e8e74>] (netlink_unicast+0x158/0x234) from [<c03e93e0>] (netlink_sendmsg+0x218/0x298)
[<c03e93e0>] (netlink_sendmsg+0x218/0x298) from [<c03b4e5c>] (sock_sendmsg+0xa4/0xc0)
[<c03b4e5c>] (sock_sendmsg+0xa4/0xc0) from [<c03b5af4>] (__sys_sendmsg+0x1d8/0x254)
[<c03b5af4>] (__sys_sendmsg+0x1d8/0x254) from [<c03b5ca8>] (sys_sendmsg+0x4c/0x70)
[<c03b5ca8>] (sys_sendmsg+0x4c/0x70) from [<c0013980>] (ret_fast_syscall+0x0/0x3c)

Note that calling the driver can also result
in undefined behaviour since it doesn't have
to deal with calls while down.

Signed-off-by: Eliad Peller <eliad@wizery.com>
[removed timestamps, added note - Johannes]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
wlcore: send EAPOLs using minimum basic rate for all roles

Send EAPOLs using minimum basic rate for AP, STA, p2p GO and Client.
The patch fixes p2p connection issue with Realtek device in p2p
certification test 5.1.13 (DEVUT reinvokes Persistent Group).

Signed-off-by: Igal Chernobelsky <igalc@ti.com>
wlcore: use basic rates for non-data packets

After the latest mac80211 changes, the sta has
the ap's sta pointer even before association.

This cause the auth and assoc frames to be sent
with the standard ap's rates, rather than the
basic rates.

Change the tx rate policy logic to use the regular
ap rates only for data packets (so control and mgmt
packets will be sent with basic rates)

Signed-off-by: Eliad Peller <eliad@wizery.com>
wlcore: define number of supported bands internally

Avoid using the IEEE80211_NUM_BANDS constant for arrays sizes etc, as
this can contain bands unsupported by the driver (e.g. 60Ghz). Use an
internal constant to determine the number of bands.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
mac80211: fix invalid band deref building preq IEs

The function building probe-request IEs does not validate the band is
supported before dereferencing it. This can result in a panic when
all bands are traversed, as done during sched-scan start.

Warn when this happens and return an empty probe request. Also fix
sched-scan to not waste memory on unsupported bands.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
cfg80211/nl80211/wl12xx: align to new nl80211.h ABI

This includes some minor changes:
- change NL80211_CQM_RSSI_BEACON_LOSS to
  NL80211_CQM_RSSI_BEACON_LOSS_EVENT
- remove all features concerning advertisement of intermediate scan
  capabilities. These are currently unused.

Signed-off-by: Arik Nemtsov <arik@wizery.com>