Commit Graph
100 Commits
Author SHA1 Message Date
Stanislaw GruszkaandFelix Fietkau ca17e5657e mt76: mt76x02: minor mt76x02_mac_set_beacon optimization
We do not call mt76x02_mac_set_beacon() with NULL skb any longer and
we do not need to return error value.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-12-22 15:17:43 +01:00
Stanislaw GruszkaandFelix Fietkau 584c0784e0 mt76: mt76x02u: do not set NULL beacons
With current implementation we do not cleanup beacon memory, so is not
needed to call mt76x02_mac_set_beacon() with NULL skb.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-12-22 15:17:43 +01:00
Stanislaw GruszkaandFelix Fietkau 09fcbc214b mt76: usb: use max packet length for m76u_copy
For transferring data over USB the optimal size is endpoint maxpacket.
For my hardware maxpaket for control endpoint is 64 bytes and changing
to this value from 128 bytes further shorten TBTT work time from
3ms to 1ms.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-12-22 15:17:42 +01:00
Stanislaw GruszkaandFelix Fietkau efcbee1d8b mt76: mt76x0u: do not reset radio on resume
On some machines mt76x0u firmware can hung during resume,
what result on messages like below:

[  475.480062] mt76x0 1-8:1.0: Error: MCU response pre-completed!
[  475.990066] mt76x0 1-8:1.0: Error: send MCU cmd failed:-110
[  475.990075] mt76x0 1-8:1.0: Error: MCU response pre-completed!
[  476.500003] mt76x0 1-8:1.0: Error: send MCU cmd failed:-110
[  476.500012] mt76x0 1-8:1.0: Error: MCU response pre-completed!
[  477.010046] mt76x0 1-8:1.0: Error: send MCU cmd failed:-110
[  477.010055] mt76x0 1-8:1.0: Error: MCU response pre-completed!
[  477.529997] mt76x0 1-8:1.0: Error: send MCU cmd failed:-110
[  477.530006] mt76x0 1-8:1.0: Error: MCU response pre-completed!
[  477.824907] mt76x0 1-8:1.0: Error: send MCU cmd failed:-71
[  477.824916] mt76x0 1-8:1.0: Error: MCU response pre-completed!
[  477.825029] usb 1-8: USB disconnect, device number 6

and possible whole system freeze.

This can be avoided, if we do not perform mt76x0_chip_onoff() reset.

Cc: [email protected]
Fixes: 134b2d0d1fcf ("mt76x0: init files")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2019-12-13 22:33:35 +01:00
Stanislaw GruszkaandFelix Fietkau 496c78e4f0 mt76: mt76x0: remove unneeded return value on set channel
We allways return 0 from mt76x0_phy_set_channel(), no need to pass
return value upward.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-09-05 17:49:41 +02:00
Stanislaw GruszkaandFelix Fietkau 1d2acd5639 mt76: mt76x0: remove redundant chandef copy
We set dev->mt76.chandef in mt76_set_channel() already.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-09-05 17:49:41 +02:00
Stanislaw GruszkaandFelix Fietkau 0167bfa7b2 mt76: make mt76_rx_convert static
mt76_rx_convert() not need to be exported any longer.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-09-05 17:49:41 +02:00
Stanislaw GruszkaandFelix Fietkau a0824197ab mt76: mt76x0e: disable 5GHz band for MT7630E
MT7630E hardware does support 5GHz, but we do not properly configure phy
for 5GHz channels. Scanning at this band not only do not show any APs
but also can hang the firmware.

Since vendor reference driver do not support 5GHz we don't know how
properly configure 5GHz channels. So disable this band for MT7630E .

Cc: [email protected]
Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-08-22 09:35:19 +02:00
Stanislaw GruszkaandFelix Fietkau 649f2e8374 mt76: mt7615: use params->ssn value directly
There is no point to use pointer to params->ssn.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-07-12 16:07:11 +02:00
Stanislaw GruszkaandFelix Fietkau f74d117ed4 mt76: mt7603: use params->ssn value directly
There is no point to use pointer to params->ssn.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-07-12 16:07:11 +02:00
Stanislaw GruszkaandFelix Fietkau 5d298297c0 mt76: mt76x02: use params->ssn value directly
There is no point to use pointer to params->ssn.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-07-12 16:07:11 +02:00
Stanislaw GruszkaandFelix Fietkau 307be50cc5 mt76: usb: remove unneeded {put,get}_unaligned
Compiler give us guarantees on variables alignment, so use
an variable as buffer when read/write registers and remove
unneeded {put,get}_unaligned.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-07-12 15:56:23 +02:00
Stanislaw GruszkaandFelix Fietkau 8c1da9367b mt76: usb: fix endian in mt76u_copy
In contrast to mt76_wr() which we use to program registers,
on mt76_wr_copy() we should not change endian of the data.

Fixes: b40b15e1521f ("mt76: add usb support to mt76 layer")
Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-07-12 15:56:23 +02:00
Stanislaw GruszkaandFelix Fietkau 5e1e5b75d6 mt76: usb: use full intermediate buffer in mt76u_copy
Instead of use several 4 bytes usb requests, use full 32 bytes buffer
to copy data to device. With the change we use less requests and copy
exact data size to the device regardless size is multiple of 4 or not.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-07-04 20:02:16 +02:00
Stanislaw GruszkaandFelix Fietkau f43b6228fa mt76: usb: remove unneeded {put,get}_unaligned
Compiler give us guaranties on variables alignment, so use
an variable as buffer when read/write registers and remove
unneeded {put,get}_unaligned.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-07-04 20:02:16 +02:00
Stanislaw GruszkaandFelix Fietkau edbe88ec7c mt76: usb: fix endian in mt76u_copy
In contrast to mt76_wr() which we use to program registers,
on mt76_wr_copy() we should not change endian of the data.

