linux/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c

// SPDX-License-Identifier: ISC
/*
 * Copyright (c) 2010 Broadcom Corporation
 */
#include <linux/types.h>
#include <linux/module.h>
#include <linux/if_ether.h>
#include <linux/spinlock.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/err.h>
#include <linux/jiffies.h>
#include <net/cfg80211.h>

#include <brcmu_utils.h>
#include <brcmu_wifi.h>
#include "core.h"
#include "debug.h"
#include "bus.h"
#include "fwil.h"
#include "fwil_types.h"
#include "fweh.h"
#include "fwsignal.h"
#include "p2p.h"
#include "cfg80211.h"
#include "proto.h"
#include "bcdc.h"
#include "common.h"

/**
 * DOC: Firmware Signalling
 *
 * Firmware can send signals to host and vice versa, which are passed in the
 * data packets using TLV based header. This signalling layer is on top of the
 * BDC bus protocol layer.
 */

/*
 * single definition for firmware-driver flow control tlv's.
 *
 * each tlv is specified by BRCMF_FWS_TLV_DEF(name, ID, length).
 * A length value 0 indicates variable length tlv.
 */
#define BRCMF_FWS_TLV_DEFLIST

/*
 * enum brcmf_fws_tlv_type - definition of tlv identifiers.
 */
#define BRCMF_FWS_TLV_DEF
enum brcmf_fws_tlv_type {};
#undef BRCMF_FWS_TLV_DEF

/*
 * enum brcmf_fws_tlv_len - definition of tlv lengths.
 */
#define BRCMF_FWS_TLV_DEF
enum brcmf_fws_tlv_len {};
#undef BRCMF_FWS_TLV_DEF

/* AMPDU rx reordering definitions */
#define BRCMF_RXREORDER_FLOWID_OFFSET
#define BRCMF_RXREORDER_MAXIDX_OFFSET
#define BRCMF_RXREORDER_FLAGS_OFFSET
#define BRCMF_RXREORDER_CURIDX_OFFSET
#define BRCMF_RXREORDER_EXPIDX_OFFSET

#define BRCMF_RXREORDER_DEL_FLOW
#define BRCMF_RXREORDER_FLUSH_ALL
#define BRCMF_RXREORDER_CURIDX_VALID
#define BRCMF_RXREORDER_EXPIDX_VALID
#define BRCMF_RXREORDER_NEW_HOLE

#ifdef DEBUG
/*
 * brcmf_fws_tlv_names - array of tlv names.
 */
#define BRCMF_FWS_TLV_DEF
static struct {} brcmf_fws_tlv_names[] =;
#undef BRCMF_FWS_TLV_DEF


static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id)
{}
#else
static const char *brcmf_fws_get_tlv_name(enum brcmf_fws_tlv_type id)
{
	return "NODEBUG";
}
#endif /* DEBUG */

/*
 * The PKTTAG tlv has additional bytes when firmware-signalling
 * mode has REUSESEQ flag set.
 */
#define BRCMF_FWS_TYPE_SEQ_LEN

/*
 * flags used to enable tlv signalling from firmware.
 */
#define BRCMF_FWS_FLAGS_RSSI_SIGNALS
#define BRCMF_FWS_FLAGS_XONXOFF_SIGNALS
#define BRCMF_FWS_FLAGS_CREDIT_STATUS_SIGNALS
#define BRCMF_FWS_FLAGS_HOST_PROPTXSTATUS_ACTIVE
#define BRCMF_FWS_FLAGS_PSQ_GENERATIONFSM_ENABLE
#define BRCMF_FWS_FLAGS_PSQ_ZERO_BUFFER_ENABLE
#define BRCMF_FWS_FLAGS_HOST_RXREORDER_ACTIVE

#define BRCMF_FWS_MAC_DESC_TABLE_SIZE
#define BRCMF_FWS_MAC_DESC_ID_INVALID

#define BRCMF_FWS_HOSTIF_FLOWSTATE_OFF
#define BRCMF_FWS_HOSTIF_FLOWSTATE_ON
#define BRCMF_FWS_FLOWCONTROL_HIWATER
#define BRCMF_FWS_FLOWCONTROL_LOWATER

#define BRCMF_FWS_PSQ_PREC_COUNT
#define BRCMF_FWS_PSQ_LEN

#define BRCMF_FWS_HTOD_FLAG_PKTFROMHOST
#define BRCMF_FWS_HTOD_FLAG_PKT_REQUESTED

