linux/drivers/net/wireless/marvell/libertas/cmd.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * This file contains the handling of command.
 * It prepares command and sends it to firmware when it is ready.
 */

#include <linux/hardirq.h>
#include <linux/kfifo.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/if_arp.h>
#include <linux/export.h>

#include "decl.h"
#include "cfg.h"
#include "cmd.h"

#define CAL_NF(nf)
#define CAL_RSSI(snr, nf)

/**
 * lbs_cmd_copyback - Simple callback that copies response back into command
 *
 * @priv:	A pointer to &struct lbs_private structure
 * @extra:	A pointer to the original command structure for which
 *		'resp' is a response
 * @resp:	A pointer to the command response
 *
 * returns:	0 on success, error on failure
 */
int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
		     struct cmd_header *resp)
{}
EXPORT_SYMBOL_GPL();

/**
 *  lbs_cmd_async_callback - Simple callback that ignores the result.
 *  Use this if you just want to send a command to the hardware, but don't
 *  care for the result.
 *
 *  @priv:	ignored
 *  @extra:	ignored
 *  @resp:	ignored
 *
 *  returns:	0 for success
 */
static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra,
		     struct cmd_header *resp)
{}


/**
 *  is_command_allowed_in_ps - tests if a command is allowed in Power Save mode
 *
 *  @cmd:	the command ID
 *
 *  returns:	1 if allowed, 0 if not allowed
 */
static u8 is_command_allowed_in_ps(u16 cmd)
{}

/**
 *  lbs_update_hw_spec - Updates the hardware details like MAC address
 *  and regulatory region
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *
 *  returns:	0 on success, error on failure
 */
int lbs_update_hw_spec(struct lbs_private *priv)
{}

static int lbs_ret_host_sleep_cfg(struct lbs_private *priv, unsigned long dummy,
			struct cmd_header *resp)
{}

int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
		struct wol_config *p_wol_config)
{}
EXPORT_SYMBOL_GPL();

/**
 *  lbs_set_ps_mode - Sets the Power Save mode
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *  @cmd_action: The Power Save operation (PS_MODE_ACTION_ENTER_PS or
 *                         PS_MODE_ACTION_EXIT_PS)
 *  @block:	Whether to block on a response or not
 *
 *  returns:	0 on success, error on failure
 */
int lbs_set_ps_mode(struct lbs_private *priv, u16 cmd_action, bool block)
{}

int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action,
				struct sleep_params *sp)
{}

static int lbs_wait_for_ds_awake(struct lbs_private *priv)
{}

int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep)
{}

static int lbs_ret_host_sleep_activate(struct lbs_private *priv,
		unsigned long dummy,
		struct cmd_header *cmd)
{}

int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep)
{}

/**
 *  lbs_set_snmp_mib - Set an SNMP MIB value
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *  @oid:	The OID to set in the firmware
 *  @val:	Value to set the OID to
 *
 *  returns: 	   	0 on success, error on failure
 */
int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val)
{}

/**
 *  lbs_get_snmp_mib - Get an SNMP MIB value
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *  @oid:	The OID to retrieve from the firmware
 *  @out_val:	Location for the returned value
 *
 *  returns:	0 on success, error on failure
 */
int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val)
{}

/**
 *  lbs_get_tx_power - Get the min, max, and current TX power
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *  @curlevel:	Current power level in dBm
 *  @minlevel:	Minimum supported power level in dBm (optional)
 *  @maxlevel:	Maximum supported power level in dBm (optional)
 *
 *  returns:	0 on success, error on failure
 */
int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel,
		     s16 *maxlevel)
{}

/**
 *  lbs_set_tx_power - Set the TX power
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *  @dbm:	The desired power level in dBm
 *
 *  returns: 	   	0 on success, error on failure
 */
int lbs_set_tx_power(struct lbs_private *priv, s16 dbm)
{}

/**
 *  lbs_set_monitor_mode - Enable or disable monitor mode
 *  (only implemented on OLPC usb8388 FW)
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *  @enable:	1 to enable monitor mode, 0 to disable
 *
 *  returns:	0 on success, error on failure
 */
int lbs_set_monitor_mode(struct lbs_private *priv, int enable)
{}

/**
 *  lbs_get_channel - Get the radio channel
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *
 *  returns:	The channel on success, error on failure
 */
static int lbs_get_channel(struct lbs_private *priv)
{}

int lbs_update_channel(struct lbs_private *priv)
{}

/**
 *  lbs_set_channel - Set the radio channel
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *  @channel:	The desired channel, or 0 to clear a locked channel
 *
 *  returns:	0 on success, error on failure
 */
int lbs_set_channel(struct lbs_private *priv, u8 channel)
{}

/**
 * lbs_get_rssi - Get current RSSI and noise floor
 *
 * @priv:	A pointer to &struct lbs_private structure
 * @rssi:	On successful return, signal level in mBm
 * @nf:		On successful return, Noise floor
 *
 * returns:	The channel on success, error on failure
 */
