linux/drivers/net/wireless/broadcom/b43legacy/main.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *
 *  Broadcom B43legacy wireless driver
 *
 *  Copyright (c) 2005 Martin Langer <[email protected]>
 *  Copyright (c) 2005-2008 Stefano Brivio <[email protected]>
 *  Copyright (c) 2005, 2006 Michael Buesch <[email protected]>
 *  Copyright (c) 2005 Danny van Dyk <[email protected]>
 *  Copyright (c) 2005 Andreas Jaggi <[email protected]>
 *  Copyright (c) 2007 Larry Finger <[email protected]>
 *
 *  Some parts of the code in this file are derived from the ipw2200
 *  driver  Copyright(c) 2003 - 2004 Intel Corporation.

 */

#include <linux/delay.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/if_arp.h>
#include <linux/etherdevice.h>
#include <linux/firmware.h>
#include <linux/workqueue.h>
#include <linux/sched/signal.h>
#include <linux/skbuff.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <net/dst.h>
#include <linux/unaligned.h>

#include "b43legacy.h"
#include "main.h"
#include "debugfs.h"
#include "phy.h"
#include "dma.h"
#include "pio.h"
#include "sysfs.h"
#include "xmit.h"
#include "radio.h"


MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_LICENSE();

MODULE_FIRMWARE();
MODULE_FIRMWARE();

#if defined(CONFIG_B43LEGACY_DMA) && defined(CONFIG_B43LEGACY_PIO)
static int modparam_pio;
module_param_named(pio, modparam_pio, int, 0444);
MODULE_PARM_DESC();
#elif defined(CONFIG_B43LEGACY_DMA)
#define modparam_pio
#elif defined(CONFIG_B43LEGACY_PIO)
#define modparam_pio
#endif

static int modparam_bad_frames_preempt;
module_param_named(bad_frames_preempt, modparam_bad_frames_preempt, int, 0444);
MODULE_PARM_DESC();

static char modparam_fwpostfix[16];
module_param_string();
MODULE_PARM_DESC();

/* The following table supports BCM4301, BCM4303 and BCM4306/2 devices. */
static const struct ssb_device_id b43legacy_ssb_tbl[] =;
MODULE_DEVICE_TABLE(ssb, b43legacy_ssb_tbl);


/* Channel and ratetables are shared for all devices.
 * They can't be const, because ieee80211 puts some precalculated
 * data in there. This data is the same for all devices, so we don't
 * get concurrency issues */
#define RATETAB_ENT(_rateid, _flags)
/*
 * NOTE: When changing this, sync with xmit.c's
 *	 b43legacy_plcp_get_bitrate_idx_* functions!
 */
static struct ieee80211_rate __b43legacy_ratetable[] =;
#define b43legacy_b_ratetable
#define b43legacy_b_ratetable_size
#define b43legacy_g_ratetable
#define b43legacy_g_ratetable_size

#define CHANTAB_ENT(_chanid, _freq)
static struct ieee80211_channel b43legacy_bg_chantable[] =;

static struct ieee80211_supported_band b43legacy_band_2GHz_BPHY =;

static struct ieee80211_supported_band b43legacy_band_2GHz_GPHY =;

static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev);
static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev);
static void b43legacy_wireless_core_stop(struct b43legacy_wldev *dev);
static int b43legacy_wireless_core_start(struct b43legacy_wldev *dev);


static int b43legacy_ratelimit(struct b43legacy_wl *wl)
{}

void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...)
{}

void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...)
{}

void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...)
{}

#if B43legacy_DEBUG
void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...)
{}
#endif /* DEBUG */

static void b43legacy_ram_write(struct b43legacy_wldev *dev, u16 offset,
				u32 val)
{}

static inline
void b43legacy_shm_control_word(struct b43legacy_wldev *dev,
				u16 routing, u16 offset)
{}

u32 b43legacy_shm_read32(struct b43legacy_wldev *dev,
		       u16 routing, u16 offset)
{}

u16 b43legacy_shm_read16(struct b43legacy_wldev *dev,
			   u16 routing, u16 offset)
{}

void b43legacy_shm_write32(struct b43legacy_wldev *dev,
			   u16 routing, u16 offset,
			   u32 value)
{}

void b43legacy_shm_write16(struct b43legacy_wldev *dev, u16 routing, u16 offset,
			   u16 value)
{}

/* Read HostFlags */
u32 b43legacy_hf_read(struct b43legacy_wldev *dev)
{}

/* Write HostFlags */
void b43legacy_hf_write(struct b43legacy_wldev *dev, u32 value)
{}

void b43legacy_tsf_read(struct b43legacy_wldev *dev, u64 *tsf)
{}