#define BRCMF_FWS_RET_OK_NOSCHEDULE
#define BRCMF_FWS_RET_OK_SCHEDULE

#define BRCMF_FWS_MODE_REUSESEQ_SHIFT
#define BRCMF_FWS_MODE_SET_REUSESEQ(x, val)
#define BRCMF_FWS_MODE_GET_REUSESEQ(x)

/**
 * enum brcmf_fws_skb_state - indicates processing state of skb.
 *
 * @BRCMF_FWS_SKBSTATE_NEW: sk_buff is newly arrived in the driver.
 * @BRCMF_FWS_SKBSTATE_DELAYED: sk_buff had to wait on queue.
 * @BRCMF_FWS_SKBSTATE_SUPPRESSED: sk_buff has been suppressed by firmware.
 * @BRCMF_FWS_SKBSTATE_TIM: allocated for TIM update info.
 */
enum brcmf_fws_skb_state {};

/**
 * struct brcmf_skbuff_cb - control buffer associated with skbuff.
 *
 * @bus_flags: 2 bytes reserved for bus specific parameters
 * @if_flags: holds interface index and packet related flags.
 * @htod: host to device packet identifier (used in PKTTAG tlv).
 * @htod_seq: this 16-bit is original seq number for every suppress packet.
 * @state: transmit state of the packet.
 * @mac: descriptor related to destination for this packet.
 *
 * This information is stored in control buffer struct sk_buff::cb, which
 * provides 48 bytes of storage so this structure should not exceed that.
 */
struct brcmf_skbuff_cb {};

/*
 * macro casting skbuff control buffer to struct brcmf_skbuff_cb.
 */
#define brcmf_skbcb(skb)

/*
 * sk_buff control if flags
 *
 *	b[11]  - packet sent upon firmware request.
 *	b[10]  - packet only contains signalling data.
 *	b[9]   - packet is a tx packet.
 *	b[8]   - packet used requested credit
 *	b[7]   - interface in AP mode.
 *	b[3:0] - interface index.
 */
#define BRCMF_SKB_IF_FLAGS_REQUESTED_MASK
#define BRCMF_SKB_IF_FLAGS_REQUESTED_SHIFT
#define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_MASK
#define BRCMF_SKB_IF_FLAGS_SIGNAL_ONLY_SHIFT
#define BRCMF_SKB_IF_FLAGS_TRANSMIT_MASK
#define BRCMF_SKB_IF_FLAGS_TRANSMIT_SHIFT
#define BRCMF_SKB_IF_FLAGS_REQ_CREDIT_MASK
#define BRCMF_SKB_IF_FLAGS_REQ_CREDIT_SHIFT
#define BRCMF_SKB_IF_FLAGS_IF_AP_MASK
#define BRCMF_SKB_IF_FLAGS_IF_AP_SHIFT
#define BRCMF_SKB_IF_FLAGS_INDEX_MASK
#define BRCMF_SKB_IF_FLAGS_INDEX_SHIFT

#define brcmf_skb_if_flags_set_field(skb, field, value)
#define brcmf_skb_if_flags_get_field(skb, field)

/*
 * sk_buff control packet identifier
 *
 * 32-bit packet identifier used in PKTTAG tlv from host to dongle.
 *
 * - Generated at the host (e.g. dhd)
 * - Seen as a generic sequence number by firmware except for the flags field.
 *
 * Generation	: b[31]	=> generation number for this packet [host->fw]
 *			   OR, current generation number [fw->host]
 * Flags	: b[30:27] => command, status flags
 * FIFO-AC	: b[26:24] => AC-FIFO id
 * h-slot	: b[23:8] => hanger-slot
 * freerun	: b[7:0] => A free running counter
 */
#define BRCMF_SKB_HTOD_TAG_GENERATION_MASK
#define BRCMF_SKB_HTOD_TAG_GENERATION_SHIFT
#define BRCMF_SKB_HTOD_TAG_FLAGS_MASK
#define BRCMF_SKB_HTOD_TAG_FLAGS_SHIFT
#define BRCMF_SKB_HTOD_TAG_FIFO_MASK
#define BRCMF_SKB_HTOD_TAG_FIFO_SHIFT
#define BRCMF_SKB_HTOD_TAG_HSLOT_MASK
#define BRCMF_SKB_HTOD_TAG_HSLOT_SHIFT
#define BRCMF_SKB_HTOD_TAG_FREERUN_MASK
#define BRCMF_SKB_HTOD_TAG_FREERUN_SHIFT

#define brcmf_skb_htod_tag_set_field(skb, field, value)
#define brcmf_skb_htod_tag_get_field(skb, field)

