linux/drivers/net/wireless/broadcom/brcm80211/include/brcmu_utils.h

// SPDX-License-Identifier: ISC
/*
 * Copyright (c) 2010 Broadcom Corporation
 */

#ifndef	_BRCMU_UTILS_H_
#define _BRCMU_UTILS_H_

#include <linux/skbuff.h>

/*
 * Spin at most 'us' microseconds while 'exp' is true.
 * Caller should explicitly test 'exp' when this completes
 * and take appropriate error action if 'exp' is still true.
 */
#define SPINWAIT(exp, us)

/* osl multi-precedence packet queue */
#define PKTQ_LEN_DEFAULT
#define PKTQ_MAX_PREC

#define BCME_STRLEN

/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
#define PKTBUFSZ

#ifndef setbit
#ifndef NBBY			/* the BSD family defines NBBY */
#define NBBY
#endif				/* #ifndef NBBY */
#define setbit(a, i)
#define clrbit(a, i)
#define isset(a, i)
#define isclr(a, i)
#endif				/* setbit */

#define NBITS(type)
#define NBITVAL(nbits)
#define MAXBITVAL(nbits)
#define NBITMASK(nbits)
#define MAXNBVAL(nbyte)

/* crc defines */
#define CRC16_INIT_VALUE
#define CRC16_GOOD_VALUE

/* 18-bytes of Ethernet address buffer length */
#define ETHER_ADDR_STR_LEN

struct pktq_prec {};

/* multi-priority pkt queue */
struct pktq {};

/* operations on a specific precedence in packet queue */

static inline int pktq_plen(struct pktq *pq, int prec)
{}

static inline int pktq_pavail(struct pktq *pq, int prec)
{}

static inline bool pktq_pfull(struct pktq *pq, int prec)
{}

static inline bool pktq_pempty(struct pktq *pq, int prec)
{}

static inline struct sk_buff *pktq_ppeek(struct pktq *pq, int prec)
{}

static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec)
{}

struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, struct sk_buff *p);
struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec,
				     struct sk_buff *p);
struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec);
struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec);
struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec,
				      bool (*match_fn)(struct sk_buff *p,
						       void *arg),
				      void *arg);

/* packet primitives */
struct sk_buff *brcmu_pkt_buf_get_skb(uint len);
void brcmu_pkt_buf_free_skb(struct sk_buff *skb);

/* Empty the queue at particular precedence level */
/* callback function fn(pkt, arg) returns true if pkt belongs to if */
void brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir,
		       bool (*fn)(struct sk_buff *, void *), void *arg);

/* operations on a set of precedences in packet queue */

int brcmu_pktq_mlen(struct pktq *pq, uint prec_bmp);
struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);

/* operations on packet queue as a whole */

static inline int pktq_len(struct pktq *pq)
{}

static inline int pktq_max(struct pktq *pq)
{}

static inline int pktq_avail(struct pktq *pq)
{}

static inline bool pktq_full(struct pktq *pq)
{}

static inline bool pktq_empty(struct pktq *pq)
{}

void brcmu_pktq_init(struct pktq *pq, int num_prec, int max_len);
/* prec_out may be NULL if caller is not interested in return value */
struct sk_buff *brcmu_pktq_peek_tail(struct pktq *pq, int *prec_out);
void brcmu_pktq_flush(struct pktq *pq, bool dir,
		      bool (*fn)(struct sk_buff *, void *), void *arg);

/* externs */
/* ip address */
struct ipv4_addr;

/*
 * bitfield macros using masking and shift
 *
 * remark: the mask parameter should be a shifted mask.
 */
static inline void brcmu_maskset32(u32 *var, u32 mask, u8 shift, u32 value)
{}
static inline u32 brcmu_maskget32(u32 var, u32 mask, u8 shift)
{}
static inline void brcmu_maskset16(u16 *var, u16 mask, u8 shift, u16 value)
{}
static inline u16 brcmu_maskget16(u16 var, u16 mask, u8 shift)
{}

/* externs */
/* format/print */
#ifdef DEBUG
void brcmu_prpkt(const char *msg, struct sk_buff *p0);
#else
#define brcmu_prpkt
#endif				/* DEBUG */

#ifdef DEBUG
__printf(3, 4)
void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...);
#else
__printf(3, 4)
static inline
void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
{
}
#endif

#define BRCMU_BOARDREV_LEN
#define BRCMU_DOTREV_LEN

char *brcmu_boardrev_str(u32 brev, char *buf);
char *brcmu_dotrev_str(u32 dotrev, char *buf);

#endif				/* _BRCMU_UTILS_H_ */