1. 07 Dec, 2021 19 commits
  2. 05 Dec, 2021 1 commit
    • Emmanuel Grumbach's avatar
      iwlwifi: mei: fix linking when tracing is not enabled · fe6db7ed
      Emmanuel Grumbach authored
      I forgot to add stubs in case tracing is disabled which caused linking errors:
      
      ERROR: modpost: "__SCT__tp_func_iwlmei_sap_data" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__SCT__tp_func_iwlmei_me_msg" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__tracepoint_iwlmei_sap_cmd" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__tracepoint_iwlmei_me_msg" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__SCK__tp_func_iwlmei_me_msg" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__SCK__tp_func_iwlmei_sap_data" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__tracepoint_iwlmei_sap_data" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__SCT__tp_func_iwlmei_sap_cmd" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      ERROR: modpost: "__SCK__tp_func_iwlmei_sap_cmd" [drivers/net/wireless/intel/iwlwifi/mei/iwlmei.ko] undefined!
      
      Fixes: 2da4366f ("iwlwifi: mei: add the driver to allow cooperation with CSME")
      Reported-by: default avatarJiri Slaby <jirislaby@kernel.org>
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Acked-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20211201113411.130409-1-emmanuel.grumbach@intel.com
      fe6db7ed
  3. 29 Nov, 2021 9 commits
  4. 26 Nov, 2021 11 commits
    • Ajay Singh's avatar
      wilc1000: remove '-Wunused-but-set-variable' warning in chip_wakeup() · d1e69b54
      Ajay Singh authored
      Remove unused variables to avoid the below warnings:
      
         drivers/net/wireless/microchip/wilc1000/wlan.c: In function 'chip_wakeup':
      >> drivers/net/wireless/microchip/wilc1000/wlan.c:620:34: warning: variable 'to_host_from_fw_bit' set but not used [-Wunused-but-set-variable]
           620 |         u32 to_host_from_fw_reg, to_host_from_fw_bit;
               |                                  ^~~~~~~~~~~~~~~~~~~
      >> drivers/net/wireless/microchip/wilc1000/wlan.c:620:13: warning: variable 'to_host_from_fw_reg' set but not used [-Wunused-but-set-variable]
           620 |         u32 to_host_from_fw_reg, to_host_from_fw_bit;
               |             ^~~~~~~~~~~~~~~~~~~
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211115102809.1408267-1-ajay.kathat@microchip.com
      d1e69b54
    • Emmanuel Grumbach's avatar
    • Emmanuel Grumbach's avatar
      iwlwifi: mvm: add vendor commands needed for iwlmei · bfcfdb59
      Emmanuel Grumbach authored
      Add the vendor commands that must be used by the network manager
      to allow proper operation of iwlmei.
      
      * Send information on the AP CSME is connected to
      * Notify the userspace when roaming is forbidden
      * Allow the userspace to require ownership
      Co-Developed-by: default avatarAyala Beker <ayala.beker@intel.com>
      Signed-off-by: default avatarAyala Beker <ayala.beker@intel.com>
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      
      v6: remove the VENDOR_CMDS Kconfig option and make the whole infra
          depend on IWLMEI directly
      v7: remove // comments
          remove an unneeded function
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211112062814.7502-5-emmanuel.grumbach@intel.com
      bfcfdb59
    • Emmanuel Grumbach's avatar
      iwlwifi: integrate with iwlmei · 6d19a5eb
      Emmanuel Grumbach authored
      iwlmei needs to know about the follwing events:
      
      * Association
      * De-association
      * Country Code change
      * SW Rfkill change
      * SAR table changes
      
      iwlmei can take the device away from us, so report the new
      rfkill type when this happens.
      Advertise the required data from the CSME firmware to the
      usersapce: mostly, the AP that the CSME firmware is currently
      associated to in case there is an active link protection
      session.
      Generate the HOST_ASSOC / HOST_DISSASSOC messages.
      
      Don't support WPA1 (non-RSNA) for now.
      Don't support shared wep either.
      We can then determine the AUTH parameter by checking the AKM.
      Feed the cipher from the key installation.
      
      SW Rfkill will be implemented later when cfg80211 will
      allow us to read the SW Rfkill state.
      Co-Developed-by: default avatarAyala Beker <ayala.beker@intel.com>
      Signed-off-by: default avatarAyala Beker <ayala.beker@intel.com>
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      
      v7: Ayala added her signed-off
          remove pointless function declaration
          fix a bug due to merge conflict in the HOST_ASSOC message
      v8: leave a print if we have a SAP connection on a device we do
          not support (yet)
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211112062814.7502-4-emmanuel.grumbach@intel.com
      6d19a5eb
    • Emmanuel Grumbach's avatar
      iwlwifi: mei: add debugfs hooks · 4ea7da5f
      Emmanuel Grumbach authored
      Add three debugfs hooks:
      * status: Check if we have a connection with the CSME
        firwmare. This hook is a read only.
      
      * req_ownership: Send a SAP command to request ownership. This
        flow should be triggered by iwlwifi (from user space through
        vendor commands really), but being able to trigger an ownership
        request from debugfs allows us to request ownership without
        connecting afterwards. This is an "error" flow that the CSME
        firmware is designed to handle this way:
        + Grant ownership since the host asked for it
        + Wait 3 seconds to let the host connect
        + If the host didn't connect, take the device back (forcefully).
        + Don't grant any new ownership request in the following 30
        seconds.
        This debugfs hook allows us to test this flow.
      
      * send_start_message: Restart the communication with the CSME
        firmware from the very beginning. At the very beginning (upon
        iwlwifi start), iwlmei send a special message: SAP_ME_MSG_START.
        This hook allows to send it again and this will retrigger the
        whole flow. It is important to test this restart in the middle
        of normal operation since it can happen (in case the CSME
        firmware decided to reset for example).
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211112062814.7502-3-emmanuel.grumbach@intel.com
      4ea7da5f
    • Emmanuel Grumbach's avatar
      iwlwifi: mei: add the driver to allow cooperation with CSME · 2da4366f
      Emmanuel Grumbach authored
      CSME in two words
      -----------------
      CSME stands for Converged Security and Management Engine. It is
      a CPU on the chipset and runs a dedicated firmware.
      AMT (Active Management Technology) is one of the applications
      that run on that CPU. AMT allows to control the platform remotely.
      Here is a partial list of the use cases:
      * View the screen of the plaform, with keyboard and mouse (KVM)
      * Attach a remote IDE device
      * Have a serial console to the device
      * Query the state of the platform
      * Reset / shut down / boot the platform
      
      Networking in CSME
      ------------------
      For those uses cases, CSME's firmware has an embedded network
      stack and is able to use the network devices of the system: LAN
      and WLAN. This is thanks to the CSME's firmware WLAN driver.
      
      One can add a profile (SSID / key / certificate) to the CSME's OS
      and CSME will connect to that profile. Then, one can use the WLAN
      link to access the applications that run on CSME (AMT is one of
      them). Note that CSME is active during power state and power state
      transitions. For example, it is possible to have a KVM session
      open to the system while the system is rebooting and actually
      configure the BIOS remotely over WLAN thanks to AMT.
      
      How all this is related to Linux
      --------------------------------
      In Linux, there is a driver that allows the OS to talk to the
      CSME firmware, this driver is drivers/misc/mei. This driver
      advertises a bus that allows other kernel drivers or even user
      space) to talk to components inside the CSME firmware.
      In practice, the system advertises a PCI device that allows
      to send / receive data to / from the CSME firmware. The mei
      bus drivers in drivers/misc/mei is an abstration on top of
      this PCI device.
      The driver being added here is called iwlmei and talks to the
      WLAN driver inside the CSME firmware through the mei bus driver.
      Note that the mei bus driver only gives bus services, it doesn't
      define the content of the communication.
      
      Why do we need this driver?
      --------------------------
      CSME uses the same WLAN device that the OS is expecting to see
      hence we need an arbitration mechanism. This is what iwlmei is
      in charge of. iwlmei maintains the communication with the CSME
      firmware's WLAN driver. The language / protocol that is used
      between the CSME's firmware WLAN driver and iwlmei is OS agnostic
      and is called SAP which stands for Software Abritration Protocol.
      With SAP, iwlmei will be able to tell the CSME firmware's WLAN
      driver:
      1) Please give me the device.
      2) Please note that the SW/HW rfkill state change.
      3) Please note that I am now associated to X.
      4) Please note that I received this packet.
      etc...
      
      There are messages that go the opposite direction as well:
      1) Please note that AMT is en/disable.
      2) Please note that I believe the OS is broken and hence I'll take
         the device *now*, whether you like it or not, to make sure that
         connectivity is preserved.
      3) Please note that I am willing to give the device if the OS
         needs it.
      4) Please give me any packet that is sent on UDP / TCP on IP address
         XX.XX.XX.XX and an port ZZ.
      5) Please send this packet.
      etc...
      
      Please check drivers/net/wireless/intel/iwlwifi/mei/sap.h for the
      full protocol specification.
      
      Arbitration is not the only purpose of iwlmei and SAP. SAP also
      allows to maintain the AMT's functionality even when the OS owns
      the device. To connect to AMT, one needs to initiate an HTTP
      connection to port 16992. iwlmei will listen to the Rx path and
      forward (through SAP) to the CSME firmware the data it got. Then,
      the embedded HTTP server in the chipset will reply to the request
      and send a SAP notification to ask iwlmei to send the reply.
      This way, AMT running on the CSME can still work.
      
      In practice this means that all the use cases quoted above (KVM,
      remote IDE device, etc...) will work even when the OS uses the
      WLAN device.
      
      How to disable all this?
      ---------------------------
      iwlmei won't be able to do anything if the CSME's networking stack
      is not enabled. By default, CSME's networking stack is disabled (this
      is a BIOS setting).
      In case the CSME's networking stack is disabled, iwlwifi will just
      get access to the device because there is no contention with any other
      actor and, hence, no arbitration is needed.
      
      In this patch, I only add the iwlmei driver. Integration with
      iwlwifi will be implemented in the next one.
      Co-Developed-by: default avatarAyala Beker <ayala.beker@intel.com>
      Signed-off-by: default avatarAyala Beker <ayala.beker@intel.com>
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      
      v2: fix a few warnings raised by the different bots
      v3: rewrite the commit message
      v4: put the debugfs content in a different patch
      v5: fix a NULL pointer dereference upon DHCP TX if SAP is connected
          since we now have the required cfg80211 bits in wl-drv-next, add
          the RFKILL handling patch to this series.
      v6: change the SAP API to inherit the values from iwl-mei.h removing
          the need to ensure the values are equal with a BUILD_BUG_ON.
          This was suggested by Arend
      v7: * fix a locking issue in case of CSME firmware reset:
            When the CSME firmware resets, we need to unregister the
            netdev, first take the mutex, and only then, rely on it
            being taken.
          * Add a comment to explain why it is ok to have static variables
            (iwlmei can't have more than a single instance).
          * Add a define for 26 + 8 + 8
          * Add a define SEND_SAP_MAX_WAIT_ITERATION
          * make struct const
          * Reword a bit the Kconfig help message
          * Ayala added her Signed-off
          * fixed an RCU annotation
      v8: do not require ownership upfront, use NIC_OWNER instead. This fixes
          a deadlock when CSME does not have the right WiFi FW.
          Add more documentation about the owernship transition
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211112062814.7502-2-emmanuel.grumbach@intel.com
      2da4366f
    • Alexander Usyskin's avatar
      mei: bus: add client dma interface · 2cca3465
      Alexander Usyskin authored
      Expose the client dma mapping via mei client bus interface.
      The client dma has to be mapped before the device is enabled,
      therefore we need to create device linking already during mapping
      and we need to unmap after the client is disable hence we need to
      postpone the unlink and flush till unmapping or when
      destroying the device.
      Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
      Co-developed-by: default avatarTomas Winkler <tomas.winkler@intel.com>
      Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
      Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Link: https://lore.kernel.org/r/20210420172755.12178-1-emmanuel.grumbach@intel.comSigned-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211112062814.7502-1-emmanuel.grumbach@intel.com
      2cca3465
    • Jonas Dreßler's avatar
      mwifiex: Ignore BTCOEX events from the 88W8897 firmware · 84d94e16
      Jonas Dreßler authored
      The firmware of the 88W8897 PCIe+USB card sends those events very
      unreliably, sometimes bluetooth together with 2.4ghz-wifi is used and no
      COEX event comes in, and sometimes bluetooth is disabled but the
      coexistance mode doesn't get disabled.
      
      This means we sometimes end up capping the rx/tx window size while
      bluetooth is not enabled anymore, artifically limiting wifi speeds even
      though bluetooth is not being used.
      
      Since we can't fix the firmware, let's just ignore those events on the
      88W8897 device. From some Wireshark capture sessions it seems that the
      Windows driver also doesn't change the rx/tx window sizes when bluetooth
      gets enabled or disabled, so this is fairly consistent with the Windows
      driver.
      Signed-off-by: default avatarJonas Dreßler <verdre@v0yd.nl>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211103205827.14559-1-verdre@v0yd.nl
      84d94e16
    • Jonas Dreßler's avatar
      mwifiex: Ensure the version string from the firmware is 0-terminated · deb573f1
      Jonas Dreßler authored
      We assume at a few places that priv->version_str is 0-terminated, but
      right now we trust the firmware that this is the case with the version
      string we get from it.
      
      Let's rather ensure this ourselves and replace the last character with
      '\0'.
      Signed-off-by: default avatarJonas Dreßler <verdre@v0yd.nl>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211103201800.13531-4-verdre@v0yd.nl
      deb573f1
    • Jonas Dreßler's avatar
      mwifiex: Add quirk to disable deep sleep with certain hardware revision · 939b571a
      Jonas Dreßler authored
      The 88W8897 PCIe+USB card in the hardware revision 20 apparently has a
      hardware issue where the card wakes up from deep sleep randomly and very
      often, somewhat depending on the card activity, maybe the hardware has a
      floating wakeup pin or something. This was found by comparing two MS
      Surface Book 2 devices, where one devices wifi card experienced spurious
      wakeups, while the other one didn't.
      
      Those continuous wakeups prevent the card from entering host sleep when
      the computer suspends. And because the host won't answer to events from
      the card anymore while it's suspended, the firmwares internal power
      saving state machine seems to get confused and the card can't sleep
      anymore at all after that.
      
      Since we can't work around that hardware bug in the firmware, let's
      get the hardware revision string from the firmware and match it with
      known bad revisions. Then disable auto deep sleep for those revisions,
      which makes sure we no longer get those spurious wakeups.
      Signed-off-by: default avatarJonas Dreßler <verdre@v0yd.nl>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211103201800.13531-3-verdre@v0yd.nl
      939b571a
    • Jonas Dreßler's avatar
      mwifiex: Use a define for firmware version string length · 2d1d7091
      Jonas Dreßler authored
      Since the version string we get from the firmware is always 128
      characters long, use a define for this size instead of having the number
      128 copied all over the place.
      Signed-off-by: default avatarJonas Dreßler <verdre@v0yd.nl>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20211103201800.13531-2-verdre@v0yd.nl
      2d1d7091