linux/drivers/net/wireless/intel/iwlegacy/3945.h

/* SPDX-License-Identifier: GPL-2.0-only */
/******************************************************************************
 *
 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
 *
 * Contact Information:
 *  Intel Linux Wireless <[email protected]>
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *
 *****************************************************************************/

#ifndef __il_3945_h__
#define __il_3945_h__

#include <linux/pci.h>		/* for struct pci_device_id */
#include <linux/kernel.h>
#include <net/ieee80211_radiotap.h>

/* Hardware specific file defines the PCI IDs table for that hardware module */
extern const struct pci_device_id il3945_hw_card_ids[];

#include "common.h"

extern const struct il_ops il3945_ops;

/* Highest firmware API version supported */
#define IL3945_UCODE_API_MAX

/* Lowest firmware API version supported */
#define IL3945_UCODE_API_MIN

#define IL3945_FW_PRE
#define _IL3945_MODULE_FIRMWARE(api)
#define IL3945_MODULE_FIRMWARE(api)

/* Default noise level to report when noise measurement is not available.
 *   This may be because we're:
 *   1)  Not associated (4965, no beacon stats being sent to driver)
 *   2)  Scanning (noise measurement does not apply to associated channel)
 *   3)  Receiving CCK (3945 delivers noise info only for OFDM frames)
 * Use default noise value of -127 ... this is below the range of measurable
 *   Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
 *   Also, -127 works better than 0 when averaging frames with/without
 *   noise info (e.g. averaging might be done in app); measured dBm values are
 *   always negative ... using a negative value as the default keeps all
 *   averages within an s8's (used in some apps) range of negative values. */
#define IL_NOISE_MEAS_NOT_AVAILABLE

/* Module parameters accessible from iwl-*.c */
extern struct il_mod_params il3945_mod_params;

struct il3945_rate_scale_data {};

struct il3945_rs_sta {};

/*
 * The common struct MUST be first because it is shared between
 * 3945 and 4965!
 */
struct il3945_sta_priv {};

enum il3945_antenna {};

/*
 * RTS threshold here is total size [2347] minus 4 FCS bytes
 * Per spec:
 *   a value of 0 means RTS on all data/management packets
 *   a value > max MSDU size means no RTS
 * else RTS for data/management frames where MPDU is larger
 *   than RTS value.
 */
#define DEFAULT_RTS_THRESHOLD
#define MIN_RTS_THRESHOLD
#define MAX_RTS_THRESHOLD
#define MAX_MSDU_SIZE
#define MAX_MPDU_SIZE
#define DEFAULT_BEACON_INTERVAL
#define DEFAULT_SHORT_RETRY_LIMIT
#define DEFAULT_LONG_RETRY_LIMIT

#define IL_TX_FIFO_AC0
#define IL_TX_FIFO_AC1
#define IL_TX_FIFO_AC2
#define IL_TX_FIFO_AC3
#define IL_TX_FIFO_HCCA_1
#define IL_TX_FIFO_HCCA_2
#define IL_TX_FIFO_NONE

#define IEEE80211_DATA_LEN
#define IEEE80211_4ADDR_LEN
#define IEEE80211_HLEN
#define IEEE80211_FRAME_LEN

struct il3945_frame {};

#define SUP_RATE_11A_MAX_NUM_CHANNELS
#define SUP_RATE_11B_MAX_NUM_CHANNELS
#define SUP_RATE_11G_MAX_NUM_CHANNELS

#define IL_SUPPORTED_RATES_IE_LEN

#define SCAN_INTERVAL

#define MAX_TID_COUNT

#define IL_INVALID_RATE
#define IL_INVALID_VALUE

#define STA_PS_STATUS_WAKE
#define STA_PS_STATUS_SLEEP

struct il3945_ibss_seq {};

#define IL_RX_HDR(x)
#define IL_RX_END(x)
#define IL_RX_STATS(x)
#define IL_RX_DATA(x)

/******************************************************************************
 *
 * Functions implemented in iwl3945-base.c which are forward declared here
 * for use by iwl-*.c
 *
 *****************************************************************************/
int il3945_calc_db_from_ratio(int sig_ratio);
void il3945_rx_replenish(void *data);
void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
unsigned int il3945_fill_beacon_frame(struct il_priv *il,
				      struct ieee80211_hdr *hdr, int left);
