Commit Graph

180 Commits

Author SHA1 Message Date
Jose Ignacio Tornos Martinez a80e8fedab wifi: iwlwifi: correctly lookup DMA address in SG table
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit 38c8d02501c09454e4fbf0f67de03de35e94d384
Author: Benjamin Berg <benjamin.berg@intel.com>
Date:   Mon Aug 12 13:06:40 2024 +0200

    wifi: iwlwifi: correctly lookup DMA address in SG table
    
    The code to lookup the scatter gather table entry assumed that it was
    possible to use sg_virt() in order to lookup the DMA address in a mapped
    scatter gather table. However, this assumption is incorrect as the DMA
    mapping code may merge multiple entries into one. In that case, the DMA
    address space may have e.g. two consecutive pages which is correctly
    represented by the scatter gather list entry, however the virtual
    addresses for these two pages may differ and the relationship cannot be
    resolved anymore.
    
    Avoid this problem entirely by working with the offset into the mapped
    area instead of using virtual addresses. With that we only use the DMA
    length and DMA address from the scatter gather list entries. The
    underlying DMA/IOMMU code is therefore free to merge two entries into
    one even if the virtual addresses space for the area is not continuous.
    
    Fixes: 90db50755228 ("wifi: iwlwifi: use already mapped data when TXing an AMSDU")
    Reported-by: Chris Bainbridge <chris.bainbridge@gmail.com>
    Closes: https://lore.kernel.org/r/ZrNRoEbdkxkKFMBi@debian.local
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Tested-by: Chris Bainbridge <chris.bainbridge@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://patch.msgid.link/20240812110640.460514-1-benjamin@sipsolutions.net

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:42 +01:00
Jose Ignacio Tornos Martinez ee868c910c wifi: iwlwifi: keep the TSO and workaround pages mapped
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit adc902ceada26add77ad75426805e973a7c67f01
Author: Benjamin Berg <benjamin.berg@intel.com>
Date:   Wed Jul 3 12:58:54 2024 +0300

    wifi: iwlwifi: keep the TSO and workaround pages mapped
    
    Map the pages when allocating them so that we will not need to map each
    of the used fragments at a later point.
    
    For now the mapping is not used, this will be changed in a later commit.
    
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Reviewed-by: Johannes Berg <johannes.berg@intel.com>
    Link: https://patch.msgid.link/20240703125541.7ced468fe431.Ibb109867dc680c37fe8d891e9ab9ef64ed5c5d2d@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:22 +01:00
Jose Ignacio Tornos Martinez 85e260c54a wifi: iwlwifi: map entire SKB when sending AMSDUs
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit 7f5e3038f02902a1409c9ad0f07e3b11c581c113
Author: Benjamin Berg <benjamin.berg@intel.com>
Date:   Wed Jul 3 12:58:53 2024 +0300

    wifi: iwlwifi: map entire SKB when sending AMSDUs
    
    This adds logic to map the entire SKB for AMSDUs. The required scatter
    gather list is allocated together with the space for TSO headers.
    Unmapping happens again when free'ing the TSO header page.
    
    For now the mapping is unused, this will be changed in a later commit.
    
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Reviewed-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20240703125541.96c6006f40ff.I55b74bc97c4026761397a7513a559c88a10b6489@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:22 +01:00
Jose Ignacio Tornos Martinez a28efd5598 wifi: iwlwifi: return a new allocation for hdr page space
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit d023a228e927c142c5c418dae346f63d1c8ba105
Author: Benjamin Berg <benjamin.berg@intel.com>
Date:   Wed Jul 3 12:58:52 2024 +0300

    wifi: iwlwifi: return a new allocation for hdr page space
    
    Instead of returning the pointer to the structure describing the header
    page, return the pointer to the newly allocated area. This disentangles
    the user from the allocation within the page as it does not need to
    advance the position itself.
    
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Reviewed-by: Johannes Berg <johannes.berg@intel.com>
    Link: https://patch.msgid.link/20240703125541.044f2cb373f1.I52a807ac6f311b89530e18deacc7452638a6f5d8@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:22 +01:00