static void b43legacy_time_lock(struct b43legacy_wldev *dev)
{}

static void b43legacy_time_unlock(struct b43legacy_wldev *dev)
{}

static void b43legacy_tsf_write_locked(struct b43legacy_wldev *dev, u64 tsf)
{}

void b43legacy_tsf_write(struct b43legacy_wldev *dev, u64 tsf)
{}

static
void b43legacy_macfilter_set(struct b43legacy_wldev *dev,
			     u16 offset, const u8 *mac)
{}

static void b43legacy_write_mac_bssid_templates(struct b43legacy_wldev *dev)
{}

static void b43legacy_upload_card_macaddress(struct b43legacy_wldev *dev)
{}

static void b43legacy_set_slot_time(struct b43legacy_wldev *dev,
				    u16 slot_time)
{}

static void b43legacy_short_slot_timing_enable(struct b43legacy_wldev *dev)
{}

static void b43legacy_short_slot_timing_disable(struct b43legacy_wldev *dev)
{}

/* Synchronize IRQ top- and bottom-half.
 * IRQs must be masked before calling this.
 * This must not be called with the irq_lock held.
 */
static void b43legacy_synchronize_irq(struct b43legacy_wldev *dev)
{}

/* DummyTransmission function, as documented on
 * https://bcm-specs.sipsolutions.net/DummyTransmission
 */
void b43legacy_dummy_transmission(struct b43legacy_wldev *dev)
{}

/* Turn the Analog ON/OFF */
static void b43legacy_switch_analog(struct b43legacy_wldev *dev, int on)
{}

void b43legacy_wireless_core_reset(struct b43legacy_wldev *dev, u32 flags)
{}

static void handle_irq_transmit_status(struct b43legacy_wldev *dev)
{}

static void drain_txstatus_queue(struct b43legacy_wldev *dev)
{}

static u32 b43legacy_jssi_read(struct b43legacy_wldev *dev)
{}

static void b43legacy_jssi_write(struct b43legacy_wldev *dev, u32 jssi)
{}

static void b43legacy_generate_noise_sample(struct b43legacy_wldev *dev)
{}

static void b43legacy_calculate_link_quality(struct b43legacy_wldev *dev)
{}

static void handle_irq_noise(struct b43legacy_wldev *dev)
{}

static void handle_irq_tbtt_indication(struct b43legacy_wldev *dev)
{}

static void handle_irq_atim_end(struct b43legacy_wldev *dev)
{}

static void handle_irq_pmq(struct b43legacy_wldev *dev)
{}

static void b43legacy_write_template_common(struct b43legacy_wldev *dev,
					    const u8 *data, u16 size,
					    u16 ram_offset,
					    u16 shm_size_offset, u8 rate)
{}

/* Convert a b43legacy antenna number value to the PHY TX control value. */
static u16 b43legacy_antenna_to_phyctl(int antenna)
{}

static void b43legacy_write_beacon_template(struct b43legacy_wldev *dev,
					    u16 ram_offset,
					    u16 shm_size_offset)
{}

static void b43legacy_write_probe_resp_plcp(struct b43legacy_wldev *dev,
					    u16 shm_offset, u16 size,
					    struct ieee80211_rate *rate)
{}

/* Instead of using custom probe response template, this function
 * just patches custom beacon template by:
 * 1) Changing packet type
 * 2) Patching duration field
 * 3) Stripping TIM
 */
static const u8 *b43legacy_generate_probe_resp(struct b43legacy_wldev *dev,
					       u16 *dest_size,
					       struct ieee80211_rate *rate)
{}

static void b43legacy_write_probe_resp_template(struct b43legacy_wldev *dev,
						u16 ram_offset,
						u16 shm_size_offset,
						struct ieee80211_rate *rate)
{}

static void b43legacy_upload_beacon0(struct b43legacy_wldev *dev)
{}

static void b43legacy_upload_beacon1(struct b43legacy_wldev *dev)
{}

static void handle_irq_beacon(struct b43legacy_wldev *dev)
{}

static void b43legacy_beacon_update_trigger_work(struct work_struct *work)
{}

/* Asynchronously update the packet templates in template RAM.
 * Locking: Requires wl->irq_lock to be locked. */
static void b43legacy_update_templates(struct b43legacy_wl *wl)
{}

static void b43legacy_set_beacon_int(struct b43legacy_wldev *dev,
				     u16 beacon_int)
{}

static void handle_irq_ucode_debug(struct b43legacy_wldev *dev)
{}

/* Interrupt handler bottom-half */
static void b43legacy_interrupt_tasklet(struct tasklet_struct *t)
{}

static void pio_irq_workaround(struct b43legacy_wldev *dev,
			       u16 base, int queueidx)
{}