int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, char **buf,
			      bool display);
void il3945_dump_nic_error_log(struct il_priv *il);

/******************************************************************************
 *
 * Functions implemented in iwl-[34]*.c which are forward declared here
 * for use by iwl3945-base.c
 *
 * NOTE:  The implementation of these functions are hardware specific
 * which is why they are in the hardware specific files (vs. iwl-base.c)
 *
 * Naming convention --
 * il3945_         <-- Its part of iwlwifi (should be changed to il3945_)
 * il3945_hw_      <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
 * iwlXXXX_     <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
 * il3945_bg_      <-- Called from work queue context
 * il3945_mac_     <-- mac80211 callback
 *
 ****************************************************************************/
void il3945_hw_handler_setup(struct il_priv *il);
void il3945_hw_setup_deferred_work(struct il_priv *il);
void il3945_hw_cancel_deferred_work(struct il_priv *il);
int il3945_hw_rxq_stop(struct il_priv *il);
int il3945_hw_set_hw_params(struct il_priv *il);
int il3945_hw_nic_init(struct il_priv *il);
int il3945_hw_nic_stop_master(struct il_priv *il);
void il3945_hw_txq_ctx_free(struct il_priv *il);
void il3945_hw_txq_ctx_stop(struct il_priv *il);
int il3945_hw_nic_reset(struct il_priv *il);
int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
				    dma_addr_t addr, u16 len, u8 reset, u8 pad);
void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
int il3945_hw_get_temperature(struct il_priv *il);
int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il,
				      struct il3945_frame *frame, u8 rate);
void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd,
				 struct ieee80211_tx_info *info,
				 struct ieee80211_hdr *hdr, int sta_id);
int il3945_hw_reg_send_txpower(struct il_priv *il);
int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power);
void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb);
void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb);
void il3945_disable_events(struct il_priv *il);
int il4965_get_temperature(const struct il_priv *il);
void il3945_post_associate(struct il_priv *il);
void il3945_config_ap(struct il_priv *il);

int il3945_commit_rxon(struct il_priv *il);

/**
 * il3945_hw_find_station - Find station id for a given BSSID
 * @bssid: MAC address of station ID to find
 *
 * NOTE:  This should not be hardware specific but the code has
 * not yet been merged into a single common layer for managing the
 * station tables.
 */
u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid);

__le32 il3945_get_antenna_flags(const struct il_priv *il);
int il3945_init_hw_rate_table(struct il_priv *il);
void il3945_reg_txpower_periodic(struct il_priv *il);
int il3945_txpower_set_from_eeprom(struct il_priv *il);

int il3945_rs_next_rate(struct il_priv *il, int rate);

/* scanning */
int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
void il3945_post_scan(struct il_priv *il);

/* rates */
extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945];

/* RSSI to dBm */
#define IL39_RSSI_OFFSET

/*
 * EEPROM related constants, enums, and structures.
 */
#define EEPROM_SKU_CAP_OP_MODE_MRC

/*
 * Mapping of a Tx power level, at factory calibration temperature,
 *   to a radio/DSP gain table idx.
 * One for each of 5 "sample" power levels in each band.
 * v_det is measured at the factory, using the 3945's built-in power amplifier
 *   (PA) output voltage detector.  This same detector is used during Tx of
 *   long packets in normal operation to provide feedback as to proper output
 *   level.
 * Data copied from EEPROM.
 * DO NOT ALTER THIS STRUCTURE!!!
 */
struct il3945_eeprom_txpower_sample {} __packed;

/*
 * Mappings of Tx power levels -> nominal radio/DSP gain table idxes.
 * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
 * Tx power setup code interpolates between the 5 "sample" power levels
 *    to determine the nominal setup for a requested power level.
 * Data copied from EEPROM.
 * DO NOT ALTER THIS STRUCTURE!!!
 */
struct il3945_eeprom_txpower_group {} __packed;

/*
 * Temperature-based Tx-power compensation data, not band-specific.
 * These coefficients are use to modify a/b/c/d/e coeffs based on
 *   difference between current temperature and factory calib temperature.
 * Data copied from EEPROM.
 */
