linux/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h

/*
 * Copyright (c) 2010 Broadcom Corporation
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef _BRCM_MAIN_H_
#define _BRCM_MAIN_H_

#include <linux/etherdevice.h>

#include <brcmu_utils.h>
#include "types.h"
#include "d11.h"
#include "scb.h"

#define INVCHANNEL

/* max # brcms_c_module_register() calls */
#define BRCMS_MAXMODULES

#define SEQNUM_SHIFT
#define SEQNUM_MAX

#define NTXRATE

/* Maximum wait time for a MAC suspend */
/* uS: 83mS is max packet time (64KB ampdu @ 6Mbps) */
#define BRCMS_MAX_MAC_SUSPEND

/* responses for probe requests older that this are tossed, zero to disable */
#define BRCMS_PRB_RESP_TIMEOUT

/* transmit buffer max headroom for protocol headers */
#define TXOFF

/* Macros for doing definition and get/set of bitfields
 * Usage example, e.g. a three-bit field (bits 4-6):
 *    #define <NAME>_M	BITFIELD_MASK(3)
 *    #define <NAME>_S	4
 * ...
 *    regval = R_REG(osh, &regs->regfoo);
 *    field = GFIELD(regval, <NAME>);
 *    regval = SFIELD(regval, <NAME>, 1);
 *    W_REG(osh, &regs->regfoo, regval);
 */
#define BITFIELD_MASK(width)
#define GFIELD(val, field)
#define SFIELD(val, field, bits)

#define SW_TIMER_MAC_STAT_UPD

/* max # supported core revisions (0 .. MAXCOREREV - 1) */
#define MAXCOREREV

/* Double check that unsupported cores are not enabled */
#if CONF_MSK(D11CONF, 0x4f) || CONF_GE(D11CONF, MAXCOREREV)
#error "Configuration for D11CONF includes unsupported versions."
#endif				/* Bad versions */

/* values for shortslot_override */
#define BRCMS_SHORTSLOT_AUTO
#define BRCMS_SHORTSLOT_OFF
#define BRCMS_SHORTSLOT_ON

/* value for short/long and mixmode/greenfield preamble */
#define BRCMS_LONG_PREAMBLE
#define BRCMS_SHORT_PREAMBLE
#define BRCMS_GF_PREAMBLE
#define BRCMS_MM_PREAMBLE
#define BRCMS_IS_MIMO_PREAMBLE(_pre)

/* TxFrameID */
/* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */
/* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */
#define TXFID_QUEUE_MASK
#define TXFID_SEQ_MASK
#define TXFID_SEQ_SHIFT
#define TXFID_RATE_PROBE_MASK
#define TXFID_RATE_MASK
#define TXFID_RATE_SHIFT

/* promote boardrev */
#define BOARDREV_PROMOTABLE
#define BOARDREV_PROMOTED

#define DATA_BLOCK_TX_SUPR

/* Ucode MCTL_WAKE override bits */
#define BRCMS_WAKE_OVERRIDE_CLKCTL
#define BRCMS_WAKE_OVERRIDE_PHYREG
#define BRCMS_WAKE_OVERRIDE_MACSUSPEND
#define BRCMS_WAKE_OVERRIDE_TXFIFO
#define BRCMS_WAKE_OVERRIDE_FORCEFAST

/* stuff pulled in from wlc.c */

/* Interrupt bit error summary.  Don't include I_RU: we refill DMA at other
 * times; and if we run out, constant I_RU interrupts may cause lockup.  We
 * will still get error counts from rx0ovfl.
 */
#define I_ERRORS
/* default software intmasks */
#define DEF_RXINTMASK
#define DEF_MACINTMASK

#define MAXTXPKTS

/* frameburst */
#define MAXTXFRAMEBURST
#define MAXFRAMEBURST_TXOP

#define NFIFO

/* PLL requests */

/* pll is shared on old chips */
#define BRCMS_PLLREQ_SHARED
/* hold pll for radio monitor register checking */
#define BRCMS_PLLREQ_RADIO_MON
/* hold/release pll for some short operation */
#define BRCMS_PLLREQ_FLIP

#define CHANNEL_BANDUNIT(wlc, ch)

#define OTHERBANDUNIT(wlc)