Fixes: b40b15e1521f ("mt76: add usb support to mt76 layer")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-07-04 20:02:16 +02:00
Stanislaw GruszkaandFelix Fietkau f06647efbd mt76: usb: use EP max packet aligned buffer sizes for rx
If buffer size is not usb_endpoint_maxp (512 or 1024 bytes) multiple,
usb host driver has to use bounce buffer and copy data. For RX we can
avoid that since we alreay allocate q->buf_size (2kB) buffers and
mt76usb hardware will not fill more data as rx packet size is limited
by network protocol. However add error message if this assumption
somehow will be not true.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-04-30 11:37:13 +02:00
Stanislaw GruszkaandFelix Fietkau b0f2a30452 mt76x02: avoid status_list.lock and sta->rate_ctrl_lock dependency
Move ieee80211_tx_status_ext() outside of status_list lock section
in order to avoid locking dependency and possible deadlock reposed by
LOCKDEP in below warning.

Also do mt76_tx_status_lock() just before it's needed.

[  440.224832] WARNING: possible circular locking dependency detected
[  440.224833] 5.1.0-rc2+ #22 Not tainted
[  440.224834] ------------------------------------------------------
[  440.224835] kworker/u16:28/2362 is trying to acquire lock:
[  440.224836] 0000000089b8cacf (&(&q->lock)->rlock#2){+.-.}, at: mt76_wake_tx_queue+0x4c/0xb0 [mt76]
[  440.224842]
               but task is already holding lock:
[  440.224842] 000000002cfedc59 (&(&sta->lock)->rlock){+.-.}, at: ieee80211_stop_tx_ba_cb+0x32/0x1f0 [mac80211]
[  440.224863]
               which lock already depends on the new lock.

[  440.224863]
               the existing dependency chain (in reverse order) is:
[  440.224864]
               -> #3 (&(&sta->lock)->rlock){+.-.}:
[  440.224869]        _raw_spin_lock_bh+0x34/0x40
[  440.224880]        ieee80211_start_tx_ba_session+0xe4/0x3d0 [mac80211]
[  440.224894]        minstrel_ht_get_rate+0x45c/0x510 [mac80211]
[  440.224906]        rate_control_get_rate+0xc1/0x140 [mac80211]
[  440.224918]        ieee80211_tx_h_rate_ctrl+0x195/0x3c0 [mac80211]
[  440.224930]        ieee80211_xmit_fast+0x26d/0xa50 [mac80211]
[  440.224942]        __ieee80211_subif_start_xmit+0xfc/0x310 [mac80211]
[  440.224954]        ieee80211_subif_start_xmit+0x38/0x390 [mac80211]
[  440.224956]        dev_hard_start_xmit+0xb8/0x300
[  440.224957]        __dev_queue_xmit+0x7d4/0xbb0
[  440.224968]        ip6_finish_output2+0x246/0x860 [ipv6]
[  440.224978]        mld_sendpack+0x1bd/0x360 [ipv6]
[  440.224987]        mld_ifc_timer_expire+0x1a4/0x2f0 [ipv6]
[  440.224989]        call_timer_fn+0x89/0x2a0
[  440.224990]        run_timer_softirq+0x1bd/0x4d0
[  440.224992]        __do_softirq+0xdb/0x47c
[  440.224994]        irq_exit+0xfa/0x100
[  440.224996]        smp_apic_timer_interrupt+0x9a/0x220
[  440.224997]        apic_timer_interrupt+0xf/0x20
[  440.224999]        cpuidle_enter_state+0xc1/0x470
[  440.225000]        do_idle+0x21a/0x260
[  440.225001]        cpu_startup_entry+0x19/0x20
[  440.225004]        start_secondary+0x135/0x170
[  440.225006]        secondary_startup_64+0xa4/0xb0
[  440.225007]
               -> #2 (&(&sta->rate_ctrl_lock)->rlock){+.-.}:
[  440.225009]        _raw_spin_lock_bh+0x34/0x40
[  440.225022]        rate_control_tx_status+0x4f/0xb0 [mac80211]
[  440.225031]        ieee80211_tx_status_ext+0x142/0x1a0 [mac80211]
[  440.225035]        mt76x02_send_tx_status+0x2e4/0x340 [mt76x02_lib]
[  440.225037]        mt76x02_tx_status_data+0x31/0x40 [mt76x02_lib]
[  440.225040]        mt76u_tx_status_data+0x51/0xa0 [mt76_usb]
[  440.225042]        process_one_work+0x237/0x5d0
[  440.225043]        worker_thread+0x3c/0x390
[  440.225045]        kthread+0x11d/0x140
[  440.225046]        ret_from_fork+0x3a/0x50
[  440.225047]
               -> #1 (&(&list->lock)->rlock#8){+.-.}:
[  440.225049]        _raw_spin_lock_bh+0x34/0x40
[  440.225052]        mt76_tx_status_skb_add+0x51/0x100 [mt76]
[  440.225054]        mt76x02u_tx_prepare_skb+0xbd/0x116 [mt76x02_usb]
[  440.225056]        mt76u_tx_queue_skb+0x5f/0x180 [mt76_usb]
[  440.225058]        mt76_tx+0x93/0x190 [mt76]
[  440.225070]        ieee80211_tx_frags+0x148/0x210 [mac80211]
[  440.225081]        __ieee80211_tx+0x75/0x1b0 [mac80211]
[  440.225092]        ieee80211_tx+0xde/0x110 [mac80211]
[  440.225105]        __ieee80211_tx_skb_tid_band+0x72/0x90 [mac80211]
[  440.225122]        ieee80211_send_auth+0x1f3/0x360 [mac80211]
[  440.225141]        ieee80211_auth.cold.40+0x6c/0x100 [mac80211]
[  440.225156]        ieee80211_mgd_auth.cold.50+0x132/0x15f [mac80211]
[  440.225171]        cfg80211_mlme_auth+0x149/0x360 [cfg80211]
[  440.225181]        nl80211_authenticate+0x273/0x2e0 [cfg80211]
[  440.225183]        genl_family_rcv_msg+0x196/0x3a0
[  440.225184]        genl_rcv_msg+0x47/0x8e
[  440.225185]        netlink_rcv_skb+0x3a/0xf0
[  440.225187]        genl_rcv+0x24/0x40
[  440.225188]        netlink_unicast+0x16d/0x210
[  440.225189]        netlink_sendmsg+0x204/0x3b0
[  440.225191]        sock_sendmsg+0x36/0x40
[  440.225193]        ___sys_sendmsg+0x259/0x2b0
[  440.225194]        __sys_sendmsg+0x47/0x80
[  440.225196]        do_syscall_64+0x60/0x1f0
[  440.225197]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
[  440.225198]
               -> #0 (&(&q->lock)->rlock#2){+.-.}:
[  440.225200]        lock_acquire+0xb9/0x1a0
[  440.225202]        _raw_spin_lock_bh+0x34/0x40
[  440.225204]        mt76_wake_tx_queue+0x4c/0xb0 [mt76]
[  440.225215]        ieee80211_agg_start_txq+0xe8/0x2b0 [mac80211]
[  440.225225]        ieee80211_stop_tx_ba_cb+0xb8/0x1f0 [mac80211]
[  440.225235]        ieee80211_ba_session_work+0x1c1/0x2f0 [mac80211]
[  440.225236]        process_one_work+0x237/0x5d0
[  440.225237]        worker_thread+0x3c/0x390
[  440.225239]        kthread+0x11d/0x140
[  440.225240]        ret_from_fork+0x3a/0x50
[  440.225240]
               other info that might help us debug this:

[  440.225241] Chain exists of:
                 &(&q->lock)->rlock#2 --> &(&sta->rate_ctrl_lock)->rlock --> &(&sta->lock)->rlock

[  440.225243]  Possible unsafe locking scenario:

[  440.225244]        CPU0                    CPU1
[  440.225244]        ----                    ----
[  440.225245]   lock(&(&sta->lock)->rlock);
[  440.225245]                                lock(&(&sta->rate_ctrl_lock)->rlock);
[  440.225246]                                lock(&(&sta->lock)->rlock);
[  440.225247]   lock(&(&q->lock)->rlock#2);
[  440.225248]
                *** DEADLOCK ***

[  440.225249] 5 locks held by kworker/u16:28/2362:
[  440.225250]  #0: 0000000048fcd291 ((wq_completion)phy0){+.+.}, at: process_one_work+0x1b5/0x5d0
[  440.225252]  #1: 00000000f1c6828f ((work_completion)(&sta->ampdu_mlme.work)){+.+.}, at: process_one_work+0x1b5/0x5d0
[  440.225254]  #2: 00000000433d2b2c (&sta->ampdu_mlme.mtx){+.+.}, at: ieee80211_ba_session_work+0x5c/0x2f0 [mac80211]
[  440.225265]  #3: 000000002cfedc59 (&(&sta->lock)->rlock){+.-.}, at: ieee80211_stop_tx_ba_cb+0x32/0x1f0 [mac80211]
[  440.225276]  #4: 000000009d7b9a44 (rcu_read_lock){....}, at: ieee80211_agg_start_txq+0x33/0x2b0 [mac80211]
[  440.225286]
               stack backtrace:
[  440.225288] CPU: 2 PID: 2362 Comm: kworker/u16:28 Not tainted 5.1.0-rc2+ #22
[  440.225289] Hardware name: LENOVO 20KGS23S0P/20KGS23S0P, BIOS N23ET55W (1.30 ) 08/31/2018
[  440.225300] Workqueue: phy0 ieee80211_ba_session_work [mac80211]
[  440.225301] Call Trace:
[  440.225304]  dump_stack+0x85/0xc0
[  440.225306]  print_circular_bug.isra.38.cold.58+0x15c/0x195
[  440.225307]  check_prev_add.constprop.48+0x5f0/0xc00
[  440.225309]  ? check_prev_add.constprop.48+0x39d/0xc00
[  440.225311]  ? __lock_acquire+0x41d/0x1100
[  440.225312]  __lock_acquire+0xd98/0x1100
[  440.225313]  ? __lock_acquire+0x41d/0x1100
[  440.225315]  lock_acquire+0xb9/0x1a0
[  440.225317]  ? mt76_wake_tx_queue+0x4c/0xb0 [mt76]
[  440.225319]  _raw_spin_lock_bh+0x34/0x40
[  440.225321]  ? mt76_wake_tx_queue+0x4c/0xb0 [mt76]
[  440.225323]  mt76_wake_tx_queue+0x4c/0xb0 [mt76]
[  440.225334]  ieee80211_agg_start_txq+0xe8/0x2b0 [mac80211]
[  440.225344]  ieee80211_stop_tx_ba_cb+0xb8/0x1f0 [mac80211]
[  440.225354]  ieee80211_ba_session_work+0x1c1/0x2f0 [mac80211]
[  440.225356]  process_one_work+0x237/0x5d0
[  440.225358]  worker_thread+0x3c/0x390
[  440.225359]  ? wq_calc_node_cpumask+0x70/0x70
[  440.225360]  kthread+0x11d/0x140
[  440.225362]  ? kthread_create_on_node+0x40/0x40
[  440.225363]  ret_from_fork+0x3a/0x50

Cc: [email protected]
Fixes: 88046b2c9f6d ("mt76: add support for reporting tx status with skb")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Acked-by: Felix Fietkau <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2019-04-29 17:21:04 +02:00
Stanislaw GruszkaandFelix Fietkau 0e674c50a5 mt76x02: remove bogus mutex usage
mac80211 .start(), .stop() callbacks are never called concurrently with
other callbacks. The only concurencly is with mt76 works which we cancel
on stop() and schedule on start().

This fixes possible deadlock on cancel_delayed_work_sync(&dev->mac_work)
as mac_work also take mutex.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-04-29 13:37:59 +02:00
Stanislaw GruszkaandFelix Fietkau 6c1cab9aba mt76usb: fix tx/rx stop
Disabling tasklets on stopping rx/tx is wrong. If blocked tasklet
is scheduled and we remove device we will get 100% cpu usage:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
    9 root      20   0       0      0      0 R  93.8   0.0   1:47.19 ksoftirqd/0

by infinite loop in tasklet_action_common() and eventuall crash on next
mt76usb module load:

[ 2068.591964] RIP: 0010:tasklet_action_common.isra.17+0x66/0x100
[ 2068.591966] Code: 41 89 f5 eb 25 f0 48 0f ba 33 00 0f 83 b1 00 00 00 48 8b 7a 20 48 8b 42 18 e8 56 a3 b5 00 f0 80 23 fd 48 89 ea 48 85 ed 74 53 <48> 8b 2a 48 8d 5a 08 f0 48 0f ba 6a 08 01 72 0b 8b 42 10 85 c0 74
[ 2068.591968] RSP: 0018:ffff98758c34be58 EFLAGS: 00010206
[ 2068.591969] RAX: ffff98758e6966d0 RBX: ffff98756e69aef8 RCX: 0000000000000006
[ 2068.591970] RDX: 01060a053d060305 RSI: 0000000000000006 RDI: ffff98758e6966d0
[ 2068.591971] RBP: 01060a053d060305 R08: 0000000000000000 R09: 00000000000203c0
[ 2068.591971] R10: 000003ff65b34f08 R11: 0000000000000001 R12: ffff98758e6966d0
[ 2068.591972] R13: 0000000000000006 R14: 0000000000000040 R15: 0000000000000006
[ 2068.591974] FS:  0000000000000000(0000) GS:ffff98758e680000(0000) knlGS:0000000000000000
[ 2068.591975] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 2068.591975] CR2: 00002c5f73a6cc20 CR3: 00000002f920a001 CR4: 00000000003606e0
[ 2068.591977] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 2068.591978] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 2068.591978] Call Trace:
[ 2068.591985]  __do_softirq+0xe3/0x30a
[ 2068.591989]  ? sort_range+0x20/0x20
[ 2068.591990]  run_ksoftirqd+0x26/0x40
[ 2068.591992]  smpboot_thread_fn+0xc5/0x160
[ 2068.591995]  kthread+0x112/0x130
[ 2068.591997]  ? kthread_create_on_node+0x40/0x40
[ 2068.591998]  ret_from_fork+0x35/0x40
[ 2068.591999] Modules linked in: ccm arc4 fuse rfcomm cmac bnep sunrpc snd_hda_codec_hdmi snd_soc_skl snd_soc_core snd_soc_acpi_intel_match snd_hda_codec_realtek snd_soc_acpi snd_hda_codec_generic snd_soc_skl_ipc snd_soc_sst_ipc snd_soc_sst_dsp snd_hda_ext_core iTCO_wdt snd_hda_intel intel_rapl iTCO_vendor_support x86_pkg_temp_thermal intel_powerclamp btusb mei_wdt coretemp btrtl snd_hda_codec btbcm btintel intel_cstate snd_hwdep intel_uncore uvcvideo snd_hda_core videobuf2_vmalloc videobuf2_memops intel_rapl_perf wmi_bmof videobuf2_v4l2 intel_wmi_thunderbolt snd_seq bluetooth joydev videobuf2_common snd_seq_device snd_pcm videodev media i2c_i801 snd_timer idma64 ecdh_generic intel_lpss_pci intel_lpss mei_me mei ucsi_acpi typec_ucsi processor_thermal_device intel_soc_dts_iosf intel_pch_thermal typec thinkpad_acpi wmi snd soundcore rfkill int3403_thermal int340x_thermal_zone int3400_thermal acpi_thermal_rel acpi_pad pcc_cpufreq uas usb_storage crc32c_intel i915 i2c_algo_bit nvme serio_raw
[ 2068.592033]  drm_kms_helper e1000e nvme_core drm video ipv6 [last unloaded: cfg80211]