#define BRCMF_SKB_HTOD_SEQ_FROMFW_MASK
#define BRCMF_SKB_HTOD_SEQ_FROMFW_SHIFT
#define BRCMF_SKB_HTOD_SEQ_FROMDRV_MASK
#define BRCMF_SKB_HTOD_SEQ_FROMDRV_SHIFT
#define BRCMF_SKB_HTOD_SEQ_NR_MASK
#define BRCMF_SKB_HTOD_SEQ_NR_SHIFT

#define brcmf_skb_htod_seq_set_field(skb, field, value)
#define brcmf_skb_htod_seq_get_field(skb, field)

#define BRCMF_FWS_TXSTAT_GENERATION_MASK
#define BRCMF_FWS_TXSTAT_GENERATION_SHIFT
#define BRCMF_FWS_TXSTAT_FLAGS_MASK
#define BRCMF_FWS_TXSTAT_FLAGS_SHIFT
#define BRCMF_FWS_TXSTAT_FIFO_MASK
#define BRCMF_FWS_TXSTAT_FIFO_SHIFT
#define BRCMF_FWS_TXSTAT_HSLOT_MASK
#define BRCMF_FWS_TXSTAT_HSLOT_SHIFT
#define BRCMF_FWS_TXSTAT_FREERUN_MASK
#define BRCMF_FWS_TXSTAT_FREERUN_SHIFT

#define brcmf_txstatus_get_field(txs, field)

/* How long to defer borrowing in jiffies */
#define BRCMF_FWS_BORROW_DEFER_PERIOD


/**
 * enum brcmf_fws_txstatus - txstatus flag values.
 *
 * @BRCMF_FWS_TXSTATUS_DISCARD:
 *	host is free to discard the packet.
 * @BRCMF_FWS_TXSTATUS_CORE_SUPPRESS:
 *	802.11 core suppressed the packet.
 * @BRCMF_FWS_TXSTATUS_FW_PS_SUPPRESS:
 *	firmware suppress the packet as device is already in PS mode.
 * @BRCMF_FWS_TXSTATUS_FW_TOSSED:
 *	firmware tossed the packet.
 * @BRCMF_FWS_TXSTATUS_FW_DISCARD_NOACK:
 *	firmware tossed the packet after retries.
 * @BRCMF_FWS_TXSTATUS_FW_SUPPRESS_ACKED:
 *	firmware wrongly reported suppressed previously, now fixing to acked.
 * @BRCMF_FWS_TXSTATUS_HOST_TOSSED:
 *	host tossed the packet.
 */
enum brcmf_fws_txstatus {};

enum brcmf_fws_fcmode {};

enum brcmf_fws_mac_desc_state {};

/**
 * struct brcmf_fws_mac_descriptor - firmware signalling data per node/interface
 *
 * @name: name of the descriptor.
 * @occupied: slot is in use.
 * @mac_handle: handle for mac entry determined by firmware.
 * @interface_id: interface index.
 * @state: current state.
 * @suppressed: mac entry is suppressed.
 * @generation: generation bit.
 * @ac_bitmap: ac queue bitmap.
 * @requested_credit: credits requested by firmware.
 * @requested_packet: packet requested by firmware.
 * @ea: ethernet address.
 * @seq: per-node free-running sequence.
 * @psq: power-save queue.
 * @transit_count: packet in transit to firmware.
 * @suppr_transit_count: suppressed packet in transit to firmware.
 * @send_tim_signal: if set tim signal will be sent.
 * @traffic_pending_bmp: traffic pending bitmap.
 * @traffic_lastreported_bmp: traffic last reported bitmap.
 */
struct brcmf_fws_mac_descriptor {};

#define BRCMF_FWS_HANGER_MAXITEMS
#define BRCMF_BORROW_RATIO

/**
 * enum brcmf_fws_hanger_item_state - state of hanger item.
 *
 * @BRCMF_FWS_HANGER_ITEM_STATE_FREE: item is free for use.
 * @BRCMF_FWS_HANGER_ITEM_STATE_INUSE: item is in use.
 * @BRCMF_FWS_HANGER_ITEM_STATE_INUSE_SUPPRESSED: item was suppressed.
 */
enum brcmf_fws_hanger_item_state {};


/**
 * struct brcmf_fws_hanger_item - single entry for tx pending packet.
 *
 * @state: entry is either free or occupied.
 * @pkt: packet itself.
 */
struct brcmf_fws_hanger_item {};