/*
 * 802.11 protection information
 *
 * _g: use g spec protection, driver internal.
 * g_override: override for use of g spec protection.
 * gmode_user: user config gmode, operating band->gmode is different.
 * overlap: Overlap BSS/IBSS protection for both 11g and 11n.
 * nmode_user: user config nmode, operating pub->nmode is different.
 * n_cfg: use OFDM protection on MIMO frames.
 * n_cfg_override: override for use of N protection.
 * nongf: non-GF present protection.
 * nongf_override: override for use of GF protection.
 * n_pam_override: override for preamble: MM or GF.
 * n_obss: indicated OBSS Non-HT STA present.
*/
struct brcms_protection {};

/*
 * anything affecting the single/dual streams/antenna operation
 *
 * hw_txchain: HW txchain bitmap cfg.
 * txchain: txchain bitmap being used.
 * txstreams: number of txchains being used.
 * hw_rxchain: HW rxchain bitmap cfg.
 * rxchain: rxchain bitmap being used.
 * rxstreams: number of rxchains being used.
 * ant_rx_ovr: rx antenna override.
 * txant: userTx antenna setting.
 * phytxant: phyTx antenna setting in txheader.
 * ss_opmode: singlestream Operational mode, 0:siso; 1:cdd.
 * ss_algosel_auto: if true, use wlc->stf->ss_algo_channel;
 *			else use wlc->band->stf->ss_mode_band.
 * ss_algo_channel: ss based on per-channel algo: 0: SISO, 1: CDD 2: STBC.
 * rxchain_restore_delay: delay time to restore default rxchain.
 * ldpc: AUTO/ON/OFF ldpc cap supported.
 * txcore[MAX_STREAMS_SUPPORTED + 1]: bitmap of selected core for each Nsts.
 * spatial_policy:
 */
struct brcms_stf {};

#define BRCMS_STF_SS_STBC_TX(wlc, scb)

#define BRCMS_STBC_CAP_PHY(wlc)

#define BRCMS_SGI_CAP_PHY(wlc)

#define BRCMS_CHAN_PHYTYPE(x)
#define BRCMS_CHAN_CHANNEL(x)

/*
 * core state (mac)
 */
struct brcms_core {};

/*
 * band state (phy+ana+radio)
 */
struct brcms_band {};

/* module control blocks */
struct modulecb {};

struct brcms_hw_band {};

struct brcms_hardware {};

/*
 * Principal common driver data structure.
 *
 * pub: pointer to driver public state.
 * wl: pointer to specific private state.
 * hw: HW related state.
 * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1.
 * fastpwrup_dly: time in us needed to bring up d11 fast clock.
 * macintstatus: bit channel between isr and dpc.
 * macintmask: sw runtime master macintmask value.
 * defmacintmask: default "on" macintmask value.
 * clk: core is out of reset and has clock.
 * core: pointer to active io core.
 * band: pointer to active per-band state.
 * corestate: per-core state (one per hw core).
 * bandstate: per-band state (one per phy/radio).
 * qvalid: DirFrmQValid and BcMcFrmQValid.
 * ampdu: ampdu module handler.
 * asi: antsel module handler.
 * cmi: channel manager module handler.
 * vendorid: PCI vendor id.
 * deviceid: PCI device id.
 * ucode_rev: microcode revision.
 * machwcap: MAC capabilities, BMAC shadow.
 * perm_etheraddr: original sprom local ethernet address.
 * bandlocked: disable auto multi-band switching.
 * bandinit_pending: track band init in auto band.
 * radio_monitor: radio timer is running.
 * going_down: down path intermediate variable.
 * wdtimer: timer for watchdog routine.
 * radio_timer: timer for hw radio button monitor routine.
 * monitor: monitor (MPDU sniffing) mode.
 * bcnmisc_monitor: bcns promisc mode override for monitor.
 * _rifs: enable per-packet rifs.
 * bcn_li_bcn: beacon listen interval in # beacons.
 * bcn_li_dtim: beacon listen interval in # dtims.
 * WDarmed: watchdog timer is armed.
 * WDlast: last time wlc_watchdog() was called.
 * edcf_txop[IEEE80211_NUM_ACS]: current txop for each ac.
 * wme_retries: per-AC retry limits.
 * bsscfg: set of BSS configurations, idx 0 is default and always valid.
 * cfg: the primary bsscfg (can be AP or STA).
 * modulecb:
 * mimoft: SIGN or 11N.
 * cck_40txbw: 11N, cck tx b/w override when in 40MHZ mode.
 * ofdm_40txbw: 11N, ofdm tx b/w override when in 40MHZ mode.
 * mimo_40txbw: 11N, mimo tx b/w override when in 40MHZ mode.
 * default_bss: configured BSS parameters.
 * mc_fid_counter: BC/MC FIFO frame ID counter.
 * country_default: saved country for leaving 802.11d auto-country mode.
 * autocountry_default: initial country for 802.11d auto-country mode.
 * prb_resp_timeout: do not send prb resp if request older
 *		     than this, 0 = disable.
 * home_chanspec: shared home chanspec.
 * chanspec: target operational channel.
 * usr_fragthresh: user configured fragmentation threshold.
 * fragthresh[NFIFO]: per-fifo fragmentation thresholds.
 * RTSThresh: 802.11 dot11RTSThreshold.
 * SRL: 802.11 dot11ShortRetryLimit.
 * LRL: 802.11 dot11LongRetryLimit.
 * SFBL: Short Frame Rate Fallback Limit.
 * LFBL: Long Frame Rate Fallback Limit.
 * shortslot: currently using 11g ShortSlot timing.
 * shortslot_override: 11g ShortSlot override.
 * include_legacy_erp: include Legacy ERP info elt ID 47 as well as g ID 42.
 * PLCPHdr_override: 802.11b Preamble Type override.
 * stf:
 * bcn_rspec: save bcn ratespec purpose.
 * tempsense_lasttime;
 * tx_duty_cycle_ofdm: maximum allowed duty cycle for OFDM.
 * tx_duty_cycle_cck: maximum allowed duty cycle for CCK.
 * wiphy:
 * pri_scb: primary Station Control Block
 */