static void b43legacy_interrupt_ack(struct b43legacy_wldev *dev, u32 reason)
{}

/* Interrupt handler top-half */
static irqreturn_t b43legacy_interrupt_handler(int irq, void *dev_id)
{}

static void b43legacy_release_firmware(struct b43legacy_wldev *dev)
{}

static void b43legacy_print_fw_helptext(struct b43legacy_wl *wl)
{}

static void b43legacy_fw_cb(const struct firmware *firmware, void *context)
{}

static int do_request_fw(struct b43legacy_wldev *dev,
			 const char *name,
			 const struct firmware **fw, bool async)
{}

static int b43legacy_one_core_attach(struct ssb_device *dev,
				     struct b43legacy_wl *wl);
static void b43legacy_one_core_detach(struct ssb_device *dev);

static void b43legacy_request_firmware(struct work_struct *work)
{}

static int b43legacy_upload_microcode(struct b43legacy_wldev *dev)
{}

static int b43legacy_write_initvals(struct b43legacy_wldev *dev,
				    const struct b43legacy_iv *ivals,
				    size_t count,
				    size_t array_size)
{}

static int b43legacy_upload_initvals(struct b43legacy_wldev *dev)
{}

/* Initialize the GPIOs
 * https://bcm-specs.sipsolutions.net/GPIO
 */
static int b43legacy_gpio_init(struct b43legacy_wldev *dev)
{}

/* Turn off all GPIO stuff. Call this on module unload, for example. */
static void b43legacy_gpio_cleanup(struct b43legacy_wldev *dev)
{}

/* http://bcm-specs.sipsolutions.net/EnableMac */
void b43legacy_mac_enable(struct b43legacy_wldev *dev)
{}

/* https://bcm-specs.sipsolutions.net/SuspendMAC */
void b43legacy_mac_suspend(struct b43legacy_wldev *dev)
{}

static void b43legacy_adjust_opmode(struct b43legacy_wldev *dev)
{}

static void b43legacy_rate_memory_write(struct b43legacy_wldev *dev,
					u16 rate,
					int is_ofdm)
{}

static void b43legacy_rate_memory_init(struct b43legacy_wldev *dev)
{}

/* Set the TX-Antenna for management frames sent by firmware. */
static void b43legacy_mgmtframe_txantenna(struct b43legacy_wldev *dev,
					  int antenna)
{}

/* This is the opposite of b43legacy_chip_init() */
static void b43legacy_chip_exit(struct b43legacy_wldev *dev)
{}

/* Initialize the chip
 * https://bcm-specs.sipsolutions.net/ChipInit
 */
static int b43legacy_chip_init(struct b43legacy_wldev *dev)
{}

static void b43legacy_periodic_every120sec(struct b43legacy_wldev *dev)
{}

static void b43legacy_periodic_every60sec(struct b43legacy_wldev *dev)
{}

static void b43legacy_periodic_every30sec(struct b43legacy_wldev *dev)
{}

static void b43legacy_periodic_every15sec(struct b43legacy_wldev *dev)
{}

static void do_periodic_work(struct b43legacy_wldev *dev)
{}

/* Periodic work locking policy:
 * 	The whole periodic work handler is protected by
 * 	wl->mutex. If another lock is needed somewhere in the
 * 	pwork callchain, it's acquired in-place, where it's needed.
 */
static void b43legacy_periodic_work_handler(struct work_struct *work)
{}

static void b43legacy_periodic_tasks_setup(struct b43legacy_wldev *dev)
{}

/* Validate access to the chip (SHM) */
static int b43legacy_validate_chipaccess(struct b43legacy_wldev *dev)
{}

static void b43legacy_security_init(struct b43legacy_wldev *dev)
{}

#ifdef CONFIG_B43LEGACY_HWRNG
static int b43legacy_rng_read(struct hwrng *rng, u32 *data)
{}
#endif

static void b43legacy_rng_exit(struct b43legacy_wl *wl)
{}

static int b43legacy_rng_init(struct b43legacy_wl *wl)
{}

static void b43legacy_tx_work(struct work_struct *work)
{}

static void b43legacy_op_tx(struct ieee80211_hw *hw,
			    struct ieee80211_tx_control *control,
			    struct sk_buff *skb)
{}

static int b43legacy_op_conf_tx(struct ieee80211_hw *hw,
				struct ieee80211_vif *vif,
				unsigned int link_id, u16 queue,
				const struct ieee80211_tx_queue_params *params)
{}

static int b43legacy_op_get_stats(struct ieee80211_hw *hw,
				  struct ieee80211_low_level_stats *stats)
{}

static const char *phymode_to_string(unsigned int phymode)
{}