Jose Ignacio Tornos Martinez 482f79b4dd wifi: iwlwifi: pcie: fix kernel-doc
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit ab713d0c883dcb59400d8cbdaae1d6a970c957ec
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Tue Jun 25 19:51:17 2024 +0300

    wifi: iwlwifi: pcie: fix kernel-doc
    
    One typo, and a few things were missing. Fix that.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20240625194805.c667bc035757.Iae0e5903a35f8e42f86deb27429131f22329b8dd@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:15 +01:00
Jose Ignacio Tornos Martinez d44bb97fff wifi: iwlwifi: trans: remove unused function parameter
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit 2917d04bce3906750b9b746736c54cc68740723e
Author: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Date:   Tue Jun 18 19:44:05 2024 +0300

    wifi: iwlwifi: trans: remove unused function parameter
    
    iwl_trans_pcie_gen2_fw_alive doesn't use the scd_addr parameter,
    it was there only because we needed the functio to have a prototype same
    as iwl_trans_ops::fw_alive callback.
    But now the ops is removed so no reason to keep the parameter.
    
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Link: https://patch.msgid.link/20240618194245.1aa8bf13aea9.I9662c10c1db545dd8849af4bb4ab47708d4548d8@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:12 +01:00
Jose Ignacio Tornos Martinez c4bec5665d wifi: iwlwifi: remove struct iwl_trans_ops
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit 0d91a2bfc3dcae0a586e67c904abef002c848e6c
Author: Yedidya Benshimol <yedidya.ben.shimol@intel.com>
Date:   Wed Jun 5 14:05:03 2024 +0300

    wifi: iwlwifi: remove struct iwl_trans_ops
    
    This was needed when we had multiple types of transports. Now we only
    have pcie, so there is no need for this ops.
    Cleanup the code such as the different trans APIs will call the pcie
    function directly, instead of calling the callback,
    and remove struct iwl_trans_ops.
    
    Signed-off-by: Yedidya Benshimol <yedidya.ben.shimol@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://msgid.link/20240605140327.8315ff64f9f3.Ifdbc1f26d49766f7de553dcb5f613885f4ee65cc@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:03 +01:00
Jose Ignacio Tornos Martinez 9573e64739 wifi: iwlwifi: pcie: integrate TX queue code
JIRA: https://issues.redhat.com/browse/RHEL-50013

Conflicts:
  - drivers/net/wireless/intel/iwlwifi/queue/tx.c
    This file is removed and it is not necessary, just remove although
    there were conflicts in the past.

commit 49101078be769e9c50a8bfbc8caaab56db9d12d9
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Jun 5 14:05:02 2024 +0300

    wifi: iwlwifi: pcie: integrate TX queue code
    
    The TX queue code was mostly moved out to support an internal
    transport that we were never going to publish, but we're no
    longer using that. Since we're also going to be dissolving
    the virtual transport layer entirely, integrate the TX queue
    code into the PCIe layer.
    
    This also has a small kernel of already removing the virtual
    transport function layer, since iwl_trans_send_cmd() calls
    iwl_trans_pcie_send_hcmd() directly now, even if that still
    calls the transport send_cmd method for now, we'll clean it
    up later.
    
    Also, not everything is renamed yet.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://msgid.link/20240605140327.936b13f45071.Ib219ce01a1e67bcad79d5131626db950252aaa46@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:03 +01:00