struct brcms_c_info {};

/* antsel module specific state */
struct antsel_info {};

enum brcms_bss_type {};

/*
 * BSS configuration state
 *
 * wlc: wlc to which this bsscfg belongs to.
 * type: interface type
 * SSID_len: the length of SSID
 * SSID: SSID string
 *
 *
 * BSSID: BSSID (associated)
 * cur_etheraddr: h/w address
 * flags: BSSCFG flags; see below
 *
 * current_bss: BSS parms in ASSOCIATED state
 *
 *
 * ID: 'unique' ID of this bsscfg, assigned at bsscfg allocation
 */
struct brcms_bss_cfg {};

int brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p);
int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
			   uint *blocks);

int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags);
u16 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, uint mac_len);
u32 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
			       bool use_rspec, u16 mimo_ctlchbw);
u16 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
			       u32 rts_rate, u32 frame_rate,
			       u8 rts_preamble_type, u8 frame_preamble_type,
			       uint frame_len, bool ba);
void brcms_c_inval_dma_pkts(struct brcms_hardware *hw,
			    struct ieee80211_sta *sta, void (*dma_callback_fn));
void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend);
int brcms_c_set_nmode(struct brcms_c_info *wlc);
void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, u32 bcn_rate);
void brcms_b_antsel_type_set(struct brcms_hardware *wlc_hw, u8 antsel_type);
void brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec,
			  bool mute, struct txpwr_limits *txpwr);
void brcms_b_write_shm(struct brcms_hardware *wlc_hw, uint offset, u16 v);
u16 brcms_b_read_shm(struct brcms_hardware *wlc_hw, uint offset);
void brcms_b_mhf(struct brcms_hardware *wlc_hw, u8 idx, u16 mask, u16 val,
		 int bands);
void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags);
void brcms_b_mctrl(struct brcms_hardware *wlc_hw, u32 mask, u32 val);
void brcms_b_phy_reset(struct brcms_hardware *wlc_hw);
void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw);
void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw);
void brcms_c_ucode_wake_override_set(struct brcms_hardware *wlc_hw,
				     u32 override_bit);
void brcms_c_ucode_wake_override_clear(struct brcms_hardware *wlc_hw,
				       u32 override_bit);
void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset,
				int len, void *buf);
u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate);
void brcms_b_copyto_objmem(struct brcms_hardware *wlc_hw, uint offset,
			   const void *buf, int len, u32 sel);
void brcms_b_copyfrom_objmem(struct brcms_hardware *wlc_hw, uint offset,
			     void *buf, int len, u32 sel);
void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode);
u16 brcms_b_get_txant(struct brcms_hardware *wlc_hw);
void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk);
void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk);
void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on);
void brcms_b_txant_set(struct brcms_hardware *wlc_hw, u16 phytxant);
void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode);
void brcms_c_init_scb(struct scb *scb);

#endif				/* _BRCM_MAIN_H_ */