linux/drivers/net/wireless/intel/iwlwifi/fw/runtime.h
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * This file is provided under a dual BSD/GPLv2 license.  When using or
   4 * redistributing this file, you may do so under either license.
   5 *
   6 * GPL LICENSE SUMMARY
   7 *
   8 * Copyright(c) 2017 Intel Deutschland GmbH
   9 * Copyright (C) 2018-2019 Intel Corporation
  10 *
  11 * This program is free software; you can redistribute it and/or modify
  12 * it under the terms of version 2 of the GNU General Public License as
  13 * published by the Free Software Foundation.
  14 *
  15 * This program is distributed in the hope that it will be useful, but
  16 * WITHOUT ANY WARRANTY; without even the implied warranty of
  17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18 * General Public License for more details.
  19 *
  20 * The full GNU General Public License is included in this distribution
  21 * in the file called COPYING.
  22 *
  23 * Contact Information:
  24 *  Intel Linux Wireless <linuxwifi@intel.com>
  25 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  26 *
  27 * BSD LICENSE
  28 *
  29 * Copyright(c) 2017 Intel Deutschland GmbH
  30 * Copyright (C) 2018-2019 Intel Corporation
  31 * All rights reserved.
  32 *
  33 * Redistribution and use in source and binary forms, with or without
  34 * modification, are permitted provided that the following conditions
  35 * are met:
  36 *
  37 *  * Redistributions of source code must retain the above copyright
  38 *    notice, this list of conditions and the following disclaimer.
  39 *  * Redistributions in binary form must reproduce the above copyright
  40 *    notice, this list of conditions and the following disclaimer in
  41 *    the documentation and/or other materials provided with the
  42 *    distribution.
  43 *  * Neither the name Intel Corporation nor the names of its
  44 *    contributors may be used to endorse or promote products derived
  45 *    from this software without specific prior written permission.
  46 *
  47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  51 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  58 *
  59 *****************************************************************************/
  60#ifndef __iwl_fw_runtime_h__
  61#define __iwl_fw_runtime_h__
  62
  63#include "iwl-config.h"
  64#include "iwl-trans.h"
  65#include "img.h"
  66#include "fw/api/debug.h"
  67#include "fw/api/dbg-tlv.h"
  68#include "fw/api/paging.h"
  69#include "iwl-eeprom-parse.h"
  70
  71struct iwl_fw_runtime_ops {
  72        int (*dump_start)(void *ctx);
  73        void (*dump_end)(void *ctx);
  74        bool (*fw_running)(void *ctx);
  75        int (*send_hcmd)(void *ctx, struct iwl_host_cmd *host_cmd);
  76        bool (*d3_debug_enable)(void *ctx);
  77};
  78
  79#define MAX_NUM_LMAC 2
  80struct iwl_fwrt_shared_mem_cfg {
  81        int num_lmacs;
  82        int num_txfifo_entries;
  83        struct {
  84                u32 txfifo_size[TX_FIFO_MAX_NUM];
  85                u32 rxfifo1_size;
  86        } lmac[MAX_NUM_LMAC];
  87        u32 rxfifo2_size;
  88        u32 internal_txfifo_addr;
  89        u32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
  90};
  91
  92#define IWL_FW_RUNTIME_DUMP_WK_NUM 5
  93
  94/**
  95 * struct iwl_fw_runtime - runtime data for firmware
  96 * @fw: firmware image
  97 * @cfg: NIC configuration
  98 * @dev: device pointer
  99 * @ops: user ops
 100 * @ops_ctx: user ops context
 101 * @fw_paging_db: paging database
 102 * @num_of_paging_blk: number of paging blocks
 103 * @num_of_pages_in_last_blk: number of pages in the last block
 104 * @smem_cfg: saved firmware SMEM configuration
 105 * @cur_fw_img: current firmware image, must be maintained by
 106 *      the driver by calling &iwl_fw_set_current_image()
 107 * @dump: debug dump data
 108 */
 109struct iwl_fw_runtime {
 110        struct iwl_trans *trans;
 111        const struct iwl_fw *fw;
 112        struct device *dev;
 113
 114        const struct iwl_fw_runtime_ops *ops;
 115        void *ops_ctx;
 116
 117        /* Paging */
 118        struct iwl_fw_paging fw_paging_db[NUM_OF_FW_PAGING_BLOCKS];
 119        u16 num_of_paging_blk;
 120        u16 num_of_pages_in_last_blk;
 121
 122        enum iwl_ucode_type cur_fw_img;
 123
 124        /* memory configuration */
 125        struct iwl_fwrt_shared_mem_cfg smem_cfg;
 126
 127        /* debug */
 128        struct {
 129                const struct iwl_fw_dump_desc *desc;
 130                bool monitor_only;
 131                struct {
 132                        u8 idx;
 133                        enum iwl_fw_ini_trigger_id ini_trig_id;
 134                        struct delayed_work wk;
 135                } wks[IWL_FW_RUNTIME_DUMP_WK_NUM];
 136                unsigned long active_wks;
 137
 138                u8 conf;
 139
 140                /* ts of the beginning of a non-collect fw dbg data period */
 141                unsigned long non_collect_ts_start[IWL_FW_TRIGGER_ID_NUM];
 142                u32 *d3_debug_data;
 143                struct iwl_fw_ini_region_cfg *active_regs[IWL_FW_INI_MAX_REGION_ID];
 144                struct iwl_fw_ini_active_triggers active_trigs[IWL_FW_TRIGGER_ID_NUM];
 145                u32 lmac_err_id[MAX_NUM_LMAC];
 146                u32 umac_err_id;
 147                void *fifo_iter;
 148                struct timer_list periodic_trig;
 149
 150                u8 img_name[IWL_FW_INI_MAX_IMG_NAME_LEN];
 151                u8 internal_dbg_cfg_name[IWL_FW_INI_MAX_DBG_CFG_NAME_LEN];
 152                u8 external_dbg_cfg_name[IWL_FW_INI_MAX_DBG_CFG_NAME_LEN];
 153
 154                struct {
 155                        u8 type;
 156                        u8 subtype;
 157                        u32 lmac_major;
 158                        u32 lmac_minor;
 159                        u32 umac_major;
 160                        u32 umac_minor;
 161                } fw_ver;
 162        } dump;
 163#ifdef CONFIG_IWLWIFI_DEBUGFS
 164        struct {
 165                struct delayed_work wk;
 166                u32 delay;
 167                u64 seq;
 168        } timestamp;
 169#endif /* CONFIG_IWLWIFI_DEBUGFS */
 170};
 171
 172void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans,
 173                        const struct iwl_fw *fw,
 174                        const struct iwl_fw_runtime_ops *ops, void *ops_ctx,
 175                        struct dentry *dbgfs_dir);
 176
 177static inline void iwl_fw_runtime_free(struct iwl_fw_runtime *fwrt)
 178{
 179        int i;
 180
 181        kfree(fwrt->dump.d3_debug_data);
 182        fwrt->dump.d3_debug_data = NULL;
 183
 184        for (i = 0; i < IWL_FW_TRIGGER_ID_NUM; i++) {
 185                struct iwl_fw_ini_active_triggers *active =
 186                        &fwrt->dump.active_trigs[i];
 187
 188                active->active = false;
 189                active->size = 0;
 190                kfree(active->trig);
 191                active->trig = NULL;
 192        }
 193}
 194
 195void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt);
 196
 197void iwl_fw_runtime_resume(struct iwl_fw_runtime *fwrt);
 198
 199static inline void iwl_fw_set_current_image(struct iwl_fw_runtime *fwrt,
 200                                            enum iwl_ucode_type cur_fw_img)
 201{
 202        fwrt->cur_fw_img = cur_fw_img;
 203}
 204
 205int iwl_init_paging(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type type);
 206void iwl_free_fw_paging(struct iwl_fw_runtime *fwrt);
 207
 208void iwl_get_shared_mem_conf(struct iwl_fw_runtime *fwrt);
 209
 210#endif /* __iwl_fw_runtime_h__ */
 211