Fortunate thing is that this not happen frequently, as scheduling
tasklet on blocked state is very exceptional, though might happen.

Due to different RX/TX tasklet processing fix is different for those.

For RX we have to assure rx_tasklet do fail to resubmit buffers
by poisoning urb's and kill the tasklet.

For TX we need to handle all stop cases properly (suspend, module
unload, device removal).

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-04-29 13:37:59 +02:00
Stanislaw GruszkaandFelix Fietkau bc9baa7b12 mt76x02u: remove bogus stop on suspend
On suspend mac80211 .stop callback is called before .suspend(), so
hw mac is already stopped and we do not have to do this again.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-04-29 13:37:58 +02:00
Stanislaw GruszkaandFelix Fietkau ffddb685a6 mt76x02u: check chip version on probe
Since some USB device IDs are duplicated between mt76x0u, mt7601u
and mt76x2u device, check chip version on probe and return error if
not match the driver.

Don't think this is serious issue, probe most likely will fail at
some other point for wrong device, but we do not have to configure
it if we know is not our device.

Reported-by: Xose Vazquez Perez <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2019-04-25 12:04:20 +02:00
Stanislaw GruszkaandFelix Fietkau 2e89721e62 mt76usb: remove queue variable from rx_tasklet
Since now only mt76u_get_next_rx_entry use queue argument move
it to this function.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:42 +01:00
Stanislaw GruszkaandFelix Fietkau 57309c7e94 mt76usb: allocate urb and sg as linear data
Alloc sg table at the end of urb structure. This will increase
cache usage.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:42 +01:00
Stanislaw GruszkaandFelix Fietkau 4d4d73a796 mt76usb: remove unneded sg_init_table
We already allocate with GFP_ZERO and sg marker is set later for
both RX and TX.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:42 +01:00
Stanislaw GruszkaandFelix Fietkau 42f2899d4d mt76usb: resue mt76u_urb_alloc for tx
Add new rx_urb_alloc routine and reuse common urb_alloc for tx
allocations.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:42 +01:00
Stanislaw GruszkaandFelix Fietkau 0904bc4168 mt76usb: remove MT_RXQ_MAIN queue from mt76u_urb_alloc
Get the RX queue inside mt76u_refill_rx. This will allow to reuse
mt76u_urb_alloc for TX allocations.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:42 +01:00
Stanislaw GruszkaandFelix Fietkau 4a366bdc0e mt76usb: remove mt76u_buf and use urb directly
Put urb pointer in mt76_queue_entry directly instead of mt76u_buf
structure.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:42 +01:00
Stanislaw GruszkaandFelix Fietkau 3f9b68d0f6 mt76usb: move mt76u_buf->done to queue entry
mt76_queue_entry has alreay one bool variable, adding new one will
not increase it's size. Removing ->done filed from mt76u_buf will
allow to use urb directly in mt76usb code.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:42 +01:00
Stanislaw GruszkaandFelix Fietkau a4eb5db07c mt76usb: remove mt76u_buf redundant fileds
Remove mt76u_buf->{len, buf} fields and operate on corresponding
urb fields directly.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:28 +01:00
Stanislaw GruszkaandFelix Fietkau e9c017190e mt76usb: use usb_dev private data
Setup usb device private data. This allows to remove mt76u_buf->dev
and simplify some routines as no longer we need to get usb device
through usb interface.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:28 +01:00
Stanislaw GruszkaandFelix Fietkau e1bfbeb162 mt76usb: change mt76u_fill_rx_sg arguments
We do not need to pass len and sglen to the function.
Additionally pass gfp to control allocation context.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:28 +01:00
Stanislaw GruszkaandFelix Fietkau 16b2ccf535 mt76: remove rx_page_lock
We can not run mt76u_alloc_buf() concurently, rx_tasklet is stooped
when mt76u_submit_rx_buffers(). We can remove rx_page_lock.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:28 +01:00
Stanislaw GruszkaandFelix Fietkau cf1838d214 mt76usb: change mt76u_submit_buf
Remove unnecessery arguments and change the function name since is
now used only for RX.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-24 08:24:28 +01:00
Stanislaw GruszkaandFelix Fietkau f720e499fc mt76x02: enable AP mode for USB
Enable AP mode. For now without multi-vif support, this will require
more testing and investigation.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau 65e634418c mt76: unify set_tim
All mt76 drivers (now also USB drivers) require empty .set_tim
callback. Add it to common mt76 module and use on all drivers.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau d4c740f071 mt76x02u: add mt76_release_buffered_frames
Create software MT_TXQ_PSD queue for USB and map it to MT_TXQ_VO
since we do not have USB endpoint for PSD. This should make
mt76_release_buffered_frames() work by sending released frames
via MT_TXQ_VO.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau 77e56b87bf mt76x02: make beacon slots bigger for USB
Since we sent PS buffered frames via beacon memory we need to make
beacon slots bigger. That imply we will also need to decrease number
of slots as beacon SRAM memory is limited to 8kB.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau e284cc2b6e mt76x02u: implement pre TBTT work for USB
Program beacons data and PS buffered frames on TBTT work for USB.
We do not have MT_TXQ_PSD queue available via USB endpoints. The way
we can send PS broadcast frames in timely manner before PS stations go
sleep again is program them in beacon data area. Hardware do not modify
those frames since TXWI is properly configured. mt76x02_mac_set_beacon()
already handle this and free no longer used frames.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau 5ac52890d9 mt76x02: disable HW encryption for group frames
This is required to sent multicast/broadcast frames in USB AP
mode just after beacon.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau dcccc04adc mt76x02u: add sta_ps
Add sta_ps callback but dont set WCID drop sicne registers for USB
can not be accessed from tasklet context.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau 41d61908b2 mt76x02: generalize some mmio beaconing functions
Move some TBTT mmio functions to mt76x02_beacon.c and create new ones
in order to be reused by USB pre-TBTT.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau 37af803a2f mt76x02u: implement beacon_ops
Add implementation of beacon_ops for USB and exit function to
stop the timer if running when device is removed. Still no
actual work on pre tbtt event.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:22:22 +01:00
Stanislaw GruszkaandFelix Fietkau 6370485deb mt76x02: introduce beacon_ops
Enabling/disableing TBTT and beacon will be diffrent for USB. Introduce
beacon_ops to encapsulate that and implement it for MMIO. USB
implementation is noop for now.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:21:28 +01:00
Stanislaw GruszkaandFelix Fietkau 91ade88519 mt76x02: add hrtimer for pre TBTT for USB
Add timer and work for pre TBTT for USB devices. For now code
doesn't do anyting useful, just add hrtimer which synchronize
with hardware MT_TBTT_TIMER.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:20:43 +01:00
Stanislaw GruszkaandFelix Fietkau f2a18f5a7f mt76x02: introduce mt76x02_beacon.c
Move most of beaconing code into separate file and separate beacon
initialization for USB and MMIO as pre TBTT implementation for USB
will be different.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-24 08:20:43 +01:00
Stanislaw GruszkaandFelix Fietkau abcb544579 mt76x02: do not enable RTS/CTS by default
My commit 26a7b5473191 ("mt76x02: set protection according to ht
operation element") enabled by default RTS/CTS protection for OFDM
and CCK traffic, because MT_TX_RTS_CFG_THRESH is configured to non
0xffff by initvals and .set_rts_threshold callback is not called by
mac80211 on initialization, only on user request or during
ieee80211_reconfig() (suspend/resuem or restart_hw).

Enabling RTS/CTS cause some problems when sending probe request
frames by hcxdumptool penetration tool, but I expect it can cause
other issues on different scenarios.

Restore previous setting of RTS/CTS being disabled by default for
OFDM/CCK by changing MT_TX_RTS_CFG_THRESH initvals to 0xffff.

Fixes: 26a7b5473191 ("mt76x02: set protection according to ht operation element")
Signed-off-by: Stanislaw Gruszka <[email protected]>
2019-03-12 16:46:26 +01:00
Stanislaw GruszkaandFelix Fietkau e72376d2f0 mt76x02: fix hdr pointer in write txwi for USB
Since we add txwi at the begining of skb->data, it no longer point
to ieee80211_hdr. This breaks settings TS bit for probe response and
beacons.

Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-03-04 09:04:44 +01:00
Stanislaw GruszkaandFelix Fietkau e4250c91f9 mt76usb: remove usb_mcu.c
Don't need separate file just for kmalloc/kfree.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-02-26 12:26:02 +01:00
Stanislaw GruszkaandFelix Fietkau 2437a9ad7b mt76usb: use synchronous msg for mcu command responses
Use usb_bulk_msg for reading MCU command responses. This simplify code
a lot.

Together with 97a3005759c ("mt76usb: allow mt76u_bulk_msg be used
for reads") it also fix possible problems with rx data buffers
not being aligned and contained within single page. After doing
page_frag_alloc(1024) consecutive page_frag_alloc(PAGE_SIZE) will
alloc PAGE_SIZE buffer at PAGE_SIZE - 1024 offset.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-02-26 12:26:02 +01:00
Stanislaw GruszkaandFelix Fietkau e5747b2c46 mt76usb: allow mt76u_bulk_msg be used for reads
Extend mt76u_bulk_msg() such it can be used for synchronous bulk reads.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-02-26 12:26:02 +01:00
Stanislaw GruszkaandFelix Fietkau f18e03a8b6 mt76x0u: fix suspend/resume
We need to reset MCU and do other initializations on resume otherwise
MT7610U device will fail to initialize, what cause system hung due to
USB requests timeouts.

Patch fixes 4.19 -> 4.20 regression.

Cc: [email protected] # 4.20+
Signed-off-by: Stanislaw Gruszka <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2019-02-18 20:39:41 +01:00
Stanislaw GruszkaandFelix Fietkau 1bb97c4d9a mt76x02u: remove bogus check and comment padding
In mt76x02u_skb_dma_info() pad is always non-zero. Patch removes
bogus check and add comments to the function.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-02-18 20:39:41 +01:00
Stanislaw GruszkaandFelix Fietkau a10e9e5e94 mt76x02u: use usb_bulk_msg to upload firmware
We don't need to send firmware data asynchronously, much simpler is just
use synchronous usb_bulk_msg().

Tested-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-02-18 20:39:41 +01:00
Stanislaw GruszkaandFelix Fietkau ff81de1fa3 mt76x02: enable support for IBSS and MESH
Since we implement beconing on USB now, similar interfaces should be
supported for USB as are for MMIO. Tested only on IBSS mode and
AP mode (not enabled due to lack of PS buffering).

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-31 09:37:27 +01:00
Stanislaw GruszkaandFelix Fietkau dcab682bd3 mt76: beaconing fixes for USB
Configure beaconing on USB devices without PS buffering support.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-31 09:37:27 +01:00
Stanislaw GruszkaandFelix Fietkau 171adaf2c2 mt76x02: init beacon config for mt76x2u
Initialize beaconing also on mt76x2u.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-31 09:37:27 +01:00
Stanislaw GruszkaandFelix Fietkau 38e832d912 mt76x02: minor beaconing init changes
Disable BEACON timer during init and configure interrupt registers
only for mmio devices.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-31 09:37:27 +01:00
Stanislaw GruszkaandFelix Fietkau a80acaf544 mt76x02: initialize mutli bss mode when set up address
BSSID is not strtirct related with beaconing (for example we can have
2 STA vifs) and more related with MAC address, so initaize BSSID when
setting MAC address.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-31 09:37:27 +01:00
Stanislaw GruszkaandFelix Fietkau dd52191faa mt76x02: use commmon add interface for mt76x2u
Since we now support mt76x2u feature to allow set mac address
when creating interface in common code we can use it for
mt76x2u.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-31 09:37:27 +01:00
Stanislaw GruszkaandFelix Fietkau edda5c56d4 mt76x02: use mask for vifs
Use vif_mask to count interfaces to allow to set mac address in HW
if there is only one interface and report error if we create
interface with wrong BSSID resulting in already used index.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-01-31 09:37:27 +01:00
Stanislaw GruszkaandFelix Fietkau f7d8c17573 mt76x0: configure MT_VHT_HT_FBK_CFG1
Configure MT_VHT_HT_FBK_CFG1 values similar like vendor driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-12-28 13:43:56 +01:00
Stanislaw GruszkaandFelix Fietkau 628f8d72e2 mt76x02: set protection according to ht operation element
Configure protection based on information that are provided to
us either by remote AP or by hostapd via HT operation IE.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-12-28 13:43:56 +01:00
Stanislaw GruszkaandFelix Fietkau 0d83d73b2e mt76x02: fixup MT_PROT_RATE_* defines
On new mt76 chips, phy mode is configured by last 3 bits
of rate value. Hence OFDM bit is marked by 0x2000
instead of 0x4000.

Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-12-28 13:43:56 +01:00
Stanislaw GruszkaandFelix Fietkau d94e9c4c44 mt76x02: do not set protection on set_rts_threshold callback
Use set_rts_threshold calback to enable/disable threshold only for
legacy traffic.

Protection for HT and VHT traffic is defined by HT operation element
and it's provided by remote AP or by hostapd.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-12-28 13:43:56 +01:00
Stanislaw GruszkaandFelix Fietkau 88f68838d9 mt76: remove wait argument from mt76x02_mcu_calibrate
We always wait for CMD_CALIBRATION_OP mcu message, but wait argument is used
for do additional MT_MCU_COM_REG0 register operations, which are needed
for mt76x2e devices and we can use appropriate check instead of wait argument.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-11-13 20:56:41 +01:00
Stanislaw GruszkaandFelix Fietkau 663b197401 mt76x02: assure we update gain after scan
Assure that after we initialize dev->cal.low_gain to -1 this
will cause update gain calibration. Otherwise this might or
might not happen depending on value of second bit of low_gain
and values read from registers in mt76x02_phy_adjust_vga_gain().

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-11-01 18:29:27 +01:00
Stanislaw GruszkaandFelix Fietkau 9b97e0f2a5 mt76x02: run calibration after scanning
If we are associated and scanning is performed, sw_scan_complete callback
is done after we get back to operating channel, so we do not perform
queue cal work. Fix this queue cal work from sw_scan_complete().

On mt76x0 we have to restore gain in MT_BBP(AGC, 8) register after
scanning, as it was multiple times modified by channel switch code.
So queue cal work without any delay to set AGC gain value.

Similar like in mt76x2 init AGC gain only when set operating channel
and just check before queuing cal work in sw_scan_complete() if
initialization was already done.

Fixes: bbd10586f0df ("mt76x0: phy: do not run calibration during channel switch")
Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-11-01 18:29:27 +01:00
Stanislaw GruszkaandFelix Fietkau cd76a835bb mt76: remove wait argument from mt76x02_mcu_set_radio_state
Remove wait argument from mt76x02_mcu_set_radio_state and newer wait
for response when sending CMD_POWER_SAVING_OP mcu command.
Note this change behaviour for PCIe devices, but the change is in
align with vendor driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-11-01 18:29:27 +01:00
Stanislaw GruszkaandFelix Fietkau 15cb426adf mt76: remove wait argument from mt76x02_mcu_function_select
Remove wait argument from mt76x02_mcu_function_select and wait for
response when function is not Q_SELECT, what is the same behaviour
like in vendor driver.

Note this change behaviour for PCIe devices for Q_SELECT function
form wait to no-wait, and for mt76x0u BW_SETTING from no-wait to wait.
But the change is in align with vendor driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-11-01 18:29:27 +01:00
Stanislaw GruszkaandFelix Fietkau 94ad030758 mt76: remove mcu_msg_alloc
We almost always use patter like this:

       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
       return mt76_mcu_send_msg(dev, skb, CMD_FUN_SET_OP, wait_resp);

This is not needed, we can allocate skb in mcu_send_msg routine.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-11-01 18:04:33 +01:00
Stanislaw GruszkaandFelix Fietkau 172f081f27 mt76x0: do not overwrite other MT_BBP(AGC, 8) fields
MT_BBP(AGC, 8) register has values depend on band in
mt76x0_bbp_switch_tab, so we should not overwrite other fields
than MT_BBP_AGC_GAIN when setting gain.

This can fix performance issues when connecting to 2.4GHz AP.

Fixes: 4636a2544c3b ("mt76x0: phy: align channel gain logic to mt76x2 one")
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-11-01 18:04:15 +01:00
Stanislaw GruszkaandFelix Fietkau 14b6c59dc6 mt76x0: use band parameter for LC calibration
We use always 1 as band parameter for MCU_CAL_LC, this break 2GHz,
we should use 0 for this band instead.

Patch fixes problems happened sometimes when try to associate with 2GHz
AP and manifest by errors like below:

[14680.920823] wlan0: authenticate with 18:31:bf:c0:51:b0
[14681.109506] wlan0: send auth to 18:31:bf:c0:51:b0 (try 1/3)
[14681.310454] wlan0: send auth to 18:31:bf:c0:51:b0 (try 2/3)
[14681.518469] wlan0: send auth to 18:31:bf:c0:51:b0 (try 3/3)
[14681.726499] wlan0: authentication with 18:31:bf:c0:51:b0 timed out

Fixes: 9aec146d0f6b ("mt76x0: pci: introduce mt76x0_phy_calirate routine")
Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-10-25 19:15:54 +02:00
Stanislaw GruszkaandFelix Fietkau 11151f4887 mt76x0: antenna select corrections
Update mt76x0_phy_ant_select() to conform vendor driver, most notably
add dual antenna mode support, read configuration from EEPROM and
move ant select out of channel config to init phase. Plus small MT7630E
quirk for MT_CMB_CTRL register which vendor driver dedicated to this
chip do.

This make MT7630E workable with mt76x0e driver and do not cause any
problems on MT7610U for me.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
2018-10-23 09:49:40 +02:00
Stanislaw GruszkaandFelix Fietkau 5ed28f34cd mt76x0: do not perform MCU calibration for MT7630
Driver works better for MT7630 without MCU calibration, which
looks like it can hangs the firmware. Vendor driver do not
perform it for MT7630 as well.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-16 12:51:14 +02:00
Stanislaw GruszkaandFelix Fietkau 5e6907f272 mt76x0: remove dma.h
dma.h is not used any longer.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:47:02 +02:00
Stanislaw GruszkaandFelix Fietkau 4f3685e11b mt76: reserve enough room for USB tx skbs
Reserve enough room for USB skb, so we don not need to check
the room every time we send frame.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:47:02 +02:00
Stanislaw GruszkaandFelix Fietkau c83abb86cb mt76x0: use bus helper to identify rf access method
Use mt76_is_usb() to identify RF access method instead of
MT76_STATE_MCU_RUNNING flag and add warning since MCU has
to be initialized before we can access RF registers via MCU.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:47:02 +02:00
Stanislaw GruszkaandFelix Fietkau c438e67e7d mt76x0: correct RF reg pairs write for PCIe
We have to use RF CSR method for PCIe.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:47:02 +02:00
Stanislaw GruszkaandFelix Fietkau 02d23855e8 mt76: allow to identify bus
Add helpers to identify bus type.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:47:02 +02:00
Stanislaw GruszkaandFelix Fietkau ddc9e0554e mt76x0: correct RF access via RF_CSR register.
PCIe version don't use MCU for RF registers access. We need
to correct RF CSR method to support up to 127 RF registers.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:47:02 +02:00
Stanislaw GruszkaandFelix Fietkau c50dca8142 mt76x0: print BBP version only for debug
Use dev_dbg to print BBP version.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-08 13:47:02 +02:00
Stanislaw GruszkaandFelix Fietkau 05c7f24bfa mt76: fix frag length allocation for usb
This is correct fix for c12128ce44b0 ("mt76: use a per rx queue page
fragment cache"). We use wrong length when we allocate segments for
MCU transmissions, which require bigger segment size than e->buf_size.

Commit 481bb0432414 ("mt76: usb: make rx page_frag_cache access atomic")
partially solved the problem or actually mask it by changing
mt76u_mcu_init_rx() and mt76u_alloc_queues() sequence, so e->buf_size
become non zero any longer, but still not big enough to handle MCU data.

Patch fixes memory corruption which can manifest itself as random,
not easy to reproduce crashes, during mt76 driver load or unload.

Fixes: c12128ce44b0 ("mt76: use a per rx queue page fragment cache")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-10-04 12:55:58 +02:00
Stanislaw GruszkaandFelix Fietkau 4112e1ca30 mt76x0: add quirk to disable 2.4GHz band for Archer T1U
TP-LINK Archer T1U do not support 2.4GHz band despite EEPROM
reports that. Add quirk to mask out 2.4GHz support.

Reported-by: Sid Hayn <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-26 22:04:27 +02:00
Stanislaw GruszkaandFelix Fietkau cf8f750600 mt76: fix return value of mt76x02_wait_for_mac
We need to return bool value in mt76x02_wait_for_mac.

Reported-by: Dan Carpenter <[email protected]>
Fixes: 2735a6dd7df3 ("mt76: unify wait_for_mac")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-09-26 16:55:35 +02:00
Stanislaw GruszkaandFelix Fietkau 1047913825 mt76x0: usb: move firmware loading to usb.c
Firmware loading is usb specific, move it to usb.c file.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2018-09-20 12:02:28 +02:00
Stanislaw GruszkaandFelix Fietkau 0aef244fa2 mt76x0: remove mt76x0_burst_write_regs()
We don't need to use custom burst write regs via MCU, we can use
generic mt76_wr_copy() for the same purpose.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-09-12 13:16:50 +02:00
Stanislaw GruszkaandFelix Fietkau d63b72f83b mt76x0: remove unused mt76x0_burst_read_regs
mt76x0_burst_read_regs is not used, but keep it for eventual use. Since
we have this function now in the driver git history, we can remove it and
eventually revert this commit it the function will be needed.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-09-12 13:16:50 +02:00
Stanislaw GruszkaandFelix Fietkau e525b01a31 mt76: add rd_rp and wr_rp to bus_ops/mcu_ops
Add callbacks for reading and writing reg pairs tables.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-09-12 13:16:24 +02:00
Stanislaw GruszkaandFelix Fietkau 479b153758 mt76: add usb implementation of {wr,rd}_rp
Add USB implementation for read and write reg pair routines.
The actual implementation can use mcu related routines according to
MCU state

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2018-09-12 13:16:24 +02:00
Stanislaw GruszkaandFelix Fietkau e4a7387cc4 mt76x0: make device allocation bus neutral
Remove some USB specific code form mt76x0_alloc_device.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-12 13:16:24 +02:00
Stanislaw GruszkaandFelix Fietkau a8c61c25ad mt76x0: remove some usb specific code from mt76x0_register_device
Initial effort to make mt76x0_register_device bus neutral.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-12 13:16:24 +02:00
Stanislaw GruszkaandFelix Fietkau 3e241f3783 mt76x0: remove unused mt76x0_wcid
We do not use mt76x0_wcid any longer.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-12 13:16:24 +02:00
Stanislaw GruszkaandFelix Fietkau bb57912be5 mt76x0: inital split between pci and usb
For now pci driver can read ASIC version from the device :-)

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-12 13:16:24 +02:00
Stanislaw GruszkaandFelix Fietkau 6a9b73c288 mt76x0: trim rx skb to proper length
We need to truncate skb to proper length. This fix below message:

wlan0: associating with AP with corrupt beacon and probe response

Fixes: 9d87d9fad47e ("mt76x0: unify tx/rx datapath with mt76x2u driver")
Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-12 13:16:24 +02:00
Stanislaw GruszkaandFelix Fietkau d8f7d2ecbf mt76: partially unify filling txwi fields
Merge code filing txwi fields the same way on mt76x0 and mt76x2.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 81a655afd7 mt76: unify {insert/remove}_hdr_pad
Merge insert/remove _hdr_pad from mt76x0 and mt76x2.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 8aac175371 mt76x0: reserve enough space in mac80211
Allocate skg with enough headroom by mac80211 , this eliminate need
to add extra skb headroom by the mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 0a17b1e18c mt76: unify mac_process_rate
Merge mac_process_rate from mt76x0 and mt76x2.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 02816b0aba mt76: use mt76_rx_status in mt76x0
Make rx status processing similar to mt76x2.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00