int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf)
{}

/**
 *  lbs_set_11d_domain_info - Send regulatory and 802.11d domain information
 *  to the firmware
 *
 *  @priv:	pointer to &struct lbs_private
 *
 *  returns:	0 on success, error code on failure
*/
int lbs_set_11d_domain_info(struct lbs_private *priv)
{}

/**
 *  lbs_get_reg - Read a MAC, Baseband, or RF register
 *
 *  @priv:	pointer to &struct lbs_private
 *  @reg:	register command, one of CMD_MAC_REG_ACCESS,
 *		CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS
 *  @offset:	byte offset of the register to get
 *  @value:	on success, the value of the register at 'offset'
 *
 *  returns:	0 on success, error code on failure
*/
int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value)
{}

/**
 *  lbs_set_reg - Write a MAC, Baseband, or RF register
 *
 *  @priv:	pointer to &struct lbs_private
 *  @reg:	register command, one of CMD_MAC_REG_ACCESS,
 *		CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS
 *  @offset:	byte offset of the register to set
 *  @value:	the value to write to the register at 'offset'
 *
 *  returns:	0 on success, error code on failure
*/
int lbs_set_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 value)
{}

static void lbs_queue_cmd(struct lbs_private *priv,
			  struct cmd_ctrl_node *cmdnode)
{}

static void lbs_submit_command(struct lbs_private *priv,
			       struct cmd_ctrl_node *cmdnode)
{}

/*
 *  This function inserts command node to cmdfreeq
 *  after cleans it. Requires priv->driver_lock held.
 */
static void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
					 struct cmd_ctrl_node *cmdnode)
{}

static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
	struct cmd_ctrl_node *ptempcmd)
{}

void __lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
			    int result)
{}

void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
			  int result)
{}

int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on)
{}

void lbs_set_mac_control(struct lbs_private *priv)
{}

int lbs_set_mac_control_sync(struct lbs_private *priv)
{}

/**
 *  lbs_allocate_cmd_buffer - allocates the command buffer and links
 *  it to command free queue
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *
 *  returns:	0 for success or -1 on error
 */
int lbs_allocate_cmd_buffer(struct lbs_private *priv)
{}

/**
 *  lbs_free_cmd_buffer - free the command buffer
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *
 *  returns:	0 for success
 */
int lbs_free_cmd_buffer(struct lbs_private *priv)
{}

/**
 *  lbs_get_free_cmd_node - gets a free command node if available in
 *  command free queue
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *
 *  returns:	A pointer to &cmd_ctrl_node structure on success
 *		or %NULL on error
 */
static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv)
{}

/**
 *  lbs_execute_next_command - execute next command in command
 *  pending queue. Will put firmware back to PS mode if applicable.
 *
 *  @priv:	A pointer to &struct lbs_private structure
 *
 *  returns:	0 on success or -1 on error
 */
int lbs_execute_next_command(struct lbs_private *priv)
{}

static void lbs_send_confirmsleep(struct lbs_private *priv)
{}

/**
 * lbs_ps_confirm_sleep - checks condition and prepares to
 * send sleep confirm command to firmware if ok
 *
 * @priv:	A pointer to &struct lbs_private structure
 *
 * returns:	n/a
 */
void lbs_ps_confirm_sleep(struct lbs_private *priv)
{}


/**
 * lbs_set_tpc_cfg - Configures the transmission power control functionality
 *
 * @priv:	A pointer to &struct lbs_private structure
 * @enable:	Transmission power control enable
 * @p0:		Power level when link quality is good (dBm).
 * @p1:		Power level when link quality is fair (dBm).
 * @p2:		Power level when link quality is poor (dBm).
 * @usesnr:	Use Signal to Noise Ratio in TPC
 *
 * returns:	0 on success
 */
int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1,
		int8_t p2, int usesnr)
{}

/**
 * lbs_set_power_adapt_cfg - Configures the power adaptation settings
 *
 * @priv:	A pointer to &struct lbs_private structure
 * @enable:	Power adaptation enable
 * @p0:		Power level for 1, 2, 5.5 and 11 Mbps (dBm).
 * @p1:		Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm).
 * @p2:		Power level for 48 and 54 Mbps (dBm).
 *
 * returns:	0 on Success
 */

int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0,
		int8_t p1, int8_t p2)
{}


struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
	uint16_t command, struct cmd_header *in_cmd, int in_cmd_size,
	int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
	unsigned long callback_arg)
{}

void lbs_cmd_async(struct lbs_private *priv, uint16_t command,
	struct cmd_header *in_cmd, int in_cmd_size)
{}

int __lbs_cmd(struct lbs_private *priv, uint16_t command,
	      struct cmd_header *in_cmd, int in_cmd_size,
	      int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
	      unsigned long callback_arg)
{}
EXPORT_SYMBOL_GPL();