1. 26 3月, 2020 1 次提交
    • Y
      rtw88: add a debugfs entry to dump coex's info · 1fe188da
      Yan-Hsuan Chuang 提交于
      Add a new entry "coex_info" in debugfs to dump coex's states for
      us to debug on coex's issues.
      
      The basic concept for co-existence (coex, usually for WiFi + BT)
      is to decide a strategy based on the current status of WiFi and
      BT. So, it means the WiFi driver requires to gather information
      from BT side and choose a strategy (TDMA/table/HW settings).
      
      Althrough we can easily check the current status of WiFi, e.g.,
      from kernel log or just dump the hardware registers, it is still
      very difficult for us to gather so many different types of WiFi
      states (such as RFE config, antenna, channel/band, TRX, Power
      save). Also we will need BT's information that is stored in
      "struct rtw_coex". So it is necessary for us to have a debugfs
      that can dump all of the WiFi/BT information required.
      
      Note that to debug on coex related issues, we usually need a
      longer period of time of coex_info dump every 2 seconds (for
      example, 30 secs, so we should have 15 times of coex_info's
      dump).
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Reviewed-by: NChris Chiu <chiu@endlessm.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200313033008.20070-2-yhchuang@realtek.com
      1fe188da
  2. 24 3月, 2020 2 次提交
    • Y
      rtw88: associate reserved pages with each vif · 895c096d
      Yan-Hsuan Chuang 提交于
      Each device has only one reserved page shared with all of the
      vifs, so it seems not reasonable to pass vif as one of the
      arguments to rtw_fw_download_rsvd_page(). If driver is going
      to run more than one vif, the content of reserved page could
      not be built for all of the vifs.
      
      To fix it, let each vif maintain its own reserved page list,
      and build the final reserved page to download to the firmware
      from all of the vifs. Hence driver should add reserved pages
      to each vif according to the vif->type when adding the vif.
      
      For station mode, add reserved page with rtw_add_rsvd_page_sta().
      If the station mode is going to suspend in PNO (net-detect)
      mode, remove the reserved pages used for normal mode, and add
      new one for wowlan mode with rtw_add_rsvd_page_pno().
      
      For beacon mode, only beacon is required to be added using
      rtw_add_rsvd_page_bcn().
      
      This would make the code flow simpler as we don't need to
      add reserved pages when vif is running, just add/remove them
      when ieee80211_ops::[add|remove]_interface.
      
      When driver is going to download the reserved page, it will
      collect pages from all of the vifs, this list is maintained
      by rtwdev, with build_list as the pages' member. That way, we
      can still build a list of reserved pages to be downloaded.
      Also we can get the location of the pages from the list that
      is maintained by rtwdev.
      
      The biggest problem is that the first page should always be
      beacon, if other type of reserved page is put in the first
      page, the tx descriptor and offset could be wrong.
      But station mode vif does not add beacon into its list, so
      we need to add a dummy page in front of the list, to make
      sure other pages will not be put in the first page. As the
      dummy page is allocated when building the list, we must free
      it before building a new list of reserved pages to firmware.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200312080852.16684-4-yhchuang@realtek.com
      895c096d
    • G
      wireless: realtek: Replace zero-length array with flexible-array member · a1b7714b
      Gustavo A. R. Silva 提交于
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200225002746.GA26789@embeddedor
      a1b7714b
  3. 12 3月, 2020 1 次提交
  4. 13 2月, 2020 2 次提交
  5. 26 1月, 2020 7 次提交
  6. 24 10月, 2019 5 次提交
  7. 14 10月, 2019 1 次提交
  8. 04 10月, 2019 6 次提交
    • Y
      rtw88: configure TX queue EDCA parameters · bf06c7ec
      Yan-Hsuan Chuang 提交于
      Set CWmax/CWmin, TXOP and AIFS according to ieee80211_tx_queue_params.
      
      Do note that hardware has only one group of EDCA[ac] registers, if more
      than one vif are added, the EDCA[ac] registers will contain value of
      params of the most recent set by ieee80211_ops::conf_tx().
      
      And AIFS = AIFSN[ac] * slot_time + SIFS, so if use_short_slot is changed,
      need to also change AIFS.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      bf06c7ec
    • Y
      rtw88: flush hardware tx queues · 1131ad7f
      Yan-Hsuan Chuang 提交于
      Sometimes mac80211 will ask us to flush the hardware queues.
      To flush them, first we need to get the corresponding priority queues
      from the RQPN mapping table.
      
      Then we can check the available pages are equal to the originally
      reserved pages, which means the hardware has returned all of the pages
      it used to transmit.
      
      Note that now we only check for 100 ms for the priority queue, but
      sometimes if we have a lot of traffic (ex. 100Mbps up), some of the
      packets could be dropped.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      1131ad7f
    • T
      rtw88: report tx rate to mac80211 stack · 699c7730
      Tzu-En Huang 提交于
      Whenever the firmware increases/decreases the bit rate used
      to transmit to a peer, it sends an RA report through C2H to
      driver. Driver can then record the bit rate in the peer's
      struct rtw_sta_info, and report to mac80211 when it asks us
      for the statistics of the sta by ieee80211_ops::sta_statistics
      Signed-off-by: NTzu-En Huang <tehuang@realtek.com>
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      699c7730
    • Y
      rtw88: take over rate control from mac80211 · 46ebb174
      Yan-Hsuan Chuang 提交于
      We can indicate IEEE80211_HW_HAS_RATE_CONTROL to mac80211 because
      the hardware has its own rate control algorithm. And what driver needs
      to do is to choose an RA mask according the peer's capabilities.
      
      But the hardware is not able to setup BA session by itself. So driver
      requires to initiate tx BA session for hardware, and tells it if it is
      possible to transmit AMPDU. The hardware can then aggregate MPDUs.
      
      And the size of AMPDU is controlled by the TX descriptor and the
      register value. Since the TX descriptor will reference the max AMPDU
      size from ieee80211_sta::ht_cap::ampdu_factor, just set the register
      value to 0x3f, and let it be controlled by TX descriptor.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      46ebb174
    • Y
      rtw88: add driver TX queue support · 3745d3e5
      Yan-Hsuan Chuang 提交于
      The mac80211 provides software TX queue for driver, as long as
      driver has hooked ieee80211_ops::wake_tx_queue. Each time a
      packet is queued onto the TX queue, that queue will be woken
      up the inform driver to serve the queue.
      
      Now driver only supports PCI interface ICs, there's no specific
      traffic control for each queue, just schedule a tasklet, and
      dump all of the packets at once to the DMA ring. Instead of TX
      the packets whenever TX queue is woke, tasklet handler can have
      more packets dumped to the device, takes advantage of burst
      write with DMA engine.
      
      And if the driver is going to support USB/SDIO ICs, the tasklet
      can be more flexible for aggregating the packets, enhance the
      efficiency of bandwidth usage.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      3745d3e5
    • Y
      rtw88: allows to set RTS in TX descriptor · 942e2a5d
      Yan-Hsuan Chuang 提交于
      Allows driver to send RTS by filling tx descriptor.
      
      The user may want to set the rts threshold. But since we have not
      been taking over rate control from mac80211 to driver by setting flag
      IEEE80211_HW_HAS_RATE_CONTROL, there is nothing we can do about it.
      So here just store the value, and mac80211 will tell us to use rts
      protection by ieee80211_tx_info::control::use_rts.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      942e2a5d
  9. 02 10月, 2019 7 次提交
    • Y
      rtw88: remove misleading module parameter rtw_fw_support_lps · bcde60e5
      Yan-Hsuan Chuang 提交于
      The module parameter rtw_fw_support_lps is misleading. It
      is not used to represent the firmware's property, but to
      determine if driver wants to ask firmware to enter LPS.
      
      However, driver should better enable/disable PS through
      cfg80211_ops::set_power_mgmt instead.
      For example, one could use iw command to set PS state.
      
        $ sudo iw wlanX set power_save [on/off]
      
      So rtw_fw_support_lps should be removed because it is
      misleading and useless. Instead of checking the parameter,
      set PS mode according to IEEE80211_CONF_PS.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      bcde60e5
    • Y
      rtw88: add deep PS PG mode for 8822c · 04b786e0
      Yan-Hsuan Chuang 提交于
      Compare with LCLK mode, PG mode saves more power, by turning
      off more circuits. Therefore, to recover from PG mode, driver
      needs to backup some information into rsvd page. Such as CAM
      entries, DPK results.
      
      As CAM entries can change, it is required to re-download CAM
      entries after set_key.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      04b786e0
    • Y
      rtw88: select deep PS mode when module is inserted · d3be4d11
      Yan-Hsuan Chuang 提交于
      Add a module parameter to select deep PS mode. And the mode
      cannot be changed after the module has been inserted and probed.
      If anyone wants to change the deep mode, should change the mode
      and probe the device again to setup the changed deep mode.
      
      When the device is probed, driver will check the deep PS mode
      with different IC's PS mode suppotability. If none of the
      PS mode is matched, the deep PS mode is changed to NONE,
      means deep PS is disabled.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      d3be4d11
    • Y
      rtw88: add deep power save support · 27e117e4
      Yan-Hsuan Chuang 提交于
      Deep power save allows firmware/hardware to operate in a
      lower power state. And the deep power save mode depends on
      LPS mode. So, before entering deep PS, driver must first
      enter LPS mode.
      
      Under Deep PS, most of hardware functions are shutdown,
      driver will not be able to read/write registers and transfer
      data to the device. Hence TX path must be protected by each
      interface. Take PCI for example, DMA engine should be idle,
      and no nore activities on the PCI bus.
      
      If driver wants to operate on the device, such as register
      read/write, it must first acquire the mutex lock and wake
      up from Deep PS, otherwise the behavior is undefined.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      27e117e4
    • Y
      rtw88: not to control LPS by each vif · 3d391c06
      Yan-Hsuan Chuang 提交于
      The original design of LPS enter/leave routines allows
      to control the LPS state by each interface. But the
      hardware cannot actually handle it that way. This means
      the hardware can only enter LPS once with an associated
      port, so there is no need to keep tracking the state of
      each vif.
      
      Hence the logic of enter/leave LPS state can be simple,
      just to check the state of the device's flag. And for
      leaving LPS state, it will get the same port id to send
      to inform the hardware.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      3d391c06
    • Y
      rtw88: not to enter or leave PS under IRQ · 61d73095
      Yan-Hsuan Chuang 提交于
      Remove PS related *_irqsafe functions to avoid entering/leaving PS
      under interrupt context. Instead, make PS decision in watch_dog.
      This could simplify the logic and make the code look clean.
      
      But it could have a little side-effect that if the driver is having
      heavy traffic before the every-2-second watch_dog detect the traffic
      and decide to leave PS, the thoughput will be lower. Once traffic is
      detected by watch_dog and left PS state, the throughput will resume
      to the peak the hardware ought to have again.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      61d73095
    • Y
      rtw88: remove redundant flag check helper function · 3c519605
      Yan-Hsuan Chuang 提交于
      These helper functions seems useless. And in some cases
      we want to use test_and_[set/clear]_bit, these helpers
      will make the code more complicated. So remove them.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      3c519605
  10. 13 9月, 2019 3 次提交
  11. 06 8月, 2019 1 次提交
    • Y
      rtw88: add BT co-existence support · 4136214f
      Yan-Hsuan Chuang 提交于
      Both RTL8822BE/RTL8822CE are WiFi + BT combo chips. Since
      WiFi and BT use 2.4GHz to transmit, it is important to
      make sure they run concurrently without interfering each
      other. To achieve this, WiFi driver requires a mechanism
      to collaborate with BT, whether they share the antenna(s)
      or not.
      
      The final decision made by the co-existence mechanism is
      to choose a proper strategy, or called "tdma/table", and
      inform either firmware or hardware of the strategy.
      To choose a strategy, co-existence mechanism needs to
      have enough information from WiFi and BT.
      
      BT information is provided through firmware C2H.
      The contents describe the current status of BT, such as
      if BT is connected or is idle, or the profile that is
      being used.
      
      WiFi information can be provided by WiFi itself. The WiFi
      driver will call various of "notify" functions each time
      the state of WiFi changed, such as WiFi is going to switch
      channel or is connected. Also WiFi driver can know if it
      shares antenna with BT by reading efuse content. Antenna
      configuration of the module will finally get a different
      strategy.
      
      Upon receiving any information from WiFi or BT, the WiFi
      driver will run the co-existence mechanism immediately.
      It will set the RF antenna configuration according to the
      strategy through the TDMA H2C to firmware and a hardware
      table. Based on the tdma/table, WiFi + BT should work with
      each other, and having a better user experience.
      Signed-off-by: NYan-Hsuan Chuang <yhchuang@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      4136214f
  12. 28 6月, 2019 2 次提交
  13. 25 6月, 2019 2 次提交