struct il3945_eeprom_temperature_corr {} __packed;

/*
 * EEPROM map
 */
struct il3945_eeprom {} __packed;

#define IL3945_EEPROM_IMG_SIZE

/* End of EEPROM */

#define PCI_CFG_REV_ID_BIT_BASIC_SKU
#define PCI_CFG_REV_ID_BIT_RTP

/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */
#define IL39_NUM_QUEUES
#define IL39_CMD_QUEUE_NUM

#define IL_DEFAULT_TX_RETRY

/*********************************************/

#define RFD_SIZE
#define NUM_TFD_CHUNKS

#define TFD_CTL_COUNT_SET(n)
#define TFD_CTL_COUNT_GET(ctl)
#define TFD_CTL_PAD_SET(n)
#define TFD_CTL_PAD_GET(ctl)

/* Sizes and addresses for instruction and data memory (SRAM) in
 * 3945's embedded processor.  Driver access is via HBUS_TARG_MEM_* regs. */
#define IL39_RTC_INST_LOWER_BOUND
#define IL39_RTC_INST_UPPER_BOUND

#define IL39_RTC_DATA_LOWER_BOUND
#define IL39_RTC_DATA_UPPER_BOUND

#define IL39_RTC_INST_SIZE
#define IL39_RTC_DATA_SIZE

#define IL39_MAX_INST_SIZE
#define IL39_MAX_DATA_SIZE

/* Size of uCode instruction memory in bootstrap state machine */
#define IL39_MAX_BSM_SIZE

static inline int
il3945_hw_valid_rtc_data_addr(u32 addr)
{}

/* Base physical address of il3945_shared is provided to FH39_TSSR_CBB_BASE
 * and &il3945_shared.rx_read_ptr[0] is provided to FH39_RCSR_RPTR_ADDR(0) */
struct il3945_shared {} __packed;

/************************************/
/* iwl3945 Flow Handler Definitions */
/************************************/

/**
 * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
 * Addresses are offsets from device's PCI hardware base address.
 */
#define FH39_MEM_LOWER_BOUND
#define FH39_MEM_UPPER_BOUND

#define FH39_CBCC_TBL
#define FH39_TFDB_TBL
#define FH39_RCSR_TBL
#define FH39_RSSR_TBL
#define FH39_TCSR_TBL
#define FH39_TSSR_TBL

/* TFDB (Transmit Frame Buffer Descriptor) */
#define FH39_TFDB(_ch, buf)
#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch)

/* CBCC channel is [0,2] */
#define FH39_CBCC(_ch)
#define FH39_CBCC_CTRL(_ch)
#define FH39_CBCC_BASE(_ch)

/* RCSR channel is [0,2] */
#define FH39_RCSR(_ch)
#define FH39_RCSR_CONFIG(_ch)
#define FH39_RCSR_RBD_BASE(_ch)
#define FH39_RCSR_WPTR(_ch)
#define FH39_RCSR_RPTR_ADDR(_ch)

#define FH39_RSCSR_CHNL0_WPTR

/* RSSR */
#define FH39_RSSR_CTRL
#define FH39_RSSR_STATUS

/* TCSR */
#define FH39_TCSR(_ch)
#define FH39_TCSR_CONFIG(_ch)
#define FH39_TCSR_CREDIT(_ch)
#define FH39_TCSR_BUFF_STTS(_ch)

/* TSSR */
#define FH39_TSSR_CBB_BASE
#define FH39_TSSR_MSG_CONFIG
#define FH39_TSSR_TX_STATUS

/* DBM */

#define FH39_SRVC_CHNL

#define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE
#define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH

#define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN

#define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE

#define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE

#define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128

#define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST

#define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH

#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF
#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER

#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL
#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL

#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD

#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT

#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE
#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE

#define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID

#define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR

#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON
#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON

#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B

#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON
#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON

#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH
#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH

#define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch)
#define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch)

#define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch)

#define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE

struct il3945_tfd_tb {} __packed;

struct il3945_tfd {} __packed;

#ifdef CONFIG_IWLEGACY_DEBUGFS
extern const struct il_debugfs_ops il3945_debugfs_ops;
#endif

#endif