Path: blob/main/sys/contrib/dev/iwlwifi/iwl-trans.c
48253 views
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause1/*2* Copyright (C) 2015 Intel Mobile Communications GmbH3* Copyright (C) 2016-2017 Intel Deutschland GmbH4* Copyright (C) 2019-2021, 2023-2025 Intel Corporation5*/6#include <linux/kernel.h>7#include <linux/bsearch.h>8#include <linux/list.h>910#include "fw/api/tx.h"11#include "iwl-trans.h"12#include "iwl-drv.h"13#include "iwl-fh.h"14#include <linux/dmapool.h>15#include "fw/api/commands.h"16#include "pcie/gen1_2/internal.h"17#include "pcie/iwl-context-info-v2.h"1819struct iwl_trans_dev_restart_data {20struct list_head list;21unsigned int restart_count;22time64_t last_error;23bool backoff;24char name[];25};2627static LIST_HEAD(restart_data_list);28static DEFINE_SPINLOCK(restart_data_lock);2930static struct iwl_trans_dev_restart_data *31iwl_trans_get_restart_data(struct device *dev)32{33struct iwl_trans_dev_restart_data *tmp, *data = NULL;34const char *name = dev_name(dev);3536spin_lock(&restart_data_lock);37list_for_each_entry(tmp, &restart_data_list, list) {38if (strcmp(tmp->name, name))39continue;40data = tmp;41break;42}43spin_unlock(&restart_data_lock);4445if (data)46return data;4748data = kzalloc(struct_size(data, name, strlen(name) + 1), GFP_ATOMIC);49if (!data)50return NULL;5152strcpy(data->name, name);53spin_lock(&restart_data_lock);54list_add_tail(&data->list, &restart_data_list);55spin_unlock(&restart_data_lock);5657return data;58}5960static void iwl_trans_inc_restart_count(struct device *dev)61{62struct iwl_trans_dev_restart_data *data;6364data = iwl_trans_get_restart_data(dev);65if (data) {66data->last_error = ktime_get_boottime_seconds();67data->restart_count++;68}69}7071void iwl_trans_free_restart_list(void)72{73struct iwl_trans_dev_restart_data *tmp;7475while ((tmp = list_first_entry_or_null(&restart_data_list,76typeof(*tmp), list))) {77list_del(&tmp->list);78kfree(tmp);79}80}8182struct iwl_trans_reprobe {83struct device *dev;84struct delayed_work work;85};8687static void iwl_trans_reprobe_wk(struct work_struct *wk)88{89struct iwl_trans_reprobe *reprobe;9091reprobe = container_of(wk, typeof(*reprobe), work.work);9293if (device_reprobe(reprobe->dev))94dev_err(reprobe->dev, "reprobe failed!\n");95put_device(reprobe->dev);96kfree(reprobe);97module_put(THIS_MODULE);98}99100static void iwl_trans_schedule_reprobe(struct iwl_trans *trans,101unsigned int delay_ms)102{103struct iwl_trans_reprobe *reprobe;104105/*106* get a module reference to avoid doing this while unloading107* anyway and to avoid scheduling a work with code that's108* being removed.109*/110if (!try_module_get(THIS_MODULE)) {111IWL_ERR(trans, "Module is being unloaded - abort\n");112return;113}114115reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);116if (!reprobe) {117module_put(THIS_MODULE);118return;119}120reprobe->dev = get_device(trans->dev);121INIT_DELAYED_WORK(&reprobe->work, iwl_trans_reprobe_wk);122schedule_delayed_work(&reprobe->work, msecs_to_jiffies(delay_ms));123}124125#define IWL_TRANS_RESET_OK_TIME 7 /* seconds */126127static enum iwl_reset_mode128iwl_trans_determine_restart_mode(struct iwl_trans *trans)129{130struct iwl_trans_dev_restart_data *data;131enum iwl_reset_mode at_least = 0;132unsigned int index;133static const enum iwl_reset_mode escalation_list_old[] = {134IWL_RESET_MODE_SW_RESET,135IWL_RESET_MODE_REPROBE,136IWL_RESET_MODE_REPROBE,137IWL_RESET_MODE_FUNC_RESET,138IWL_RESET_MODE_PROD_RESET,139};140static const enum iwl_reset_mode escalation_list_sc[] = {141IWL_RESET_MODE_SW_RESET,142IWL_RESET_MODE_REPROBE,143IWL_RESET_MODE_REPROBE,144IWL_RESET_MODE_FUNC_RESET,145IWL_RESET_MODE_TOP_RESET,146IWL_RESET_MODE_PROD_RESET,147IWL_RESET_MODE_TOP_RESET,148IWL_RESET_MODE_PROD_RESET,149IWL_RESET_MODE_TOP_RESET,150IWL_RESET_MODE_PROD_RESET,151};152const enum iwl_reset_mode *escalation_list;153size_t escalation_list_size;154155/* used by TOP fatal error/TOP reset */156if (trans->restart.mode.type == IWL_ERR_TYPE_TOP_RESET_FAILED)157return IWL_RESET_MODE_PROD_RESET;158159if (trans->request_top_reset) {160trans->request_top_reset = 0;161if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_SC)162return IWL_RESET_MODE_TOP_RESET;163return IWL_RESET_MODE_PROD_RESET;164}165166if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_SC) {167escalation_list = escalation_list_sc;168escalation_list_size = ARRAY_SIZE(escalation_list_sc);169} else {170escalation_list = escalation_list_old;171escalation_list_size = ARRAY_SIZE(escalation_list_old);172}173174if (trans->restart.during_reset)175at_least = IWL_RESET_MODE_REPROBE;176177data = iwl_trans_get_restart_data(trans->dev);178if (!data)179return at_least;180181if (!data->backoff &&182ktime_get_boottime_seconds() - data->last_error >=183IWL_TRANS_RESET_OK_TIME)184data->restart_count = 0;185186index = data->restart_count;187if (index >= escalation_list_size) {188index = escalation_list_size - 1;189if (!data->backoff) {190data->backoff = true;191return IWL_RESET_MODE_BACKOFF;192}193data->backoff = false;194}195196return max(at_least, escalation_list[index]);197}198199#define IWL_TRANS_TOP_FOLLOWER_WAIT 180 /* ms */200201#define IWL_TRANS_RESET_DELAY (HZ * 60)202203static void iwl_trans_restart_wk(struct work_struct *wk)204{205struct iwl_trans *trans = container_of(wk, typeof(*trans),206restart.wk.work);207enum iwl_reset_mode mode;208209if (trans->restart.mode.type == IWL_ERR_TYPE_TOP_RESET_BY_BT) {210iwl_trans_schedule_reprobe(trans, IWL_TRANS_TOP_FOLLOWER_WAIT);211return;212}213214if (!trans->op_mode)215return;216217/* might have been scheduled before marked as dead, re-check */218if (test_bit(STATUS_TRANS_DEAD, &trans->status))219return;220221iwl_op_mode_dump_error(trans->op_mode, &trans->restart.mode);222223/*224* If the opmode stopped the device while we were trying to dump and225* reset, then we'll have done the dump already (synchronized by the226* opmode lock that it will acquire in iwl_op_mode_dump_error()) and227* managed that via trans->restart.mode.228* Additionally, make sure that in such a case we won't attempt to do229* any resets now, since it's no longer requested.230*/231if (!test_and_clear_bit(STATUS_RESET_PENDING, &trans->status))232return;233234if (!iwlwifi_mod_params.fw_restart)235return;236237mode = iwl_trans_determine_restart_mode(trans);238if (mode == IWL_RESET_MODE_BACKOFF) {239IWL_ERR(trans, "Too many device errors - delay next reset\n");240queue_delayed_work(system_unbound_wq, &trans->restart.wk,241IWL_TRANS_RESET_DELAY);242return;243}244245iwl_trans_inc_restart_count(trans->dev);246247switch (mode) {248case IWL_RESET_MODE_TOP_RESET:249trans->do_top_reset = 1;250IWL_ERR(trans, "Device error - TOP reset\n");251fallthrough;252case IWL_RESET_MODE_SW_RESET:253if (mode == IWL_RESET_MODE_SW_RESET)254IWL_ERR(trans, "Device error - SW reset\n");255iwl_trans_opmode_sw_reset(trans, trans->restart.mode.type);256break;257case IWL_RESET_MODE_REPROBE:258IWL_ERR(trans, "Device error - reprobe!\n");259260iwl_trans_schedule_reprobe(trans, 0);261break;262default:263iwl_trans_pcie_reset(trans, mode);264break;265}266}267268struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,269struct device *dev,270const struct iwl_mac_cfg *mac_cfg,271unsigned int txcmd_size,272unsigned int txcmd_align)273{274struct iwl_trans *trans;275#ifdef CONFIG_LOCKDEP276static struct lock_class_key __sync_cmd_key;277#endif278279trans = devm_kzalloc(dev, sizeof(*trans) + priv_size, GFP_KERNEL);280if (!trans)281return NULL;282283trans->mac_cfg = mac_cfg;284285#ifdef CONFIG_LOCKDEP286lockdep_init_map(&trans->sync_cmd_lockdep_map, "sync_cmd_lockdep_map",287&__sync_cmd_key, 0);288#endif289290trans->dev = dev;291292INIT_DELAYED_WORK(&trans->restart.wk, iwl_trans_restart_wk);293294snprintf(trans->dev_cmd_pool_name, sizeof(trans->dev_cmd_pool_name),295"iwl_cmd_pool:%s", dev_name(trans->dev));296trans->dev_cmd_pool =297kmem_cache_create(trans->dev_cmd_pool_name,298txcmd_size, txcmd_align,299SLAB_HWCACHE_ALIGN, NULL);300if (!trans->dev_cmd_pool)301return NULL;302303return trans;304}305306void iwl_trans_free(struct iwl_trans *trans)307{308cancel_delayed_work_sync(&trans->restart.wk);309kmem_cache_destroy(trans->dev_cmd_pool);310}311312int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd)313{314int ret;315316if (unlikely(!(cmd->flags & CMD_SEND_IN_RFKILL) &&317test_bit(STATUS_RFKILL_OPMODE, &trans->status)))318return -ERFKILL;319320if (unlikely(test_bit(STATUS_SUSPENDED, &trans->status)))321return -EHOSTDOWN;322323if (unlikely(test_bit(STATUS_FW_ERROR, &trans->status)))324return -EIO;325326if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,327"bad state = %d\n", trans->state))328return -EIO;329330if (!(cmd->flags & CMD_ASYNC))331lock_map_acquire_read(&trans->sync_cmd_lockdep_map);332333if (trans->conf.wide_cmd_header && !iwl_cmd_groupid(cmd->id)) {334if (cmd->id != REPLY_ERROR)335cmd->id = DEF_ID(cmd->id);336}337338ret = iwl_trans_pcie_send_hcmd(trans, cmd);339340if (!(cmd->flags & CMD_ASYNC))341lock_map_release(&trans->sync_cmd_lockdep_map);342343if (WARN_ON((cmd->flags & CMD_WANT_SKB) && !ret && !cmd->resp_pkt))344return -EIO;345346return ret;347}348IWL_EXPORT_SYMBOL(iwl_trans_send_cmd);349350/* Comparator for struct iwl_hcmd_names.351* Used in the binary search over a list of host commands.352*353* @key: command_id that we're looking for.354* @elt: struct iwl_hcmd_names candidate for match.355*356* @return 0 iff equal.357*/358static int iwl_hcmd_names_cmp(const void *key, const void *elt)359{360const struct iwl_hcmd_names *name = elt;361const u8 *cmd1 = key;362u8 cmd2 = name->cmd_id;363364return (*cmd1 - cmd2);365}366367const char *iwl_get_cmd_string(struct iwl_trans *trans, u32 id)368{369u8 grp, cmd;370struct iwl_hcmd_names *ret;371const struct iwl_hcmd_arr *arr;372size_t size = sizeof(struct iwl_hcmd_names);373374grp = iwl_cmd_groupid(id);375cmd = iwl_cmd_opcode(id);376377if (!trans->conf.command_groups ||378grp >= trans->conf.command_groups_size ||379!trans->conf.command_groups[grp].arr)380return "UNKNOWN";381382arr = &trans->conf.command_groups[grp];383ret = bsearch(&cmd, arr->arr, arr->size, size, iwl_hcmd_names_cmp);384if (!ret)385return "UNKNOWN";386return ret->cmd_name;387}388IWL_EXPORT_SYMBOL(iwl_get_cmd_string);389390void iwl_trans_op_mode_enter(struct iwl_trans *trans,391struct iwl_op_mode *op_mode)392{393trans->op_mode = op_mode;394395if (WARN_ON(trans->conf.n_no_reclaim_cmds > MAX_NO_RECLAIM_CMDS))396trans->conf.n_no_reclaim_cmds =397ARRAY_SIZE(trans->conf.no_reclaim_cmds);398399WARN_ON_ONCE(!trans->conf.rx_mpdu_cmd);400401iwl_trans_pcie_op_mode_enter(trans);402}403IWL_EXPORT_SYMBOL(iwl_trans_op_mode_enter);404405int iwl_trans_start_hw(struct iwl_trans *trans)406{407might_sleep();408409clear_bit(STATUS_TRANS_RESET_IN_PROGRESS, &trans->status);410/* opmode may not resume if it detects errors */411clear_bit(STATUS_SUSPENDED, &trans->status);412413return iwl_trans_pcie_start_hw(trans);414}415IWL_EXPORT_SYMBOL(iwl_trans_start_hw);416417void iwl_trans_op_mode_leave(struct iwl_trans *trans)418{419might_sleep();420421if (trans->mac_cfg->gen2)422iwl_trans_pcie_gen2_op_mode_leave(trans);423else424iwl_trans_pcie_op_mode_leave(trans);425426cancel_delayed_work_sync(&trans->restart.wk);427428trans->op_mode = NULL;429memset(&trans->conf, 0, sizeof(trans->conf));430431trans->state = IWL_TRANS_NO_FW;432}433IWL_EXPORT_SYMBOL(iwl_trans_op_mode_leave);434435void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val)436{437iwl_trans_pcie_write8(trans, ofs, val);438}439440void iwl_trans_write32(struct iwl_trans *trans, u32 ofs, u32 val)441{442iwl_trans_pcie_write32(trans, ofs, val);443}444445u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs)446{447return iwl_trans_pcie_read32(trans, ofs);448}449450u32 iwl_trans_read_prph(struct iwl_trans *trans, u32 ofs)451{452return iwl_trans_pcie_read_prph(trans, ofs);453}454455void iwl_trans_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)456{457return iwl_trans_pcie_write_prph(trans, ofs, val);458}459460int iwl_trans_read_mem(struct iwl_trans *trans, u32 addr,461void *buf, int dwords)462{463return iwl_trans_pcie_read_mem(trans, addr, buf, dwords);464}465IWL_EXPORT_SYMBOL(iwl_trans_read_mem);466467int iwl_trans_write_mem(struct iwl_trans *trans, u32 addr,468const void *buf, int dwords)469{470int offs, ret = 0;471const u32 *vals = buf;472473if (iwl_trans_grab_nic_access(trans)) {474iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr);475for (offs = 0; offs < dwords; offs++)476iwl_write32(trans, HBUS_TARG_MEM_WDAT,477vals ? vals[offs] : 0);478iwl_trans_release_nic_access(trans);479} else {480ret = -EBUSY;481}482return ret;483}484IWL_EXPORT_SYMBOL(iwl_trans_write_mem);485486void iwl_trans_set_pmi(struct iwl_trans *trans, bool state)487{488if (state)489set_bit(STATUS_TPOWER_PMI, &trans->status);490else491clear_bit(STATUS_TPOWER_PMI, &trans->status);492}493IWL_EXPORT_SYMBOL(iwl_trans_set_pmi);494495int iwl_trans_sw_reset(struct iwl_trans *trans)496{497return iwl_trans_pcie_sw_reset(trans, true);498}499500struct iwl_trans_dump_data *501iwl_trans_dump_data(struct iwl_trans *trans, u32 dump_mask,502const struct iwl_dump_sanitize_ops *sanitize_ops,503void *sanitize_ctx)504{505return iwl_trans_pcie_dump_data(trans, dump_mask,506sanitize_ops, sanitize_ctx);507}508509int iwl_trans_d3_suspend(struct iwl_trans *trans, bool test, bool reset)510{511int err;512513might_sleep();514515err = iwl_trans_pcie_d3_suspend(trans, test, reset);516517if (!err)518set_bit(STATUS_SUSPENDED, &trans->status);519520return err;521}522IWL_EXPORT_SYMBOL(iwl_trans_d3_suspend);523524int iwl_trans_d3_resume(struct iwl_trans *trans, enum iwl_d3_status *status,525bool test, bool reset)526{527int err;528529might_sleep();530531err = iwl_trans_pcie_d3_resume(trans, status, test, reset);532533clear_bit(STATUS_SUSPENDED, &trans->status);534535return err;536}537IWL_EXPORT_SYMBOL(iwl_trans_d3_resume);538539void iwl_trans_interrupts(struct iwl_trans *trans, bool enable)540{541iwl_trans_pci_interrupts(trans, enable);542}543544void iwl_trans_sync_nmi(struct iwl_trans *trans)545{546iwl_trans_pcie_sync_nmi(trans);547}548549int iwl_trans_write_imr_mem(struct iwl_trans *trans, u32 dst_addr,550u64 src_addr, u32 byte_cnt)551{552return iwl_trans_pcie_copy_imr(trans, dst_addr, src_addr, byte_cnt);553}554555void iwl_trans_set_bits_mask(struct iwl_trans *trans, u32 reg,556u32 mask, u32 value)557{558iwl_trans_pcie_set_bits_mask(trans, reg, mask, value);559}560IWL_EXPORT_SYMBOL(iwl_trans_set_bits_mask);561562int iwl_trans_read_config32(struct iwl_trans *trans, u32 ofs,563u32 *val)564{565return iwl_trans_pcie_read_config32(trans, ofs, val);566}567568bool _iwl_trans_grab_nic_access(struct iwl_trans *trans)569{570return iwl_trans_pcie_grab_nic_access(trans);571}572IWL_EXPORT_SYMBOL(_iwl_trans_grab_nic_access);573574void __releases(nic_access)575iwl_trans_release_nic_access(struct iwl_trans *trans)576{577iwl_trans_pcie_release_nic_access(trans);578}579IWL_EXPORT_SYMBOL(iwl_trans_release_nic_access);580581void iwl_trans_fw_alive(struct iwl_trans *trans)582{583might_sleep();584585trans->state = IWL_TRANS_FW_ALIVE;586587if (trans->mac_cfg->gen2)588iwl_trans_pcie_gen2_fw_alive(trans);589else590iwl_trans_pcie_fw_alive(trans);591}592IWL_EXPORT_SYMBOL(iwl_trans_fw_alive);593594int iwl_trans_start_fw(struct iwl_trans *trans, const struct iwl_fw *fw,595enum iwl_ucode_type ucode_type, bool run_in_rfkill)596{597const struct fw_img *img;598int ret;599600might_sleep();601602img = iwl_get_ucode_image(fw, ucode_type);603if (!img)604return -EINVAL;605606clear_bit(STATUS_FW_ERROR, &trans->status);607608if (trans->mac_cfg->gen2)609ret = iwl_trans_pcie_gen2_start_fw(trans, fw, img,610run_in_rfkill);611else612ret = iwl_trans_pcie_start_fw(trans, fw, img,613run_in_rfkill);614615if (ret == 0)616trans->state = IWL_TRANS_FW_STARTED;617618return ret;619}620IWL_EXPORT_SYMBOL(iwl_trans_start_fw);621622void iwl_trans_stop_device(struct iwl_trans *trans)623{624might_sleep();625626/*627* See also the comment in iwl_trans_restart_wk().628*629* When the opmode stops the device while a reset is pending, the630* worker (iwl_trans_restart_wk) might not have run yet or, more631* likely, will be blocked on the opmode lock. Due to the locking,632* we can't just flush the worker.633*634* If this is the case, then the test_and_clear_bit() ensures that635* the worker won't attempt to do anything after the stop.636*637* The trans->restart.mode is a handshake with the opmode, we set638* the context there to ABORT so that when the worker can finally639* acquire the lock in the opmode, the code there won't attempt to640* do any dumps. Since we'd really like to have the dump though,641* also do it inline here (with the opmode locks already held),642* but use a separate mode struct to avoid races.643*/644if (test_and_clear_bit(STATUS_RESET_PENDING, &trans->status)) {645struct iwl_fw_error_dump_mode mode;646647mode = trans->restart.mode;648mode.context = IWL_ERR_CONTEXT_FROM_OPMODE;649trans->restart.mode.context = IWL_ERR_CONTEXT_ABORT;650651iwl_op_mode_dump_error(trans->op_mode, &mode);652}653654if (trans->mac_cfg->gen2)655iwl_trans_pcie_gen2_stop_device(trans);656else657iwl_trans_pcie_stop_device(trans);658659trans->state = IWL_TRANS_NO_FW;660}661IWL_EXPORT_SYMBOL(iwl_trans_stop_device);662663int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb,664struct iwl_device_tx_cmd *dev_cmd, int queue)665{666if (unlikely(test_bit(STATUS_FW_ERROR, &trans->status)))667return -EIO;668669if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,670"bad state = %d\n", trans->state))671return -EIO;672673if (trans->mac_cfg->gen2)674return iwl_txq_gen2_tx(trans, skb, dev_cmd, queue);675676return iwl_trans_pcie_tx(trans, skb, dev_cmd, queue);677}678IWL_EXPORT_SYMBOL(iwl_trans_tx);679680void iwl_trans_reclaim(struct iwl_trans *trans, int queue, int ssn,681struct sk_buff_head *skbs, bool is_flush)682{683if (unlikely(test_bit(STATUS_FW_ERROR, &trans->status)))684return;685686if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,687"bad state = %d\n", trans->state))688return;689690iwl_pcie_reclaim(trans, queue, ssn, skbs, is_flush);691}692IWL_EXPORT_SYMBOL(iwl_trans_reclaim);693694void iwl_trans_txq_disable(struct iwl_trans *trans, int queue,695bool configure_scd)696{697iwl_trans_pcie_txq_disable(trans, queue, configure_scd);698}699IWL_EXPORT_SYMBOL(iwl_trans_txq_disable);700701bool iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int queue, u16 ssn,702const struct iwl_trans_txq_scd_cfg *cfg,703unsigned int queue_wdg_timeout)704{705might_sleep();706707if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,708"bad state = %d\n", trans->state))709return false;710711return iwl_trans_pcie_txq_enable(trans, queue, ssn,712cfg, queue_wdg_timeout);713}714IWL_EXPORT_SYMBOL(iwl_trans_txq_enable_cfg);715716int iwl_trans_wait_txq_empty(struct iwl_trans *trans, int queue)717{718if (unlikely(test_bit(STATUS_FW_ERROR, &trans->status)))719return -EIO;720721if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,722"bad state = %d\n", trans->state))723return -EIO;724725return iwl_trans_pcie_wait_txq_empty(trans, queue);726}727IWL_EXPORT_SYMBOL(iwl_trans_wait_txq_empty);728729int iwl_trans_wait_tx_queues_empty(struct iwl_trans *trans, u32 txqs)730{731if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,732"bad state = %d\n", trans->state))733return -EIO;734735return iwl_trans_pcie_wait_txqs_empty(trans, txqs);736}737IWL_EXPORT_SYMBOL(iwl_trans_wait_tx_queues_empty);738739void iwl_trans_freeze_txq_timer(struct iwl_trans *trans,740unsigned long txqs, bool freeze)741{742if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,743"bad state = %d\n", trans->state))744return;745746iwl_pcie_freeze_txq_timer(trans, txqs, freeze);747}748IWL_EXPORT_SYMBOL(iwl_trans_freeze_txq_timer);749750void iwl_trans_txq_set_shared_mode(struct iwl_trans *trans,751int txq_id, bool shared_mode)752{753iwl_trans_pcie_txq_set_shared_mode(trans, txq_id, shared_mode);754}755IWL_EXPORT_SYMBOL(iwl_trans_txq_set_shared_mode);756757#ifdef CONFIG_IWLWIFI_DEBUGFS758void iwl_trans_debugfs_cleanup(struct iwl_trans *trans)759{760iwl_trans_pcie_debugfs_cleanup(trans);761}762#endif763764void iwl_trans_set_q_ptrs(struct iwl_trans *trans, int queue, int ptr)765{766if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,767"bad state = %d\n", trans->state))768return;769770iwl_pcie_set_q_ptrs(trans, queue, ptr);771}772IWL_EXPORT_SYMBOL(iwl_trans_set_q_ptrs);773774int iwl_trans_txq_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask,775u8 tid, int size, unsigned int wdg_timeout)776{777might_sleep();778779if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,780"bad state = %d\n", trans->state))781return -EIO;782783return iwl_txq_dyn_alloc(trans, flags, sta_mask, tid,784size, wdg_timeout);785}786IWL_EXPORT_SYMBOL(iwl_trans_txq_alloc);787788void iwl_trans_txq_free(struct iwl_trans *trans, int queue)789{790iwl_txq_dyn_free(trans, queue);791}792IWL_EXPORT_SYMBOL(iwl_trans_txq_free);793794int iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue,795struct iwl_trans_rxq_dma_data *data)796{797return iwl_trans_pcie_rxq_dma_data(trans, queue, data);798}799800int iwl_trans_load_pnvm(struct iwl_trans *trans,801const struct iwl_pnvm_image *pnvm_data,802const struct iwl_ucode_capabilities *capa)803{804return iwl_trans_pcie_ctx_info_v2_load_pnvm(trans, pnvm_data, capa);805}806IWL_EXPORT_SYMBOL(iwl_trans_load_pnvm);807808void iwl_trans_set_pnvm(struct iwl_trans *trans,809const struct iwl_ucode_capabilities *capa)810{811iwl_trans_pcie_ctx_info_v2_set_pnvm(trans, capa);812}813814int iwl_trans_load_reduce_power(struct iwl_trans *trans,815const struct iwl_pnvm_image *payloads,816const struct iwl_ucode_capabilities *capa)817{818return iwl_trans_pcie_ctx_info_v2_load_reduce_power(trans, payloads,819capa);820}821822void iwl_trans_set_reduce_power(struct iwl_trans *trans,823const struct iwl_ucode_capabilities *capa)824{825iwl_trans_pcie_ctx_info_v2_set_reduce_power(trans, capa);826}827828829