Jose Ignacio Tornos Martinez ffbff36361 wifi: iwlwifi: pcie: allocate dummy net_device dynamically
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit b73c138a879fd7f8d75ad90f5b453615171c2acc
Author: Breno Leitao <leitao@debian.org>
Date:   Wed May 1 09:54:04 2024 -0700

    wifi: iwlwifi: pcie: allocate dummy net_device dynamically
    
    struct net_device shouldn't be embedded into any structure, instead,
    the owner should use the priv space to embed their state into net_device.
    
    Embedding net_device into structures prohibits the usage of flexible
    arrays in the net_device structure. For more details, see the discussion
    at [1].
    
    Un-embed the net_device from struct iwl_trans_pcie by converting it
    into a pointer. Then use the leverage alloc_netdev() to allocate the
    net_device object at iwl_trans_pcie_alloc.
    
    The private data of net_device becomes a pointer for the struct
    iwl_trans_pcie, so, it is easy to get back to the iwl_trans_pcie parent
    given the net_device object.
    
    [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
    
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Breno Leitao <leitao@debian.org>
    Link: https://msgid.link/20240501165417.3406039-1-leitao@debian.org
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:17:15 +01:00
Jose Ignacio Tornos Martinez 6a041abb10 wifi: iwlwifi: pcie: don't synchronize IRQs from IRQ
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit 400f6ebbc175286576c7f7fddf3c347d09d12310
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Dec 15 11:13:34 2023 +0100

    wifi: iwlwifi: pcie: don't synchronize IRQs from IRQ
    
    On older devices (before unified image!) we can end up calling
    stop_device from an rfkill interrupt. However, in stop_device
    we attempt to synchronize IRQs, which then of course deadlocks.
    
    Avoid this by checking the context, if running from the IRQ
    thread then don't synchronize. This wouldn't be correct on a
    new device since RSS is supported, but older devices only have
    a single interrupt/queue.
    
    Fixes: 37fb29bd1f90 ("wifi: iwlwifi: pcie: synchronize IRQs before NAPI")
    Reviewed-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://msgid.link/20231215111335.59aab00baed7.Iadfe154d6248e7f9dfd69522e5429dbbd72925d7@changeid

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:30:00 +01:00
Jose Ignacio Tornos Martinez e82e150f0a wifi: iwlwifi: pcie: fix RB status reading
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit 9f9797c7de18d2ec6be4ef6e0abbaea585040b39
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Aug 30 11:31:03 2023 +0300

    wifi: iwlwifi: pcie: fix RB status reading
    
    On newer hardware, a queue's RB status / write pointer
    can be bigger than 4095 (0xFFF), so we cannot mask the
    value by 0xFFF unconditionally. Since anyway that's
    only necessary on older hardware, move the masking to
    the helper function and apply it only for older HW.
    This also moves the endian conversion in to handle it
    more easily.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230830112059.7be2a3fff6f4.I94f11dee314a4f7c1941d2d223936b1fa8aa9ee4@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:28:59 +01:00
Jose Ignacio Tornos Martinez c67d8e8bc2 wifi: iwlwifi: pcie: fix kernel-doc issues
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit 221e290bee238f6b81ea39b4ba781209e8fd07f3
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Aug 30 11:30:57 2023 +0300

    wifi: iwlwifi: pcie: fix kernel-doc issues
    
    Fix various missing kernel-doc annotations etc.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230830112059.a11b39f9a07e.Ia7b189f003db8f6ccaf0a547e71c80e00b85fb5a@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:28:58 +01:00
Jose Ignacio Tornos Martinez dff682a0fa wifi: iwlwifi: remove 'def_rx_queue' struct member
JIRA: https://issues.redhat.com/browse/RHEL-2907

commit d5050543f1ed78beb85f85b5830242cb0c4968c0
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Aug 16 11:10:47 2023 +0300

    wifi: iwlwifi: remove 'def_rx_queue' struct member
    
    This is only ever initialized to zero, use a new define
    for the default RX queue instead.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230816104355.e0c6fa57c162.I907bbb428cf99725f06a348c8dbce5d3dd877136@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-11-27 15:02:24 +01:00
Jose Ignacio Tornos Martinez 5194749330 wifi: iwlwifi: Enable loading of reduce-power tables into several segments
JIRA: https://issues.redhat.com/browse/RHEL-2907

commit 7c9c8477170d32def5df9d88823ea10d65749341
Author: Alon Giladi <alon.giladi@intel.com>
Date:   Tue Jun 6 10:43:06 2023 +0300

    wifi: iwlwifi: Enable loading of reduce-power tables into several segments
    
    Replace the field reduce_power_dram with a struct that holds data about
    the reduced-power tables drams regions. Generalize load_payloads_segments()
    to work for both pnvm tables and reduction power tables.
    Make required adjustments in the data structures.
    
    Signed-off-by: Alon Giladi <alon.giladi@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230606103519.6fe66958f049.I85d80682229fc02fe354462cc9da40937558f30c@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-11-27 15:01:15 +01:00
Jose Ignacio Tornos Martinez ef550d2860 wifi: iwlwifi: Implement loading and setting of fragmented pnvm image
JIRA: https://issues.redhat.com/browse/RHEL-2907

commit 63b9e7b9f02ee3b10b6998778e2ed11f23510d9c
Author: Alon Giladi <alon.giladi@intel.com>
Date:   Tue Jun 6 10:43:03 2023 +0300

    wifi: iwlwifi: Implement loading and setting of fragmented pnvm image
    
    Save the pnvm payloads in several DRAM segments (not only in one as
    used to). In addition, allocate a FW structure in DRAM that holds the
    segments' addresses and forward its address to the FW. It's done when
    FW has the capability to handle pnvm images this way (helps to process
    large pnvm images).
    
    Signed-off-by: Alon Giladi <alon.giladi@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230606103519.dbdad8995ce1.I986213527982637042532de3851a1bd8a11be87a@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-11-27 15:01:15 +01:00
Jose Ignacio Tornos Martinez 27e4f4239a wifi: iwlwifi: Allow trans_pcie track more than 1 pnvm DRAM region
JIRA: https://issues.redhat.com/browse/RHEL-2907

commit f6fa5835652150734c57ccb2a21f3653cbe42a27
Author: Alon Giladi <alon.giladi@intel.com>
Date:   Tue Jun 6 10:43:01 2023 +0300

    wifi: iwlwifi: Allow trans_pcie track more than 1 pnvm DRAM region
    
    Change the field pnvm_dram to an array that describes many regions
    and add a counter to the number of pnvm regions that were allocated
    in DRAM.
    
    Signed-off-by: Alon Giladi <alon.giladi@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230606103519.bb206d71bf45.I627640701757bb2f234f8e18a3afbd6af1206658@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-11-27 15:01:15 +01:00
Íñigo Huguet 4cae11e8e2 wifi: iwlwifi: call napi_synchronize() before freeing rx/tx queues
Bugzilla: https://bugzilla.redhat.com/2196821

commit 5af2bb3168db6b0af9988eb25cccf2e3bc4455e2
Author: Gregory Greenman <gregory.greenman@intel.com>
Date:   Sun Apr 16 15:47:26 2023 +0300

    wifi: iwlwifi: call napi_synchronize() before freeing rx/tx queues
    
    When rx/tx queues are being freed, on a different CPU there could be
    still rx flow running. Call napi_synchronize() to prevent such a race.
    
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Co-developed-by: Benjamin Berg <benjamin.berg@intel.com>
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Link: https://lore.kernel.org/r/20230416154301.5171ee44dcc1.Iff18718540da412e084e7d8266447d40730600ed@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-07-26 13:15:55 +02:00
Íñigo Huguet f23868ebf4 iwlwifi: pcie: adjust to Bz completion descriptor
Bugzilla: https://bugzilla.redhat.com/2059999

commit 5d19e2087fea28651eff7eadf4510fa1564688a2
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Feb 4 12:25:04 2022 +0200

    iwlwifi: pcie: adjust to Bz completion descriptor
    
    The Bz devices got a new completion descriptor again since
    we only ever really used 4 out of 32 bytes anyway. Adjust
    the code to deal with that. Note that the intention was to
    reduce the size, but the hardware was implemented wrongly.
    
    While at it, do some cleanups and remove the union to simplify
    the code, clean up iwl_pcie_free_bd_size() to no longer need
    an argument and add iwl_pcie_used_bd_size() with the logic to
    selct completion descriptor size.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20220204122220.bef461a04110.I90c8885550fa54eb0aaa4363d322f50e301175a6@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 14:50:52 +02:00
Íñigo Huguet 26595aa261 iwlwifi: yoyo: add IMR DRAM dump support
Bugzilla: https://bugzilla.redhat.com/2059999

commit c0941ace9a134bd1a9c2c09afad4e6bf0066c1e3
Author: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Date:   Sat Jan 29 13:16:19 2022 +0200

    iwlwifi: yoyo: add IMR DRAM dump support
    
    Support debug collection of the platform IMR memory region,
    where data is copied by FW during d3 state
    
    Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20220129105618.715f04ecc635.Ib89a6caa06c1324c1c0dd3f9f4cf7407f2857155@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 14:50:49 +02:00
Íñigo Huguet d9cd71e6be iwlwifi: avoid void pointer arithmetic
Bugzilla: https://bugzilla.redhat.com/2059999

commit 3827cb59b3b8ce4b1687385d35034dadcd90d7ce
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Jan 28 15:34:29 2022 +0200

    iwlwifi: avoid void pointer arithmetic
    
    Avoid void pointer arithmetic since it's technically
    undefined and causes warnings in some places that use
    our code.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20220128153014.e349104ecd94.Iadc937f475158b9437becdfefb361a97e7eaa934@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 14:50:47 +02:00
Íñigo Huguet 00028f114e iwlwifi: pcie: remove spaces from queue names
Bugzilla: http://bugzilla.redhat.com/2033354

commit 02289645a085eedb55b185da2766b5c6f9492577
Author: Luca Coelho <luciano.coelho@intel.com>
Date:   Mon Aug 2 17:28:21 2021 +0300

    iwlwifi: pcie: remove spaces from queue names
    
    If we use spaces in the queue names, we get files with spaces in their
    name in procfs, which is ugly.  Remove the spaces.
    
    Reported-by: Joe Perches <joe@perches.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20210802172232.0ef8aedd4f9b.If527b9ae5bf8de8c6877d4b6a21ed8d81b0f877e@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2021-12-22 13:45:58 +01:00
Íñigo Huguet d74cc61ac4 iwlwifi: pcie: dump error on FW reset handshake failures
Bugzilla: http://bugzilla.redhat.com/2033354

commit e63aafea74393e6c6ca0dd439e72021830a0fcac
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Mon Aug 2 17:09:40 2021 +0300

    iwlwifi: pcie: dump error on FW reset handshake failures
    
    If the firmware crashes while we're waiting for the reset
    handshake then it cannot possibly make progress anymore,
    and we will just time out the wait. That's pointless, so
    just stop waiting at that point.
    
    Additionally, if it never acknowledges the reset handshake,
    something went wrong.
    
    Dump an error in both of these cases, but we need to do it
    synchronously here since the device will be turned off.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20210802170640.8b6a33544b4b.I55f97f70f8efa64db064a9207177a094c60ac8f1@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2021-12-22 13:45:57 +01:00
Íñigo Huguet adb1a9c2e7 iwlwifi: pcie: optimise struct iwl_rx_mem_buffer layout
Bugzilla: http://bugzilla.redhat.com/2033354

commit 95fe8d89bb8c9c114ca3e46f8b2457f894f55746
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Mon Aug 2 17:09:37 2021 +0300

    iwlwifi: pcie: optimise struct iwl_rx_mem_buffer layout
    
    On 64-bit machines, struct iwl_rx_mem_buffer has a lot of
    padding due to the use of pointers after the small items.
    Move the list entry before them, and while at it also add
    documentation for it.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20210802170640.6a62255b3df0.I47bb36530a3c2cdbd73454c796ce608ee2a32a6c@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2021-12-22 13:45:57 +01:00
Luca Coelho 9dad325f9d iwlwifi: support loading the reduced power table from UEFI
This new feature allows OEMs to set a special reduced power table in a
UEFI variable, which we use to tell the firmware to change the TX
power tables.

Read the variable and store it in a dram block to pass it to the
firmware.  We do this as part of the PNVM loading flow.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210621103449.259a33ba5074.I2e0bb142d2a9c412547cba89b62dd077b328fdc4@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-06-22 16:57:57 +03:00
Johannes Berg 310f60f53a iwlwifi: pcie: free IML DMA memory allocation
In the case of gen3 devices with image loader (IML) support,
we were leaking the IML DMA allocation and never freeing it.
Fix that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210618105614.07e117dbedb7.I7bb9ebbe0617656986c2a598ea5e827b533bd3b9@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-06-22 16:57:56 +03:00
Johannes Berg 8e08e191fc iwlwifi: pcie: remove TR/CR tail allocations
The TR/CR tail data are meant to be per-queue-arrays, however,
we allocate them completely wrong (we have a separate allocation
per queue).

Looking at this more closely, it turns out that the hardware
never uses these - we have a separate free list per RX queue
and maintain a write pointer for that in a register, and the
RX itself is indicated in the RB status (rb_stts) DMA region.

Despite nothing using the tail pointers, the hardware will
unconditionally access them to write updates, even when we aren't
using CRs/TRs.

Give it dummy values that we never use/update so it can do that
without causing trouble.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210617110647.5f5764e04c46.I4d5de1929be048085767f1234a1e07b517ab6a2d@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-06-22 16:57:55 +03:00
Johannes Berg bef99c7d91 iwlwifi: pcie: fix some kernel-doc comments
"ubd" is really called "used_bd", fix that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210617100544.2d4b46c656bb.Iff9ee6a7e65d439169202911dad2cbea626fb887@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-06-22 16:57:55 +03:00
Johannes Berg aa899e683f iwlwifi: pcie: identify the RF module
Identify and print out the RF module to be able to identify
(from logs and through debugfs) which one (and version) is
present on the system.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210617100544.cd1ef97b2c04.Iad42a59902a87a50b45b9ce88705863686a83b54@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-06-22 15:11:26 +03:00
Johannes Berg c544d89b0d iwlwifi: pcie: don't enable BHs with IRQs disabled
After the fix from Jiri that disabled local IRQs instead of
just BHs (necessary to fix an issue with submitting a command
with IRQs already disabled), there was still a situation in
which we could deep in there enable BHs, if the device config
sets the apmg_wake_up_wa configuration, which is true on all
7000 series devices.

To fix that, but not require reverting commit 1ed08f6fb5
("iwlwifi: remove flags argument for nic_access"), split up
nic access into a version with BH manipulation to use most
of the time, and without it for this specific case where the
local IRQs are already disabled.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/iwlwifi.20210415164821.d0f2edda1651.I75f762e0bed38914d1300ea198b86dd449b4b206@changeid
2021-04-18 09:37:38 +03:00
Mordechay Goodstein 13f028b4f7 iwlwifi: tx: move handing sync/async host command to trans
Handling host commands in a sync way is not directly related to PCIe
transport, and can serve as common logic for any transport, so move
it to trans layer.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210117164916.fde99af4e0f7.I4cab95919eb35cc5bfb26d32dcf5e15419d0e0ef@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-02-05 11:55:19 +02:00
Mordechay Goodstein 3161a34d65 iwl-trans: iwlwifi: move sync NMI logic to trans
The code is not directly related to PCIe transport, and it will help
moving sync/async commands logic out of PCIe in the next patches.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210117130510.271f59887fd1.I8ff41236f4e11a25df83d76c982a2a30ba2b9903@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-02-05 11:52:32 +02:00
Johannes Berg 25edc8f259 iwlwifi: pcie: properly implement NAPI
Instead of pretending to have NAPI and then relying entirely on
interrupts anyway, properly implement NAPI and schedule the poll
when we get an interrupt, re-enabling the interrupt only after
the poll completed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210117130510.a5951ac4fc06.I9c84a147288fcfb1b019572c6758f2d92949f5d7@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-02-05 11:52:31 +02:00
Johannes Berg 906d4eb844 iwlwifi: support firmware reset handshake
There are some races in the hardware that can possibly lead to
a bus lockup later during a restart when we manage to kill the
firmware at a bad time (while it's accessing the bus).

To work around this, add support for a new handshake between
firmware and driver to ensure that the firmware is in a well-
known state before we kill it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201209231352.7756fcc9865c.I13de65e0ffcb4186dd4c1a465f66df2e98c9a947@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-12-10 00:16:03 +02:00
Johannes Berg 8e99ea8d09 iwlwifi: use SPDX tags
Use SPDX tags instead of the long copyright notices.  Also cleanup
some duplicate copyright notices and combine the years where possible.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201210000603.481bcb512a6f.I8146abe5a637079e7336209f23cb26af98b12b31@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-12-10 00:15:31 +02:00
Emmanuel Grumbach 59fa61f3fd iwlwifi: remove sw_csum_tx
This was a hack done to test the data path of devices that
didn't support well CSUM offload in Tx. This is not needed
anymore.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201209231352.6c9fc9fb48d5.I2aaebf90e6fe81860105d049a8d35746fa8d86c2@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-12-10 00:14:15 +02:00
Mordechay Goodstein a445098058 iwlwifi: move reclaim flows to the queue file
Reclaim flows are bus-independent TX functions so we move
it to the common place handling bus-independent tx operations

used spatch rule

@@
@@
(
-iwl_trans_pcie_freeze_txq_timer
+iwl_trans_txq_freeze_timer
|
-iwl_trans_pcie_set_q_ptrs
+iwl_trans_txq_set_q_ptrs
|
-iwl_pcie_txq_free_tfd
+iwl_txq_free_tfd
|
-iwl_pcie_txq_progress
+iwl_txq_progress
|
-iwl_trans_pcie_reclaim
+iwl_trans_txq_reclaim
)

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201209231352.40723e92b6bf.I83cf71d9c6d989ec42f52b353f1d33f32540db59@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-12-10 00:11:17 +02:00
Luca Coelho 6654cd4eb9 iwlwifi: pcie: implement set_pnvm op
Implement the set_pnvm op to store the PNVM settings to the context
info and the corresponding code to free the DRAM block when the
context is freed.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/iwlwifi.20201008181047.85847cfb0972.I202d90e99779f722df14b2d4102d3e466343a6f6@changeid
2020-10-08 20:15:00 +03:00
Mordechay Goodstein 0179bfff97 iwlwifi: pcie: make iwl_pcie_txq_update_byte_cnt_tbl bus independent
To avoid duplicating code we need to call iwl_pcie_txq_update_byte_cnt_tbl
function from non bus independent code so make it bus independent.

Used spatch rule

@r1@
struct iwl_trans_pcie *trans_pcie;
@@
(
-trans_pcie->scd_bc_tbls
+trans->txqs.scd_bc_tbls
|
-iwl_pcie_txq_update_byte_cnt_tbl
+iwl_txq_gen1_update_byte_cnt_tbl
|
-iwl_pcie_txq_inval_byte_cnt_tbl
+iwl_txq_gen1_inval_byte_cnt_tbl
|
-iwl_pcie_tfd_unmap
+iwl_txq_gen1_tfd_unmap
|
-iwl_pcie_tfd_tb_get_addr
+iwl_txq_gen1_tfd_tb_get_addr
|
-iwl_pcie_tfd_tb_get_len
+iwl_txq_gen1_tfd_tb_get_len
|
-iwl_pcie_tfd_get_num_tbs
+iwl_txq_gen1_tfd_get_num_tbs
)

/* clean all new unused variables */
@ depends on r1@
type T;
identifier i;
expression E;
@@
- T i = E;
 ... when != i

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200930191738.8d33e791ec8c.Ica35125ed640aa3aa1ecc38fb5e8f1600caa8df6@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-10-01 22:02:23 +03:00
Mordechay Goodstein 0cd1ad2d7f iwlwifi: move all bus-independent TX functions to common code
After moving out all Tx fields not related to pcie-bus
it's time to move the code to a common place.

We also rename all pcie functions name to txq.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200930161256.3947a5276003.I3fe1bec2b25a965a49532df288f47b8b59eb1500@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-10-01 22:00:57 +03:00
Mordechay Goodstein 22852fad9c iwl-trans: move dev_cmd_offs, page_offs to a common trans header
dev_cmd_offs, page_offs field is not directly related to the PCIe
transport, so move the structures it uses to the common iwl-trans.h header.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200926002540.83b41765961f.Icd12bfb2a736ccf4cbe080973c746fb70a3c4a50@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-10-01 21:57:22 +03:00
Mordechay Goodstein 8e3b79f887 iwlwifi: move bc_table_dword to a common trans header
The bc_table_dword code is not directly related to the PCIe transport,
so move the structures it uses to the common iwl-trans.h header.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200924162105.1e3027abd0b5.Ie9f672983796586671a4374bf6dcda846875b690@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-10-01 21:56:47 +03:00
Mordechay Goodstein 885375d0bb iwlwifi: iwl-trans: move tfd to trans layer
The tfd_* code is not directly related to the PCIe transport,
so move the structures it uses to the common iwl-trans.h header.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200924162105.a1a2ce2bce38.Ieada0fe087ebcc9bc84e22fc5abc9dba8914dd9f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-10-01 21:56:47 +03:00
Mordechay Goodstein a26014e2de iwlwifi: move bc_pool to a common trans header
The bc_pool code is not directly related to the PCIe transport,
so move the structures it uses to the common iwl-trans.h header.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200924162105.f6469c62665d.Id920f1ae8f70886b66a98956a6412726d29a9481@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-10-01 21:56:46 +03:00
Mordechay Goodstein 4f4822b7cd iwlwifi: move txq-specific from trans_pcie to common trans
We don't want to have txq code in the PCIe transport code, so move all
the relevant elements to a new iwl_txq structure and store it in
iwl_trans.

spatch

@ replace_pcie @
struct iwl_trans_pcie *trans_pcie;
@@

(
-trans_pcie->queue_stopped
+trans->txqs.queue_stopped
|
-trans_pcie->queue_used
+trans->txqs.queue_used
|
-trans_pcie->txq
+trans->txqs.txq
|
-trans_pcie->txq
+trans->txqs.txq
|
-trans_pcie->cmd_queue
+trans->txqs.cmd.q_id
|
-trans_pcie->cmd_fifo
+trans->txqs.cmd.fifo
|
-trans_pcie->cmd_q_wdg_timeout
+trans->txqs.cmd.wdg_timeout
)

// clean all new unused variables
@ depends on replace_pcie @
type T;
identifier i;
expression E;
@@
- T i = E;
 ... when != i

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200529092401.a428d3c9d66f.Ie04ae55f33954636a39c98e7ae1e739c0507435b@changeid
2020-05-29 10:32:30 +03:00
Mordechay Goodstein 4807e73685 iwlwifi: move iwl_txq and substructures to a common trans header
The txq code is not directly related to the PCIe transport, so move the
structures it uses to the common iwl-trans.h header.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200529092401.d9d0082b8369.I8298f6e83804c1ea99217a79d95d23ef68b184d4@changeid
2020-05-29 10:32:26 +03:00
Mordechay Goodstein fcac70029c iwlwifi: pcie: keep trans instead of trans_pcie in iwl_txq
We used both the trans and the trans_pcie structures in
iwl_txq, so we can keep the trans structure instead.  This
helps with the refactoring of txq code out of pcie.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200529092401.1f826d34339e.I23182a59bfbe089a1f659742d6fee6f64d2ed08c@changeid
2020-05-29 10:32:10 +03:00
Johannes Berg b1c860f6ec iwlwifi: pcie: skip fragmented receive buffers
We don't really expect fragmented RBs, and don't seem to be seeing
them in practice since that would've caused a crash. Nevertheless,
we should be expecting the hardware to send them.

Parse the flag indicating a fragmented buffer, but then discard it
and any fragments thereof, at least for now. We need to do more
work in the higher layers to properly deal with this, since we may
not get "normal" firmware notifications that are fragmented, only
RX, and then we need to put it back together and add the necessary
API to report a chain of things to the higher layers, this doesn't
fit into the struct iwl_rx_cmd_buffer today.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200425130140.e78a59f70b1d.Ica656a98a4e4220d73edc97600edd680cbc97241@changeid
2020-05-08 09:53:09 +03:00
Johannes Berg c239feec50 iwlwifi: pcie: gen2: use DMA pool for byte-count tables
Since the recent patch in this area, we no longer allocate 64k
for a single queue, but only 1k, which still means a full page.
Use a DMA pool to reduce this further, since we will have a lot
of queues in a typical system that can share pages.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200425130140.6e84c79aea30.Ie9a417132812d110ec1cc87852f101477c01cfcb@changeid
2020-05-08 09:52:53 +03:00
Johannes Berg 63417549fc iwlwifi: pcie: move iwl_pcie_ctxt_info_alloc_dma() to user
There's no need for this to be an inline in the header file,
only the context-info.c file ever uses it. Move it there.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200418110539.818a06457888.Ib4f55280cd14d7edab37f2992b381c9b6ca4cd7a@changeid
2020-04-24 16:38:10 +03:00
Johannes Berg 7216dc99b7 iwlwifi: pcie: make iwl_pcie_cmdq_reclaim static
There's no need for this to be exposed outside of the tx.c
file, make it static.

Change-Id: I41d40008311b108d0578bd2ec73c5477e700a839
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-03-27 08:12:53 +02:00