static int find_wldev_for_phymode(struct b43legacy_wl *wl,
				  unsigned int phymode,
				  struct b43legacy_wldev **dev,
				  bool *gmode)
{}

static void b43legacy_put_phy_into_reset(struct b43legacy_wldev *dev)
{}

/* Expects wl->mutex locked */
static int b43legacy_switch_phymode(struct b43legacy_wl *wl,
				      unsigned int new_mode)
{}

/* Write the short and long frame retry limit values. */
static void b43legacy_set_retry_limits(struct b43legacy_wldev *dev,
				       unsigned int short_retry,
				       unsigned int long_retry)
{}

static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
				   u32 changed)
{}

static void b43legacy_update_basic_rates(struct b43legacy_wldev *dev, u32 brates)
{}

static void b43legacy_op_bss_info_changed(struct ieee80211_hw *hw,
				    struct ieee80211_vif *vif,
				    struct ieee80211_bss_conf *conf,
				    u64 changed)
{}

static void b43legacy_op_configure_filter(struct ieee80211_hw *hw,
					  unsigned int changed,
					  unsigned int *fflags,u64 multicast)
{}

/* Locking: wl->mutex */
static void b43legacy_wireless_core_stop(struct b43legacy_wldev *dev)
{}

/* Locking: wl->mutex */
static int b43legacy_wireless_core_start(struct b43legacy_wldev *dev)
{}

/* Get PHY and RADIO versioning numbers */
static int b43legacy_phy_versioning(struct b43legacy_wldev *dev)
{}

static void setup_struct_phy_for_init(struct b43legacy_wldev *dev,
				      struct b43legacy_phy *phy)
{}

static void setup_struct_wldev_for_init(struct b43legacy_wldev *dev)
{}

static void b43legacy_set_synth_pu_delay(struct b43legacy_wldev *dev,
					  bool idle) {}

/* Set the TSF CFP pre-TargetBeaconTransmissionTime. */
static void b43legacy_set_pretbtt(struct b43legacy_wldev *dev)
{}

/* Shutdown a wireless core */
/* Locking: wl->mutex */
static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev)
{}

static void prepare_phy_data_for_init(struct b43legacy_wldev *dev)
{}

/* Initialize a wireless core */
static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev)
{}

static int b43legacy_op_add_interface(struct ieee80211_hw *hw,
				      struct ieee80211_vif *vif)
{}

static void b43legacy_op_remove_interface(struct ieee80211_hw *hw,
					  struct ieee80211_vif *vif)
{}

static int b43legacy_op_start(struct ieee80211_hw *hw)
{}

static void b43legacy_op_stop(struct ieee80211_hw *hw, bool suspend)
{}

static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw,
				       struct ieee80211_sta *sta, bool set)
{}

static int b43legacy_op_get_survey(struct ieee80211_hw *hw, int idx,
				   struct survey_info *survey)
{}

static const struct ieee80211_ops b43legacy_hw_ops =;

/* Hard-reset the chip. Do not call this directly.
 * Use b43legacy_controller_restart()
 */
static void b43legacy_chip_reset(struct work_struct *work)
{}

static int b43legacy_setup_modes(struct b43legacy_wldev *dev,
				 int have_bphy,
				 int have_gphy)
{}

static void b43legacy_wireless_core_detach(struct b43legacy_wldev *dev)
{}

static int b43legacy_wireless_core_attach(struct b43legacy_wldev *dev)
{}

static void b43legacy_one_core_detach(struct ssb_device *dev)
{}

static int b43legacy_one_core_attach(struct ssb_device *dev,
				     struct b43legacy_wl *wl)
{}

static void b43legacy_sprom_fixup(struct ssb_bus *bus)
{}

static void b43legacy_wireless_exit(struct ssb_device *dev,
				  struct b43legacy_wl *wl)
{}

static int b43legacy_wireless_init(struct ssb_device *dev)
{}

static int b43legacy_probe(struct ssb_device *dev,
			 const struct ssb_device_id *id)
{}

static void b43legacy_remove(struct ssb_device *dev)
{}

/* Perform a hardware reset. This can be called from any context. */
void b43legacy_controller_restart(struct b43legacy_wldev *dev,
				  const char *reason)
{}

#ifdef CONFIG_PM

static int b43legacy_suspend(struct ssb_device *dev, pm_message_t state)
{}

static int b43legacy_resume(struct ssb_device *dev)
{}

#else	/* CONFIG_PM */
#define b43legacy_suspend
#define b43legacy_resume
#endif	/* CONFIG_PM */

static struct ssb_driver b43legacy_ssb_driver =;

static void b43legacy_print_driverinfo(void)
{}

static int __init b43legacy_init(void)
{}

static void __exit b43legacy_exit(void)
{}

module_init()
module_exit()