/**
 * struct brcmf_fws_hanger - holds packets awaiting firmware txstatus.
 *
 * @pushed: packets pushed to await txstatus.
 * @popped: packets popped upon handling txstatus.
 * @failed_to_push: packets that could not be pushed.
 * @failed_to_pop: packets that could not be popped.
 * @failed_slotfind: packets for which failed to find an entry.
 * @slot_pos: last returned item index for a free entry.
 * @items: array of hanger items.
 */
struct brcmf_fws_hanger {};

struct brcmf_fws_macdesc_table {};

struct brcmf_fws_stats {};

struct brcmf_fws_info {};

#define BRCMF_FWS_TLV_DEF

/**
 * brcmf_fws_get_tlv_len() - returns defined length for given tlv id.
 *
 * @fws: firmware-signalling information.
 * @id: identifier of the TLV.
 *
 * Return: the specified length for the given TLV; Otherwise -EINVAL.
 */
static int brcmf_fws_get_tlv_len(struct brcmf_fws_info *fws,
				 enum brcmf_fws_tlv_type id)
{}
#undef BRCMF_FWS_TLV_DEF

static void brcmf_fws_lock(struct brcmf_fws_info *fws)
		__acquires(&fws->spinlock)
{}

static void brcmf_fws_unlock(struct brcmf_fws_info *fws)
		__releases(&fws->spinlock)
{}

static bool brcmf_fws_ifidx_match(struct sk_buff *skb, void *arg)
{}

static void brcmf_fws_hanger_init(struct brcmf_fws_hanger *hanger)
{}

static u32 brcmf_fws_hanger_get_free_slot(struct brcmf_fws_hanger *h)
{}

static int brcmf_fws_hanger_pushpkt(struct brcmf_fws_hanger *h,
				    struct sk_buff *pkt, u32 slot_id)
{}

static inline int brcmf_fws_hanger_poppkt(struct brcmf_fws_hanger *h,
					  u32 slot_id, struct sk_buff **pktout,
					  bool remove_item)
{}

static void brcmf_fws_psq_flush(struct brcmf_fws_info *fws, struct pktq *q,
				int ifidx)
{}

static int brcmf_fws_hanger_mark_suppressed(struct brcmf_fws_hanger *h,
					    u32 slot_id)
{}

static void brcmf_fws_hanger_cleanup(struct brcmf_fws_info *fws,
				     bool (*fn)(struct sk_buff *, void *),
				     int ifidx)
{}

static void brcmf_fws_macdesc_set_name(struct brcmf_fws_info *fws,
				       struct brcmf_fws_mac_descriptor *desc)
{}

static void brcmf_fws_macdesc_init(struct brcmf_fws_mac_descriptor *desc,
				   u8 *addr, u8 ifidx)
{}

static
void brcmf_fws_macdesc_deinit(struct brcmf_fws_mac_descriptor *desc)
{}

static struct brcmf_fws_mac_descriptor *
brcmf_fws_macdesc_lookup(struct brcmf_fws_info *fws, u8 *ea)
{}

static struct brcmf_fws_mac_descriptor*
brcmf_fws_macdesc_find(struct brcmf_fws_info *fws, struct brcmf_if *ifp, u8 *da)
{}

static bool brcmf_fws_macdesc_closed(struct brcmf_fws_info *fws,
				     struct brcmf_fws_mac_descriptor *entry,
				     int fifo)
{}

static void brcmf_fws_macdesc_cleanup(struct brcmf_fws_info *fws,
				      struct brcmf_fws_mac_descriptor *entry,
				      int ifidx)
{}

static void brcmf_fws_bus_txq_cleanup(struct brcmf_fws_info *fws,
				      bool (*fn)(struct sk_buff *, void *),
				      int ifidx)
{}

static void brcmf_fws_cleanup(struct brcmf_fws_info *fws, int ifidx)
{}

static u8 brcmf_fws_hdrpush(struct brcmf_fws_info *fws, struct sk_buff *skb)
{}

static bool brcmf_fws_tim_update(struct brcmf_fws_info *fws,
				 struct brcmf_fws_mac_descriptor *entry,
				 int fifo, bool send_immediately)
{}

static void
brcmf_fws_flow_control_check(struct brcmf_fws_info *fws, struct pktq *pq,
			     u8 if_id)
{}

static int brcmf_fws_rssi_indicate(struct brcmf_fws_info *fws, s8 rssi)
{}

static
int brcmf_fws_macdesc_indicate(struct brcmf_fws_info *fws, u8 type, u8 *data)
{}

