mac80211: refactor mesh peer initialization

This patch unifies the previous two paths toward mesh peer creation a
bit. It also fixes a bug where a peer's changing rates or HT mode
wouldn't register on leaving and then returning to the mesh with a sta
entry still present.

Also clean up locking and clear possibly stale ht cap.

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
mac80211: refactor mesh peer rate handling

To avoid passing supp_rates and basic_rates around all the time, just
derive these when needed in mesh_matches_local() and mesh_peer_init().

Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
mac80211: set correct HT protection mode

Section 9.23.3.5 of IEEE 80211s standard describes the protection rules for
HT mesh STA in a MBSS. Two HT protection modes are supported for now, non-HT
mixed mode and no-protection mode. non-HT mixed mode is selected if any
established non-HT stations are present in our MBSS otherwise no-protection
mode is selected.  Operation mode is needed to be determined at two
checkpoints: 1. when a peer joins the mesh and 2. when a peer leaves the mesh.

Signed-off-by: Ashok Nagarajan <ashok@cozybit.com>
Reviewed-by: Thomas Pedersen <thomas@cozybit.com>
mac80211: Allow peering between HT and non-HT STAs

Now that non-ht protection mode is added, allow peering between HT and non-HT
STAs.  Mixed channel type between HT peers is still disallowed as ht-mixed mode
protection is not yet implemented.

Signed-off-by: Ashok Nagarajan <ashok@cozybit.com>
[nl,cfg,mac]80211: Allow user to configure basic rates when joining

Currently mesh uses mandatory rates as default basic rates. This patch
introduces configurable basic rates at the time of joining mesh. This patch
is used for testing purposes.

Sets the correct sband?
TODO: Fix the bug. Trace:

root@popeye:~/hwsim_tests# dmesg
[   23.682367] serial8250: too much work for irq4
[   23.725241] serial8250: too much work for irq4
[   23.825299] serial8250: too much work for irq4
[   23.862618] serial8250: too much work for irq4
[   23.895825] serial8250: too much work for irq4
[   23.961129] serial8250: too much work for irq4
[   23.998037] serial8250: too much work for irq4
[   24.065345] serial8250: too much work for irq4
[   31.692908] BUG: unable to handle kernel NULL pointer dereference at           (null)
[   31.692923] IP: [<ffffffff816c4950>] nl80211_join_mesh+0x110/0x210
[   31.692948] PGD 15d11067 PUD 12b4a067 PMD 0
[   31.692959] Oops: 0000 [#1] SMP
[   31.692974] CPU 0
[   31.692977] Modules linked in: mac80211_hwsim mac80211
[   31.692989]
[   31.692995] Pid: 1810, comm: iw Not tainted 3.3.0-6d42d27-wl+ #295 Bochs Bochs
[   31.693015] RIP: 0010:[<ffffffff816c4950>]  [<ffffffff816c4950>] nl80211_join_mesh+0x110/0x210
[   31.693033] RSP: 0018:ffff880015d059a8  EFLAGS: 00010282
[   31.693039] RAX: 0000000000000000 RBX: ffff880015d05a48 RCX: ffff880015d05a04
[   31.693045] RDX: 0000000000000006 RSI: ffff880014538c2c RDI: ffff880017b9d000
[   31.693046] RBP: ffff880015d05a28 R08: 0000000000000000 R09: 0000000000000001
[   31.693046] R10: 0000000000000000 R11: 00000000000002dd R12: ffff880015fa2000
[   31.693046] R13: ffff880012a30000 R14: ffff880015fa27d0 R15: ffffffff82681680
[   31.693046] FS:  00007f18956d3700(0000) GS:ffff880017c00000(0000) knlGS:0000000000000000
[   31.693046] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   31.693046] CR2: 0000000000000000 CR3: 0000000012b59000 CR4: 00000000000006f0
[   31.693046] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   31.693046] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[   31.693046] Process iw (pid: 1810, threadinfo ffff880015d04000, task ffff880016829020)
[   31.693046] Stack:
[   31.693046]  ffff880015d059b8 006400648170e2de 011f1f0300200064 000003e800000004
[   31.693046]  0000138800000064 000000320064000a 0000000001001388 ffff880014538c20
[   31.693046]  0000000000000007 0000000000000000 0000000000000000 0000000000000000
[   31.693046] Call Trace:
[   31.693046]  [<ffffffff815b5895>] genl_rcv_msg+0x1d5/0x250
[   31.693046]  [<ffffffff815b56c0>] ? genl_rcv+0x40/0x40
[   31.693046]  [<ffffffff815b50e9>] netlink_rcv_skb+0xa9/0xd0
[   31.693046]  [<ffffffff815b56a5>] genl_rcv+0x25/0x40
[   31.693046]  [<ffffffff815b4aae>] netlink_unicast+0x1ae/0x1f0
[   31.693046]  [<ffffffff815b4db6>] netlink_sendmsg+0x2c6/0x320
[   31.693046]  [<ffffffff81578640>] ? sock_update_classid+0xa0/0x110
[   31.693046]  [<ffffffff81571eb7>] sock_sendmsg+0x117/0x130
[   31.693046]  [<ffffffff8110e725>] ? might_fault+0x45/0xa0
[   31.693046]  [<ffffffff8110e725>] ? might_fault+0x45/0xa0
[   31.693046]  [<ffffffff8110e76e>] ? might_fault+0x8e/0xa0
[   31.693046]  [<ffffffff8110e725>] ? might_fault+0x45/0xa0
[   31.693046]  [<ffffffff81580276>] ? verify_iovec+0x56/0xd0
[   31.693046]  [<ffffffff81572f86>] __sys_sendmsg+0x376/0x380
[   31.693046]  [<ffffffff8105f243>] ? up_read+0x23/0x40
[   31.693046]  [<ffffffff8171407c>] ? do_page_fault+0x21c/0x4d0
[   31.693046]  [<ffffffff81155e11>] ? vfsmount_lock_local_unlock+0x21/0x40
[   31.693046]  [<ffffffff81156ec8>] ? mntput_no_expire+0x38/0x130
[   31.693046]  [<ffffffff81156fe4>] ? mntput+0x24/0x40
[   31.693046]  [<ffffffff81575509>] sys_sendmsg+0x49/0x90
[   31.693046]  [<ffffffff817186d2>] system_call_fastpath+0x16/0x1b
[   31.693046] Code: 01 00 00 48 89 55 b8 0f b7 00 83 e8 04 48 85 f6 88 45 c0 0f 84 e2 00 00 00 49 8b 86 c0 01 00 00 0f b7 16 48 8d 4d dc 48 83 c6 04 <8b> 00 83 ea 04 49 8b bc c5 c0 04 00 00 e8 1e 7c ff ff 85 c0 0f
[   31.693046] RIP  [<ffffffff816c4950>] nl80211_join_mesh+0x110/0x210
[   31.693046]  RSP <ffff880015d059a8>
[   31.693046] CR2: 0000000000000000
[   31.693646] ---[ end trace f4f8fb8814268218 ]---
[   33.842118] mesh2: no IPv6 routers present
[   34.194111] mesh4: no IPv6 routers present
[   34.290120] mesh3: no IPv6 routers present
[   34.386133] mesh1: no IPv6 routers present
[   34.594082] mesh0: no IPv6 routers present
Workaround for wdev->channel issue
mac80211: set default HT protection mode of mesh to non-HT mixed

Advertise the HT protection mode in IEs