static int brcmf_fws_macdesc_state_indicate(struct brcmf_fws_info *fws,
					    u8 type, u8 *data)
{}

static int brcmf_fws_interface_state_indicate(struct brcmf_fws_info *fws,
					      u8 type, u8 *data)
{}

static int brcmf_fws_request_indicate(struct brcmf_fws_info *fws, u8 type,
				      u8 *data)
{}

static void
brcmf_fws_macdesc_use_req_credit(struct brcmf_fws_mac_descriptor *entry,
				 struct sk_buff *skb)
{}

static void brcmf_fws_macdesc_return_req_credit(struct sk_buff *skb)
{}

static void brcmf_fws_return_credits(struct brcmf_fws_info *fws,
				     u8 fifo, u8 credits)
{}

static void brcmf_fws_schedule_deq(struct brcmf_fws_info *fws)
{}

static int brcmf_fws_enq(struct brcmf_fws_info *fws,
			 enum brcmf_fws_skb_state state, int fifo,
			 struct sk_buff *p)
{}

static struct sk_buff *brcmf_fws_deq(struct brcmf_fws_info *fws, int fifo)
{}

static int brcmf_fws_txstatus_suppressed(struct brcmf_fws_info *fws, int fifo,
					 struct sk_buff *skb,
					 u32 genbit, u16 seq)
{}

static int
brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot,
		      u32 genbit, u16 seq, u8 compcnt)
{}

static int brcmf_fws_fifocreditback_indicate(struct brcmf_fws_info *fws,
					     u8 *data)
{}

static int brcmf_fws_txstatus_indicate(struct brcmf_fws_info *fws, u8 type,
				       u8 *data)
{}

static int brcmf_fws_dbg_seqnum_check(struct brcmf_fws_info *fws, u8 *data)
{}

static int brcmf_fws_notify_credit_map(struct brcmf_if *ifp,
				       const struct brcmf_event_msg *e,
				       void *data)
{}

static int brcmf_fws_notify_bcmc_credit_support(struct brcmf_if *ifp,
						const struct brcmf_event_msg *e,
						void *data)
{}

static void brcmf_rxreorder_get_skb_list(struct brcmf_ampdu_rx_reorder *rfi,
					 u8 start, u8 end,
					 struct sk_buff_head *skb_list)
{}

void brcmf_fws_rxreorder(struct brcmf_if *ifp, struct sk_buff *pkt)
{}

void brcmf_fws_hdrpull(struct brcmf_if *ifp, s16 siglen, struct sk_buff *skb)
{}

static u8 brcmf_fws_precommit_skb(struct brcmf_fws_info *fws, int fifo,
				   struct sk_buff *p)
{}

static void brcmf_fws_rollback_toq(struct brcmf_fws_info *fws,
				   struct sk_buff *skb, int fifo)
{}

static int brcmf_fws_borrow_credit(struct brcmf_fws_info *fws,
				   int highest_lender_ac, int borrower_ac,
				   bool borrow_all)
{}

static int brcmf_fws_commit_skb(struct brcmf_fws_info *fws, int fifo,
				struct sk_buff *skb)
{}

static int brcmf_fws_assign_htod(struct brcmf_fws_info *fws, struct sk_buff *p,
				  int fifo)
{}

int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)
{}

void brcmf_fws_reset_interface(struct brcmf_if *ifp)
{}

void brcmf_fws_add_interface(struct brcmf_if *ifp)
{}

void brcmf_fws_del_interface(struct brcmf_if *ifp)
{}

static void brcmf_fws_dequeue_worker(struct work_struct *worker)
{}

#ifdef DEBUG
static int brcmf_debugfs_fws_stats_read(struct seq_file *seq, void *data)
{}
#else
static int brcmf_debugfs_fws_stats_read(struct seq_file *seq, void *data)
{
	return 0;
}
#endif

struct brcmf_fws_info *brcmf_fws_attach(struct brcmf_pub *drvr)
{}

void brcmf_fws_detach(struct brcmf_fws_info *fws)
{}

void brcmf_fws_debugfs_create(struct brcmf_pub *drvr)
{}

bool brcmf_fws_queue_skbs(struct brcmf_fws_info *fws)
{}

bool brcmf_fws_fc_active(struct brcmf_fws_info *fws)
{}

void brcmf_fws_bustxcomplete(struct brcmf_fws_info *fws, struct sk_buff *skb,
			     bool success)
{}

void brcmf_fws_bus_blocked(struct brcmf_pub *drvr, bool flow_blocked)
{}